// File: /workspace/github_c_makefile_star2_O1/jsh58[P]Genrich/Genrich.c
// Function: saveChrom
int saveChrom(char* name, uint32_t len, int* chromLen,
    Chrom** chrom, int xcount, char** xchrList,
    int xBedLen, Bed* xBed, bool ctrl, bool verbose) {

  // determine if chrom has been saved already
  for (int i = 0; i < *chromLen; i++) {
    Chrom* c = *chrom + i;
    if (!strcmp(c->name, name)) {
      if (c->len != len)
        exit(error(c->name, ERRCHRLEN));
      if (! ctrl)
        c->save = true;
      return i;
    }
  }

  // save to list
  *chrom = (Chrom*) memrealloc(*chrom,
    (*chromLen + 1) * sizeof(Chrom));
  Chrom* c = *chrom + *chromLen;
  c->name = (char*) memalloc(1 + strlen(name));
  strcpy(c->name, name);
  c->len = len;
  c->skip = checkChrom(c->name, xcount, xchrList);
  c->save = ! ctrl; // do not save if ref in ctrl sample only
  c->diff = NULL;
  c->expt = (Pileup*) memalloc(sizeof(Pileup));
  c->expt->end = NULL;
  c->expt->cov = NULL;
  c->exptLen = 0;
  c->exptMem = 0;
  c->ctrl = (Pileup*) memalloc(sizeof(Pileup));
  c->ctrl->end = NULL;
  c->ctrl->cov = NULL;
  c->ctrlLen = 0;
  c->ctrlMem = 0;
  c->pval = NULL;
  c->pvalLen = NULL;
  c->sample = 0;
  c->qval = NULL;

  // determine if there are regions to be skipped
  c->bed = NULL;
  c->bedLen = 0;
  if (! c->skip)
    saveXBed(c->name, c->len, &c->bedLen, &c->bed,
      xBedLen, xBed, verbose);

  (*chromLen)++;
  return *chromLen - 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x20(%rsp)
movl %r8d, 0x1c(%rsp)
movl %esi, 0xc(%rsp)
movq %rdi, %r12
movq %rdx, 0x30(%rsp)
movslq (%rdx), %r13
testq %r13, %r13
setg %r14b
movq %rcx, 0x28(%rsp)
jle 0xc7b1
movq (%rcx), %r15
addq $0xd, %r15
xorl %ebp, %ebp
movq %rax, 0x10(%rsp)
movq -0xd(%r15), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x21b0
testl %eax, %eax
jne 0xc798
movl 0xc(%rsp), %ecx
cmpl %ecx, -0x5(%r15)
jne 0xc908
cmpb $0x0, 0x80(%rsp)
jne 0xc791
movb $0x1, (%r15)
movl %ebp, %ecx
movq %rcx, 0x10(%rsp)
testl %eax, %eax
je 0xc7b6
incq %rbp
cmpq %r13, %rbp
setb %r14b
addq $0x68, %r15
cmpq %rbp, %r13
jne 0xc762
jmp 0xc7b6
movq %rax, 0x10(%rsp)
testb $0x1, %r14b
movq 0x10(%rsp), %rax
jne 0xc8f9
movq 0x28(%rsp), %r14
movq (%r14), %rdi
imulq $0x68, %r13, %rsi
addq $0x68, %rsi
callq 0x3915
movq %rax, %rbx
movq %rax, (%r14)
movq 0x30(%rsp), %r15
movslq (%r15), %rax
imulq $0x68, %rax, %r14
leaq (%rbx,%r14), %rbp
movq %r12, %rdi
callq 0x20f0
leaq 0x1(%rax), %rdi
callq 0x3903
movq %rax, %r13
movq %rax, (%rbx,%r14)
movq %rax, %rdi
movq %r12, %rsi
callq 0x2070
movl 0xc(%rsp), %eax
movl %eax, 0x8(%rbx,%r14)
movl 0x1c(%rsp), %ebx
testl %ebx, %ebx
setg %al
jle 0xc869
movq 0x20(%rsp), %r12
movq (%r12), %rdi
movq %r13, %rsi
callq 0x21b0
testl %eax, %eax
je 0xc867
movl %ebx, %ebx
movl $0x1, %ecx
movq %rcx, %r14
cmpq %rcx, %rbx
je 0xc85f
movq (%r12,%r14,8), %rdi
movq %r13, %rsi
callq 0x21b0
leaq 0x1(%r14), %rcx
testl %eax, %eax
jne 0xc843
cmpq %rbx, %r14
setb %al
jmp 0xc869
movb $0x1, %al
movb %al, 0xc(%rbp)
movb 0x80(%rsp), %al
xorb $0x1, %al
movb %al, 0xd(%rbp)
xorl %ebx, %ebx
movq %rbx, 0x20(%rbp)
movl $0x10, %edi
callq 0x3903
movq %rax, 0x28(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rbx, 0x30(%rbp)
movl $0x10, %edi
callq 0x3903
movq %rax, 0x38(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rbx, 0x60(%rbp)
movq %rbx, 0x10(%rbp)
movl $0x0, 0x18(%rbp)
movups %xmm0, 0x40(%rbp)
movups %xmm0, 0x49(%rbp)
cmpb $0x0, 0xc(%rbp)
jne 0xc8f0
movq 0x78(%rsp), %r9
movl 0x70(%rsp), %r8d
leaq 0x10(%rbp), %rcx
leaq 0x18(%rbp), %rdx
movq (%rbp), %rdi
movl 0x8(%rbp), %esi
movzbl 0x88(%rsp), %eax
movl %eax, (%rsp)
callq 0x5d5e
movl (%r15), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r15)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x2f7f