#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double fabs(double);
int /*<<< orphan*/ free(double *);
double l2norm(double *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ mmult(double *, double *, double *, int, int, int);
int /*<<< orphan*/ msub(double *, double *, double *, int, int);
double sqrt(double);
void bfgs_naive(double *H, int N, double *xi, double *xf, double *jac,
                double *jacf) {
  int i, j, supd, ct;
  double sn, yn, fd, yt, jacm;
  double *sk, *yk, *temp, *temp2, *t;
  sk = (double *)malloc(sizeof(double) * N);
  yk = (double *)malloc(sizeof(double) * N);
  temp = (double *)malloc(sizeof(double) * 1);
  temp2 = (double *)malloc(sizeof(double) * 1);
  t = (double *)malloc(sizeof(double) * N);
  msub(xf, xi, sk, 1, N);
  msub(jacf, jac, yk, 1, N);
  sn = l2norm(sk, N);
  yn = l2norm(yk, N);
  fd = sqrt((double)1e-15);
  mmult(yk, sk, temp, 1, N, 1);
  if (temp[0] >= fd * sn * yn) {
    supd = 1;
    for (i = 0; i < N; ++i) {
      t[i] = 0.0;
      for (j = 0; j < i; ++j) {
        ct = j * N;
        t[i] += H[ct + i] * sk[j];
      }
      for (j = i; j < N; ++j) {
        ct = i * N;
        t[i] += H[ct + j] * sk[j];
      }
      yt = fabs(yk[i] - t[i]);
      if (jac[i] > jacf[i]) {
        jacm = jac[i];
      } else {
        jacm = jacf[i];
      }
      if (yt >= fd * jacm) {
        supd = 0;
      }
    }
    if (supd == 0) {
      mmult(sk, t, temp2, 1, N, 1);
      for (i = 0; i < N; ++i) {
        ct = i * N;
        for (j = i; j < N; ++j) {
          H[ct + j] += (yk[i] * yk[j] / temp[0]);
          H[ct + j] -= (t[i] * t[j] / temp2[0]);
        }
      }
    }
  }
  free(sk);
  free(yk);
  free(temp);
  free(temp2);
  free(t);
}


x86 assembly (clang, -O0):
<bfgs_naive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x70(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,-0x88(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x90(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x70(%rbp),%rdx
mov    -0xc(%rbp),%r8d
mov    $0x1,%ecx
call   1060 <msub@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x78(%rbp),%rdx
mov    -0xc(%rbp),%r8d
mov    $0x1,%ecx
call   1060 <msub@plt>
mov    -0x70(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <l2norm@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <l2norm@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xdc5(%rip),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    -0x80(%rbp),%rdx
mov    -0xc(%rbp),%r8d
mov    $0x1,%r9d
mov    %r9d,%ecx
call   1050 <mmult@plt>
mov    -0x80(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jb     152e <bfgs_naive+0x3ce>
movl   $0x1,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1427 <bfgs_naive+0x2c7>
mov    -0x90(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1318 <bfgs_naive+0x1b8>
mov    -0x38(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x70(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x90(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12b8 <bfgs_naive+0x158>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    137e <bfgs_naive+0x21e>
mov    -0x34(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x70(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x90(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    131e <bfgs_naive+0x1be>
mov    -0x78(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x90(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xc6e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    13e2 <bfgs_naive+0x282>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    13f4 <bfgs_naive+0x294>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jb     1414 <bfgs_naive+0x2b4>
movl   $0x0,-0x3c(%rbp)
jmp    1419 <bfgs_naive+0x2b9>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1292 <bfgs_naive+0x132>
cmpl   $0x0,-0x3c(%rbp)
jne    1529 <bfgs_naive+0x3c9>
mov    -0x70(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    -0x88(%rbp),%rdx
mov    -0xc(%rbp),%r8d
mov    $0x1,%r9d
mov    %r9d,%ecx
call   1050 <mmult@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1524 <bfgs_naive+0x3c4>
mov    -0x34(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1511 <bfgs_naive+0x3b1>
mov    -0x78(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x78(%rbp),%rax
movslq -0x38(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x80(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x90(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x90(%rbp),%rax
movslq -0x38(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mov    -0x88(%rbp),%rax
divsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1478 <bfgs_naive+0x318>
jmp    1516 <bfgs_naive+0x3b6>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    145c <bfgs_naive+0x2fc>
jmp    1529 <bfgs_naive+0x3c9>
jmp    152e <bfgs_naive+0x3ce>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x90(%rbp),%rdi
call   1030 <free@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfgs_naive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9,%r14
mov    %r8,0x30(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x28(%rsp)
mov    %esi,%ebx
mov    %rdi,0x48(%rsp)
lea    0x0(,%rbx,8),%ebp
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,0x40(%rsp)
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,0x38(%rsp)
mov    %ebp,%edi
mov    %rbx,%rbp
call   1070 <malloc@plt>
mov    %rax,%r12
mov    0x18(%rsp),%rdi
mov    0x28(%rsp),%rsi
mov    %r13,%rdx
mov    $0x1,%ecx
mov    %ebp,%r8d
call   1060 <msub@plt>
mov    %r14,0x28(%rsp)
mov    %r14,%rdi
mov    0x30(%rsp),%rsi
mov    %r15,%rdx
mov    $0x1,%ecx
mov    %ebp,%r8d
call   1060 <msub@plt>
mov    %r13,%rdi
mov    %ebp,%esi
call   1040 <l2norm@plt>
movsd  %xmm0,0x18(%rsp)
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <l2norm@plt>
movsd  %xmm0,0x20(%rsp)
mov    %r15,%rdi
mov    %r13,%rsi
mov    0x40(%rsp),%rbx
mov    %rbx,%rdx
mov    $0x1,%ecx
mov    %ebp,%r8d
mov    $0x1,%r9d
call   1050 <mmult@plt>
mov    0x38(%rsp),%rdx
movsd  0x18(%rsp),%xmm1
mulsd  0xdb8(%rip),%xmm1
movsd  (%rbx),%xmm0
mulsd  0x20(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jb     13e0 <bfgs_naive+0x290>
test   %ebp,%ebp
jle    13e0 <bfgs_naive+0x290>
mov    %rbp,0x20(%rsp)
mov    %ebp,%r14d
mov    %r14,%r11
shl    $0x4,%r11
lea    0x8(,%r14,8),%rbp
mov    $0x1,%r9d
movapd 0xd87(%rip),%xmm0
movsd  0xd6f(%rip),%xmm1
mov    %r14,%rsi
mov    %r13,%rdi
mov    0x48(%rsp),%r8
mov    %r8,%rdx
xor    %ecx,%ecx
mov    %rbp,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
movq   $0x0,(%r12,%rcx,8)
test   %rcx,%rcx
je     12d0 <bfgs_naive+0x180>
cmp    $0x1,%rcx
jne    12e0 <bfgs_naive+0x190>
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
jmp    1329 <bfgs_naive+0x1d9>
nopl   0x0(%rax,%rax,1)
xorpd  %xmm2,%xmm2
jmp    1359 <bfgs_naive+0x209>
nopl   0x0(%rax)
mov    %rcx,%rax
and    $0xfffffffffffffffe,%rax
xorpd  %xmm2,%xmm2
mov    %r8,%r10
xor    %ebx,%ebx
movsd  (%r10),%xmm3
mulsd  0x0(%r13,%rbx,8),%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,(%r12,%rcx,8)
movsd  (%r10,%r14,8),%xmm2
mulsd  0x8(%r13,%rbx,8),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%r12,%rcx,8)
add    $0x2,%rbx
add    %r11,%r10
cmp    %rbx,%rax
jne    12f0 <bfgs_naive+0x1a0>
test   $0x1,%cl
je     1359 <bfgs_naive+0x209>
mov    %rbx,%rax
imul   %r14,%rax
add    %rcx,%rax
mov    0x48(%rsp),%rbp
movsd  0x0(%rbp,%rax,8),%xmm3
mov    0x18(%rsp),%rbp
mulsd  0x0(%r13,%rbx,8),%xmm3
addsd  %xmm3,%xmm2
movsd  %xmm2,(%r12,%rcx,8)
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movsd  (%rdx,%rax,8),%xmm3
mulsd  (%rdi,%rax,8),%xmm3
addsd  %xmm3,%xmm2
movsd  %xmm2,(%r12,%rcx,8)
add    $0x1,%rax
cmp    %rax,%rsi
jne    1360 <bfgs_naive+0x210>
movsd  (%r15,%rcx,8),%xmm3
subsd  %xmm2,%xmm3
mov    0x30(%rsp),%rax
movsd  (%rax,%rcx,8),%xmm2
mov    0x28(%rsp),%rax
maxsd  (%rax,%rcx,8),%xmm2
andpd  %xmm0,%xmm3
mulsd  %xmm1,%xmm2
ucomisd %xmm2,%xmm3
mov    $0x0,%eax
cmovae %eax,%r9d
add    $0x1,%rcx
add    $0x8,%r8
add    %rbp,%rdx
add    $0x8,%rdi
add    $0xffffffffffffffff,%rsi
cmp    %r14,%rcx
jne    12b0 <bfgs_naive+0x160>
test   %r9d,%r9d
mov    0x40(%rsp),%rbx
mov    0x38(%rsp),%rdx
mov    0x20(%rsp),%rbp
je     1419 <bfgs_naive+0x2c9>
mov    %r13,%rdi
mov    %rdx,%rbp
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x1,%ecx
mov    %ebp,%r8d
mov    $0x1,%r9d
call   1050 <mmult@plt>
mov    0x38(%rsp),%rdx
mov    0x40(%rsp),%rbx
test   %ebp,%ebp
jle    13e0 <bfgs_naive+0x290>
lea    0x0(,%r14,8),%rax
mov    %rax,0x70(%rsp)
lea    (%r15,%r14,8),%rax
mov    %rax,0x68(%rsp)
lea    0x8(%rbx),%rax
mov    %rax,0x60(%rsp)
lea    (%r12,%r14,8),%rax
mov    %rax,0x58(%rsp)
lea    0x8(%rdx),%rax
mov    %rax,0x50(%rsp)
xor    %r10d,%r10d
mov    0x48(%rsp),%rsi
mov    %rsi,%rcx
mov    %r12,%r11
mov    %r15,%rdi
mov    %r14,0x20(%rsp)
jmp    14b9 <bfgs_naive+0x369>
nopl   0x0(%rax)
addq   $0xffffffffffffffff,0x20(%rsp)
add    $0x8,%rdi
add    0x18(%rsp),%rsi
add    $0x8,%r11
add    0x70(%rsp),%rcx
mov    0x30(%rsp),%rbp
mov    %rbp,%r10
cmp    %r14,%rbp
je     13e0 <bfgs_naive+0x290>
mov    %r14,%r8
sub    %r10,%r8
lea    0x1(%r10),%rbp
mov    %rbp,0x30(%rsp)
mov    %r10,%r9
mov    %r8,0x28(%rsp)
cmp    $0x2,%r8
jae    1530 <bfgs_naive+0x3e0>
cs nopw 0x0(%rax,%rax,1)
movsd  (%r15,%r10,8),%xmm0
mulsd  (%r15,%r9,8),%xmm0
divsd  (%rbx),%xmm0
addsd  (%rcx,%r9,8),%xmm0
movsd  %xmm0,(%rcx,%r9,8)
movsd  (%r12,%r10,8),%xmm1
mulsd  (%r12,%r9,8),%xmm1
divsd  (%rdx),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx,%r9,8)
add    $0x1,%r9
cmp    %r9,%r14
jne    14e0 <bfgs_naive+0x390>
jmp    1490 <bfgs_naive+0x340>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x18(%rsp),%r8
imul   %r10,%r8
mov    0x48(%rsp),%rbp
add    %rbp,%r8
mov    %r10,%rax
imul   %r14,%rax
add    %r14,%rax
lea    0x0(,%rax,8),%rax
add    %rbp,%rax
lea    (%r15,%r10,8),%rbx
lea    (%r12,%r10,8),%r9
mov    0x30(%rsp),%rbp
lea    (%r15,%rbp,8),%rdx
cmp    0x68(%rsp),%r8
setb   0x17(%rsp)
cmp    %rax,%rbx
setb   0x16(%rsp)
cmp    %rdx,%r8
mov    0x40(%rsp),%rbx
setb   0x15(%rsp)
cmp    0x60(%rsp),%r8
setb   0x14(%rsp)
cmp    %rax,%rbx
setb   0x13(%rsp)
cmp    0x58(%rsp),%r8
setb   0x12(%rsp)
cmp    %rax,%r9
lea    (%r12,%rbp,8),%r9
setb   %bpl
cmp    %r9,%r8
setb   0x11(%rsp)
cmp    0x50(%rsp),%r8
mov    0x38(%rsp),%rdx
setb   0xf(%rsp)
cmp    %rax,%rdx
setb   0x10(%rsp)
mov    %r10,%r9
mov    0x16(%rsp),%al
test   %al,0x17(%rsp)
jne    14e0 <bfgs_naive+0x390>
mov    %eax,%r8d
mov    %r10,%r9
and    %al,0x15(%rsp)
jne    14e0 <bfgs_naive+0x390>
mov    %r10,%r9
mov    0x13(%rsp),%al
and    %al,0x14(%rsp)
jne    14e0 <bfgs_naive+0x390>
mov    %r10,%r9
and    %bpl,0x12(%rsp)
jne    14e0 <bfgs_naive+0x390>
mov    %r10,%r9
and    %bpl,0x11(%rsp)
jne    14e0 <bfgs_naive+0x390>
mov    %r10,%r9
mov    0xf(%rsp),%al
and    0x10(%rsp),%al
jne    14e0 <bfgs_naive+0x390>
mov    0x20(%rsp),%rbp
and    $0xfffffffffffffffe,%rbp
mov    0x28(%rsp),%r8
and    $0xfffffffffffffffe,%r8
lea    (%r10,%r8,1),%r9
movsd  (%r15,%r10,8),%xmm0
unpcklpd %xmm0,%xmm0
movsd  (%rbx),%xmm1
unpcklpd %xmm1,%xmm1
movsd  (%r12,%r10,8),%xmm2
unpcklpd %xmm2,%xmm2
movsd  (%rdx),%xmm3
unpcklpd %xmm3,%xmm3
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movupd (%rdi,%rax,8),%xmm4
mulpd  %xmm0,%xmm4
divpd  %xmm1,%xmm4
movupd (%rsi,%rax,8),%xmm5
addpd  %xmm4,%xmm5
movupd %xmm5,(%rsi,%rax,8)
movupd (%r11,%rax,8),%xmm4
mulpd  %xmm2,%xmm4
divpd  %xmm3,%xmm4
subpd  %xmm4,%xmm5
movupd %xmm5,(%rsi,%rax,8)
add    $0x2,%rax
cmp    %rax,%rbp
jne    1670 <bfgs_naive+0x520>
cmp    %r8,0x28(%rsp)
jne    14e0 <bfgs_naive+0x390>
jmp    1490 <bfgs_naive+0x340>

LLVM IR (-O0):
define void @bfgs_naive(double* %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double*
%23 = alloca double*
%24 = alloca double*
%25 = alloca double*
%26 = alloca double*
store double* %0, double** %7
store i32 %1, i32* %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = mul i64 8, %28
%30 = trunc i64 %29 to i32
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to double*
store double* %32, double** %22
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = mul i64 8, %34
%36 = trunc i64 %35 to i32
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to double*
store double* %38, double** %23
%39 = call i64 @malloc(i32 8)
%40 = inttoptr i64 %39 to double*
store double* %40, double** %24
%41 = call i64 @malloc(i32 8)
%42 = inttoptr i64 %41 to double*
store double* %42, double** %25
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = mul i64 8, %44
%46 = trunc i64 %45 to i32
%47 = call i64 @malloc(i32 %46)
%48 = inttoptr i64 %47 to double*
store double* %48, double** %26
%49 = load double*, double** %10
%50 = load double*, double** %9
%51 = load double*, double** %22
%52 = load i32, i32* %8
%53 = call i32 @msub(double* %49, double* %50, double* %51, i32 1, i32 %52)
%54 = load double*, double** %12
%55 = load double*, double** %11
%56 = load double*, double** %23
%57 = load i32, i32* %8
%58 = call i32 @msub(double* %54, double* %55, double* %56, i32 1, i32 %57)
%59 = load double*, double** %22
%60 = load i32, i32* %8
%61 = call double @l2norm(double* %59, i32 %60)
store double %61, double* %17
%62 = load double*, double** %23
%63 = load i32, i32* %8
%64 = call double @l2norm(double* %62, i32 %63)
store double %64, double* %18
%65 = call double @sqrt(double 1.000000e-15)
store double %65, double* %19
%66 = load double*, double** %23
%67 = load double*, double** %22
%68 = load double*, double** %24
%69 = load i32, i32* %8
%70 = call i32 @mmult(double* %66, double* %67, double* %68, i32 1, i32 %69, i32 1)
%71 = load double*, double** %24
%72 = getelementptr inbounds double, double* %71, i64 0
%73 = load double, double* %72
%74 = load double, double* %19
%75 = load double, double* %17
%76 = fmul double %74, %75
%77 = load double, double* %18
%78 = fmul double %76, %77
%79 = fcmp oge double %73, %78
br i1 %79, label %80, label %275
80: ; preds = %6
store i32 1, i32* %15
store i32 0, i32* %13
br label %81
81: ; preds = %194, %80
%82 = load i32, i32* %13
%83 = load i32, i32* %8
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %197
85: ; preds = %81
%86 = load double*, double** %26
%87 = load i32, i32* %13
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %86, i64 %88
store double 0.000000e+00, double* %89
store i32 0, i32* %14
br label %90
90: ; preds = %116, %85
%91 = load i32, i32* %14
%92 = load i32, i32* %13
%93 = icmp slt i32 %91, %92
br i1 %93, label %94, label %119
94: ; preds = %90
%95 = load i32, i32* %14
%96 = load i32, i32* %8
%97 = mul nsw i32 %95, %96
store i32 %97, i32* %16
%98 = load double*, double** %7
%99 = load i32, i32* %16
%100 = load i32, i32* %13
%101 = add nsw i32 %99, %100
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %98, i64 %102
%104 = load double, double* %103
%105 = load double*, double** %22
%106 = load i32, i32* %14
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds double, double* %105, i64 %107
%109 = load double, double* %108
%110 = load double*, double** %26
%111 = load i32, i32* %13
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds double, double* %110, i64 %112
%114 = load double, double* %113
%115 = call double @llvm.fmuladd.f64(double %104, double %109, double %114)
store double %115, double* %113
br label %116
116: ; preds = %94
%117 = load i32, i32* %14
%118 = add nsw i32 %117, 1
store i32 %118, i32* %14
br label %90
119: ; preds = %90
%120 = load i32, i32* %13
store i32 %120, i32* %14
br label %121
121: ; preds = %147, %119
%122 = load i32, i32* %14
%123 = load i32, i32* %8
%124 = icmp slt i32 %122, %123
br i1 %124, label %125, label %150
125: ; preds = %121
%126 = load i32, i32* %13
%127 = load i32, i32* %8
%128 = mul nsw i32 %126, %127
store i32 %128, i32* %16
%129 = load double*, double** %7
%130 = load i32, i32* %16
%131 = load i32, i32* %14
%132 = add nsw i32 %130, %131
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds double, double* %129, i64 %133
%135 = load double, double* %134
%136 = load double*, double** %22
%137 = load i32, i32* %14
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds double, double* %136, i64 %138
%140 = load double, double* %139
%141 = load double*, double** %26
%142 = load i32, i32* %13
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds double, double* %141, i64 %143
%145 = load double, double* %144
%146 = call double @llvm.fmuladd.f64(double %135, double %140, double %145)
store double %146, double* %144
br label %147
147: ; preds = %125
%148 = load i32, i32* %14
%149 = add nsw i32 %148, 1
store i32 %149, i32* %14
br label %121
150: ; preds = %121
%151 = load double*, double** %23
%152 = load i32, i32* %13
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds double, double* %151, i64 %153
%155 = load double, double* %154
%156 = load double*, double** %26
%157 = load i32, i32* %13
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %156, i64 %158
%160 = load double, double* %159
%161 = fsub double %155, %160
%162 = call double @llvm.fabs.f64(double %161)
store double %162, double* %20
%163 = load double*, double** %11
%164 = load i32, i32* %13
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds double, double* %163, i64 %165
%167 = load double, double* %166
%168 = load double*, double** %12
%169 = load i32, i32* %13
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds double, double* %168, i64 %170
%172 = load double, double* %171
%173 = fcmp ogt double %167, %172
br i1 %173, label %174, label %180
174: ; preds = %150
%175 = load double*, double** %11
%176 = load i32, i32* %13
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds double, double* %175, i64 %177
%179 = load double, double* %178
store double %179, double* %21
br label %186
180: ; preds = %150
%181 = load double*, double** %12
%182 = load i32, i32* %13
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %181, i64 %183
%185 = load double, double* %184
store double %185, double* %21
br label %186
186: ; preds = %180, %174
%187 = load double, double* %20
%188 = load double, double* %19
%189 = load double, double* %21
%190 = fmul double %188, %189
%191 = fcmp oge double %187, %190
br i1 %191, label %192, label %193
192: ; preds = %186
store i32 0, i32* %15
br label %193
193: ; preds = %192, %186
br label %194
194: ; preds = %193
%195 = load i32, i32* %13
%196 = add nsw i32 %195, 1
store i32 %196, i32* %13
br label %81
197: ; preds = %81
%198 = load i32, i32* %15
%199 = icmp eq i32 %198, 0
br i1 %199, label %200, label %274
200: ; preds = %197
%201 = load double*, double** %22
%202 = load double*, double** %26
%203 = load double*, double** %25
%204 = load i32, i32* %8
%205 = call i32 @mmult(double* %201, double* %202, double* %203, i32 1, i32 %204, i32 1)
store i32 0, i32* %13
br label %206
206: ; preds = %270, %200
%207 = load i32, i32* %13
%208 = load i32, i32* %8
%209 = icmp slt i32 %207, %208
br i1 %209, label %210, label %273
210: ; preds = %206
%211 = load i32, i32* %13
%212 = load i32, i32* %8
%213 = mul nsw i32 %211, %212
store i32 %213, i32* %16
%214 = load i32, i32* %13
store i32 %214, i32* %14
br label %215
215: ; preds = %266, %210
%216 = load i32, i32* %14
%217 = load i32, i32* %8
%218 = icmp slt i32 %216, %217
br i1 %218, label %219, label %269
219: ; preds = %215
%220 = load double*, double** %23
%221 = load i32, i32* %13
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds double, double* %220, i64 %222
%224 = load double, double* %223
%225 = load double*, double** %23
%226 = load i32, i32* %14
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds double, double* %225, i64 %227
%229 = load double, double* %228
%230 = fmul double %224, %229
%231 = load double*, double** %24
%232 = getelementptr inbounds double, double* %231, i64 0
%233 = load double, double* %232
%234 = fdiv double %230, %233
%235 = load double*, double** %7
%236 = load i32, i32* %16
%237 = load i32, i32* %14
%238 = add nsw i32 %236, %237
%239 = sext i32 %238 to i64
%240 = getelementptr inbounds double, double* %235, i64 %239
%241 = load double, double* %240
%242 = fadd double %241, %234
store double %242, double* %240
%243 = load double*, double** %26
%244 = load i32, i32* %13
%245 = sext i32 %244 to i64
%246 = getelementptr inbounds double, double* %243, i64 %245
%247 = load double, double* %246
%248 = load double*, double** %26
%249 = load i32, i32* %14
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds double, double* %248, i64 %250
%252 = load double, double* %251
%253 = fmul double %247, %252
%254 = load double*, double** %25
%255 = getelementptr inbounds double, double* %254, i64 0
%256 = load double, double* %255
%257 = fdiv double %253, %256
%258 = load double*, double** %7
%259 = load i32, i32* %16
%260 = load i32, i32* %14
%261 = add nsw i32 %259, %260
%262 = sext i32 %261 to i64
%263 = getelementptr inbounds double, double* %258, i64 %262
%264 = load double, double* %263
%265 = fsub double %264, %257
store double %265, double* %263
br label %266
266: ; preds = %219
%267 = load i32, i32* %14
%268 = add nsw i32 %267, 1
store i32 %268, i32* %14
br label %215
269: ; preds = %215
br label %270
270: ; preds = %269
%271 = load i32, i32* %13
%272 = add nsw i32 %271, 1
store i32 %272, i32* %13
br label %206
273: ; preds = %206
br label %274
274: ; preds = %273, %197
br label %275
275: ; preds = %274, %6
%276 = load double*, double** %22
%277 = call i32 @free(double* %276)
%278 = load double*, double** %23
%279 = call i32 @free(double* %278)
%280 = load double*, double** %24
%281 = call i32 @free(double* %280)
%282 = load double*, double** %25
%283 = call i32 @free(double* %282)
%284 = load double*, double** %26
%285 = call i32 @free(double* %284)
ret void
}

LLVM IR (-O2):
define void @bfgs_naive(double* nocapture %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = bitcast double* %0 to i8*
%8 = shl i32 %1, 3
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to double*
%11 = tail call i64 @malloc(i32 %8)
%12 = inttoptr i64 %11 to double*
%13 = tail call i64 @malloc(i32 8)
%14 = inttoptr i64 %13 to double*
%15 = inttoptr i64 %13 to i8*
%16 = tail call i64 @malloc(i32 8)
%17 = inttoptr i64 %16 to double*
%18 = inttoptr i64 %16 to i8*
%19 = tail call i64 @malloc(i32 %8)
%20 = inttoptr i64 %19 to double*
%21 = tail call i32 @msub(double* %3, double* %2, double* %10, i32 1, i32 %1)
%22 = tail call i32 @msub(double* %5, double* %4, double* %12, i32 1, i32 %1)
%23 = tail call double @l2norm(double* %10, i32 %1)
%24 = tail call double @l2norm(double* %12, i32 %1)
%25 = tail call i32 @mmult(double* %12, double* %10, double* %14, i32 1, i32 %1, i32 1)
%26 = load double, double* %14
%27 = fmul double %23, 0x3E60FA3389D6EB40
%28 = fmul double %27, %24
%29 = fcmp ult double %26, %28
br i1 %29, label %237, label %30
30: ; preds = %6
%31 = icmp sgt i32 %1, 0
br i1 %31, label %32, label %237
32: ; preds = %30
%33 = zext i32 %1 to i64
%34 = zext i32 %1 to i64
br label %35
35: ; preds = %32, %94
%36 = phi i64 [ 0, %32 ], [ %108, %94 ]
%37 = phi i32 [ 1, %32 ], [ %107, %94 ]
%38 = getelementptr inbounds double, double* %20, i64 %36
store double 0.000000e+00, double* %38
%39 = icmp eq i64 %36, 0
br i1 %39, label %58, label %40
40: ; preds = %35
%41 = and i64 %36, 1
%42 = icmp eq i64 %36, 1
br i1 %42, label %45, label %43
43: ; preds = %40
%44 = and i64 %36, 9223372036854775806
br label %61
45: ; preds = %61, %40
%46 = phi double [ undef, %40 ], [ %79, %61 ]
%47 = phi double [ 0.000000e+00, %40 ], [ %79, %61 ]
%48 = phi i64 [ 0, %40 ], [ %80, %61 ]
%49 = icmp eq i64 %41, 0
br i1 %49, label %58, label %50
50: ; preds = %45
%51 = mul nsw i64 %48, %33
%52 = add nuw nsw i64 %51, %36
%53 = getelementptr inbounds double, double* %0, i64 %52
%54 = load double, double* %53
%55 = getelementptr inbounds double, double* %10, i64 %48
%56 = load double, double* %55
%57 = tail call double @llvm.fmuladd.f64(double %54, double %56, double %47)
store double %57, double* %38
br label %58
58: ; preds = %50, %45, %35
%59 = phi double [ 0.000000e+00, %35 ], [ %46, %45 ], [ %57, %50 ]
%60 = mul nsw i64 %36, %33
br label %83
61: ; preds = %61, %43
%62 = phi double [ 0.000000e+00, %43 ], [ %79, %61 ]
%63 = phi i64 [ 0, %43 ], [ %80, %61 ]
%64 = phi i64 [ 0, %43 ], [ %81, %61 ]
%65 = mul nsw i64 %63, %33
%66 = add nuw nsw i64 %65, %36
%67 = getelementptr inbounds double, double* %0, i64 %66
%68 = load double, double* %67
%69 = getelementptr inbounds double, double* %10, i64 %63
%70 = load double, double* %69
%71 = tail call double @llvm.fmuladd.f64(double %68, double %70, double %62)
store double %71, double* %38
%72 = or i64 %63, 1
%73 = mul nsw i64 %72, %33
%74 = add nuw nsw i64 %73, %36
%75 = getelementptr inbounds double, double* %0, i64 %74
%76 = load double, double* %75
%77 = getelementptr inbounds double, double* %10, i64 %72
%78 = load double, double* %77
%79 = tail call double @llvm.fmuladd.f64(double %76, double %78, double %71)
store double %79, double* %38
%80 = add nuw nsw i64 %63, 2
%81 = add i64 %64, 2
%82 = icmp eq i64 %81, %44
br i1 %82, label %45, label %61
83: ; preds = %58, %83
%84 = phi double [ %59, %58 ], [ %91, %83 ]
%85 = phi i64 [ %36, %58 ], [ %92, %83 ]
%86 = add nuw nsw i64 %85, %60
%87 = getelementptr inbounds double, double* %0, i64 %86
%88 = load double, double* %87
%89 = getelementptr inbounds double, double* %10, i64 %85
%90 = load double, double* %89
%91 = tail call double @llvm.fmuladd.f64(double %88, double %90, double %84)
store double %91, double* %38
%92 = add nuw nsw i64 %85, 1
%93 = icmp eq i64 %92, %34
br i1 %93, label %94, label %83
94: ; preds = %83
%95 = getelementptr inbounds double, double* %12, i64 %36
%96 = load double, double* %95
%97 = fsub double %96, %91
%98 = tail call double @llvm.fabs.f64(double %97)
%99 = getelementptr inbounds double, double* %4, i64 %36
%100 = load double, double* %99
%101 = getelementptr inbounds double, double* %5, i64 %36
%102 = load double, double* %101
%103 = fcmp ogt double %100, %102
%104 = select i1 %103, double %100, double %102
%105 = fmul double %104, 0x3E60FA3389D6EB40
%106 = fcmp ult double %98, %105
%107 = select i1 %106, i32 %37, i32 0
%108 = add nuw nsw i64 %36, 1
%109 = icmp eq i64 %108, %34
br i1 %109, label %110, label %35
110: ; preds = %94
%111 = icmp eq i32 %107, 0
br i1 %111, label %112, label %237
112: ; preds = %110
%113 = tail call i32 @mmult(double* %10, double* %20, double* %17, i32 1, i32 %1, i32 1)
br i1 %31, label %114, label %237
114: ; preds = %112
%115 = zext i32 %1 to i64
%116 = zext i32 %1 to i64
%117 = shl nuw nsw i64 %34, 3
%118 = add nuw nsw i64 %117, 8
%119 = getelementptr double, double* %12, i64 %34
%120 = bitcast double* %119 to i8*
%121 = getelementptr double, double* %14, i64 1
%122 = bitcast double* %121 to i8*
%123 = getelementptr double, double* %20, i64 %34
%124 = bitcast double* %123 to i8*
%125 = getelementptr double, double* %17, i64 1
%126 = bitcast double* %125 to i8*
br label %127
127: ; preds = %234, %114
%128 = phi i64 [ 0, %114 ], [ %235, %234 ]
%129 = sub nsw i64 %34, %128
%130 = mul i64 %118, %128
%131 = getelementptr i8, i8* %7, i64 %130
%132 = mul i64 %128, %34
%133 = add i64 %132, %34
%134 = getelementptr double, double* %0, i64 %133
%135 = bitcast double* %134 to i8*
%136 = getelementptr double, double* %12, i64 %128
%137 = add nuw i64 %128, 1
%138 = getelementptr double, double* %20, i64 %128
%139 = mul nsw i64 %128, %115
%140 = getelementptr inbounds double, double* %12, i64 %128
%141 = getelementptr inbounds double, double* %20, i64 %128
%142 = icmp ult i64 %129, 2
br i1 %142, label %211, label %143
143: ; preds = %127
%144 = getelementptr double, double* %20, i64 %137
%145 = bitcast double* %144 to i8*
%146 = getelementptr double, double* %12, i64 %137
%147 = bitcast double* %146 to i8*
%148 = icmp ult i8* %131, %120
%149 = icmp ult double* %136, %134
%150 = and i1 %148, %149
%151 = icmp ult i8* %131, %147
%152 = icmp ult double* %136, %134
%153 = and i1 %151, %152
%154 = or i1 %150, %153
%155 = icmp ult i8* %131, %122
%156 = icmp ult i8* %15, %135
%157 = and i1 %155, %156
%158 = or i1 %154, %157
%159 = icmp ult i8* %131, %124
%160 = icmp ult double* %138, %134
%161 = and i1 %159, %160
%162 = or i1 %158, %161
%163 = icmp ult i8* %131, %145
%164 = icmp ult double* %138, %134
%165 = and i1 %163, %164
%166 = or i1 %162, %165
%167 = icmp ult i8* %131, %126
%168 = icmp ult i8* %18, %135
%169 = and i1 %167, %168
%170 = or i1 %166, %169
br i1 %170, label %211, label %171
171: ; preds = %143
%172 = and i64 %129, -2
%173 = add i64 %128, %172
%174 = load double, double* %140
%175 = insertelement <2 x double> poison, double %174, i64 0
%176 = shufflevector <2 x double> %175, <2 x double> poison, <2 x i32> zeroinitializer
%177 = load double, double* %14
%178 = insertelement <2 x double> poison, double %177, i64 0
%179 = shufflevector <2 x double> %178, <2 x double> poison, <2 x i32> zeroinitializer
%180 = load double, double* %141
%181 = insertelement <2 x double> poison, double %180, i64 0
%182 = shufflevector <2 x double> %181, <2 x double> poison, <2 x i32> zeroinitializer
%183 = load double, double* %17
%184 = insertelement <2 x double> poison, double %183, i64 0
%185 = shufflevector <2 x double> %184, <2 x double> poison, <2 x i32> zeroinitializer
br label %186
186: ; preds = %186, %171
%187 = phi i64 [ 0, %171 ], [ %207, %186 ]
%188 = add i64 %128, %187
%189 = getelementptr inbounds double, double* %12, i64 %188
%190 = bitcast double* %189 to <2 x double>*
%191 = load <2 x double>, <2 x double>* %190
%192 = fmul <2 x double> %176, %191
%193 = fdiv <2 x double> %192, %179
%194 = add nuw nsw i64 %188, %139
%195 = getelementptr inbounds double, double* %0, i64 %194
%196 = bitcast double* %195 to <2 x double>*
%197 = load <2 x double>, <2 x double>* %196
%198 = fadd <2 x double> %197, %193
%199 = bitcast double* %195 to <2 x double>*
store <2 x double> %198, <2 x double>* %199
%200 = getelementptr inbounds double, double* %20, i64 %188
%201 = bitcast double* %200 to <2 x double>*
%202 = load <2 x double>, <2 x double>* %201
%203 = fmul <2 x double> %182, %202
%204 = fdiv <2 x double> %203, %185
%205 = fsub <2 x double> %198, %204
%206 = bitcast double* %195 to <2 x double>*
store <2 x double> %205, <2 x double>* %206
%207 = add nuw i64 %187, 2
%208 = icmp eq i64 %207, %172
br i1 %208, label %209, label %186
209: ; preds = %186
%210 = icmp eq i64 %129, %172
br i1 %210, label %234, label %211
211: ; preds = %143, %127, %209
%212 = phi i64 [ %128, %143 ], [ %128, %127 ], [ %173, %209 ]
br label %213
213: ; preds = %211, %213
%214 = phi i64 [ %232, %213 ], [ %212, %211 ]
%215 = load double, double* %140
%216 = getelementptr inbounds double, double* %12, i64 %214
%217 = load double, double* %216
%218 = fmul double %215, %217
%219 = load double, double* %14
%220 = fdiv double %218, %219
%221 = add nuw nsw i64 %214, %139
%222 = getelementptr inbounds double, double* %0, i64 %221
%223 = load double, double* %222
%224 = fadd double %223, %220
store double %224, double* %222
%225 = load double, double* %141
%226 = getelementptr inbounds double, double* %20, i64 %214
%227 = load double, double* %226
%228 = fmul double %225, %227
%229 = load double, double* %17
%230 = fdiv double %228, %229
%231 = fsub double %224, %230
store double %231, double* %222
%232 = add nuw nsw i64 %214, 1
%233 = icmp eq i64 %232, %116
br i1 %233, label %234, label %213
234: ; preds = %213, %209
%235 = add nuw nsw i64 %128, 1
%236 = icmp eq i64 %235, %116
br i1 %236, label %237, label %127
237: ; preds = %234, %30, %112, %110, %6
%238 = tail call i32 @free(double* %10)
%239 = tail call i32 @free(double* %12)
%240 = tail call i32 @free(double* %14)
%241 = tail call i32 @free(double* %17)
%242 = tail call i32 @free(double* %20)
ret void
}