#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 backvalue(int, int, int, int, int, int, double, int);
int /*<<< orphan*/ golden(int, int, int, int, int, int, int, double, double,
                          double, double, double *, double *);
void csucs(int t, int r, int f1, int f2, int e, int a, int actn, double uleft,
           double uright, double *umax, double *vmax, int besti, double bestv,
           double *ugrid) {
  double ul, ur, du, um, vm;
  du = (uright - uleft) / ((double)10);
  if (besti == 0) {
    ul = uleft;
    ur = uleft + du;
    *umax = ul;
    *vmax = ugrid[0];
    do {
      um = 0.5 * (ul + ur);
      vm = backvalue(t, r, f1, f2, e, a, um, actn);
      if (vm > ugrid[0]) {
        golden(t, r, f1, f2, e, a, actn, ul, um, ur, vm, umax, vmax);
        break;
      }
      ur = um;
    } while ((ur - ul) > 1.0e-3);
  } else if (besti == 10) {
    ur = uright;
    ul = uright - du;
    *umax = ur;
    *vmax = ugrid[10];
    do {
      um = 0.5 * (ul + ur);
      vm = backvalue(t, r, f1, f2, e, a, um, actn);
      if (vm > ugrid[10]) {
        golden(t, r, f1, f2, e, a, actn, ul, um, ur, vm, umax, vmax);
        break;
      }
      ul = um;
    } while ((ur - ul) > 1.0e-3);
  } else {
    um = uleft + ((double)besti) * du;
    golden(t, r, f1, f2, e, a, actn, um - du, um, um + du, bestv, umax, vmax);
  }
}


