/* goodB2G1() - use badsource and goodsink by changing second IO.STATIC_FINAL_TRUE to IO.STATIC_FINAL_FALSE */
  private void goodB2G1() throws Throwable {
    long data;
    if (IO.STATIC_FINAL_TRUE) {
      /* init data */
      data = -1;
      /* POTENTIAL FLAW: Read data from console with readLine*/
      BufferedReader readerBuffered = null;
      InputStreamReader readerInputStream = null;
      try {
        readerInputStream = new InputStreamReader(System.in, "UTF-8");
        readerBuffered = new BufferedReader(readerInputStream);
        String stringNumber = readerBuffered.readLine();
        if (stringNumber != null) {
          data = Long.parseLong(stringNumber.trim());
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
      } catch (NumberFormatException exceptNumberFormat) {
        IO.logger.log(Level.WARNING, "Error with number parsing", exceptNumberFormat);
      } finally {
        /* clean up stream reading objects */
        try {
          if (readerBuffered != null) {
            readerBuffered.close();
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
        } finally {
          try {
            if (readerInputStream != null) {
              readerInputStream.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0L;
    }

    if (IO.STATIC_FINAL_FALSE) {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
      IO.writeLine("Benign, fixed string");
    } else {

      if (data < 0) /* ensure we won't have an overflow */ {
        /* FIX: Add a check to prevent an underflow from occurring */
        if (data > (Long.MIN_VALUE / 2)) {
          long result = (long) (data * 2);
          IO.writeLine("result: " + result);
        } else {
          IO.writeLine("data value is too small to perform multiplication.");
        }
      }
    }
  }
  /* goodB2G() - use badsource and goodsink */
  private void goodB2G() throws Throwable {
    long data;

    while (true) {
      /* init data */
      data = -1;
      /* POTENTIAL FLAW: Read data from console with readLine*/
      BufferedReader readerBuffered = null;
      InputStreamReader readerInputStream = null;
      try {
        readerInputStream = new InputStreamReader(System.in, "UTF-8");
        readerBuffered = new BufferedReader(readerInputStream);
        String stringNumber = readerBuffered.readLine();
        if (stringNumber != null) {
          data = Long.parseLong(stringNumber.trim());
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
      } catch (NumberFormatException exceptNumberFormat) {
        IO.logger.log(Level.WARNING, "Error with number parsing", exceptNumberFormat);
      } finally {
        /* clean up stream reading objects */
        try {
          if (readerBuffered != null) {
            readerBuffered.close();
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
        } finally {
          try {
            if (readerInputStream != null) {
              readerInputStream.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
          }
        }
      }
      break;
    }

    while (true) {
      if (data > 0) /* ensure we won't have an underflow */ {
        /* FIX: Add a check to prevent an overflow from occurring */
        if (data < (Long.MAX_VALUE / 2)) {
          long result = (long) (data * 2);
          IO.writeLine("result: " + result);
        } else {
          IO.writeLine("data value is too large to perform multiplication.");
        }
      }
      break;
    }
  }
  public void bad() throws Throwable {
    long data;
    if (IO.STATIC_FINAL_TRUE) {
      /* init data */
      data = -1;
      /* POTENTIAL FLAW: Read data from console with readLine*/
      BufferedReader readerBuffered = null;
      InputStreamReader readerInputStream = null;
      try {
        readerInputStream = new InputStreamReader(System.in, "UTF-8");
        readerBuffered = new BufferedReader(readerInputStream);
        String stringNumber = readerBuffered.readLine();
        if (stringNumber != null) {
          data = Long.parseLong(stringNumber.trim());
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
      } catch (NumberFormatException exceptNumberFormat) {
        IO.logger.log(Level.WARNING, "Error with number parsing", exceptNumberFormat);
      } finally {
        /* clean up stream reading objects */
        try {
          if (readerBuffered != null) {
            readerBuffered.close();
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
        } finally {
          try {
            if (readerInputStream != null) {
              readerInputStream.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = 0L;
    }

    if (IO.STATIC_FINAL_TRUE) {
      if (data < 0) /* ensure we won't have an overflow */ {
        /* POTENTIAL FLAW: if (data * 2) < Long.MIN_VALUE, this will underflow */
        long result = (long) (data * 2);
        IO.writeLine("result: " + result);
      }
    }
  }
  public void bad() throws Throwable {
    long data;

    while (true) {
      /* init data */
      data = -1;
      /* POTENTIAL FLAW: Read data from console with readLine*/
      BufferedReader readerBuffered = null;
      InputStreamReader readerInputStream = null;
      try {
        readerInputStream = new InputStreamReader(System.in, "UTF-8");
        readerBuffered = new BufferedReader(readerInputStream);
        String stringNumber = readerBuffered.readLine();
        if (stringNumber != null) {
          data = Long.parseLong(stringNumber.trim());
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
      } catch (NumberFormatException exceptNumberFormat) {
        IO.logger.log(Level.WARNING, "Error with number parsing", exceptNumberFormat);
      } finally {
        /* clean up stream reading objects */
        try {
          if (readerBuffered != null) {
            readerBuffered.close();
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
        } finally {
          try {
            if (readerInputStream != null) {
              readerInputStream.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
          }
        }
      }
      break;
    }

    while (true) {
      if (data > 0) /* ensure we won't have an underflow */ {
        /* POTENTIAL FLAW: if (data*2) > Long.MAX_VALUE, this will overflow */
        long result = (long) (data * 2);
        IO.writeLine("result: " + result);
      }
      break;
    }
  }
  /* goodB2G() - use badsource and goodsink */
  public long goodB2GSource() throws Throwable {
    long data;

    /* init data */
    data = -1;

    /* POTENTIAL FLAW: Read data from console with readLine*/
    BufferedReader readerBuffered = null;
    InputStreamReader readerInputStream = null;
    try {
      readerInputStream = new InputStreamReader(System.in, "UTF-8");
      readerBuffered = new BufferedReader(readerInputStream);
      String stringNumber = readerBuffered.readLine();
      if (stringNumber != null) {
        data = Long.parseLong(stringNumber.trim());
      }
    } catch (IOException exceptIO) {
      IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
    } catch (NumberFormatException exceptNumberFormat) {
      IO.logger.log(Level.WARNING, "Error with number parsing", exceptNumberFormat);
    } finally {
      /* clean up stream reading objects */
      try {
        if (readerBuffered != null) {
          readerBuffered.close();
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
      } finally {
        try {
          if (readerInputStream != null) {
            readerInputStream.close();
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
        }
      }
    }

    return data;
  }
  public void bad() throws Throwable {
    long data;

    /* init data */
    data = -1;

    /* POTENTIAL FLAW: Read data from console with readLine*/
    BufferedReader readerBuffered = null;
    InputStreamReader readerInputStream = null;

    try {
      readerInputStream = new InputStreamReader(System.in, "UTF-8");
      readerBuffered = new BufferedReader(readerInputStream);

      String stringNumber = readerBuffered.readLine();
      if (stringNumber != null) {
        data = Long.parseLong(stringNumber.trim());
      }
    } catch (IOException exceptIO) {
      IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
    } catch (NumberFormatException exceptNumberFormat) {
      IO.logger.log(Level.WARNING, "Error with number parsing", exceptNumberFormat);
    } finally {
      /* clean up stream reading objects */
      try {
        if (readerBuffered != null) {
          readerBuffered.close();
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
      } finally {
        try {
          if (readerInputStream != null) {
            readerInputStream.close();
          }
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
        }
      }
    }

    /* serialize data to a byte array */
    ByteArrayOutputStream streamByteArrayOutput = null;
    ObjectOutput outputObject = null;

    try {
      streamByteArrayOutput = new ByteArrayOutputStream();
      outputObject = new ObjectOutputStream(streamByteArrayOutput);
      outputObject.writeObject(data);
      byte[] dataSerialized = streamByteArrayOutput.toByteArray();
      (new CWE191_Integer_Underflow__long_console_readLine_sub_75b()).badSink(dataSerialized);
    } catch (IOException exceptIO) {
      IO.logger.log(Level.WARNING, "IOException in serialization", exceptIO);
    } finally {
      /* clean up stream writing objects */
      try {
        if (outputObject != null) {
          outputObject.close();
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error closing ObjectOutputStream", exceptIO);
      }

      try {
        if (streamByteArrayOutput != null) {
          streamByteArrayOutput.close();
        }
      } catch (IOException exceptIO) {
        IO.logger.log(Level.WARNING, "Error closing ByteArrayOutputStream", exceptIO);
      }
    }
  }