#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 */
int /*<<< orphan*/ free(double *);
double l2norm(double *, int);
scalar_t__ malloc(int);
double sqrt(double);
int /*<<< orphan*/ trstep(double *, double *, int, double *, double *, double *,
                          double, double *, double *);
int trupdate(double (*)(double *, int), double *, double *, double *, int,
             double *, double, int, double *, double *, double, int, double *,
             double *, double *);
int trsrch(double (*funcpt)(double *, int), double *xi, double *jac, double *sN,
           int N, double *dx, double maxstep, int iter, double *L, double *hess,
           double stol, double *ioval, double *x) {
  int retval, i, j, method;
  double alpha, beta;
  double nlen, t1;
  double *temp, *step, *xprev;
  retval = 4;
  nlen = 0.0;
  ioval[7] = 1.0;
  method = 0;
  temp = (double *)malloc(sizeof(double) * N);
  step = (double *)malloc(sizeof(double) * N);
  xprev = (double *)malloc(sizeof(double) * N);
  for (i = 0; i < N; ++i) {
    nlen += dx[i] * sN[i] * dx[i] * sN[i];
  }
  nlen = sqrt(nlen);
  if (iter == 1 || ioval[0] == -1) {
    ioval[1] = 0.;
    for (i = 0; i < N; ++i) {
      temp[i] = jac[i] / dx[i];
    }
    alpha = l2norm(temp, N);
    alpha = alpha * alpha;
    beta = 0;
    for (i = 0; i < N; ++i) {
      t1 = 0.;
      for (j = i; j < N; ++j) {
        t1 += L[j * N + i] * jac[j] / (dx[j] * dx[j]);
      }
      beta += t1 * t1;
    }
    ioval[0] = alpha * sqrt(alpha) / beta;
    if (ioval[0] > maxstep) {
      ioval[0] = maxstep;
    }
  }
  while (retval >= 2) {
    trstep(jac, sN, N, dx, L, hess, nlen, ioval, step);
    ioval[2] = ioval[0];
    retval = trupdate(funcpt, xi, jac, step, N, dx, maxstep, retval, L, hess,
                      stol, method, ioval, xprev, x);
  }
  free(temp);
  free(step);
  free(xprev);
  return retval;
}


