#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 *calloc(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ printf(char *);
void Hessian_BFGS(int nDim, const double *dR, const double *dGrad, double *H) {
  int i, j;
  double alpha;
  double beta;
  double *HdR;
  HdR = calloc(nDim, sizeof(double));
  if (HdR == NULL) {
    printf("Hessian_BFGS: error cannnot allocate memory\n");
    exit(-1);
  }
  alpha = 0.0;
  for (i = 0; i < nDim; i++)
    alpha += dGrad[i] * dR[i];
  for (i = 0; i < nDim; i++)
    for (j = 0; j < nDim; j++)
      HdR[i] += H[i * nDim + j] * dR[j];
  beta = 0.0;
  for (i = 0; i < nDim; i++)
    beta += HdR[i] * dR[i];
  if (alpha == 0.0) {
    printf("Hessian_BFGS: error dR perpendicular to dGrad\n");
    exit(-1);
  }
  if (beta == 0.0) {
    printf("Hessian_BFGS: error dR perpendicular to HdR\n");
    exit(-1);
  }
  for (i = 0; i < nDim; i++)
    for (j = 0; j < nDim; j++)
      H[i * nDim + j] += dGrad[i] * dGrad[j] / alpha - HdR[i] * HdR[j] / beta;
  free(HdR);
}


