// File: /workspace/github_c_makefile_star2_O1/jsh58[P]Genrich/Genrich.c
// Function: loadBED
int loadBED(char* xFile, char* line, Bed** xBed) {

  // loop through BED files
  int count = 0;  // count of intervals saved
  char* end;
  char* filename = strtok_r(xFile, COM, &end);
  while (filename) {

    // open BED file
    File in;
    bool gz = openRead(filename, &in);

    // load BED records
    while (getLine(line, MAX_SIZE, in, gz) != NULL) {

      // parse BED record
      char* name = strtok(line, TAB);
      if (name == NULL)
        exit(error(line, ERRBED));
      int pos[2];
      for (int i = 0; i < 2; i++) {
        char* val = strtok(NULL, i ? TABN : TAB);
        if (val == NULL)
          exit(error(line, ERRBED));
        pos[i] = getInt(val);
      }
      if (pos[1] <= pos[0] || pos[0] < 0 || pos[1] < 0) {
        char msg[MAX_ALNS];
        sprintf(msg, "%s, %d - %d", name, pos[0], pos[1]);
        exit(error(msg, ERRBED));
      }

      // save info to xBed array
      *xBed = (Bed*) memrealloc(*xBed, (count + 1) * sizeof(Bed));
      Bed* b = *xBed + count;
      b->name = memalloc(1 + strlen(name));
      strcpy(b->name, name);
      b->pos[0] = pos[0];
      b->pos[1] = pos[1];
      count++;
    }

    // close file
    if ( (gz && gzclose(in.gzf) != Z_OK)
        || (! gz && fclose(in.f)) )
      exit(error(filename, ERRCLOSE));

    filename = strtok_r(NULL, COM, &end);
  }

  return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, 0x38(%rsp)
movq %rsi, %r14
leaq 0x4c79(%rip), %rsi      # 0x13bd4
leaq 0x58(%rsp), %rdx
callq 0x2190
xorl %r13d, %r13d
testq %rax, %rax
je 0xf100
leaq 0x4be9(%rip), %rbp      # 0x13b61
leaq 0x472f(%rip), %r15      # 0x136ae
movq %r14, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0xedd9
movb %al, 0xf(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movslq %r13d, %r13
cmpb $0x0, 0xf(%rsp)
je 0xefc2
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movl $0xfff0, %edx           # imm = 0xFFF0
callq 0x2090
jmp 0xefd4
movq %r14, %rdi
movl $0xfff0, %esi           # imm = 0xFFF0
movq 0x10(%rsp), %rdx
callq 0x21a0
testq %rax, %rax
je 0xf0b6
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2280
testq %rax, %rax
je 0xf11d
movq %rax, %r12
xorl %ebx, %ebx
testq %rbx, %rbx
movq %r15, %rsi
cmoveq %rbp, %rsi
xorl %edi, %edi
callq 0x2280
testq %rax, %rax
je 0xf115
movq %rax, %rdi
callq 0x3951
movl %eax, 0x20(%rsp,%rbx,4)
incq %rbx
cmpq $0x1, %rbx
je 0xeff6
movl 0x20(%rsp), %r14d
movl 0x24(%rsp), %r8d
cmpl %r14d, %r8d
jle 0xf125
movl %r14d, %eax
orl %r8d, %eax
js 0xf125
movq %r12, 0x40(%rsp)
movq 0x38(%rsp), %r12
movq (%r12), %rdi
leaq 0x1(%r13), %rsi
movq %rsi, 0x48(%rsp)
shlq $0x4, %rsi
movl %r8d, 0x1c(%rsp)
callq 0x3915
movq %rax, %rbx
movq %rax, (%r12)
shlq $0x4, %r13
movq 0x40(%rsp), %r12
movq %r12, %rdi
callq 0x20f0
leaq 0x1(%rax), %rdi
callq 0x3903
movq %rax, 0x8(%rbx,%r13)
movq %rax, %rdi
movq %r12, %rsi
callq 0x2070
movl %r14d, (%rbx,%r13)
movl 0x1c(%rsp), %eax
movl %eax, 0x4(%rbx,%r13)
movq 0x48(%rsp), %r13
movq 0x30(%rsp), %r14
jmp 0xefa7
cmpb $0x0, 0xf(%rsp)
je 0xf0d6
movq 0x10(%rsp), %rdi
callq 0x2030
testl %eax, %eax
jne 0xf158
cmpb $0x0, 0xf(%rsp)
jne 0xf0e4
movq 0x10(%rsp), %rdi
callq 0x20d0
testl %eax, %eax
jne 0xf158
xorl %edi, %edi
leaq 0x4ae7(%rip), %rsi      # 0x13bd4
leaq 0x58(%rsp), %rdx
callq 0x2190
testq %rax, %rax
jne 0xef84
movl %r13d, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x32ce
movq %r14, %rdi
callq 0x32df
leaq 0x4aab(%rip), %rsi      # 0x13bd7
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rdx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2290
movq %rbx, %rdi
movl $0x1c, %esi
callq 0x22f0
movl $0x1, %edi
callq 0x22a0
movq 0x28(%rsp), %rdi
callq 0x32f0