#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 EOF;
int EXIT_FAILURE;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *, int, char *);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ stdout;
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int main(int argc, char **argv) {
  int opt;
  int i;
  char *filename_inputFile = NULL;
  char *filename_outputFile = NULL;
  FILE *inputFile;
  FILE *outputFile;
  char *line = NULL;
  size_t line_len = 0;
  size_t line_buffer = 0;
  while ((opt = getopt(argc, argv, "i:o:")) != -1) {
    switch (opt) {
    case 'i':
      filename_inputFile = optarg;
      break;
    case 'o':
      filename_outputFile = optarg;
      break;
    default:
      fprintf(stderr, "error %s\n", argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  if (filename_inputFile == NULL) {
    fprintf(stderr, "Error undefined samFile input, don't forget -i");
    return EXIT_FAILURE;
  }
  if (filename_outputFile == NULL) {
    fprintf(stderr, "Error undefined output file, don't forget -o");
    return EXIT_FAILURE;
  }
  inputFile = fopen(filename_inputFile, "r");
  if (inputFile == NULL) {
    fprintf(stderr, "[%s:%d] Error opening file %s : %s.\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/emlec/Sam2SQL/refs/heads/master/src/"
            "sam2sql.c",
            59, filename_inputFile, strerror(errno));
    return (EXIT_FAILURE);
  }
  outputFile = fopen(filename_outputFile, "w");
  if (inputFile == NULL) {
    fprintf(stderr, "[%s:%d] Error opening file %s : %s.\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/emlec/Sam2SQL/refs/heads/master/src/"
            "sam2sql.c",
            65, filename_outputFile, strerror(errno));
    return (EXIT_FAILURE);
  }
  fprintf(
      outputFile,
      "ref_name\tread_name\twell_it\tposition\ttype_mut\tbase_ref\tbase_alt\n");
  while (!feof(inputFile)) {
    int c;
    line_len = 0;
    int columns[20];
    int num_cols = 0;
    columns[0] = 0;
    while ((c = fgetc(inputFile)) != EOF && c != '\n') {
      if (line == NULL || line_len + 2 >= line_buffer) {
        line_buffer += 2048;
        line = (char *)realloc(line, sizeof(char) * (line_buffer));
        if (line == NULL) {
          fprintf(stderr, "[%s:%d] OUT OF MEMORY",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/emlec/Sam2SQL/refs/heads/"
                  "master/src/sam2sql.c",
                  94);
          exit(EXIT_FAILURE);
        }
        assert(line != NULL);
      }
      if (c == '\t' && num_cols + 1 < 20) {
        c = 0;
        ++num_cols;
        columns[num_cols] = line_len + 1;
      }
      line[line_len] = c;
      line_len++;
    }
    line[line_len] = 0;
    if (line[0] == '@')
      continue;
    fprintf(stdout, "%s\n", line);
    for (i = 0; i < num_cols; ++i) {
      printf("col[%d]=%s\n", i, &line[columns[i]]);
    }
    fprintf(stdout, "CIGAR=%s\n", &line[columns[5]]);
    int cigar_len = strlen(&line[columns[5]]);
    fprintf(stdout, "CIGAR_LEN = %d\n", cigar_len);
    fprintf(stderr, "\n");
    do {
    } while (0);
    free(line);
  }
  fclose(inputFile);
  fclose(outputFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xde1(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12b3 <main+0xe3>
mov    -0x14(%rbp),%eax
mov    %eax,-0xbc(%rbp)
sub    $0x69,%eax
je     125b <main+0x8b>
jmp    1247 <main+0x77>
mov    -0xbc(%rbp),%eax
sub    $0x6f,%eax
je     126e <main+0x9e>
jmp    1281 <main+0xb1>
mov    0x2d96(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    12ae <main+0xde>
mov    0x2d83(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    12ae <main+0xde>
mov    0x2d48(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    1211 <main+0x41>
cmpq   $0x0,-0x20(%rbp)
jne    12e7 <main+0x117>
mov    0x2d0b(%rip),%rax
mov    (%rax),%rdi
lea    0xd40(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    16d6 <main+0x506>
cmpq   $0x0,-0x28(%rbp)
jne    131b <main+0x14b>
mov    0x2cd7(%rip),%rax
mov    (%rax),%rdi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2caf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    16d6 <main+0x506>
mov    -0x20(%rbp),%rdi
lea    0xd45(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    13a0 <main+0x1d0>
mov    0x2c8f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    0x2c6b(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xd0(%rbp),%rdi
mov    -0xc8(%rbp),%r8
mov    %rax,%r9
lea    0xcf1(%rip),%rsi
lea    0xd0f(%rip),%rdx
mov    $0x3b,%ecx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    16d6 <main+0x506>
mov    -0x28(%rbp),%rdi
lea    0xd6f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1425 <main+0x255>
mov    0x2c0a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xe0(%rbp),%rdi
mov    -0xd8(%rbp),%r8
mov    %rax,%r9
lea    0xc6c(%rip),%rsi
lea    0xc8a(%rip),%rdx
mov    $0x41,%ecx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ba5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    16d6 <main+0x506>
mov    -0x38(%rbp),%rdi
lea    0xcec(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1455 <main+0x285>
jmp    16bd <main+0x4ed>
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb0(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x54(%rbp)
xor    %eax,%eax
mov    0x2b58(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xe1(%rbp)
je     14a3 <main+0x2d3>
cmpl   $0xa,-0x54(%rbp)
setne  %al
mov    %al,-0xe1(%rbp)
mov    -0xe1(%rbp),%al
test   $0x1,%al
jne    14b6 <main+0x2e6>
jmp    15b2 <main+0x3e2>
cmpq   $0x0,-0x40(%rbp)
je     14d3 <main+0x303>
mov    -0x48(%rbp),%rax
add    $0x2,%rax
cmp    -0x50(%rbp),%rax
jb     1547 <main+0x377>
mov    -0x50(%rbp),%rax
add    $0x800,%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   10b0 <realloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1535 <main+0x365>
mov    0x2ac6(%rip),%rax
mov    (%rax),%rdi
lea    0xc48(%rip),%rsi
lea    0xb77(%rip),%rdx
mov    $0x5e,%ecx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2a92(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpq   $0x0,-0x40(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
cmpl   $0x9,-0x54(%rbp)
jne    1591 <main+0x3c1>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
cmp    $0x14,%eax
jge    1591 <main+0x3c1>
movl   $0x0,-0x54(%rbp)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %eax,%ecx
movslq -0xb4(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0x54(%rbp),%eax
mov    %al,%dl
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1471 <main+0x2a1>
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    15d3 <main+0x403>
jmp    1437 <main+0x267>
mov    0x29de(%rip),%rax
movslq (%rax),%rdi
mov    -0x40(%rbp),%rdx
lea    0xa23(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    1635 <main+0x465>
mov    -0x18(%rbp),%esi
mov    -0x40(%rbp),%rdx
movslq -0x18(%rbp),%rax
movslq -0xb0(%rbp,%rax,4),%rax
ff
add    %rax,%rdx
lea    0xb50(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    15f6 <main+0x426>
mov    0x297c(%rip),%rax
movslq (%rax),%rdi
mov    -0x40(%rbp),%rdx
movslq -0x9c(%rbp),%rax
add    %rax,%rdx
lea    0xb2a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
movslq -0x9c(%rbp),%rax
add    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,-0xb8(%rbp)
mov    0x293d(%rip),%rax
movslq (%rax),%rdi
mov    -0xb8(%rbp),%edx
lea    0xafd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2937(%rip),%rax
mov    (%rax),%rdi
lea    0x9ed(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    16af <main+0x4df>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    1437 <main+0x267>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r14d,%r14d
lea    0xdf3(%rip),%r12
mov    0x2de4(%rip),%r13
xor    %r15d,%r15d
jmp    1224 <main+0x34>
nopl   0x0(%rax)
mov    0x0(%r13),%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10e0 <getopt@plt>
cmp    $0x69,%eax
je     1220 <main+0x30>
cmp    $0xffffffff,%eax
je     124a <main+0x5a>
cmp    $0x6f,%eax
jne    14f0 <main+0x300>
mov    0x0(%r13),%r14
jmp    1224 <main+0x34>
test   %r15,%r15
je     12c6 <main+0xd6>
test   %r14,%r14
je     12de <main+0xee>
lea    0xe0c(%rip),%rsi
mov    %r15,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1316 <main+0x126>
mov    %rax,%rbx
lea    0xea0(%rip),%rsi
mov    %r14,%rdi
call   10d0 <fopen@plt>
lea    0xe93(%rip),%rdi
mov    $0x3f,%esi
mov    $0x1,%edx
mov    %rax,0x8(%rsp)
mov    %rax,%rcx
call   1100 <fwrite@plt>
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
je     1353 <main+0x163>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1307 <main+0x117>
mov    0x2d03(%rip),%rax
mov    (%rax),%rcx
lea    0xd38(%rip),%rdi
mov    $0x2e,%esi
jmp    12f4 <main+0x104>
mov    0x2ceb(%rip),%rax
mov    (%rax),%rcx
lea    0xd4f(%rip),%rdi
mov    $0x2c,%esi
mov    $0x1,%edx
call   1100 <fwrite@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cb3(%rip),%rax
mov    (%rax),%rbx
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd38(%rip),%rsi
lea    0xd56(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3b,%ecx
mov    %r15,%r8
mov    %rax,%r9
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    12fe <main+0x10e>
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    13cd <main+0x1dd>
nopl   0x0(%rax,%rax,1)
mov    0x2c51(%rip),%rbx
movslq (%rbx),%rdi
movslq 0x24(%rsp),%rbp
add    %r15,%rbp
lea    0xe05(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
movslq (%rbx),%rdi
lea    0xdf3(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2c2b(%rip),%rax
mov    (%rax),%rsi
mov    $0xa,%edi
call   1080 <fputc@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rbx
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    12b0 <main+0xc0>
movl   $0x0,0x10(%rsp)
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    $0xa,%eax
je     1480 <main+0x290>
mov    %eax,%r13d
mov    0x2bf0(%rip),%rax
cmp    (%rax),%r13d
je     1480 <main+0x290>
xor    %ebp,%ebp
xor    %r12d,%r12d
xchg   %ax,%ax
test   %r15,%r15
je     140f <main+0x21f>
lea    0x2(%r12),%rax
cmp    %r14,%rax
jb     1437 <main+0x247>
add    $0x800,%r14
mov    %r15,%rdi
mov    %r14d,%esi
call   10c0 <realloc@plt>
test   %rax,%rax
je     150d <main+0x31d>
mov    %rax,%r15
mov    $0x1,%edi
call   1090 <assert@plt>
cmp    $0x9,%r13d
jne    145a <main+0x26a>
mov    $0x9,%r13d
cmp    $0x12,%ebp
jg     145a <main+0x26a>
add    $0x1,%ebp
lea    0x1(%r12),%eax
movslq %ebp,%rcx
mov    %eax,0x10(%rsp,%rcx,4)
xor    %r13d,%r13d
mov    %r13b,(%r15,%r12,1)
add    $0x1,%r12
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    $0xa,%eax
je     1485 <main+0x295>
mov    %eax,%r13d
mov    0x2b67(%rip),%rax
cmp    (%rax),%r13d
jne    1400 <main+0x210>
jmp    1485 <main+0x295>
xor    %r12d,%r12d
xor    %ebp,%ebp
movb   $0x0,(%r15,%r12,1)
cmpb   $0x40,(%r15)
lea    0xcdd(%rip),%r13
je     13bd <main+0x1cd>
mov    %rbx,%r12
mov    0x2b13(%rip),%rax
movslq (%rax),%rdi
lea    0xb5c(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %ebp,%ebp
jle    1360 <main+0x170>
mov    %ebp,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movslq 0x10(%rsp,%rbp,4),%rdx
add    %r15,%rdx
mov    %r13,%rdi
mov    %ebp,%esi
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    14d0 <main+0x2e0>
jmp    1360 <main+0x170>
mov    0x2ad9(%rip),%rax
mov    (%rax),%rdi
mov    (%rbx),%rdx
lea    0xb01(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1531 <main+0x341>
mov    0x2abc(%rip),%rax
mov    (%rax),%rdi
lea    0xc3e(%rip),%rsi
lea    0xb6d(%rip),%rdx
mov    $0x5e,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2a88(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"i:o:\00"
@optarg = global i8* null
@stderr = global i32* null
@.str.1 = [10 x i8] c"error %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [47 x i8] c"Error undefined samFile input, don't forget -i\00"
@.str.3 = [45 x i8] c"Error undefined output file, don't forget -o\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [37 x i8] c"[%s:%d] Error opening file %s : %s.\0A\00"
@.str.6 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/emlec/Sam2SQL/refs/heads/master/src/sam2sql.c\00"
@errno = global i32 0
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [64 x i8] c"ref_name\09read_name\09well_it\09position\09type_mut\09base_ref\09base_alt\0A\00"
@EOF = global i32 0
@.str.9 = [22 x i8] c"[%s:%d] OUT OF MEMORY\00"
@stdout = global i32 0
@.str.10 = [4 x i8] c"%s\0A\00"
@.str.11 = [12 x i8] c"col[%d]=%s\0A\00"
@.str.12 = [10 x i8] c"CIGAR=%s\0A\00"
@.str.13 = [16 x i8] c"CIGAR_LEN = %d\0A\00"
@.str.14 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca [20 x i32]
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %12
store i64 0, i64* %13
store i64 0, i64* %14
br label %19
19: ; preds = %38, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call i32 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %22, i32* %6
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %39
24: ; preds = %19
%25 = load i32, i32* %6
switch i32 %25, label %30 [
i32 105, label %26
i32 111, label %28
]
26: ; preds = %24
%27 = load i8*, i8** @optarg
store i8* %27, i8** %8
br label %38
28: ; preds = %24
%29 = load i8*, i8** @optarg
store i8* %29, i8** %9
br label %38
30: ; preds = %24
%31 = load i32*, i32** @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %28, %26
br label %19
39: ; preds = %19
%40 = load i8*, i8** %8
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32*, i32** @stderr
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
store i32 %45, i32* %3
br label %215
46: ; preds = %39
%47 = load i8*, i8** %9
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i32*, i32** @stderr
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
store i32 %52, i32* %3
br label %215
53: ; preds = %46
%54 = load i8*, i8** %8
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %55, i32** %10
%56 = load i32*, i32** %10
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %65
58: ; preds = %53
%59 = load i32*, i32** @stderr
%60 = load i8*, i8** %8
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.6, i64 0, i64 0), i32 59, i8* %60, i8* %62)
%64 = load i32, i32* @EXIT_FAILURE
store i32 %64, i32* %3
br label %215
65: ; preds = %53
%66 = load i8*, i8** %9
%67 = call i32* @fopen(i8* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %67, i32** %11
%68 = load i32*, i32** %10
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %77
70: ; preds = %65
%71 = load i32*, i32** @stderr
%72 = load i8*, i8** %9
%73 = load i32, i32* @errno
%74 = call i8* @strerror(i32 %73)
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.6, i64 0, i64 0), i32 65, i8* %72, i8* %74)
%76 = load i32, i32* @EXIT_FAILURE
store i32 %76, i32* %3
br label %215
77: ; preds = %65
%78 = load i32*, i32** %11
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.8, i64 0, i64 0))
br label %80
80: ; preds = %207, %159, %77
%81 = load i32*, i32** %10
%82 = call i32 @feof(i32* %81)
%83 = icmp ne i32 %82, 0
%84 = xor i1 %83, true
br i1 %84, label %85, label %210
85: ; preds = %80
store i64 0, i64* %13
store i32 0, i32* %17
%86 = getelementptr inbounds [20 x i32], [20 x i32]* %16, i64 0, i64 0
store i32 0, i32* %86
br label %87
87: ; preds = %142, %85
%88 = load i32*, i32** %10
%89 = call i32 @fgetc(i32* %88)
store i32 %89, i32* %15
%90 = load i32, i32* @EOF
%91 = icmp ne i32 %89, %90
br i1 %91, label %92, label %95
92: ; preds = %87
%93 = load i32, i32* %15
%94 = icmp ne i32 %93, 10
br label %95
95: ; preds = %92, %87
%96 = phi i1 [ false, %87 ], [ %94, %92 ]
br i1 %96, label %97, label %150
97: ; preds = %95
%98 = load i8*, i8** %12
%99 = icmp eq i8* %98, null
br i1 %99, label %105, label %100
100: ; preds = %97
%101 = load i64, i64* %13
%102 = add i64 %101, 2
%103 = load i64, i64* %14
%104 = icmp uge i64 %102, %103
br i1 %104, label %105, label %126
105: ; preds = %100, %97
%106 = load i64, i64* %14
%107 = add i64 %106, 2048
store i64 %107, i64* %14
%108 = load i8*, i8** %12
%109 = load i64, i64* %14
%110 = mul i64 1, %109
%111 = trunc i64 %110 to i32
%112 = call i64 @realloc(i8* %108, i32 %111)
%113 = inttoptr i64 %112 to i8*
store i8* %113, i8** %12
%114 = load i8*, i8** %12
%115 = icmp eq i8* %114, null
br i1 %115, label %116, label %121
116: ; preds = %105
%117 = load i32*, i32** @stderr
%118 = call i32 (i32*, i8*, ...) @fprintf(i32* %117, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.6, i64 0, i64 0), i32 94)
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @exit(i32 %119)
unreachable
121: ; preds = %105
%122 = load i8*, i8** %12
%123 = icmp ne i8* %122, null
%124 = zext i1 %123 to i32
%125 = call i32 @assert(i32 %124)
br label %126
126: ; preds = %121, %100
%127 = load i32, i32* %15
%128 = icmp eq i32 %127, 9
br i1 %128, label %129, label %142
129: ; preds = %126
%130 = load i32, i32* %17
%131 = add nsw i32 %130, 1
%132 = icmp slt i32 %131, 20
br i1 %132, label %133, label %142
133: ; preds = %129
store i32 0, i32* %15
%134 = load i32, i32* %17
%135 = add nsw i32 %134, 1
store i32 %135, i32* %17
%136 = load i64, i64* %13
%137 = add i64 %136, 1
%138 = trunc i64 %137 to i32
%139 = load i32, i32* %17
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [20 x i32], [20 x i32]* %16, i64 0, i64 %140
store i32 %138, i32* %141
br label %142
142: ; preds = %133, %129, %126
%143 = load i32, i32* %15
%144 = trunc i32 %143 to i8
%145 = load i8*, i8** %12
%146 = load i64, i64* %13
%147 = getelementptr inbounds i8, i8* %145, i64 %146
store i8 %144, i8* %147
%148 = load i64, i64* %13
%149 = add i64 %148, 1
store i64 %149, i64* %13
br label %87
150: ; preds = %95
%151 = load i8*, i8** %12
%152 = load i64, i64* %13
%153 = getelementptr inbounds i8, i8* %151, i64 %152
store i8 0, i8* %153
%154 = load i8*, i8** %12
%155 = getelementptr inbounds i8, i8* %154, i64 0
%156 = load i8, i8* %155
%157 = sext i8 %156 to i32
%158 = icmp eq i32 %157, 64
br i1 %158, label %159, label %160
159: ; preds = %150
br label %80
160: ; preds = %150
%161 = load i32, i32* @stdout
%162 = sext i32 %161 to i64
%163 = inttoptr i64 %162 to i32*
%164 = load i8*, i8** %12
%165 = call i32 (i32*, i8*, ...) @fprintf(i32* %163, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %164)
store i32 0, i32* %7
br label %166
166: ; preds = %180, %160
%167 = load i32, i32* %7
%168 = load i32, i32* %17
%169 = icmp slt i32 %167, %168
br i1 %169, label %170, label %183
170: ; preds = %166
%171 = load i32, i32* %7
%172 = load i8*, i8** %12
%173 = load i32, i32* %7
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds [20 x i32], [20 x i32]* %16, i64 0, i64 %174
%176 = load i32, i32* %175
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds i8, i8* %172, i64 %177
%179 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %171, i8* %178)
br label %180
180: ; preds = %170
%181 = load i32, i32* %7
%182 = add nsw i32 %181, 1
store i32 %182, i32* %7
br label %166
183: ; preds = %166
%184 = load i32, i32* @stdout
%185 = sext i32 %184 to i64
%186 = inttoptr i64 %185 to i32*
%187 = load i8*, i8** %12
%188 = getelementptr inbounds [20 x i32], [20 x i32]* %16, i64 0, i64 5
%189 = load i32, i32* %188
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds i8, i8* %187, i64 %190
%192 = call i32 (i32*, i8*, ...) @fprintf(i32* %186, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* %191)
%193 = load i8*, i8** %12
%194 = getelementptr inbounds [20 x i32], [20 x i32]* %16, i64 0, i64 5
%195 = load i32, i32* %194
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds i8, i8* %193, i64 %196
%198 = call i32 @strlen(i8* %197)
store i32 %198, i32* %18
%199 = load i32, i32* @stdout
%200 = sext i32 %199 to i64
%201 = inttoptr i64 %200 to i32*
%202 = load i32, i32* %18
%203 = call i32 (i32*, i8*, ...) @fprintf(i32* %201, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), i32 %202)
%204 = load i32*, i32** @stderr
%205 = call i32 (i32*, i8*, ...) @fprintf(i32* %204, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %206
206: ; preds = %183
br label %207
207: ; preds = %206
%208 = load i8*, i8** %12
%209 = call i32 @free(i8* %208)
br label %80
210: ; preds = %80
%211 = load i32*, i32** %10
%212 = call i32 @fclose(i32* %211)
%213 = load i32*, i32** %11
%214 = call i32 @fclose(i32* %213)
store i32 0, i32* %3
br label %215
215: ; preds = %210, %70, %58, %49, %42
%216 = load i32, i32* %3
ret i32 %216
}

LLVM IR (-O2):
@.str = [5 x i8] c"i:o:\00"
@optarg = global i8* null
@stderr = global i32* null
@.str.1 = [10 x i8] c"error %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [47 x i8] c"Error undefined samFile input, don't forget -i\00"
@.str.3 = [45 x i8] c"Error undefined output file, don't forget -o\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [37 x i8] c"[%s:%d] Error opening file %s : %s.\0A\00"
@.str.6 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/emlec/Sam2SQL/refs/heads/master/src/sam2sql.c\00"
@errno = global i32 0
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [64 x i8] c"ref_name\09read_name\09well_it\09position\09type_mut\09base_ref\09base_alt\0A\00"
@EOF = global i32 0
@.str.9 = [22 x i8] c"[%s:%d] OUT OF MEMORY\00"
@stdout = global i32 0
@.str.10 = [4 x i8] c"%s\0A\00"
@.str.11 = [12 x i8] c"col[%d]=%s\0A\00"
@.str.12 = [10 x i8] c"CIGAR=%s\0A\00"
@.str.13 = [16 x i8] c"CIGAR_LEN = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [20 x i32]
br label %4
4: ; preds = %12, %2
%5 = phi i8* [ %13, %12 ], [ null, %2 ]
%6 = phi i8* [ %8, %12 ], [ null, %2 ]
br label %7
7: ; preds = %4, %10
%8 = phi i8* [ %11, %10 ], [ %6, %4 ]
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %14 [
i32 -1, label %20
i32 105, label %10
i32 111, label %12
]
10: ; preds = %7
%11 = load i8*, i8** @optarg
br label %7
12: ; preds = %7
%13 = load i8*, i8** @optarg
br label %4
14: ; preds = %7
%15 = load i32*, i32** @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %7
%21 = icmp eq i8* %8, null
br i1 %21, label %22, label %26
22: ; preds = %20
%23 = load i32*, i32** @stderr
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i64 46, i64 1, i32* %23)
%25 = load i32, i32* @EXIT_FAILURE
br label %152
26: ; preds = %20
%27 = icmp eq i8* %5, null
br i1 %27, label %28, label %32
28: ; preds = %26
%29 = load i32*, i32** @stderr
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i64 44, i64 1, i32* %29)
%31 = load i32, i32* @EXIT_FAILURE
br label %152
32: ; preds = %26
%33 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load i32*, i32** @stderr
%37 = load i32, i32* @errno
%38 = tail call i8* @strerror(i32 %37)
%39 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.6, i64 0, i64 0), i32 59, i8* %8, i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
br label %152
41: ; preds = %32
%42 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%43 = tail call i64 @fwrite(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.8, i64 0, i64 0), i64 63, i64 1, i32* %42)
%44 = tail call i32 @feof(i32* %33)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %149
46: ; preds = %41
%47 = bitcast [20 x i32]* %3 to i8*
%48 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%49 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 5
br label %50
50: ; preds = %46, %146
%51 = phi i64 [ 0, %46 ], [ %107, %146 ]
%52 = phi i8* [ null, %46 ], [ %105, %146 ]
store i32 0, i32* %48
%53 = tail call i32 @fgetc(i32* %33)
%54 = load i32, i32* @EOF
%55 = icmp ne i32 %53, %54
%56 = icmp ne i32 %53, 10
%57 = and i1 %56, %55
br i1 %57, label %58, label %104
58: ; preds = %50, %93
%59 = phi i32 [ %99, %93 ], [ %53, %50 ]
%60 = phi i32 [ %95, %93 ], [ 0, %50 ]
%61 = phi i64 [ %83, %93 ], [ %51, %50 ]
%62 = phi i64 [ %98, %93 ], [ 0, %50 ]
%63 = phi i8* [ %82, %93 ], [ %52, %50 ]
%64 = icmp ne i8* %63, null
%65 = add i64 %62, 2
%66 = icmp ult i64 %65, %61
%67 = select i1 %64, i1 %66, i1 false
br i1 %67, label %81, label %68
68: ; preds = %58
%69 = add i64 %61, 2048
%70 = trunc i64 %69 to i32
%71 = tail call i64 @realloc(i8* %63, i32 %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %78
73: ; preds = %68
%74 = load i32*, i32** @stderr
%75 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.6, i64 0, i64 0), i32 94)
%76 = load i32, i32* @EXIT_FAILURE
%77 = tail call i32 @exit(i32 %76)
unreachable
78: ; preds = %68
%79 = inttoptr i64 %71 to i8*
%80 = tail call i32 @assert(i32 1)
br label %81
81: ; preds = %58, %78
%82 = phi i8* [ %79, %78 ], [ %63, %58 ]
%83 = phi i64 [ %69, %78 ], [ %61, %58 ]
%84 = icmp eq i32 %59, 9
br i1 %84, label %85, label %93
85: ; preds = %81
%86 = add nsw i32 %60, 1
%87 = icmp slt i32 %60, 19
br i1 %87, label %88, label %93
88: ; preds = %85
%89 = trunc i64 %62 to i32
%90 = add i32 %89, 1
%91 = sext i32 %86 to i64
%92 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %91
store i32 %90, i32* %92
br label %93
93: ; preds = %88, %85, %81
%94 = phi i32 [ 0, %88 ], [ 9, %85 ], [ %59, %81 ]
%95 = phi i32 [ %86, %88 ], [ %60, %85 ], [ %60, %81 ]
%96 = trunc i32 %94 to i8
%97 = getelementptr inbounds i8, i8* %82, i64 %62
store i8 %96, i8* %97
%98 = add i64 %62, 1
%99 = tail call i32 @fgetc(i32* %33)
%100 = load i32, i32* @EOF
%101 = icmp ne i32 %99, %100
%102 = icmp ne i32 %99, 10
%103 = and i1 %102, %101
br i1 %103, label %58, label %104
104: ; preds = %93, %50
%105 = phi i8* [ %52, %50 ], [ %82, %93 ]
%106 = phi i64 [ 0, %50 ], [ %98, %93 ]
%107 = phi i64 [ %51, %50 ], [ %83, %93 ]
%108 = phi i32 [ 0, %50 ], [ %95, %93 ]
%109 = getelementptr inbounds i8, i8* %105, i64 %106
store i8 0, i8* %109
%110 = load i8, i8* %105
%111 = icmp eq i8 %110, 64
br i1 %111, label %146, label %112
112: ; preds = %104
%113 = load i32, i32* @stdout
%114 = sext i32 %113 to i64
%115 = inttoptr i64 %114 to i32*
%116 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %115, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %105)
%117 = icmp sgt i32 %108, 0
br i1 %117, label %118, label %130
118: ; preds = %112
%119 = zext i32 %108 to i64
br label %120
120: ; preds = %118, %120
%121 = phi i64 [ 0, %118 ], [ %128, %120 ]
%122 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %121
%123 = load i32, i32* %122
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %105, i64 %124
%126 = trunc i64 %121 to i32
%127 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %126, i8* %125)
%128 = add nuw nsw i64 %121, 1
%129 = icmp eq i64 %128, %119
br i1 %129, label %130, label %120
130: ; preds = %120, %112
%131 = load i32, i32* @stdout
%132 = sext i32 %131 to i64
%133 = inttoptr i64 %132 to i32*
%134 = load i32, i32* %49
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds i8, i8* %105, i64 %135
%137 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %133, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* %136)
%138 = tail call i32 @strlen(i8* %136)
%139 = load i32, i32* @stdout
%140 = sext i32 %139 to i64
%141 = inttoptr i64 %140 to i32*
%142 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %141, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), i32 %138)
%143 = load i32*, i32** @stderr
%144 = tail call i32 @fputc(i32 10, i32* %143)
%145 = tail call i32 @free(i8* %105)
br label %146
146: ; preds = %104, %130
%147 = tail call i32 @feof(i32* %33)
%148 = icmp eq i32 %147, 0
br i1 %148, label %50, label %149
149: ; preds = %146, %41
%150 = tail call i32 @fclose(i32* %33)
%151 = tail call i32 @fclose(i32* %42)
br label %152
152: ; preds = %149, %35, %28, %22
%153 = phi i32 [ %25, %22 ], [ %31, %28 ], [ %40, %35 ], [ 0, %149 ]
ret i32 %153
}