#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 cgpr(double (*)(double *, int), double *, int, double *, double *);
int conjgrad_min_lin(double (*funcpt)(double *, int), double *xi, int N,
                     double *dx, double *xf) {
  int rcode, i;
  for (i = 0; i < N; ++i) {
    xi[i] *= dx[i];
    dx[i] = 1.0 / dx[i];
  }
  rcode = cgpr(funcpt, xi, N, dx, xf);
  return rcode;
}


x86 assembly (clang, -O0):
<conjgrad_min_lin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118d <conjgrad_min_lin+0x7d>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  0xe93(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1132 <conjgrad_min_lin+0x22>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <cgpr@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conjgrad_min_lin>:
push   %rbx
test   %edx,%edx
jle    12a0 <conjgrad_min_lin+0x190>
mov    %edx,%r9d
cmp    $0x1,%edx
je     113b <conjgrad_min_lin+0x2b>
lea    (%rcx,%r9,8),%rax
cmp    %rsi,%rax
jbe    11cd <conjgrad_min_lin+0xbd>
lea    (%rsi,%r9,8),%rax
cmp    %rcx,%rax
jbe    11cd <conjgrad_min_lin+0xbd>
xor    %eax,%eax
mov    %rax,%rbx
not    %rbx
test   $0x1,%r9b
je     116e <conjgrad_min_lin+0x5e>
movsd  (%rcx,%rax,8),%xmm0
mulsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,(%rsi,%rax,8)
movsd  0xeb0(%rip),%xmm0
divsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,(%rcx,%rax,8)
or     $0x1,%rax
add    %r9,%rbx
je     12a0 <conjgrad_min_lin+0x190>
movsd  0xe91(%rip),%xmm0
nop
movsd  (%rcx,%rax,8),%xmm1
mulsd  (%rsi,%rax,8),%xmm1
movsd  %xmm1,(%rsi,%rax,8)
movapd %xmm0,%xmm1
divsd  (%rcx,%rax,8),%xmm1
movsd  %xmm1,(%rcx,%rax,8)
movsd  0x8(%rcx,%rax,8),%xmm1
mulsd  0x8(%rsi,%rax,8),%xmm1
movsd  %xmm1,0x8(%rsi,%rax,8)
movapd %xmm0,%xmm1
divsd  0x8(%rcx,%rax,8),%xmm1
movsd  %xmm1,0x8(%rcx,%rax,8)
add    $0x2,%rax
cmp    %rax,%r9
jne    1180 <conjgrad_min_lin+0x70>
jmp    12a0 <conjgrad_min_lin+0x190>
mov    %r9d,%eax
and    $0xfffffffe,%eax
lea    -0x2(%rax),%rbx
mov    %rbx,%r11
shr    %r11
add    $0x1,%r11
test   %rbx,%rbx
je     12a6 <conjgrad_min_lin+0x196>
mov    %r11,%rbx
and    $0xfffffffffffffffe,%rbx
xor    %r10d,%r10d
movapd 0xe04(%rip),%xmm0
nopl   0x0(%rax)
movupd (%rcx,%r10,8),%xmm1
movupd (%rsi,%r10,8),%xmm2
mulpd  %xmm1,%xmm2
movupd %xmm2,(%rsi,%r10,8)
movupd (%rcx,%r10,8),%xmm1
movupd 0x10(%rcx,%r10,8),%xmm2
movapd %xmm0,%xmm3
divpd  %xmm1,%xmm3
movupd %xmm3,(%rcx,%r10,8)
movupd 0x10(%rsi,%r10,8),%xmm1
mulpd  %xmm2,%xmm1
movupd %xmm1,0x10(%rsi,%r10,8)
movupd 0x10(%rcx,%r10,8),%xmm1
movapd %xmm0,%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,0x10(%rcx,%r10,8)
add    $0x4,%r10
add    $0xfffffffffffffffe,%rbx
jne    1200 <conjgrad_min_lin+0xf0>
test   $0x1,%r11b
je     1297 <conjgrad_min_lin+0x187>
movupd (%rcx,%r10,8),%xmm0
movupd (%rsi,%r10,8),%xmm1
mulpd  %xmm0,%xmm1
movupd %xmm1,(%rsi,%r10,8)
movupd (%rcx,%r10,8),%xmm0
movapd 0xd73(%rip),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,(%rcx,%r10,8)
cmp    %r9,%rax
jne    113d <conjgrad_min_lin+0x2d>
pop    %rbx
jmp    1030 <cgpr@plt>
xor    %r10d,%r10d
test   $0x1,%r11b
jne    1269 <conjgrad_min_lin+0x159>
jmp    1297 <conjgrad_min_lin+0x187>

LLVM IR (-O0):
define i32 @conjgrad_min_lin(double (double*, i32)* %0, double* %1, i32 %2, double* %3, double* %4) {
%6 = alloca double (double*, i32)*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
store double (double*, i32)* %0, double (double*, i32)** %6
store double* %1, double** %7
store i32 %2, i32* %8
store double* %3, double** %9
store double* %4, double** %10
store i32 0, i32* %12
br label %13
13: ; preds = %39, %5
%14 = load i32, i32* %12
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %42
17: ; preds = %13
%18 = load double*, double** %9
%19 = load i32, i32* %12
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %7
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fmul double %27, %22
store double %28, double* %26
%29 = load double*, double** %9
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = fdiv double 1.000000e+00, %33
%35 = load double*, double** %9
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
store double %34, double* %38
br label %39
39: ; preds = %17
%40 = load i32, i32* %12
%41 = add nsw i32 %40, 1
store i32 %41, i32* %12
br label %13
42: ; preds = %13
%43 = load double (double*, i32)*, double (double*, i32)** %6
%44 = load double*, double** %7
%45 = load i32, i32* %8
%46 = load double*, double** %9
%47 = load double*, double** %10
%48 = call i32 @cgpr(double (double*, i32)* %43, double* %44, i32 %45, double* %46, double* %47)
store i32 %48, i32* %11
%49 = load i32, i32* %11
ret i32 %49
}

LLVM IR (-O2):
define i32 @conjgrad_min_lin(double (double*, i32)* %0, double* %1, i32 %2, double* %3, double* %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %111
7: ; preds = %5
%8 = zext i32 %2 to i64
%9 = icmp eq i32 %2, 1
br i1 %9, label %74, label %10
10: ; preds = %7
%11 = getelementptr double, double* %1, i64 %8
%12 = getelementptr double, double* %3, i64 %8
%13 = icmp ugt double* %12, %1
%14 = icmp ugt double* %11, %3
%15 = and i1 %13, %14
br i1 %15, label %74, label %16
16: ; preds = %10
%17 = and i64 %8, 4294967294
%18 = add nsw i64 %17, -2
%19 = lshr exact i64 %18, 1
%20 = add nuw i64 %19, 1
%21 = and i64 %20, 1
%22 = icmp eq i64 %18, 0
br i1 %22, label %56, label %23
23: ; preds = %16
%24 = and i64 %20, -2
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %53, %25 ]
%27 = phi i64 [ 0, %23 ], [ %54, %25 ]
%28 = getelementptr inbounds double, double* %3, i64 %26
%29 = bitcast double* %28 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
%31 = getelementptr inbounds double, double* %1, i64 %26
%32 = bitcast double* %31 to <2 x double>*
%33 = load <2 x double>, <2 x double>* %32
%34 = fmul <2 x double> %30, %33
%35 = bitcast double* %31 to <2 x double>*
store <2 x double> %34, <2 x double>* %35
%36 = bitcast double* %28 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %37
%39 = bitcast double* %28 to <2 x double>*
store <2 x double> %38, <2 x double>* %39
%40 = or i64 %26, 2
%41 = getelementptr inbounds double, double* %3, i64 %40
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %1, i64 %40
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = fmul <2 x double> %43, %46
%48 = bitcast double* %44 to <2 x double>*
store <2 x double> %47, <2 x double>* %48
%49 = bitcast double* %41 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %50
%52 = bitcast double* %41 to <2 x double>*
store <2 x double> %51, <2 x double>* %52
%53 = add nuw i64 %26, 4
%54 = add nuw i64 %27, 2
%55 = icmp eq i64 %54, %24
br i1 %55, label %56, label %25
56: ; preds = %25, %16
%57 = phi i64 [ 0, %16 ], [ %53, %25 ]
%58 = icmp eq i64 %21, 0
br i1 %58, label %72, label %59
59: ; preds = %56
%60 = getelementptr inbounds double, double* %3, i64 %57
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = getelementptr inbounds double, double* %1, i64 %57
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = fmul <2 x double> %62, %65
%67 = bitcast double* %63 to <2 x double>*
store <2 x double> %66, <2 x double>* %67
%68 = bitcast double* %60 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %69
%71 = bitcast double* %60 to <2 x double>*
store <2 x double> %70, <2 x double>* %71
br label %72
72: ; preds = %56, %59
%73 = icmp eq i64 %17, %8
br i1 %73, label %111, label %74
74: ; preds = %10, %7, %72
%75 = phi i64 [ 0, %10 ], [ 0, %7 ], [ %17, %72 ]
%76 = xor i64 %75, -1
%77 = and i64 %8, 1
%78 = icmp eq i64 %77, 0
br i1 %78, label %88, label %79
79: ; preds = %74
%80 = getelementptr inbounds double, double* %3, i64 %75
%81 = load double, double* %80
%82 = getelementptr inbounds double, double* %1, i64 %75
%83 = load double, double* %82
%84 = fmul double %81, %83
store double %84, double* %82
%85 = load double, double* %80
%86 = fdiv double 1.000000e+00, %85
store double %86, double* %80
%87 = or i64 %75, 1
br label %88
88: ; preds = %79, %74
%89 = phi i64 [ %75, %74 ], [ %87, %79 ]
%90 = sub nsw i64 0, %8
%91 = icmp eq i64 %76, %90
br i1 %91, label %111, label %92
92: ; preds = %88, %92
%93 = phi i64 [ %109, %92 ], [ %89, %88 ]
%94 = getelementptr inbounds double, double* %3, i64 %93
%95 = load double, double* %94
%96 = getelementptr inbounds double, double* %1, i64 %93
%97 = load double, double* %96
%98 = fmul double %95, %97
store double %98, double* %96
%99 = load double, double* %94
%100 = fdiv double 1.000000e+00, %99
store double %100, double* %94
%101 = add nuw nsw i64 %93, 1
%102 = getelementptr inbounds double, double* %3, i64 %101
%103 = load double, double* %102
%104 = getelementptr inbounds double, double* %1, i64 %101
%105 = load double, double* %104
%106 = fmul double %103, %105
store double %106, double* %104
%107 = load double, double* %102
%108 = fdiv double 1.000000e+00, %107
store double %108, double* %102
%109 = add nuw nsw i64 %93, 2
%110 = icmp eq i64 %109, %8
br i1 %110, label %111, label %92
111: ; preds = %88, %92, %72, %5
%112 = tail call i32 @cgpr(double (double*, i32)* %0, double* %1, i32 %2, double* %3, double* %4)
ret i32 %112
}