x86 assembly (clang, -O0):
<trsrch>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
mov    %r8d,-0x44(%rbp)
mov    %r9,-0x50(%rbp)
movsd  %xmm0,-0x58(%rbp)
movsd  %xmm1,-0x60(%rbp)
movl   $0x4,-0x64(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    0x28(%rbp),%rax
movsd  0xe3b(%rip),%xmm0
movsd  %xmm0,0x38(%rax)
movl   $0x0,-0x70(%rbp)
movslq -0x44(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x98(%rbp)
movslq -0x44(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xa0(%rbp)
movslq -0x44(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xa8(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1280 <trsrch+0x120>
mov    -0x50(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x68(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x68(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x88(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    121a <trsrch+0xba>
movsd  -0x88(%rbp),%xmm0
ff
call   1070 <sqrt@plt>
movsd  %xmm0,-0x88(%rbp)
ff
cmpl   $0x1,0x10(%rbp)
je     12bf <trsrch+0x15f>
mov    0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xd59(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1458 <trsrch+0x2f8>
jp     1458 <trsrch+0x2f8>
mov    0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1316 <trsrch+0x1b6>
mov    -0x38(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x68(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x98(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    12d2 <trsrch+0x172>
mov    -0x98(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1040 <l2norm@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1400 <trsrch+0x2a0>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x68(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    13d0 <trsrch+0x270>
mov    0x18(%rbp),%rax
mov    -0x6c(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x68(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x50(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1365 <trsrch+0x205>
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x90(%rbp),%xmm2
ff
movsd  -0x80(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1348 <trsrch+0x1e8>
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
divsd  -0x80(%rbp),%xmm0
mov    0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x28(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    1453 <trsrch+0x2f3>
movsd  -0x58(%rbp),%xmm0
mov    0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1458 <trsrch+0x2f8>
jmp    145d <trsrch+0x2fd>
cmpl   $0x2,-0x64(%rbp)
jl     1521 <trsrch+0x3c1>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    0x18(%rbp),%r8
mov    0x20(%rbp),%r9
movsd  -0x88(%rbp),%xmm0
ff
mov    0x28(%rbp),%r10
mov    -0xa0(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <trstep@plt>
mov    0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0xa0(%rbp),%rcx
mov    -0x44(%rbp),%r8d
mov    -0x50(%rbp),%r9
movsd  -0x58(%rbp),%xmm0
mov    -0x64(%rbp),%r12d
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
movsd  -0x60(%rbp),%xmm1
mov    -0x70(%rbp),%ebx
mov    0x28(%rbp),%r11
mov    -0xa8(%rbp),%r10
mov    0x30(%rbp),%rax
mov    %r12d,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1080 <trupdate@plt>
mov    %eax,-0x64(%rbp)
jmp    145d <trsrch+0x2fd>
mov    -0x98(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa0(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x64(%rbp),%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<trsrch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  %xmm1,0x60(%rsp)
movsd  %xmm0,0x28(%rsp)
mov    %r9,%r13
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,0x58(%rsp)
mov    %rdi,0x50(%rsp)
mov    0xb8(%rsp),%rcx
movabs $0x3ff0000000000000,%rax
mov    %rax,0x38(%rcx)
lea    0x0(,%r14,8),%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,0x38(%rsp)
mov    %ebp,%edi
mov    %r14,%rbp
call   1060 <malloc@plt>
xorpd  %xmm1,%xmm1
mov    %ebp,%r15d
xorpd  %xmm0,%xmm0
test   %ebp,%ebp
jle    1270 <trsrch+0x110>
cmp    $0x1,%ebp
jne    11f0 <trsrch+0x90>
xorpd  %xmm0,%xmm0
xor    %edx,%edx
jmp    124a <trsrch+0xea>
mov    %r15d,%ecx
and    $0xfffffffe,%ecx
xorpd  %xmm0,%xmm0
xor    %edx,%edx
nopl   0x0(%rax)
movsd  0x0(%r13,%rdx,8),%xmm2
movsd  0x8(%r13,%rdx,8),%xmm3
movsd  (%rbx,%rdx,8),%xmm4
movsd  0x8(%rbx,%rdx,8),%xmm5
movapd %xmm2,%xmm6
mulsd  %xmm4,%xmm6
mulsd  %xmm2,%xmm6
mulsd  %xmm4,%xmm6
addsd  %xmm0,%xmm6
movapd %xmm3,%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm5,%xmm0
addsd  %xmm6,%xmm0
add    $0x2,%rdx
cmp    %rdx,%rcx
jne    1200 <trsrch+0xa0>
test   $0x1,%r15b
je     1270 <trsrch+0x110>
movsd  0x0(%r13,%rdx,8),%xmm2
movsd  (%rbx,%rdx,8),%xmm3
movapd %xmm2,%xmm4
mulsd  %xmm3,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm3,%xmm4
addsd  %xmm4,%xmm0
mov    %rbx,0x48(%rsp)
mov    0xa0(%rsp),%ebx
ucomisd %xmm1,%xmm0
mov    %rax,0x30(%rsp)
jb     1290 <trsrch+0x130>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
jmp    1299 <trsrch+0x139>
call   1070 <sqrt@plt>
movapd %xmm0,%xmm2
mov    0xa8(%rsp),%rax
cmp    $0x1,%ebx
mov    0xb8(%rsp),%rbx
movsd  %xmm2,0x20(%rsp)
je     12cc <trsrch+0x16c>
movsd  (%rbx),%xmm0
ucomisd 0xd40(%rip),%xmm0
jne    153e <trsrch+0x3de>
jp     153e <trsrch+0x3de>
movq   $0x0,0x8(%rbx)
test   %ebp,%ebp
jle    1354 <trsrch+0x1f4>
cmp    $0x1,%ebp
mov    0x8(%rsp),%rdi
mov    %rax,%r14
jne    136d <trsrch+0x20d>
xor    %eax,%eax
mov    %rax,%rcx
not    %rcx
test   $0x1,%r15b
je     130d <trsrch+0x1ad>
movsd  (%r12,%rax,8),%xmm0
divsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,(%rdi,%rax,8)
or     $0x1,%rax
add    %r15,%rcx
je     143c <trsrch+0x2dc>
cs nopw 0x0(%rax,%rax,1)
movsd  (%r12,%rax,8),%xmm0
divsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,(%rdi,%rax,8)
movsd  0x8(%r12,%rax,8),%xmm0
divsd  0x8(%r13,%rax,8),%xmm0
movsd  %xmm0,0x8(%rdi,%rax,8)
add    $0x2,%rax
cmp    %rax,%r15
jne    1320 <trsrch+0x1c0>
jmp    143c <trsrch+0x2dc>
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   1040 <l2norm@plt>
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
jmp    14e4 <trsrch+0x384>
lea    (%rdi,%r15,8),%rax
lea    (%r12,%r15,8),%rcx
cmp    %rcx,%rdi
setb   %bl
cmp    %r12,%rax
seta   %dl
lea    0x0(,%r15,8),%rcx
add    %r13,%rcx
cmp    %rcx,%rdi
setb   %cl
cmp    %r13,%rax
seta   %sil
xor    %eax,%eax
test   %dl,%bl
jne    1641 <trsrch+0x4e1>
and    %sil,%cl
mov    0xb8(%rsp),%rbx
jne    12eb <trsrch+0x18b>
mov    %r15d,%eax
and    $0xfffffffe,%eax
lea    -0x2(%rax),%rdx
mov    %rdx,%rcx
shr    %rcx
add    $0x1,%rcx
test   %rdx,%rdx
je     164e <trsrch+0x4ee>
mov    %rcx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
movupd (%r12,%rdx,8),%xmm0
movupd 0x0(%r13,%rdx,8),%xmm1
divpd  %xmm1,%xmm0
movupd %xmm0,(%rdi,%rdx,8)
movupd 0x10(%r12,%rdx,8),%xmm0
movupd 0x10(%r13,%rdx,8),%xmm1
divpd  %xmm1,%xmm0
movupd %xmm0,0x10(%rdi,%rdx,8)
add    $0x4,%rdx
add    $0xfffffffffffffffe,%rsi
jne    13e0 <trsrch+0x280>
test   $0x1,%cl
je     1433 <trsrch+0x2d3>
movupd (%r12,%rdx,8),%xmm0
movupd 0x0(%r13,%rdx,8),%xmm1
divpd  %xmm1,%xmm0
movupd %xmm0,(%rdi,%rdx,8)
cmp    %r15,%rax
jne    12eb <trsrch+0x18b>
mov    %ebp,%esi
call   1040 <l2norm@plt>
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
test   %ebp,%ebp
jle    14e4 <trsrch+0x384>
mov    %rbp,%r10
lea    0x0(,%r15,8),%rax
lea    0x8(,%r15,8),%r8
xorpd  %xmm4,%xmm4
xor    %r9d,%r9d
mov    %r15,%rsi
mov    %r12,%rdi
mov    %r13,%rbx
mov    %r14,%rdx
nopl   0x0(%rax)
xor    %ecx,%ecx
mov    %rdx,%rbp
xorpd  %xmm0,%xmm0
nopl   0x0(%rax)
movsd  0x0(%rbp),%xmm1
mulsd  (%rdi,%rcx,8),%xmm1
movsd  (%rbx,%rcx,8),%xmm2
mulsd  %xmm2,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    %rax,%rbp
add    $0x1,%rcx
cmp    %rcx,%rsi
jne    1490 <trsrch+0x330>
mulsd  %xmm0,%xmm0
addsd  %xmm0,%xmm4
add    $0x1,%r9
add    %r8,%rdx
add    $0x8,%rbx
add    $0x8,%rdi
add    $0xffffffffffffffff,%rsi
cmp    %r15,%r9
jne    1480 <trsrch+0x320>
mov    %r10,%rbp
mov    0xb8(%rsp),%rbx
jmp    14e8 <trsrch+0x388>
xorpd  %xmm4,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
jb     14fb <trsrch+0x39b>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    151c <trsrch+0x3bc>
movapd %xmm3,%xmm0
movsd  %xmm3,0x18(%rsp)
movsd  %xmm4,0x10(%rsp)
call   1070 <sqrt@plt>
movsd  0x10(%rsp),%xmm4
movsd  0x18(%rsp),%xmm3
movsd  0x28(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  %xmm0,%xmm3
divsd  %xmm4,%xmm3
movsd  %xmm3,(%rbx)
ucomisd %xmm1,%xmm3
jbe    153e <trsrch+0x3de>
movsd  %xmm1,(%rbx)
mov    %rbp,0x40(%rsp)
mov    %r12,0x18(%rsp)
mov    $0x4,%ebx
mov    %r13,0x10(%rsp)
mov    0x18(%rsp),%r14
mov    0x40(%rsp),%r15
mov    0x10(%rsp),%rbp
mov    0x38(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    0x48(%rsp),%rsi
mov    %r15d,%edx
mov    %rbp,%rcx
mov    0xa8(%rsp),%r8
mov    0xb0(%rsp),%r9
movapd %xmm2,%xmm0
push   %r13
mov    0xc0(%rsp),%r12
push   %r12
call   1050 <trstep@plt>
add    $0x10,%rsp
movsd  (%r12),%xmm0
movsd  %xmm0,0x10(%r12)
sub    $0x8,%rsp
mov    0x58(%rsp),%rdi
mov    0x60(%rsp),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %r15d,%r8d
mov    %rbp,%r9
movsd  0x30(%rsp),%xmm0
movsd  0x68(%rsp),%xmm1
push   0xc8(%rsp)
push   0x40(%rsp)
push   %r12
push   $0x0
push   0xd8(%rsp)
push   0xd8(%rsp)
push   %rbx
call   1080 <trupdate@plt>
movsd  0x60(%rsp),%xmm2
add    $0x40,%rsp
mov    %eax,%ebx
cmp    $0x1,%eax
jg     1570 <trsrch+0x410>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0xb8(%rsp),%rbx
jmp    12eb <trsrch+0x18b>
xor    %edx,%edx
test   $0x1,%cl
jne    141d <trsrch+0x2bd>
jmp    1433 <trsrch+0x2d3>

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

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