#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*/ MatrixVectorMult(double *, double **, double *, int);
double dot(double *, double *, int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
double min2(double, double);
double norm(double *, int);
double pow(double, int);
void getCauchyPoint(double *CauchyPoint, double **Hes, double *Grad,
                    double delta, int numSS) {
  int i;
  double coeff;
  double tau;
  double normGrad;
  double *Hgrad;
  double numerator;
  double denominator;
  Hgrad = (double *)malloc(numSS * sizeof(double));
  normGrad = norm(Grad, numSS);
  MatrixVectorMult(Hgrad, Hes, Grad, numSS);
  numerator = pow(normGrad, 3);
  denominator = delta * dot(Grad, Hgrad, numSS);
  tau = min2(numerator / denominator, 1.0);
  coeff = -tau * delta / normGrad;
  for (i = 0; i < numSS; i++) {
    CauchyPoint[i] = coeff * Grad[i];
  }
  free(Hgrad);
}


x86 assembly (clang, -O0):
<getCauchyPoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <norm@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1070 <MatrixVectorMult@plt>
movsd  -0x40(%rbp),%xmm0
mov    $0x3,%edi
call   1090 <pow@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <dot@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  0xdeb(%rip),%xmm1
call   1080 <min2@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    128a <getCauchyPoint+0x11a>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1251 <getCauchyPoint+0xe1>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCauchyPoint>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %ecx,%r12d
movsd  %xmm0,0x10(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%r14
lea    0x0(,%r12,8),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r12d,%esi
call   1050 <norm@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12d,%ecx
call   1070 <MatrixVectorMult@plt>
movsd  0x8(%rsp),%xmm0
mov    $0x3,%edi
call   1090 <pow@plt>
movsd  %xmm0,0x18(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1030 <dot@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0xe03(%rip),%xmm1
movapd %xmm2,%xmm0
call   1080 <min2@plt>
test   %r12d,%r12d
jle    138b <getCauchyPoint+0x21b>
xorpd  0xdf9(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
mov    %r12d,%eax
cmp    $0x4,%r12d
jb     1246 <getCauchyPoint+0xd6>
lea    (%rbx,%rax,8),%rcx
cmp    %r14,%rcx
jbe    12e0 <getCauchyPoint+0x170>
lea    (%r14,%rax,8),%rcx
cmp    %rbx,%rcx
jbe    12e0 <getCauchyPoint+0x170>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %rax,%rdx
mov    %rax,%rsi
and    $0x3,%rsi
je     1279 <getCauchyPoint+0x109>
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1260 <getCauchyPoint+0xf0>
cmp    $0x3,%rdx
jb     138b <getCauchyPoint+0x21b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rbx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rcx,8)
movsd  0x8(%rbx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14,%rcx,8)
movsd  0x10(%rbx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14,%rcx,8)
movsd  0x18(%rbx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%r14,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%rax
jne    1290 <getCauchyPoint+0x120>
jmp    138b <getCauchyPoint+0x21b>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     13a0 <getCauchyPoint+0x230>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
xchg   %ax,%ax
movupd (%rbx,%rdx,8),%xmm2
movupd 0x10(%rbx,%rdx,8),%xmm3
mulpd  %xmm1,%xmm2
mulpd  %xmm1,%xmm3
movupd %xmm2,(%r14,%rdx,8)
movupd %xmm3,0x10(%r14,%rdx,8)
movupd 0x20(%rbx,%rdx,8),%xmm2
movupd 0x30(%rbx,%rdx,8),%xmm3
mulpd  %xmm1,%xmm2
mulpd  %xmm1,%xmm3
movupd %xmm2,0x20(%r14,%rdx,8)
movupd %xmm3,0x30(%r14,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1310 <getCauchyPoint+0x1a0>
test   $0x1,%sil
je     1382 <getCauchyPoint+0x212>
movupd (%rbx,%rdx,8),%xmm2
movupd 0x10(%rbx,%rdx,8),%xmm3
mulpd  %xmm1,%xmm2
mulpd  %xmm1,%xmm3
movupd %xmm2,(%r14,%rdx,8)
movupd %xmm3,0x10(%r14,%rdx,8)
cmp    %rax,%rcx
jne    1248 <getCauchyPoint+0xd8>
mov    %r15,%rdi
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <free@plt>
xor    %edx,%edx
test   $0x1,%sil
jne    1362 <getCauchyPoint+0x1f2>
jmp    1382 <getCauchyPoint+0x212>

LLVM IR (-O0):
define void @getCauchyPoint(double* %0, double** %1, double* %2, double %3, i32 %4) {
%6 = alloca double*
%7 = alloca double**
%8 = alloca double*
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca double
%17 = alloca double
store double* %0, double** %6
store double** %1, double*** %7
store double* %2, double** %8
store double %3, double* %9
store i32 %4, i32* %10
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 8
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to double*
store double* %23, double** %15
%24 = load double*, double** %8
%25 = load i32, i32* %10
%26 = call double @norm(double* %24, i32 %25)
store double %26, double* %14
%27 = load double*, double** %15
%28 = load double**, double*** %7
%29 = load double*, double** %8
%30 = load i32, i32* %10
%31 = call i32 @MatrixVectorMult(double* %27, double** %28, double* %29, i32 %30)
%32 = load double, double* %14
%33 = call double @pow(double %32, i32 3)
store double %33, double* %16
%34 = load double, double* %9
%35 = load double*, double** %8
%36 = load double*, double** %15
%37 = load i32, i32* %10
%38 = call double @dot(double* %35, double* %36, i32 %37)
%39 = fmul double %34, %38
store double %39, double* %17
%40 = load double, double* %16
%41 = load double, double* %17
%42 = fdiv double %40, %41
%43 = call double @min2(double %42, double 1.000000e+00)
store double %43, double* %13
%44 = load double, double* %13
%45 = fneg double %44
%46 = load double, double* %9
%47 = fmul double %45, %46
%48 = load double, double* %14
%49 = fdiv double %47, %48
store double %49, double* %12
store i32 0, i32* %11
br label %50
50: ; preds = %66, %5
%51 = load i32, i32* %11
%52 = load i32, i32* %10
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %69
54: ; preds = %50
%55 = load double, double* %12
%56 = load double*, double** %8
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double, double* %59
%61 = fmul double %55, %60
%62 = load double*, double** %6
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
store double %61, double* %65
br label %66
66: ; preds = %54
%67 = load i32, i32* %11
%68 = add nsw i32 %67, 1
store i32 %68, i32* %11
br label %50
69: ; preds = %50
%70 = load double*, double** %15
%71 = call i32 @free(double* %70)
ret void
}

LLVM IR (-O2):
define void @getCauchyPoint(double* nocapture writeonly %0, double** %1, double* %2, double %3, i32 %4) {
%6 = shl i32 %4, 3
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to double*
%9 = tail call double @norm(double* %2, i32 %4)
%10 = tail call i32 @MatrixVectorMult(double* %8, double** %1, double* %2, i32 %4)
%11 = tail call double @pow(double %9, i32 3)
%12 = tail call double @dot(double* %2, double* %8, i32 %4)
%13 = fmul double %12, %3
%14 = fdiv double %11, %13
%15 = tail call double @min2(double %14, double 1.000000e+00)
%16 = fneg double %15
%17 = fmul double %16, %3
%18 = fdiv double %17, %9
%19 = icmp sgt i32 %4, 0
br i1 %19, label %20, label %133
20: ; preds = %5
%21 = zext i32 %4 to i64
%22 = icmp ult i32 %4, 4
br i1 %22, label %91, label %23
23: ; preds = %20
%24 = getelementptr double, double* %0, i64 %21
%25 = getelementptr double, double* %2, i64 %21
%26 = icmp ugt double* %25, %0
%27 = icmp ugt double* %24, %2
%28 = and i1 %26, %27
br i1 %28, label %91, label %29
29: ; preds = %23
%30 = and i64 %21, 4294967292
%31 = insertelement <2 x double> poison, double %18, i64 0
%32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> zeroinitializer
%33 = insertelement <2 x double> poison, double %18, i64 0
%34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> zeroinitializer
%35 = add nsw i64 %30, -4
%36 = lshr exact i64 %35, 2
%37 = add nuw nsw i64 %36, 1
%38 = and i64 %37, 1
%39 = icmp eq i64 %35, 0
br i1 %39, label %73, label %40
40: ; preds = %29
%41 = and i64 %37, 9223372036854775806
br label %42
42: ; preds = %42, %40
%43 = phi i64 [ 0, %40 ], [ %70, %42 ]
%44 = phi i64 [ 0, %40 ], [ %71, %42 ]
%45 = getelementptr inbounds double, double* %2, i64 %43
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = getelementptr inbounds double, double* %45, i64 2
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = fmul <2 x double> %32, %47
%52 = fmul <2 x double> %34, %50
%53 = getelementptr inbounds double, double* %0, i64 %43
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %51, <2 x double>* %54
%55 = getelementptr inbounds double, double* %53, i64 2
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> %52, <2 x double>* %56
%57 = or i64 %43, 4
%58 = getelementptr inbounds double, double* %2, i64 %57
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %58, i64 2
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = fmul <2 x double> %32, %60
%65 = fmul <2 x double> %34, %63
%66 = getelementptr inbounds double, double* %0, i64 %57
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> %64, <2 x double>* %67
%68 = getelementptr inbounds double, double* %66, i64 2
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> %65, <2 x double>* %69
%70 = add nuw i64 %43, 8
%71 = add i64 %44, 2
%72 = icmp eq i64 %71, %41
br i1 %72, label %73, label %42
73: ; preds = %42, %29
%74 = phi i64 [ 0, %29 ], [ %70, %42 ]
%75 = icmp eq i64 %38, 0
br i1 %75, label %89, label %76
76: ; preds = %73
%77 = getelementptr inbounds double, double* %2, i64 %74
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = getelementptr inbounds double, double* %77, i64 2
%81 = bitcast double* %80 to <2 x double>*
%82 = load <2 x double>, <2 x double>* %81
%83 = fmul <2 x double> %32, %79
%84 = fmul <2 x double> %34, %82
%85 = getelementptr inbounds double, double* %0, i64 %74
%86 = bitcast double* %85 to <2 x double>*
store <2 x double> %83, <2 x double>* %86
%87 = getelementptr inbounds double, double* %85, i64 2
%88 = bitcast double* %87 to <2 x double>*
store <2 x double> %84, <2 x double>* %88
br label %89
89: ; preds = %73, %76
%90 = icmp eq i64 %30, %21
br i1 %90, label %133, label %91
91: ; preds = %23, %20, %89
%92 = phi i64 [ 0, %23 ], [ 0, %20 ], [ %30, %89 ]
%93 = xor i64 %92, -1
%94 = add nsw i64 %93, %21
%95 = and i64 %21, 3
%96 = icmp eq i64 %95, 0
br i1 %96, label %107, label %97
97: ; preds = %91, %97
%98 = phi i64 [ %104, %97 ], [ %92, %91 ]
%99 = phi i64 [ %105, %97 ], [ 0, %91 ]
%100 = getelementptr inbounds double, double* %2, i64 %98
%101 = load double, double* %100
%102 = fmul double %18, %101
%103 = getelementptr inbounds double, double* %0, i64 %98
store double %102, double* %103
%104 = add nuw nsw i64 %98, 1
%105 = add i64 %99, 1
%106 = icmp eq i64 %105, %95
br i1 %106, label %107, label %97
107: ; preds = %97, %91
%108 = phi i64 [ %92, %91 ], [ %104, %97 ]
%109 = icmp ult i64 %94, 3
br i1 %109, label %133, label %110
110: ; preds = %107, %110
%111 = phi i64 [ %131, %110 ], [ %108, %107 ]
%112 = getelementptr inbounds double, double* %2, i64 %111
%113 = load double, double* %112
%114 = fmul double %18, %113
%115 = getelementptr inbounds double, double* %0, i64 %111
store double %114, double* %115
%116 = add nuw nsw i64 %111, 1
%117 = getelementptr inbounds double, double* %2, i64 %116
%118 = load double, double* %117
%119 = fmul double %18, %118
%120 = getelementptr inbounds double, double* %0, i64 %116
store double %119, double* %120
%121 = add nuw nsw i64 %111, 2
%122 = getelementptr inbounds double, double* %2, i64 %121
%123 = load double, double* %122
%124 = fmul double %18, %123
%125 = getelementptr inbounds double, double* %0, i64 %121
store double %124, double* %125
%126 = add nuw nsw i64 %111, 3
%127 = getelementptr inbounds double, double* %2, i64 %126
%128 = load double, double* %127
%129 = fmul double %18, %128
%130 = getelementptr inbounds double, double* %0, i64 %126
store double %129, double* %130
%131 = add nuw nsw i64 %111, 4
%132 = icmp eq i64 %131, %21
br i1 %132, label %133, label %110
133: ; preds = %107, %110, %89, %5
%134 = tail call i32 @free(double* %8)
ret void
}