// File: /workspace/github_c_makefile_star2_O0/jsh58[P]Genrich/Genrich.c
// Function: saveLambda
void saveLambda(Chrom* chr, float lambda) {
  if (chr->bedLen == 0) {
    // no BED intervals: save constant of lambda
    saveConst(chr->ctrl, &chr->ctrlLen, &chr->ctrlMem,
      chr->len, lambda);
    return;
  }

  // with BED intervals
  int num = chr->bedLen + 1;  // number of array intervals
  int idx = 0;    // index into chr->bed array
  bool save = true;
  if (chr->bed[0] == 0) {
    num--;
    idx++;
    save = false; // 1st interval skipped
  }
  if (chr->bed[chr->bedLen - 1] == chr->len)
    num--;

  // expand pileup arrays (if necessary)
  if (num > chr->ctrlMem) {
    chr->ctrl->end = (uint32_t*) memrealloc(chr->ctrl->end,
      num * sizeof(uint32_t));
    chr->ctrl->cov = (float*) memrealloc(chr->ctrl->cov,
      num * sizeof(float));
    chr->ctrlMem = num;
  }
  chr->ctrlLen = num;

  // populate chr->ctrl arrays: alternate lambda and -1
  for (int j = 0; j < num - 1; j++) {
    chr->ctrl->end[j] = chr->bed[idx];
    chr->ctrl->cov[j] = save ? lambda : SKIP;
    save = ! save;
    idx++;
  }
  chr->ctrl->end[num-1] = chr->len;
  chr->ctrl->cov[num-1] = save ? lambda : SKIP;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movss %xmm0, 0x1c(%rsp)
movq 0x20(%rsp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x92fd
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x20(%rsp), %rsi
addq $0x40, %rsi
movq 0x20(%rsp), %rdx
addq $0x44, %rdx
movq 0x20(%rsp), %rax
movl 0x8(%rax), %ecx
movss 0x1c(%rsp), %xmm0
callq 0x90d0
jmp 0x94fc
movq 0x20(%rsp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movb $0x1, 0x13(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
cmpl $0x0, (%rax)
jne 0x9342
movl 0x18(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x18(%rsp)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movb $0x0, 0x13(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
movl 0x18(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq 0x20(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x9371
movl 0x18(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x18(%rsp)
movl 0x18(%rsp), %eax
movq 0x20(%rsp), %rcx
cmpl 0x44(%rcx), %eax
jbe 0x93df
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rdi
movslq 0x18(%rsp), %rsi
shlq $0x2, %rsi
callq 0x28e0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rdi
movslq 0x18(%rsp), %rsi
shlq $0x2, %rsi
callq 0x28e0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x8(%rax)
movl 0x18(%rsp), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x44(%rax)
movl 0x18(%rsp), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x40(%rax)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x9494
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x14(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movslq 0xc(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
testb $0x1, 0x13(%rsp)
je 0x9440
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0x8(%rsp)
jmp 0x9450
movss 0x14d4c(%rip), %xmm0    # 0x1e194
movss %xmm0, 0x8(%rsp)
jmp 0x9450
movss 0x8(%rsp), %xmm0
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movslq 0xc(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movb 0x13(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x13(%rsp)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x93f3
movq 0x20(%rsp), %rax
movl 0x8(%rax), %edx
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
testb $0x1, 0x13(%rsp)
je 0x94ca
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0x4(%rsp)
jmp 0x94da
movss 0x14cc2(%rip), %xmm0    # 0x1e194
movss %xmm0, 0x4(%rsp)
jmp 0x94da
movss 0x4(%rsp), %xmm0
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)