// File: /workspace/github_c_makefile_star2_O0/debbiemarkslab[P]plmc/src/inference.c
// Function: ReportProgresslBFGS
static int ReportProgresslBFGS(void *instance, const lbfgsfloatval_t *x,
    const lbfgsfloatval_t *g, const lbfgsfloatval_t fx,
    const lbfgsfloatval_t xnorm, const lbfgsfloatval_t gnorm,
    const lbfgsfloatval_t step, int n, int k, int ls) {
    void **d = (void **)instance;
    alignment_t *ali = (alignment_t *)d[0];

    /* Compute norms of relevant parameters */
    lbfgsfloatval_t hNorm = 0.0, eNorm = 0.0, hGNorm = 0.0, eGNorm = 0.0;
    for (int i = 0; i < ali->nSites * ali->nCodes; i++)
        hNorm += x[i]*x[i];
    for (int i = 0; i < ali->nSites * ali->nCodes; i++)
        hGNorm += g[i]*g[i];
    for (int i = ali->nSites * ali->nCodes; i < ali->nParams; i++)
        eNorm += x[i]*x[i];
    for (int i = ali->nSites * ali->nCodes; i < ali->nParams; i++)
        eGNorm += g[i]*g[i];
    hNorm = sqrt(hNorm);
    hGNorm = sqrt(hGNorm);
    eNorm = sqrt(eNorm);
    eGNorm = sqrt(eGNorm);

    /* Retrieve elapsed time */
    static struct timeval now;
    gettimeofday(&now, NULL);
    if (now.tv_usec < ali->start.tv_usec) {
        int nsec = (ali->start.tv_usec - now.tv_usec) / 1000000 + 1;
        ali->start.tv_usec -= 1000000 * nsec;
        ali->start.tv_sec += nsec;
    }
    if (now.tv_usec - ali->start.tv_usec > 1000000) {
        int nsec = (now.tv_usec - ali->start.tv_usec) / 1000000;
        ali->start.tv_usec += 1000000 * nsec;
        ali->start.tv_sec -= nsec;
    }
    numeric_t elapsed = (numeric_t) (now.tv_sec - ali->start.tv_sec)
                      + ((numeric_t) (now.tv_usec - ali->start.tv_usec)) / 1E6;

    if (k == 1) fprintf(stderr,
        "iter\ttime\tcond\tfx\t-loglk"
        "\t||h||\t||e||\n");
    fprintf(stderr, "%d\t%.1f\t%.2f\t%.1f\t%.1f\t%.1f\t%.1f\n",
        k, elapsed, gnorm / xnorm, fx, ali->negLogLk, hNorm, eNorm);
    return 0;
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movsd %xmm0, 0x78(%rsp)
movsd %xmm1, 0x70(%rsp)
movsd %xmm2, 0x68(%rsp)
movsd %xmm3, 0x60(%rsp)
movl %ecx, 0x5c(%rsp)
movl %r8d, 0x58(%rsp)
movl %r9d, 0x54(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x40(%rsp), %rcx
movl 0x4(%rcx), %ecx
movq 0x40(%rsp), %rdx
imull 0x8(%rdx), %ecx
cmpl %ecx, %eax
jge 0x14089
movq 0x88(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x88(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x38(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x1402b
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
movq 0x40(%rsp), %rcx
movl 0x4(%rcx), %ecx
movq 0x40(%rsp), %rdx
imull 0x8(%rdx), %ecx
cmpl %ecx, %eax
jge 0x140ef
movq 0x80(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x80(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x28(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x14091
movq 0x40(%rsp), %rax
movl 0x4(%rax), %eax
movq 0x40(%rsp), %rcx
imull 0x8(%rcx), %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
movq 0x40(%rsp), %rcx
cmpl 0x68(%rcx), %eax
jge 0x14157
movq 0x88(%rsp), %rax
movslq 0x14(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x88(%rsp), %rax
movslq 0x14(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x30(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x14104
movq 0x40(%rsp), %rax
movl 0x4(%rax), %eax
movq 0x40(%rsp), %rcx
imull 0x8(%rcx), %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movq 0x40(%rsp), %rcx
cmpl 0x68(%rcx), %eax
jge 0x141bf
movq 0x80(%rsp), %rax
movslq 0x10(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x80(%rsp), %rax
movslq 0x10(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x20(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x1416c
movsd 0x38(%rsp), %xmm0
callq 0x11e0
movsd %xmm0, 0x38(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x11e0
movsd %xmm0, 0x28(%rsp)
movsd 0x30(%rsp), %xmm0
callq 0x11e0
movsd %xmm0, 0x30(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x11e0
movsd %xmm0, 0x20(%rsp)
leaq 0x92fe(%rip), %rdi      # 0x1d508
xorl %eax, %eax
movl %eax, %esi
callq 0x10e0
movq 0x92f6(%rip), %rax      # 0x1d510
movq 0x40(%rsp), %rcx
cmpq 0x80(%rcx), %rax
jge 0x14280
movq 0x40(%rsp), %rax
movq 0x80(%rax), %rax
subq 0x92d5(%rip), %rax      # 0x1d510
movl $0xf4240, %ecx          # imm = 0xF4240
cqto
idivq %rcx
addq $0x1, %rax
movl %eax, 0xc(%rsp)
imull $0xf4240, 0xc(%rsp), %eax # imm = 0xF4240
movslq %eax, %rdx
movq 0x40(%rsp), %rax
movq 0x80(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x80(%rax)
movslq 0xc(%rsp), %rcx
movq 0x40(%rsp), %rax
addq 0x78(%rax), %rcx
movq %rcx, 0x78(%rax)
movq 0x9289(%rip), %rax      # 0x1d510
movq 0x40(%rsp), %rcx
subq 0x80(%rcx), %rax
cmpq $0xf4240, %rax          # imm = 0xF4240
jle 0x142ef
movq 0x926e(%rip), %rax      # 0x1d510
movq 0x40(%rsp), %rcx
subq 0x80(%rcx), %rax
movl $0xf4240, %ecx          # imm = 0xF4240
cqto
idivq %rcx
movl %eax, 0x8(%rsp)
imull $0xf4240, 0x8(%rsp), %eax # imm = 0xF4240
movslq %eax, %rcx
movq 0x40(%rsp), %rax
addq 0x80(%rax), %rcx
movq %rcx, 0x80(%rax)
movslq 0x8(%rsp), %rdx
movq 0x40(%rsp), %rax
movq 0x78(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x78(%rax)
movq 0x9212(%rip), %rax      # 0x1d508
movq 0x40(%rsp), %rcx
subq 0x78(%rcx), %rax
cvtsi2sd %rax, %xmm0
movq 0x9205(%rip), %rax      # 0x1d510
movq 0x40(%rsp), %rcx
subq 0x80(%rcx), %rax
cvtsi2sd %rax, %xmm1
movsd 0x50c4(%rip), %xmm2     # 0x193e8
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
cmpl $0x1, 0x58(%rsp)
jne 0x14350
movq 0x7cb9(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
leaq 0x542c(%rip), %rsi      # 0x19775
movb $0x0, %al
callq 0x1140
movq 0x7ca1(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movl 0x58(%rsp), %edx
movsd (%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
divsd 0x70(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
movq 0x40(%rsp), %rax
movsd 0x70(%rax), %xmm3
movsd 0x38(%rsp), %xmm4
movsd 0x30(%rsp), %xmm5
leaq 0x5409(%rip), %rsi      # 0x1979b
movb $0x6, %al
callq 0x1140
xorl %eax, %eax
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)