x86 assembly (clang, -O0):
<Hessian_BFGS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1189 <Hessian_BFGS+0x49>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11de <Hessian_BFGS+0x9e>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1198 <Hessian_BFGS+0x58>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1262 <Hessian_BFGS+0x122>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    124f <Hessian_BFGS+0x10f>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f8 <Hessian_BFGS+0xb8>
jmp    1254 <Hessian_BFGS+0x114>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e5 <Hessian_BFGS+0xa5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12b7 <Hessian_BFGS+0x177>
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1271 <Hessian_BFGS+0x131>
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12e5 <Hessian_BFGS+0x1a5>
jp     12e5 <Hessian_BFGS+0x1a5>
lea    0xd57(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1313 <Hessian_BFGS+0x1d3>
jp     1313 <Hessian_BFGS+0x1d3>
lea    0xd58(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13b7 <Hessian_BFGS+0x277>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13a4 <Hessian_BFGS+0x264>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x40(%rbp),%rax
movslq -0x28(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
divsd  -0x38(%rbp),%xmm1
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    132d <Hessian_BFGS+0x1ed>
jmp    13a9 <Hessian_BFGS+0x269>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    131a <Hessian_BFGS+0x1da>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Hessian_BFGS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r15d
mov    $0x8,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     1556 <Hessian_BFGS+0x416>
test   %r15d,%r15d
jle    154d <Hessian_BFGS+0x40d>
mov    %r15d,%r10d
lea    -0x1(%r10),%r8
mov    %r10d,%ecx
and    $0x3,%ecx
cmp    $0x3,%r8
jae    1193 <Hessian_BFGS+0x53>
xorpd  %xmm0,%xmm0
xor    %edx,%edx
jmp    11e8 <Hessian_BFGS+0xa8>
mov    %r10d,%esi
and    $0xfffffffc,%esi
xorpd  %xmm0,%xmm0
xor    %edx,%edx
nop
movsd  (%rbx,%rdx,8),%xmm1
movsd  0x8(%rbx,%rdx,8),%xmm2
mulsd  0x0(%rbp,%rdx,8),%xmm1
mulsd  0x8(%rbp,%rdx,8),%xmm2
addsd  %xmm0,%xmm1
movsd  0x10(%rbx,%rdx,8),%xmm3
mulsd  0x10(%rbp,%rdx,8),%xmm3
addsd  %xmm1,%xmm2
movsd  0x18(%rbx,%rdx,8),%xmm0
mulsd  0x18(%rbp,%rdx,8),%xmm0
addsd  %xmm2,%xmm3
addsd  %xmm3,%xmm0
add    $0x4,%rdx
cmp    %rdx,%rsi
jne    11a0 <Hessian_BFGS+0x60>
test   %rcx,%rcx
je     1217 <Hessian_BFGS+0xd7>
lea    0x0(,%rdx,8),%rsi
add    %rbp,%rsi
lea    (%rbx,%rdx,8),%rdx
xor    %edi,%edi
xchg   %ax,%ax
movsd  (%rdx,%rdi,8),%xmm1
mulsd  (%rsi,%rdi,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rdi
cmp    %rdi,%rcx
jne    1200 <Hessian_BFGS+0xc0>
xorpd  %xmm2,%xmm2
xorpd  %xmm1,%xmm1
test   %r15d,%r15d
jle    13a7 <Hessian_BFGS+0x267>
mov    %r10d,%esi
and    $0x3,%esi
mov    %r10d,%r13d
and    $0xfffffffc,%r13d
mov    0x8(%rsp),%r11
lea    0x18(%r11),%rdx
lea    0x0(,%r10,8),%r9
xor    %r12d,%r12d
jmp    1269 <Hessian_BFGS+0x129>
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,(%rax,%r12,8)
add    $0x1,%r12
add    %r9,%rdx
add    %r9,%r11
cmp    %r10,%r12
je     12fe <Hessian_BFGS+0x1be>
movsd  (%rax,%r12,8),%xmm1
xor    %ecx,%ecx
cmp    $0x3,%r8
jb     12c8 <Hessian_BFGS+0x188>
nopw   0x0(%rax,%rax,1)
movsd  -0x18(%rdx,%rcx,8),%xmm3
movsd  -0x10(%rdx,%rcx,8),%xmm4
mulsd  0x0(%rbp,%rcx,8),%xmm3
mulsd  0x8(%rbp,%rcx,8),%xmm4
addsd  %xmm1,%xmm3
movsd  -0x8(%rdx,%rcx,8),%xmm5
mulsd  0x10(%rbp,%rcx,8),%xmm5
addsd  %xmm3,%xmm4
movsd  (%rdx,%rcx,8),%xmm1
mulsd  0x18(%rbp,%rcx,8),%xmm1
addsd  %xmm4,%xmm5
addsd  %xmm5,%xmm1
add    $0x4,%rcx
cmp    %rcx,%r13
jne    1280 <Hessian_BFGS+0x140>
test   %rsi,%rsi
je     1250 <Hessian_BFGS+0x110>
lea    0x0(,%rcx,8),%rdi
add    %rbp,%rdi
lea    (%r11,%rcx,8),%rcx
xor    %r14d,%r14d
nop
movsd  (%rcx,%r14,8),%xmm3
mulsd  (%rdi,%r14,8),%xmm3
addsd  %xmm3,%xmm1
add    $0x1,%r14
cmp    %r14,%rsi
jne    12e0 <Hessian_BFGS+0x1a0>
jmp    1250 <Hessian_BFGS+0x110>
xorpd  %xmm1,%xmm1
test   %r15d,%r15d
jle    13a7 <Hessian_BFGS+0x267>
mov    %r10d,%ecx
and    $0x3,%ecx
cmp    $0x3,%r8
jae    131f <Hessian_BFGS+0x1df>
xorpd  %xmm1,%xmm1
xor    %edx,%edx
jmp    1378 <Hessian_BFGS+0x238>
mov    %r10d,%esi
and    $0xfffffffc,%esi
xorpd  %xmm1,%xmm1
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movsd  (%rax,%rdx,8),%xmm3
movsd  0x8(%rax,%rdx,8),%xmm4
mulsd  0x0(%rbp,%rdx,8),%xmm3
mulsd  0x8(%rbp,%rdx,8),%xmm4
addsd  %xmm1,%xmm3
movsd  0x10(%rax,%rdx,8),%xmm5
mulsd  0x10(%rbp,%rdx,8),%xmm5
addsd  %xmm3,%xmm4
movsd  0x18(%rax,%rdx,8),%xmm1
mulsd  0x18(%rbp,%rdx,8),%xmm1
addsd  %xmm4,%xmm5
addsd  %xmm5,%xmm1
add    $0x4,%rdx
cmp    %rdx,%rsi
jne    1330 <Hessian_BFGS+0x1f0>
test   %rcx,%rcx
je     13a7 <Hessian_BFGS+0x267>
lea    0x0(,%rdx,8),%rsi
add    %rbp,%rsi
lea    (%rax,%rdx,8),%rdx
xor    %edi,%edi
xchg   %ax,%ax
movsd  (%rdx,%rdi,8),%xmm3
mulsd  (%rsi,%rdi,8),%xmm3
addsd  %xmm3,%xmm1
add    $0x1,%rdi
cmp    %rdi,%rcx
jne    1390 <Hessian_BFGS+0x250>
ucomisd %xmm2,%xmm0
jne    13b3 <Hessian_BFGS+0x273>
jnp    154d <Hessian_BFGS+0x40d>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    13c3 <Hessian_BFGS+0x283>
jnp    155f <Hessian_BFGS+0x41f>
test   %r15d,%r15d
jle    1537 <Hessian_BFGS+0x3f7>
lea    (%rbx,%r10,8),%rcx
mov    %rcx,0x10(%rsp)
mov    %r10d,%r9d
and    $0xfffffffe,%r9d
movapd %xmm0,%xmm8
unpcklpd %xmm0,%xmm8
movapd %xmm1,%xmm3
unpcklpd %xmm1,%xmm3
lea    0x0(,%r10,8),%r12
mov    %r12,%rdi
and    $0xfffffffffffffff0,%rdi
xor    %edx,%edx
mov    0x8(%rsp),%rsi
jmp    1420 <Hessian_BFGS+0x2e0>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rdx
add    %r12,%rsi
cmp    %r10,%rdx
je     1537 <Hessian_BFGS+0x3f7>
movsd  (%rax,%rdx,8),%xmm4
cmp    $0x2,%r15d
jae    1440 <Hessian_BFGS+0x300>
xor    %ecx,%ecx
jmp    1500 <Hessian_BFGS+0x3c0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%r8d
mov    %rdx,%rcx
imul   %r10,%rcx
mov    0x8(%rsp),%r11
lea    (%r11,%rcx,8),%rbp
add    %r10,%rcx
lea    (%r11,%rcx,8),%rcx
lea    (%rbx,%rdx,8),%r11
add    $0x8,%r11
lea    (%rbx,%rdx,8),%r14
cmp    0x10(%rsp),%rbp
setb   %r13b
cmp    %rbx,%rcx
seta   %r15b
cmp    %r11,%rbp
setb   %r11b
cmp    %rcx,%r14
setb   %r14b
test   %r15b,%r13b
jne    14f3 <Hessian_BFGS+0x3b3>
mov    $0x0,%ecx
and    %r14b,%r11b
mov    %r8d,%r15d
jne    1500 <Hessian_BFGS+0x3c0>
movapd %xmm4,%xmm5
unpcklpd %xmm4,%xmm5
movsd  (%rbx,%rdx,8),%xmm6
unpcklpd %xmm6,%xmm6
xor    %ecx,%ecx
nopl   0x0(%rax)
movupd (%rbx,%rcx,1),%xmm7
mulpd  %xmm6,%xmm7
divpd  %xmm8,%xmm7
movupd (%rax,%rcx,1),%xmm2
mulpd  %xmm5,%xmm2
divpd  %xmm3,%xmm2
subpd  %xmm2,%xmm7
movupd (%rsi,%rcx,1),%xmm2
addpd  %xmm7,%xmm2
movupd %xmm2,(%rsi,%rcx,1)
add    $0x10,%rcx
cmp    %rcx,%rdi
jne    14b0 <Hessian_BFGS+0x370>
mov    %r9,%rcx
cmp    %r10,%r9
jne    1500 <Hessian_BFGS+0x3c0>
jmp    1410 <Hessian_BFGS+0x2d0>
xor    %ecx,%ecx
mov    %r8d,%r15d
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rdx,8),%xmm2
mulsd  (%rbx,%rcx,8),%xmm2
divsd  %xmm0,%xmm2
movsd  (%rax,%rcx,8),%xmm5
mulsd  %xmm4,%xmm5
divsd  %xmm1,%xmm5
subsd  %xmm5,%xmm2
addsd  (%rsi,%rcx,8),%xmm2
movsd  %xmm2,(%rsi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%r10
jne    1500 <Hessian_BFGS+0x3c0>
jmp    1410 <Hessian_BFGS+0x2d0>
mov    %rax,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xad8(%rip),%rdi
jmp    1566 <Hessian_BFGS+0x426>
lea    0xafd(%rip),%rdi
jmp    1566 <Hessian_BFGS+0x426>
lea    0xa9a(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"Hessian_BFGS: error cannnot allocate memory\0A\00"
@.str.1 = [47 x i8] c"Hessian_BFGS: error dR perpendicular to dGrad\0A\00"
@.str.2 = [45 x i8] c"Hessian_BFGS: error dR perpendicular to HdR\0A\00"
define void @Hessian_BFGS(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double*
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%14 = load i32, i32* %5
%15 = call double* @calloc(i32 %14, i32 8)
store double* %15, double** %13
%16 = load double*, double** %13
%17 = icmp eq double* %16, null
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %4
store double 0.000000e+00, double* %11
store i32 0, i32* %9
br label %22
22: ; preds = %39, %21
%23 = load i32, i32* %9
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %42
26: ; preds = %22
%27 = load double*, double** %7
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = load double*, double** %6
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = load double, double* %11
%38 = call double @llvm.fmuladd.f64(double %31, double %36, double %37)
store double %38, double* %11
br label %39
39: ; preds = %26
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %22
42: ; preds = %22
store i32 0, i32* %9
br label %43
43: ; preds = %77, %42
%44 = load i32, i32* %9
%45 = load i32, i32* %5
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %80
47: ; preds = %43
store i32 0, i32* %10
br label %48
48: ; preds = %73, %47
%49 = load i32, i32* %10
%50 = load i32, i32* %5
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %76
52: ; preds = %48
%53 = load double*, double** %8
%54 = load i32, i32* %9
%55 = load i32, i32* %5
%56 = mul nsw i32 %54, %55
%57 = load i32, i32* %10
%58 = add nsw i32 %56, %57
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %53, i64 %59
%61 = load double, double* %60
%62 = load double*, double** %6
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = load double*, double** %13
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
%71 = load double, double* %70
%72 = call double @llvm.fmuladd.f64(double %61, double %66, double %71)
store double %72, double* %70
br label %73
73: ; preds = %52
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %48
76: ; preds = %48
br label %77
77: ; preds = %76
%78 = load i32, i32* %9
%79 = add nsw i32 %78, 1
store i32 %79, i32* %9
br label %43
80: ; preds = %43
store double 0.000000e+00, double* %12
store i32 0, i32* %9
br label %81
81: ; preds = %98, %80
%82 = load i32, i32* %9
%83 = load i32, i32* %5
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %101
85: ; preds = %81
%86 = load double*, double** %13
%87 = load i32, i32* %9
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %86, i64 %88
%90 = load double, double* %89
%91 = load double*, double** %6
%92 = load i32, i32* %9
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
%95 = load double, double* %94
%96 = load double, double* %12
%97 = call double @llvm.fmuladd.f64(double %90, double %95, double %96)
store double %97, double* %12
br label %98
98: ; preds = %85
%99 = load i32, i32* %9
%100 = add nsw i32 %99, 1
store i32 %100, i32* %9
br label %81
101: ; preds = %81
%102 = load double, double* %11
%103 = fcmp oeq double %102, 0.000000e+00
br i1 %103, label %104, label %107
104: ; preds = %101
%105 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%106 = call i32 @exit(i32 -1)
unreachable
107: ; preds = %101
%108 = load double, double* %12
%109 = fcmp oeq double %108, 0.000000e+00
br i1 %109, label %110, label %113
110: ; preds = %107
%111 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%112 = call i32 @exit(i32 -1)
unreachable
113: ; preds = %107
store i32 0, i32* %9
br label %114
114: ; preds = %165, %113
%115 = load i32, i32* %9
%116 = load i32, i32* %5
%117 = icmp slt i32 %115, %116
br i1 %117, label %118, label %168
118: ; preds = %114
store i32 0, i32* %10
br label %119
119: ; preds = %161, %118
%120 = load i32, i32* %10
%121 = load i32, i32* %5
%122 = icmp slt i32 %120, %121
br i1 %122, label %123, label %164
123: ; preds = %119
%124 = load double*, double** %7
%125 = load i32, i32* %9
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds double, double* %124, i64 %126
%128 = load double, double* %127
%129 = load double*, double** %7
%130 = load i32, i32* %10
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds double, double* %129, i64 %131
%133 = load double, double* %132
%134 = fmul double %128, %133
%135 = load double, double* %11
%136 = fdiv double %134, %135
%137 = load double*, double** %13
%138 = load i32, i32* %9
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds double, double* %137, i64 %139
%141 = load double, double* %140
%142 = load double*, double** %13
%143 = load i32, i32* %10
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %142, i64 %144
%146 = load double, double* %145
%147 = fmul double %141, %146
%148 = load double, double* %12
%149 = fdiv double %147, %148
%150 = fsub double %136, %149
%151 = load double*, double** %8
%152 = load i32, i32* %9
%153 = load i32, i32* %5
%154 = mul nsw i32 %152, %153
%155 = load i32, i32* %10
%156 = add nsw i32 %154, %155
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds double, double* %151, i64 %157
%159 = load double, double* %158
%160 = fadd double %159, %150
store double %160, double* %158
br label %161
161: ; preds = %123
%162 = load i32, i32* %10
%163 = add nsw i32 %162, 1
store i32 %163, i32* %10
br label %119
164: ; preds = %119
br label %165
165: ; preds = %164
%166 = load i32, i32* %9
%167 = add nsw i32 %166, 1
store i32 %167, i32* %9
br label %114
168: ; preds = %114
%169 = load double*, double** %13
%170 = call i32 @free(double* %169)
ret void
}

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