// File: /workspace/github_c_makefile_star2_O3/jsh58[P]Genrich/Genrich.c
// Function: readBAM
uint64_t readBAM(gzFile in, char* line, Aln** aln,
    char* readName, double* totalLen, uint64_t* unmapped,
    uint64_t* paired, uint64_t* single, uint64_t* pairedPr,
    uint64_t* singlePr, uint64_t* supp, uint64_t* skipped,
    uint64_t* lowMapQ, int minMapQ, int xcount,
    char** xchrList, int xBedLen, Bed* xBed,
    uint64_t* secPair, uint64_t* secSingle,
    uint64_t* orphan, int* chromLen, Chrom** chrom,
    bool singleOpt, bool extendOpt, int extend,
    bool avgExtOpt, Aln*** unpair, int* unpairMem,
    float asDiff, bool atacOpt, int atacLen5, int atacLen3,
    bool atacAdj, File bed, bool bedOpt, bool gzOut,
    bool ctrl, int sample, bool dupsOpt, File dups,
    bool dupsVerb, Read*** readPr, int* readMemPr,
    Read*** readDc, int* readMemDc, Read*** readSn,
    int* readMemSn, HashAln*** table, uint32_t* tableMem,
    HashAln*** tableSn, uint32_t* tableSnMem,
    uint32_t** order, uint32_t** order0, uint32_t** order1,
    uint32_t** order2, uint16_t** qual, uint16_t** qual0,
    uint16_t** qual1, uint16_t** qual2, uint32_t* arrMem,
    uint64_t* countPr, uint64_t* dupsPr, uint64_t* countDc,
    uint64_t* dupsDc, uint64_t* countSn, uint64_t* dupsSn,
    uint64_t* errCount, bool sortOpt, bool verbose) {

  // load first line from header
  int32_t l_text = readInt32(in, true);
  int i;
  for (i = 0; i < l_text; i++) {
    int m = gzgetc(in);
    if (m == -1)
      exit(error("", ERRBAM));
    unsigned char n = m;
    if (n == '\n' || n == '\0')
      break;
    line[i] = n;
  }
  line[i] = '\0';
  // check sort order
  char* tag = strtok(line, TAB);
  if (tag == NULL || strcmp(tag, "@HD"))
    exit(error("", ERRBAM));
  char* sortOrder = NULL;
  char* field = strtok(NULL, TAB);
  while (field != NULL) {
    if (!strncmp(field, "SO:", 3))
      sortOrder = field + 3;
    field = strtok(NULL, TAB);
  }
  if (sortOpt && (sortOrder == NULL
      || strcmp(sortOrder, "queryname")))
    exit(error("", ERRSORT));
  if (gzseek(in, l_text - i - 1, SEEK_CUR) == -1)
    exit(error("", ERRBAM));

  // save chromosome lengths
  int32_t n_ref = readInt32(in, true); // number of ref sequences
  int idx[n_ref];  // index of reference sequences into *chrom array
  for (int i = 0; i < n_ref; i++) {
    int32_t len = readInt32(in, true);
    if (len < 1 || len > MAX_SIZE)
      exit(error("", ERRBAM));
    for (int j = 0; j < len; j++) {
      int m = gzgetc(in);
      if (m == -1)
        exit(error("", ERRBAM));
      line[j] = m;
    }
    if (line[len-1] != '\0')
      exit(error("", ERRBAM));
    idx[i] = saveChrom(line, (uint32_t) readInt32(in, true),
      chromLen, chrom, xcount, xchrList, xBedLen, xBed,
      ctrl, verbose);
  }

  return parseBAM(in, line, aln, readName, *chromLen,
    *chrom, n_ref, idx, totalLen, unmapped, paired, single,
    pairedPr, singlePr, supp, skipped, lowMapQ, minMapQ,
    secPair, secSingle, orphan, singleOpt, extendOpt,
    extend, avgExtOpt, unpair, unpairMem, asDiff, atacOpt,
    atacLen5, atacLen3, atacAdj, bed, bedOpt, gzOut, ctrl,
    sample, dupsOpt, dups, dupsVerb, readPr, readMemPr,
    readDc, readMemDc, readSn, readMemSn, table, tableMem,
    tableSn, tableSnMem, order, order0, order1, order2,
    qual, qual0, qual1, qual2, arrMem, countPr, dupsPr,
    countDc, dupsDc, countSn, dupsSn, errCount, verbose);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movss %xmm0, -0x34(%rbp)
movq %r9, %r15
movq %r8, %r14
movq %rcx, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
movq %rsi, %r13
movq %rdi, %rbx
movl $0x1, %esi
callq 0xd9a7
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
xorl %r12d, %r12d
testl %eax, %eax
jle 0xe818
movl (%rbx), %eax
testl %eax, %eax
je 0xe7e9
decl %eax
movl %eax, (%rbx)
incq 0x10(%rbx)
movq 0x8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rbx)
movzbl (%rax), %eax
jmp 0xe7fa
movq %rbx, %rdi
callq 0x20a0
cmpl $-0x1, %eax
je 0xebd4
testb %al, %al
je 0xe818
movzbl %al, %ecx
cmpl $0xa, %ecx
je 0xe818
movb %al, (%r13,%r12)
incq %r12
cmpq %r12, -0x30(%rbp)
jne 0xe7ca
movq -0x30(%rbp), %r12
movl %r12d, %eax
movb $0x0, (%r13,%rax)
leaq 0x5339(%rip), %rsi      # 0x13b61
movq %r13, %rdi
callq 0x2280
testq %rax, %rax
je 0xebd9
leaq 0x5323(%rip), %rsi      # 0x13b63
movq %rax, %rdi
callq 0x21b0
testl %eax, %eax
jne 0xebd9
movq %r15, -0x70(%rbp)
movq %r14, -0x78(%rbp)
leaq 0x5302(%rip), %rsi      # 0x13b61
xorl %edi, %edi
callq 0x2280
testq %rax, %rax
je 0xe8c1
xorl %r14d, %r14d
leaq 0x52ec(%rip), %r15      # 0x13b61
cmpb $0x53, (%rax)
jne 0xe88c
cmpb $0x4f, 0x1(%rax)
jne 0xe88c
leaq 0x3(%rax), %rcx
cmpb $0x3a, 0x2(%rax)
cmoveq %rcx, %r14
xorl %edi, %edi
movq %r15, %rsi
callq 0x2280
testq %rax, %rax
jne 0xe875
cmpb $0x0, 0x1f8(%rbp)
je 0xe8ca
testq %r14, %r14
je 0xe8bc
leaq 0x52b7(%rip), %rsi      # 0x13b67
movq %r14, %rdi
callq 0x21b0
testl %eax, %eax
je 0xe8ca
callq 0x319a
cmpb $0x0, 0x1f8(%rbp)
jne 0xe8bc
notl %r12d
addl -0x30(%rbp), %r12d
movslq %r12d, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x2110
cmpq $-0x1, %rax
je 0xebde
movb 0x200(%rbp), %r14b
movb 0x100(%rbp), %r15b
movq %rbx, %rdi
movl $0x1, %esi
callq 0xd9a7
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
leaq 0xf(,%rcx,4), %rcx
andq $-0x10, %rcx
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0x50(%rbp)
movq %rdx, %rsp
movzbl %r14b, %ecx
movq %rcx, -0x40(%rbp)
movzbl %r15b, %ecx
movq %rcx, -0x48(%rbp)
testl %eax, %eax
jle 0xea01
xorl %r12d, %r12d
movq %rbx, %rdi
movl $0x1, %esi
callq 0xd9a7
leal -0xfff1(%rax), %ecx
cmpl $0xffff0010, %ecx       # imm = 0xFFFF0010
jb 0xebcf
movl %eax, %r14d
xorl %r15d, %r15d
movl (%rbx), %eax
testl %eax, %eax
je 0xe984
decl %eax
movl %eax, (%rbx)
incq 0x10(%rbx)
movq 0x8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rbx)
movzbl (%rax), %eax
jmp 0xe995
movq %rbx, %rdi
callq 0x20a0
cmpl $-0x1, %eax
je 0xebc5
movb %al, (%r13,%r15)
incq %r15
cmpq %r15, %r14
jne 0xe965
cmpb $0x0, -0x1(%r13,%r14)
jne 0xebca
movq %rbx, %rdi
movl $0x1, %esi
callq 0xd9a7
movq %r13, %rdi
movl %eax, %esi
movq 0x88(%rbp), %rdx
movq 0x90(%rbp), %rcx
movl 0x50(%rbp), %r8d
movq 0x58(%rbp), %r9
pushq -0x40(%rbp)
pushq -0x48(%rbp)
pushq 0x68(%rbp)
movl 0x60(%rbp), %eax
pushq %rax
callq 0xc85f
addq $0x20, %rsp
movq -0x50(%rbp), %rcx
movl %eax, (%rcx,%r12,4)
incq %r12
cmpq -0x30(%rbp), %r12
jne 0xe940
movb 0x120(%rbp), %al
movb 0x110(%rbp), %r10b
movb 0xf8(%rbp), %r11b
movb 0xf0(%rbp), %sil
movb 0xe0(%rbp), %dil
movb 0xc8(%rbp), %r14b
movb 0xb0(%rbp), %r15b
movb 0xa0(%rbp), %cl
movb 0x98(%rbp), %dl
movq 0x88(%rbp), %r8
movl (%r8), %r8d
movq 0x90(%rbp), %r9
movq (%r9), %r9
movzbl %al, %eax
movzbl %r10b, %r10d
movzbl %r11b, %r12d
movzbl %sil, %r11d
movzbl %dil, %esi
movq %rsi, -0x58(%rbp)
movzbl %r14b, %esi
movq %rsi, -0x60(%rbp)
movzbl %r15b, %esi
movq %rsi, -0x68(%rbp)
movzbl %cl, %r15d
movzbl %dl, %r14d
movq %rbx, %rdi
movq %r13, %rsi
movq -0x80(%rbp), %rdx
movq -0x88(%rbp), %rcx
movss -0x34(%rbp), %xmm0
pushq -0x40(%rbp)
pushq 0x1f0(%rbp)
pushq 0x1e8(%rbp)
pushq 0x1e0(%rbp)
pushq 0x1d8(%rbp)
pushq 0x1d0(%rbp)
pushq 0x1c8(%rbp)
pushq 0x1c0(%rbp)
pushq 0x1b8(%rbp)
pushq 0x1b0(%rbp)
pushq 0x1a8(%rbp)
pushq 0x1a0(%rbp)
pushq 0x198(%rbp)
pushq 0x190(%rbp)
pushq 0x188(%rbp)
pushq 0x180(%rbp)
pushq 0x178(%rbp)
pushq 0x170(%rbp)
pushq 0x168(%rbp)
pushq 0x160(%rbp)
pushq 0x158(%rbp)
pushq 0x150(%rbp)
pushq 0x148(%rbp)
pushq 0x140(%rbp)
pushq 0x138(%rbp)
pushq 0x130(%rbp)
pushq 0x128(%rbp)
pushq %rax
pushq 0x118(%rbp)
pushq %r10
movl 0x108(%rbp), %eax
pushq %rax
pushq -0x48(%rbp)
pushq %r12
pushq %r11
pushq 0xe8(%rbp)
pushq -0x58(%rbp)
movl 0xd8(%rbp), %eax
pushq %rax
movl 0xd0(%rbp), %eax
pushq %rax
pushq -0x60(%rbp)
pushq 0xc0(%rbp)
pushq 0xb8(%rbp)
pushq -0x68(%rbp)
movl 0xa8(%rbp), %eax
pushq %rax
pushq %r15
pushq %r14
pushq 0x80(%rbp)
pushq 0x78(%rbp)
pushq 0x70(%rbp)
movl 0x48(%rbp), %eax
pushq %rax
pushq 0x40(%rbp)
pushq 0x38(%rbp)
pushq 0x30(%rbp)
pushq 0x28(%rbp)
pushq 0x20(%rbp)
pushq 0x18(%rbp)
pushq 0x10(%rbp)
pushq -0x70(%rbp)
pushq -0x78(%rbp)
pushq -0x50(%rbp)
pushq -0x30(%rbp)
callq 0xde6d
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3152
callq 0x313a
callq 0x316a
callq 0x31ca
callq 0x31b2
callq 0x3182