#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(int);
char *optarg;
int optind;
int optopt;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int qseq2fastq(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ qseq2fastq_demultiplex(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *, char **, int,
                                          int /*<<< orphan*/ **, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ strcat(char *, char *);
char *strdup(char *);
char *strtok_r(char *, char *, char **);
int /*<<< orphan*/ usage();
int main(int argn, char **argv) {
  char *filename;
  FILE *fp;
  int err, c, all_flag = 0;
  char *barcodes[1024];
  int barcodes_num = 0;
  char *demultiplex_filename;
  char *output_base = "";
  char *barcode_string;
  while ((c = getopt(argn, argv, "ab:d:ho:")) != -1)
    switch (c) {
    case 'a':
      all_flag = 1;
      break;
    case 'd':
      demultiplex_filename = optarg;
      break;
    case 'b':
      barcode_string = strdup(optarg);
      for (int i = 0;; i++, barcode_string = NULL) {
        char *saveptr1;
        char *token = strtok_r(barcode_string, ",", &saveptr1);
        if (token != NULL)
          barcodes[barcodes_num++] = token;
        else
          break;
      }
      break;
    case 'o':
      output_base = optarg;
      break;
    case 'h':
      usage();
      break;
    case '?':
      if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    default:
      return 1;
    }
  if (optind == argn) {
    puts("ERROR: Need input file (or \"-\" for STDIN)!");
    usage();
    return 1;
  }
  if (barcodes_num > 0 && demultiplex_filename == NULL) {
    puts("ERROR: Barcodes (-b) need demultiplex file (-d)!");
    usage();
    return 1;
  }
  for (int i = optind; i < argn; i++) {
    filename = argv[i];
    if (filename[0] == '-' && filename[1] == '\0')
      fp = stdin;
    else
      fp = fopen(filename, "r");
    if (barcodes_num > 0) {
      FILE *barcode_output_files[barcodes_num];
      FILE *demultiplex_reads_file = fopen(demultiplex_filename, "r");
      if (demultiplex_reads_file == NULL) {
        perror("Couldn't open demultiplex file.");
        return 1;
      }
      char filename[4096];
      for (int i = 0; i < barcodes_num; i++) {
        filename[0] = '\0';
        strcat(filename, output_base);
        strcat(filename, barcodes[i]);
        strcat(filename, ".fastq");
        barcode_output_files[i] = fopen(filename, "a");
        if (barcode_output_files[i] == NULL) {
          puts(filename);
          perror("Couldn't open barcode output file.");
          return 1;
        }
      }
      qseq2fastq_demultiplex(fp, demultiplex_reads_file, barcodes, barcodes_num,
                             barcode_output_files, all_flag);
    } else
      err = qseq2fastq(fp, all_flag);
    if (err > 0)
      fprintf(stderr, " error in filename: %s\n", filename);
  }
  return err;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x2034(%rbp)
lea    0xef4(%rip),%rax
mov    %rax,-0x2048(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xebe(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     13a7 <main+0x1e7>
mov    -0x28(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x30a0(%rbp)
sub    $0x30,%eax
ja     1396 <main+0x1d6>
mov    -0x30a0(%rbp),%rax
lea    0xdc3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x2c(%rbp)
jmp    13a2 <main+0x1e2>
mov    0x2d9f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x2040(%rbp)
jmp    13a2 <main+0x1e2>
mov    0x2d89(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x2050(%rbp)
movl   $0x0,-0x2054(%rbp)
mov    -0x2050(%rbp),%rdi
lea    0xe37(%rip),%rsi
lea    -0x2060(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x2068(%rbp)
cmpq   $0x0,-0x2068(%rbp)
je     12de <main+0x11e>
mov    -0x2068(%rbp),%rcx
mov    -0x2034(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x2034(%rbp)
cltq
mov    %rcx,-0x2030(%rbp,%rax,8)
ff
jmp    12e3 <main+0x123>
jmp    1307 <main+0x147>
jmp    12e8 <main+0x128>
mov    -0x2054(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2054(%rbp)
movq   $0x0,-0x2050(%rbp)
jmp    1288 <main+0xc8>
jmp    13a2 <main+0x1e2>
mov    0x2ce5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x2048(%rbp)
jmp    13a2 <main+0x1e2>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    13a2 <main+0x1e2>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   1070 <isprint@plt>
cmp    $0x0,%eax
je     136a <main+0x1aa>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
mov    0x2c83(%rip),%rax
mov    (%rax),%edx
lea    0xd71(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    138a <main+0x1ca>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
mov    0x2c5e(%rip),%rax
mov    (%rax),%edx
lea    0xd63(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16a6 <main+0x4e6>
movl   $0x1,-0x4(%rbp)
jmp    16a6 <main+0x4e6>
jmp    11f8 <main+0x38>
mov    0x2c22(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    13d8 <main+0x218>
lea    0xd48(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    16a6 <main+0x4e6>
cmpl   $0x0,-0x2034(%rbp)
jle    1412 <main+0x252>
cmpq   $0x0,-0x2040(%rbp)
jne    1412 <main+0x252>
lea    0xd39(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    16a6 <main+0x4e6>
mov    0x2bb7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x206c(%rbp)
mov    -0x206c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    16a0 <main+0x4e0>
mov    -0x10(%rbp),%rax
movslq -0x206c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1477 <main+0x2b7>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1477 <main+0x2b7>
mov    0x2b75(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    148b <main+0x2cb>
mov    -0x18(%rbp),%rdi
lea    0xce2(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x2034(%rbp)
jle    1653 <main+0x493>
mov    -0x2034(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x2078(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30a8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x2080(%rbp)
mov    -0x2040(%rbp),%rdi
lea    0xc8b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x2088(%rbp)
cmpq   $0x0,-0x2088(%rbp)
jne    1515 <main+0x355>
lea    0xc6c(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x208c(%rbp)
jmp    162c <main+0x46c>
movl   $0x0,-0x3094(%rbp)
mov    -0x3094(%rbp),%eax
cmp    -0x2034(%rbp),%eax
jge    15fa <main+0x43a>
movb   $0x0,-0x3090(%rbp)
lea    -0x3090(%rbp),%rdi
mov    -0x2048(%rbp),%rsi
call   10b0 <strcat@plt>
lea    -0x3090(%rbp),%rdi
movslq -0x3094(%rbp),%rax
mov    -0x2030(%rbp,%rax,8),%rsi
ff
call   10b0 <strcat@plt>
lea    -0x3090(%rbp),%rdi
lea    0xc12(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x3090(%rbp),%rdi
lea    0xc06(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rdx
mov    -0x30a8(%rbp),%rax
movslq -0x3094(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movslq -0x3094(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    15e1 <main+0x421>
lea    -0x3090(%rbp),%rdi
call   1030 <puts@plt>
lea    0xbc9(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x208c(%rbp)
jmp    162c <main+0x46c>
jmp    15e6 <main+0x426>
mov    -0x3094(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3094(%rbp)
jmp    151f <main+0x35f>
mov    -0x30a8(%rbp),%r8
mov    -0x20(%rbp),%rdi
mov    -0x2088(%rbp),%rsi
lea    -0x2030(%rbp),%rdx
mov    -0x2034(%rbp),%ecx
mov    -0x2c(%rbp),%r9d
call   10e0 <qseq2fastq_demultiplex@plt>
movl   $0x0,-0x208c(%rbp)
mov    -0x2078(%rbp),%rax
mov    %rax,%rsp
mov    -0x208c(%rbp),%eax
test   %eax,%eax
je     164e <main+0x48e>
jmp    1649 <main+0x489>
jmp    16a6 <main+0x4e6>
jmp    1662 <main+0x4a2>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10c0 <qseq2fastq@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1687 <main+0x4c7>
mov    0x294d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xb32(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    168c <main+0x4cc>
mov    -0x206c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x206c(%rbp)
jmp    1421 <main+0x261>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3058,%rsp
mov    %rsi,%rbx
mov    %edi,%r15d
lea    0xf04(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xed8(%rip),%r13
lea    0xe0d(%rip),%r12
xor    %r14d,%r14d
movl   $0x0,-0x34(%rbp)
jmp    1207 <main+0x47>
nop
xor    %eax,%eax
call   1060 <usage@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10a0 <getopt@plt>
cmp    $0x68,%eax
je     1200 <main+0x40>
lea    -0x3f(%rax),%ecx
cmp    $0x30,%ecx
ja     12e7 <main+0x127>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
movl   $0x1,-0x34(%rbp)
jmp    1207 <main+0x47>
mov    %r15d,-0x2c(%rbp)
mov    %rbx,-0x50(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strdup@plt>
mov    %rax,%rdi
lea    0xe74(%rip),%rsi
lea    -0x1080(%rbp),%rdx
call   1040 <strtok_r@plt>
test   %rax,%rax
je     12ad <main+0xed>
movslq %r14d,%rcx
lea    -0x3080(,%rcx,8),%rbx
ff
add    %rbp,%rbx
lea    0xe4e(%rip),%r15
lea    -0x1080(%rbp),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rax,(%rbx)
xor    %edi,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <strtok_r@plt>
add    $0x8,%rbx
add    $0x1,%r14d
test   %rax,%rax
jne    1290 <main+0xd0>
mov    -0x50(%rbp),%rbx
mov    -0x2c(%rbp),%r15d
lea    0xd44(%rip),%r12
jmp    1207 <main+0x47>
mov    0x2d30(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    1207 <main+0x47>
mov    0x2d1d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    1207 <main+0x47>
cmp    $0xffffffff,%eax
jne    135d <main+0x19d>
mov    0x2cdd(%rip),%rax
movslq (%rax),%r12
cmp    %r15d,%r12d
jne    133c <main+0x17c>
lea    0xe06(%rip),%rdi
jmp    1351 <main+0x191>
mov    0x2ccd(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1070 <isprint@plt>
mov    0x2ca5(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     132a <main+0x16a>
lea    0xda7(%rip),%rsi
jmp    1331 <main+0x171>
lea    0xdb5(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    135d <main+0x19d>
test   %r14d,%r14d
jle    1371 <main+0x1b1>
mov    -0x40(%rbp),%rax
test   %rax,%rax
jne    1375 <main+0x1b5>
lea    0xde2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <usage@plt>
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    %rbx,-0x50(%rbp)
cmp    %r15d,%r12d
jge    1362 <main+0x1a2>
mov    %r14d,%ebx
lea    0xf(,%rbx,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rax,-0x60(%rbp)
lea    -0x1080(%rbp),%r13
mov    %r15d,-0x2c(%rbp)
jmp    13db <main+0x21b>
mov    %rax,%rdi
mov    -0x34(%rbp),%esi
call   10c0 <qseq2fastq@plt>
test   %eax,%eax
jle    13d2 <main+0x212>
mov    0x2c08(%rip),%rcx
mov    (%rcx),%edi
lea    0xdf1(%rip),%rsi
mov    -0x80(%rbp),%rdx
mov    %eax,-0x30(%rbp)
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%r12
cmp    %r15d,%r12d
je     1362 <main+0x1a2>
mov    %eax,-0x30(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax,%r12,8),%rdi
cmpb   $0x2d,(%rdi)
mov    %rdi,-0x80(%rbp)
jne    13f9 <main+0x239>
cmpb   $0x0,0x1(%rdi)
je     14cd <main+0x30d>
lea    0xd64(%rip),%rsi
call   1080 <fopen@plt>
mov    -0x40(%rbp),%rdi
test   %r14d,%r14d
jle    13a2 <main+0x1e2>
mov    %rax,-0x78(%rbp)
mov    %rsp,-0x48(%rbp)
mov    %rsp,%r15
sub    -0x60(%rbp),%r15
mov    %r15,%rsp
lea    0xd3d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1502 <main+0x342>
mov    %rax,-0x68(%rbp)
mov    %r12,-0x70(%rbp)
xor    %r12d,%r12d
movb   $0x0,-0x1080(%rbp)
mov    %r13,%rdi
mov    -0x58(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x3080(%rbp,%r12,8),%rsi
ff
mov    %r13,%rdi
call   10b0 <strcat@plt>
mov    %r13,%rdi
lea    0xd19(%rip),%rsi
call   10b0 <strcat@plt>
mov    %r13,%rdi
lea    0xd11(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,(%r15,%r12,8)
test   %rax,%rax
je     14dc <main+0x31c>
add    $0x1,%r12
cmp    %r12,%rbx
jne    1440 <main+0x280>
mov    -0x78(%rbp),%rdi
mov    -0x68(%rbp),%rsi
lea    -0x3080(%rbp),%rdx
mov    %r14d,%ecx
mov    %r15,%r8
mov    -0x34(%rbp),%r9d
call   10e0 <qseq2fastq_demultiplex@plt>
mov    -0x48(%rbp),%rsp
mov    -0x2c(%rbp),%r15d
mov    -0x70(%rbp),%r12
mov    -0x30(%rbp),%eax
test   %eax,%eax
jg     13b1 <main+0x1f1>
jmp    13d2 <main+0x212>
mov    0x2b0c(%rip),%rax
mov    (%rax),%rax
jmp    1405 <main+0x245>
lea    -0x1080(%rbp),%rdi
call   1030 <puts@plt>
lea    0xca0(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
mov    -0x48(%rbp),%rsp
jmp    1362 <main+0x1a2>
lea    0xc5d(%rip),%rdi
jmp    14ef <main+0x32f>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"ab:d:ho:\00"
@optarg = global i8* null
@.str.2 = [2 x i8] c",\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.3 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.5 = [43 x i8] c"ERROR: Need input file (or \22-\22 for STDIN)!\00"
@.str.6 = [49 x i8] c"ERROR: Barcodes (-b) need demultiplex file (-d)!\00"
@stdin = global i32* null
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [32 x i8] c"Couldn't open demultiplex file.\00"
@.str.9 = [7 x i8] c".fastq\00"
@.str.10 = [2 x i8] c"a\00"
@.str.11 = [35 x i8] c"Couldn't open barcode output file.\00"
@.str.12 = [24 x i8] c" error in filename: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1024 x i8*]
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i32*
%23 = alloca i32
%24 = alloca [4096 x i8]
%25 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 0, i32* %12
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %14
br label %26
26: ; preds = %74, %2
%27 = load i32, i32* %4
%28 = load i8**, i8*** %5
%29 = call i32 @getopt(i32 %27, i8** %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i32 %29, i32* %9
%30 = icmp ne i32 %29, -1
br i1 %30, label %31, label %75
31: ; preds = %26
%32 = load i32, i32* %9
switch i32 %32, label %73 [
i32 97, label %33
i32 100, label %34
i32 98, label %36
i32 111, label %56
i32 104, label %58
i32 63, label %60
]
33: ; preds = %31
store i32 1, i32* %10
br label %74
34: ; preds = %31
%35 = load i8*, i8** @optarg
store i8* %35, i8** %13
br label %74
36: ; preds = %31
%37 = load i8*, i8** @optarg
%38 = call i8* @strdup(i8* %37)
store i8* %38, i8** %15
store i32 0, i32* %16
br label %39
39: ; preds = %52, %36
%40 = load i8*, i8** %15
%41 = call i8* @strtok_r(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %17)
store i8* %41, i8** %18
%42 = load i8*, i8** %18
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %50
44: ; preds = %39
%45 = load i8*, i8** %18
%46 = load i32, i32* %12
%47 = add nsw i32 %46, 1
store i32 %47, i32* %12
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %11, i64 0, i64 %48
store i8* %45, i8** %49
br label %51
50: ; preds = %39
br label %55
51: ; preds = %44
br label %52
52: ; preds = %51
%53 = load i32, i32* %16
%54 = add nsw i32 %53, 1
store i32 %54, i32* %16
store i8* null, i8** %15
br label %39
55: ; preds = %50
br label %74
56: ; preds = %31
%57 = load i8*, i8** @optarg
store i8* %57, i8** %14
br label %74
58: ; preds = %31
%59 = call i32 (...) @usage()
br label %74
60: ; preds = %31
%61 = load i32, i32* @optopt
%62 = call i32 @isprint(i32 %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = load i32, i32* @stderr
%66 = load i32, i32* @optopt
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %66)
br label %72
68: ; preds = %60
%69 = load i32, i32* @stderr
%70 = load i32, i32* @optopt
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %68, %64
store i32 1, i32* %3
br label %197
73: ; preds = %31
store i32 1, i32* %3
br label %197
74: ; preds = %58, %56, %55, %34, %33
br label %26
75: ; preds = %26
%76 = load i32, i32* @optind
%77 = load i32, i32* %4
%78 = icmp eq i32 %76, %77
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%81 = call i32 (...) @usage()
store i32 1, i32* %3
br label %197
82: ; preds = %75
%83 = load i32, i32* %12
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %91
85: ; preds = %82
%86 = load i8*, i8** %13
%87 = icmp eq i8* %86, null
br i1 %87, label %88, label %91
88: ; preds = %85
%89 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%90 = call i32 (...) @usage()
store i32 1, i32* %3
br label %197
91: ; preds = %85, %82
%92 = load i32, i32* @optind
store i32 %92, i32* %19
br label %93
93: ; preds = %192, %91
%94 = load i32, i32* %19
%95 = load i32, i32* %4
%96 = icmp slt i32 %94, %95
br i1 %96, label %97, label %195
97: ; preds = %93
%98 = load i8**, i8*** %5
%99 = load i32, i32* %19
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8*, i8** %98, i64 %100
%102 = load i8*, i8** %101
store i8* %102, i8** %6
%103 = load i8*, i8** %6
%104 = getelementptr inbounds i8, i8* %103, i64 0
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp eq i32 %106, 45
br i1 %107, label %108, label %116
108: ; preds = %97
%109 = load i8*, i8** %6
%110 = getelementptr inbounds i8, i8* %109, i64 1
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 0
br i1 %113, label %114, label %116
114: ; preds = %108
%115 = load i32*, i32** @stdin
store i32* %115, i32** %7
br label %119
116: ; preds = %108, %97
%117 = load i8*, i8** %6
%118 = call i32* @fopen(i8* %117, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %118, i32** %7
br label %119
119: ; preds = %116, %114
%120 = load i32, i32* %12
%121 = icmp sgt i32 %120, 0
br i1 %121, label %122, label %180
122: ; preds = %119
%123 = load i32, i32* %12
%124 = zext i32 %123 to i64
%125 = call i8* @llvm.stacksave()
store i8* %125, i8** %20
%126 = alloca i32*, i64 %124
store i64 %124, i64* %21
%127 = load i8*, i8** %13
%128 = call i32* @fopen(i8* %127, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %128, i32** %22
%129 = load i32*, i32** %22
%130 = icmp eq i32* %129, null
br i1 %130, label %131, label %133
131: ; preds = %122
%132 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %23
br label %176
133: ; preds = %122
store i32 0, i32* %25
br label %134
134: ; preds = %166, %133
%135 = load i32, i32* %25
%136 = load i32, i32* %12
%137 = icmp slt i32 %135, %136
br i1 %137, label %138, label %169
138: ; preds = %134
%139 = getelementptr inbounds [4096 x i8], [4096 x i8]* %24, i64 0, i64 0
store i8 0, i8* %139
%140 = getelementptr inbounds [4096 x i8], [4096 x i8]* %24, i64 0, i64 0
%141 = load i8*, i8** %14
%142 = call i32 @strcat(i8* %140, i8* %141)
%143 = getelementptr inbounds [4096 x i8], [4096 x i8]* %24, i64 0, i64 0
%144 = load i32, i32* %25
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %11, i64 0, i64 %145
%147 = load i8*, i8** %146
%148 = call i32 @strcat(i8* %143, i8* %147)
%149 = getelementptr inbounds [4096 x i8], [4096 x i8]* %24, i64 0, i64 0
%150 = call i32 @strcat(i8* %149, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%151 = getelementptr inbounds [4096 x i8], [4096 x i8]* %24, i64 0, i64 0
%152 = call i32* @fopen(i8* %151, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%153 = load i32, i32* %25
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds i32*, i32** %126, i64 %154
store i32* %152, i32** %155
%156 = load i32, i32* %25
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i32*, i32** %126, i64 %157
%159 = load i32*, i32** %158
%160 = icmp eq i32* %159, null
br i1 %160, label %161, label %165
161: ; preds = %138
%162 = getelementptr inbounds [4096 x i8], [4096 x i8]* %24, i64 0, i64 0
%163 = call i32 @puts(i8* %162)
%164 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %23
br label %176
165: ; preds = %138
br label %166
166: ; preds = %165
%167 = load i32, i32* %25
%168 = add nsw i32 %167, 1
store i32 %168, i32* %25
br label %134
169: ; preds = %134
%170 = load i32*, i32** %7
%171 = load i32*, i32** %22
%172 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %11, i64 0, i64 0
%173 = load i32, i32* %12
%174 = load i32, i32* %10
%175 = call i32 @qseq2fastq_demultiplex(i32* %170, i32* %171, i8** %172, i32 %173, i32** %126, i32 %174)
store i32 0, i32* %23
br label %176
176: ; preds = %169, %161, %131
%177 = load i8*, i8** %20
%178 = load i32, i32* %23
switch i32 %178, label %199 [
i32 0, label %179
i32 1, label %197
]
179: ; preds = %176
br label %184
180: ; preds = %119
%181 = load i32*, i32** %7
%182 = load i32, i32* %10
%183 = call i32 @qseq2fastq(i32* %181, i32 %182)
store i32 %183, i32* %8
br label %184
184: ; preds = %180, %179
%185 = load i32, i32* %8
%186 = icmp sgt i32 %185, 0
br i1 %186, label %187, label %191
187: ; preds = %184
%188 = load i32, i32* @stderr
%189 = load i8*, i8** %6
%190 = call i32 (i32, i8*, ...) @fprintf(i32 %188, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %189)
br label %191
191: ; preds = %187, %184
br label %192
192: ; preds = %191
%193 = load i32, i32* %19
%194 = add nsw i32 %193, 1
store i32 %194, i32* %19
br label %93
195: ; preds = %93
%196 = load i32, i32* %8
store i32 %196, i32* %3
br label %197
197: ; preds = %195, %176, %88, %79, %73, %72
%198 = load i32, i32* %3
ret i32 %198
199: ; preds = %176
unreachable
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"ab:d:ho:\00"
@optarg = global i8* null
@.str.2 = [2 x i8] c",\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.3 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.5 = [43 x i8] c"ERROR: Need input file (or \22-\22 for STDIN)!\00"
@.str.6 = [49 x i8] c"ERROR: Barcodes (-b) need demultiplex file (-d)!\00"
@stdin = global i32* null
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [32 x i8] c"Couldn't open demultiplex file.\00"
@.str.9 = [7 x i8] c".fastq\00"
@.str.10 = [2 x i8] c"a\00"
@.str.11 = [35 x i8] c"Couldn't open barcode output file.\00"
@.str.12 = [24 x i8] c" error in filename: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1024 x i8*]
%4 = alloca i8*
%5 = alloca [4096 x i8]
%6 = bitcast [1024 x i8*]* %3 to i8*
%7 = bitcast i8** %4 to i8*
br label %8
8: ; preds = %35, %2
%9 = phi i32 [ %36, %35 ], [ 0, %2 ]
%10 = phi i8* [ %14, %35 ], [ undef, %2 ]
%11 = phi i8* [ %18, %35 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = phi i32 [ %21, %35 ], [ 0, %2 ]
br label %13
13: ; preds = %8, %24
%14 = phi i8* [ %10, %8 ], [ %25, %24 ]
%15 = phi i8* [ %11, %8 ], [ %18, %24 ]
%16 = phi i32 [ %12, %8 ], [ %21, %24 ]
br label %17
17: ; preds = %13, %44
%18 = phi i8* [ %15, %13 ], [ %45, %44 ]
%19 = phi i32 [ %16, %13 ], [ %21, %44 ]
br label %20
20: ; preds = %22, %17
%21 = phi i32 [ %19, %17 ], [ 1, %22 ]
br label %22
22: ; preds = %20, %46
%23 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
switch i32 %23, label %132 [
i32 -1, label %57
i32 97, label %20
i32 100, label %24
i32 98, label %26
i32 111, label %44
i32 104, label %46
i32 63, label %48
]
24: ; preds = %22
%25 = load i8*, i8** @optarg
br label %13
26: ; preds = %22
%27 = load i8*, i8** @optarg
%28 = call i8* @strdup(i8* %27)
%29 = call i8* @strtok_r(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %4)
%30 = icmp eq i8* %29, null
br i1 %30, label %35, label %31
31: ; preds = %26
%32 = sext i32 %9 to i64
br label %37
33: ; preds = %37
%34 = trunc i64 %40 to i32
br label %35
35: ; preds = %33, %26
%36 = phi i32 [ %9, %26 ], [ %34, %33 ]
br label %8
37: ; preds = %31, %37
%38 = phi i64 [ %32, %31 ], [ %40, %37 ]
%39 = phi i8* [ %29, %31 ], [ %42, %37 ]
%40 = add i64 %38, 1
%41 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %3, i64 0, i64 %38
store i8* %39, i8** %41
%42 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %4)
%43 = icmp eq i8* %42, null
br i1 %43, label %33, label %37
44: ; preds = %22
%45 = load i8*, i8** @optarg
br label %17
46: ; preds = %22
%47 = call i32 (...) @usage()
br label %22
48: ; preds = %22
%49 = load i32, i32* @optopt
%50 = call i32 @isprint(i32 %49)
%51 = icmp eq i32 %50, 0
%52 = load i32, i32* @stderr
br i1 %51, label %55, label %53
53: ; preds = %48
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %49)
br label %132
55: ; preds = %48
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %49)
br label %132
57: ; preds = %22
%58 = load i32, i32* @optind
%59 = icmp eq i32 %58, %0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%62 = call i32 (...) @usage()
br label %132
63: ; preds = %57
%64 = icmp sgt i32 %9, 0
%65 = icmp eq i8* %14, null
%66 = select i1 %64, i1 %65, i1 false
br i1 %66, label %74, label %67
67: ; preds = %63
%68 = icmp slt i32 %58, %0
br i1 %68, label %69, label %132
69: ; preds = %67
%70 = zext i32 %9 to i64
%71 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%72 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %3, i64 0, i64 0
%73 = sext i32 %58 to i64
br label %77
74: ; preds = %63
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%76 = call i32 (...) @usage()
br label %132
77: ; preds = %69, %128
%78 = phi i64 [ %73, %69 ], [ %129, %128 ]
%79 = phi i32 [ undef, %69 ], [ %123, %128 ]
%80 = getelementptr inbounds i8*, i8** %1, i64 %78
%81 = load i8*, i8** %80
%82 = load i8, i8* %81
%83 = icmp eq i8 %82, 45
br i1 %83, label %84, label %90
84: ; preds = %77
%85 = getelementptr inbounds i8, i8* %81, i64 1
%86 = load i8, i8* %85
%87 = icmp eq i8 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %84
%89 = load i32*, i32** @stdin
br label %92
90: ; preds = %84, %77
%91 = call i32* @fopen(i8* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %92
92: ; preds = %90, %88
%93 = phi i32* [ %89, %88 ], [ %91, %90 ]
br i1 %64, label %94, label %120
94: ; preds = %92
%95 = call i8* @llvm.stacksave()
%96 = alloca i32*, i64 %70
%97 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%98 = icmp eq i32* %97, null
br i1 %98, label %99, label %101
99: ; preds = %94
%100 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
br label %132
101: ; preds = %94
br label %104
102: ; preds = %104
%103 = icmp eq i64 %114, %70
br i1 %103, label %115, label %104
104: ; preds = %101, %102
%105 = phi i64 [ 0, %101 ], [ %114, %102 ]
store i8 0, i8* %71
%106 = call i32 @strcat(i8* %71, i8* %18)
%107 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %3, i64 0, i64 %105
%108 = load i8*, i8** %107
%109 = call i32 @strcat(i8* %71, i8* %108)
%110 = call i32 @strcat(i8* %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%111 = call i32* @fopen(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%112 = getelementptr inbounds i32*, i32** %96, i64 %105
store i32* %111, i32** %112
%113 = icmp eq i32* %111, null
%114 = add nuw nsw i64 %105, 1
br i1 %113, label %117, label %102
115: ; preds = %102
%116 = call i32 @qseq2fastq_demultiplex(i32* %93, i32* %97, i8** %72, i32 %9, i32** %96, i32 %21)
br label %122
117: ; preds = %104
%118 = call i32 @puts(i8* %71)
%119 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0))
br label %132
120: ; preds = %92
%121 = call i32 @qseq2fastq(i32* %93, i32 %21)
br label %122
122: ; preds = %115, %120
%123 = phi i32 [ %121, %120 ], [ %79, %115 ]
%124 = icmp sgt i32 %123, 0
br i1 %124, label %125, label %128
125: ; preds = %122
%126 = load i32, i32* @stderr
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %81)
br label %128
128: ; preds = %122, %125
%129 = add nsw i64 %78, 1
%130 = trunc i64 %129 to i32
%131 = icmp eq i32 %130, %0
br i1 %131, label %132, label %77
132: ; preds = %22, %128, %67, %99, %117, %53, %55, %74, %60
%133 = phi i32 [ 1, %60 ], [ 1, %74 ], [ 1, %55 ], [ 1, %53 ], [ 1, %117 ], [ 1, %99 ], [ undef, %67 ], [ %123, %128 ], [ 1, %22 ]
ret i32 %133
}