x86 assembly (clang, -O0):
<csucs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe91(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x0,0x28(%rbp)
jne    1286 <csucs+0x166>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xe3e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
movsd  -0x50(%rbp),%xmm0
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <backvalue@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    0x30(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    125b <csucs+0x13b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    0x10(%rbp),%r11d
movsd  -0x38(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <golden@plt>
jmp    1281 <csucs+0x161>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  0xd99(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11b8 <csucs+0x98>
jmp    1408 <csucs+0x2e8>
cmpl   $0xa,0x28(%rbp)
jne    1396 <csucs+0x276>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x30(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xd2f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
movsd  -0x50(%rbp),%xmm0
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <backvalue@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    0x30(%rbp),%rax
ucomisd 0x50(%rax),%xmm0
jbe    136b <csucs+0x24b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    0x10(%rbp),%r11d
movsd  -0x38(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <golden@plt>
jmp    1391 <csucs+0x271>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  0xc89(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     12c7 <csucs+0x1a7>
jmp    1403 <csucs+0x2e3>
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl 0x28(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    0x10(%rbp),%r11d
movsd  -0x50(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
addsd  -0x48(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <golden@plt>
jmp    1408 <csucs+0x2e8>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csucs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movapd %xmm2,%xmm3
mov    %r9d,0x4(%rsp)
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x90(%rsp),%r14
mov    0x88(%rsp),%eax
mov    0x80(%rsp),%r11
mov    0x78(%rsp),%r10
mov    0x70(%rsp),%ecx
mov    %rcx,0x20(%rsp)
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
divsd  0xe87(%rip),%xmm2
cmp    $0xa,%eax
je     122d <csucs+0x10d>
movapd %xmm0,%xmm4
test   %eax,%eax
jne    12bf <csucs+0x19f>
addsd  %xmm4,%xmm2
mov    %r10,0x30(%rsp)
movsd  %xmm4,(%r10)
movsd  (%r14),%xmm0
mov    %r11,0x28(%rsp)
movsd  %xmm0,(%r11)
movapd %xmm2,%xmm0
movsd  %xmm4,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm2,0x18(%rsp)
addsd  %xmm4,%xmm0
mulsd  0xe36(%rip),%xmm0
sub    $0x8,%rsp
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0xc(%rsp),%r9d
movsd  %xmm0,0x10(%rsp)
push   0x28(%rsp)
call   1040 <backvalue@plt>
add    $0x10,%rsp
ucomisd (%r14),%xmm0
ja     12f6 <csucs+0x1d6>
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm4
subsd  %xmm4,%xmm1
ucomisd 0xdee(%rip),%xmm1
movapd %xmm0,%xmm2
ja     11c0 <csucs+0xa0>
jmp    12b9 <csucs+0x199>
movapd %xmm1,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm1,(%r10)
movsd  0x50(%r14),%xmm0
movsd  %xmm0,(%r11)
movapd %xmm3,%xmm0
movsd  %xmm1,0x18(%rsp)
nop
movsd  %xmm3,0x10(%rsp)
addsd  %xmm1,%xmm0
mulsd  0xda6(%rip),%xmm0
sub    $0x8,%rsp
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0xc(%rsp),%r9d
movsd  %xmm0,0x10(%rsp)
push   0x28(%rsp)
call   1040 <backvalue@plt>
add    $0x10,%rsp
ucomisd 0x50(%r14),%xmm0
ja     1342 <csucs+0x222>
movsd  0x18(%rsp),%xmm1
movapd %xmm1,%xmm2
movsd  0x8(%rsp),%xmm0
subsd  %xmm0,%xmm2
ucomisd 0xd5d(%rip),%xmm2
movapd %xmm0,%xmm3
ja     1250 <csucs+0x130>
add    $0x38,%rsp
jmp    1337 <csucs+0x217>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm4,%xmm1
movapd %xmm1,%xmm0
subsd  %xmm2,%xmm0
addsd  %xmm1,%xmm2
sub    $0x8,%rsp
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0xc(%rsp),%r9d
push   %r11
push   %r10
jmp    132a <csucs+0x20a>
movapd %xmm0,%xmm3
sub    $0x8,%rsp
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0xc(%rsp),%r9d
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
push   0x30(%rsp)
push   0x40(%rsp)
push   0x38(%rsp)
call   1030 <golden@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movapd %xmm0,%xmm3
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0x4(%rsp),%r9d
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <golden@plt>

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

LLVM IR (-O2):
define void @csucs(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double %7, double %8, double* %9, double* %10, i32 %11, double %12, double* nocapture %13) {
%15 = fsub double %8, %7
%16 = fdiv double %15, 1.000000e+01
switch i32 %11, label %48 [
i32 0, label %17
i32 10, label %32
]
17: ; preds = %14
%18 = fadd double %16, %7
store double %7, double* %9
%19 = load double, double* %13
store double %19, double* %10
br label %20
20: ; preds = %29, %17
%21 = phi double [ %18, %17 ], [ %23, %29 ]
%22 = fadd double %21, %7
%23 = fmul double %22, 5.000000e-01
%24 = tail call double @backvalue(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %23, i32 %6)
%25 = load double, double* %13
%26 = fcmp ogt double %24, %25
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = tail call i32 @golden(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double %7, double %23, double %21, double %24, double* %9, double* %10)
br label %54
29: ; preds = %20
%30 = fsub double %23, %7
%31 = fcmp ogt double %30, 1.000000e-03
br i1 %31, label %20, label %54
32: ; preds = %14
%33 = fsub double %8, %16
store double %8, double* %9
%34 = getelementptr inbounds double, double* %13, i64 10
%35 = load double, double* %34
store double %35, double* %10
br label %36
36: ; preds = %45, %32
%37 = phi double [ %33, %32 ], [ %39, %45 ]
%38 = fadd double %37, %8
%39 = fmul double %38, 5.000000e-01
%40 = tail call double @backvalue(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %39, i32 %6)
%41 = load double, double* %34
%42 = fcmp ogt double %40, %41
br i1 %42, label %43, label %45
43: ; preds = %36
%44 = tail call i32 @golden(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double %37, double %39, double %8, double %40, double* %9, double* %10)
br label %54
45: ; preds = %36
%46 = fsub double %8, %39
%47 = fcmp ogt double %46, 1.000000e-03
br i1 %47, label %36, label %54
48: ; preds = %14
%49 = sitofp i32 %11 to double
%50 = tail call double @llvm.fmuladd.f64(double %49, double %16, double %7)
%51 = fsub double %50, %16
%52 = fadd double %16, %50
%53 = tail call i32 @golden(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double %51, double %50, double %52, double %12, double* %9, double* %10)
br label %54
54: ; preds = %45, %29, %48, %43, %27
ret void
}