#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 ldintensity(double, double *);
double ldmaxintensity(double lda[5]) {
  int i;
  double rmin, rmid, rmax, imin, imid, imax;
  imin = 0.0;
  imax = 0.0;
  rmax = 0.0;
  for (rmid = 0.0; rmid <= 1.0; rmid += 0.001) {
    imid = ldintensity(rmid, lda);
    if (imid > imin)
      if (imid > imax) {
        rmin = rmax;
        imin = imax;
        rmax = rmid;
        imax = imid;
      } else {
        rmin = rmid;
        imin = imid;
      }
  }
  if (rmin > rmax) {
    rmid = rmin;
    rmin = rmax;
    rmax = rmid;
  }
  imin = ldintensity(rmin, lda);
  imax = ldintensity(rmax, lda);
  for (i = 0; i < 100; i++) {
    rmid = (rmin + rmax) / 2.0;
    if (imin > imax) {
      rmax = rmid;
      imax = ldintensity(rmax, lda);
    } else if (imin < imax) {
      rmin = rmid;
      imin = ldintensity(rmin, lda);
    } else {
      i = 100;
    }
  }
  if (imax > imin)
    return imax;
  else
    return imin;
}


x86 assembly (clang, -O0):
<ldmaxintensity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xebc(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11e4 <ldmaxintensity+0xd4>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1030 <ldintensity@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11c8 <ldmaxintensity+0xb8>
movsd  -0x40(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    11af <ldmaxintensity+0x9f>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11c3 <ldmaxintensity+0xb3>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11c8 <ldmaxintensity+0xb8>
jmp    11cd <ldmaxintensity+0xbd>
movsd  0xe3b(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    113c <ldmaxintensity+0x2c>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1212 <ldmaxintensity+0x102>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1030 <ldintensity@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1030 <ldintensity@plt>
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    12eb <ldmaxintensity+0x1db>
movsd  -0x20(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xdad(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1296 <ldmaxintensity+0x186>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1030 <ldintensity@plt>
movsd  %xmm0,-0x48(%rbp)
jmp    12d8 <ldmaxintensity+0x1c8>
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12cc <ldmaxintensity+0x1bc>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1030 <ldintensity@plt>
movsd  %xmm0,-0x38(%rbp)
jmp    12d3 <ldmaxintensity+0x1c3>
movl   $0x64,-0x14(%rbp)
jmp    12d8 <ldmaxintensity+0x1c8>
jmp    12dd <ldmaxintensity+0x1cd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123f <ldmaxintensity+0x12f>
movsd  -0x48(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    130a <ldmaxintensity+0x1fa>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1314 <ldmaxintensity+0x204>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ldmaxintensity>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
xorpd  %xmm4,%xmm4
jmp    1199 <ldmaxintensity+0x89>
nopl   0x0(%rax,%rax,1)
movsd  (%rsp),%xmm3
movapd %xmm3,%xmm2
cmpltsd %xmm0,%xmm2
movapd 0x30(%rsp),%xmm5
andpd  %xmm2,%xmm5
andnpd %xmm4,%xmm2
orpd   %xmm5,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm3,%xmm2
minsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
maxsd  %xmm3,%xmm0
movapd %xmm1,0x30(%rsp)
movsd  %xmm0,(%rsp)
addsd  0xe75(%rip),%xmm4
movsd  0xe75(%rip),%xmm0
ucomisd %xmm4,%xmm0
jb     11e8 <ldmaxintensity+0xd8>
movapd %xmm4,0x20(%rsp)
movapd %xmm4,%xmm0
mov    %rbx,%rdi
call   1030 <ldintensity@plt>
ucomisd 0x8(%rsp),%xmm0
jbe    11e0 <ldmaxintensity+0xd0>
ucomisd (%rsp),%xmm0
movapd 0x20(%rsp),%xmm4
movapd %xmm4,%xmm1
ja     1140 <ldmaxintensity+0x30>
movapd 0x30(%rsp),%xmm1
jmp    1140 <ldmaxintensity+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd 0x20(%rsp),%xmm4
jmp    1183 <ldmaxintensity+0x73>
movapd 0x30(%rsp),%xmm2
movapd %xmm2,%xmm0
movapd 0x10(%rsp),%xmm1
minsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
maxsd  %xmm2,%xmm1
movapd %xmm1,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <ldintensity@plt>
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
mov    %rbx,%rdi
call   1030 <ldintensity@plt>
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm1
movapd %xmm0,%xmm3
movapd 0x10(%rsp),%xmm4
mov    $0xffffffff,%ebp
jmp    1280 <ldmaxintensity+0x170>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
movsd  %xmm1,(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1030 <ldintensity@plt>
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm1
movapd %xmm0,%xmm3
movsd  0x20(%rsp),%xmm4
add    $0x1,%ebp
cmp    $0x63,%ebp
jae    12cc <ldmaxintensity+0x1bc>
movapd %xmm2,%xmm0
addsd  %xmm4,%xmm0
mulsd  0xd80(%rip),%xmm0
ucomisd %xmm3,%xmm1
movsd  %xmm0,0x20(%rsp)
ja     1250 <ldmaxintensity+0x140>
ucomisd %xmm1,%xmm3
jbe    12cc <ldmaxintensity+0x1bc>
movapd %xmm4,0x10(%rsp)
mov    %rbx,%rdi
movsd  %xmm3,(%rsp)
call   1030 <ldintensity@plt>
movsd  (%rsp),%xmm3
movapd %xmm0,%xmm1
movapd 0x10(%rsp),%xmm4
movsd  0x20(%rsp),%xmm2
jmp    1278 <ldmaxintensity+0x168>
maxsd  %xmm1,%xmm3
movapd %xmm3,%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @ldmaxintensity(double* %0) {
%2 = alloca double
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %3
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %6
br label %11
11: ; preds = %35, %1
%12 = load double, double* %6
%13 = fcmp ole double %12, 1.000000e+00
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = load double, double* %6
%16 = load double*, double** %3
%17 = call double @ldintensity(double %15, double* %16)
store double %17, double* %9
%18 = load double, double* %9
%19 = load double, double* %8
%20 = fcmp ogt double %18, %19
br i1 %20, label %21, label %34
21: ; preds = %14
%22 = load double, double* %9
%23 = load double, double* %10
%24 = fcmp ogt double %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load double, double* %7
store double %26, double* %5
%27 = load double, double* %10
store double %27, double* %8
%28 = load double, double* %6
store double %28, double* %7
%29 = load double, double* %9
store double %29, double* %10
br label %33
30: ; preds = %21
%31 = load double, double* %6
store double %31, double* %5
%32 = load double, double* %9
store double %32, double* %8
br label %33
33: ; preds = %30, %25
br label %34
34: ; preds = %33, %14
br label %35
35: ; preds = %34
%36 = load double, double* %6
%37 = fadd double %36, 1.000000e-03
store double %37, double* %6
br label %11
38: ; preds = %11
%39 = load double, double* %5
%40 = load double, double* %7
%41 = fcmp ogt double %39, %40
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load double, double* %5
store double %43, double* %6
%44 = load double, double* %7
store double %44, double* %5
%45 = load double, double* %6
store double %45, double* %7
br label %46
46: ; preds = %42, %38
%47 = load double, double* %5
%48 = load double*, double** %3
%49 = call double @ldintensity(double %47, double* %48)
store double %49, double* %8
%50 = load double, double* %7
%51 = load double*, double** %3
%52 = call double @ldintensity(double %50, double* %51)
store double %52, double* %10
store i32 0, i32* %4
br label %53
53: ; preds = %81, %46
%54 = load i32, i32* %4
%55 = icmp slt i32 %54, 100
br i1 %55, label %56, label %84
56: ; preds = %53
%57 = load double, double* %5
%58 = load double, double* %7
%59 = fadd double %57, %58
%60 = fdiv double %59, 2.000000e+00
store double %60, double* %6
%61 = load double, double* %8
%62 = load double, double* %10
%63 = fcmp ogt double %61, %62
br i1 %63, label %64, label %69
64: ; preds = %56
%65 = load double, double* %6
store double %65, double* %7
%66 = load double, double* %7
%67 = load double*, double** %3
%68 = call double @ldintensity(double %66, double* %67)
store double %68, double* %10
br label %80
69: ; preds = %56
%70 = load double, double* %8
%71 = load double, double* %10
%72 = fcmp olt double %70, %71
br i1 %72, label %73, label %78
73: ; preds = %69
%74 = load double, double* %6
store double %74, double* %5
%75 = load double, double* %5
%76 = load double*, double** %3
%77 = call double @ldintensity(double %75, double* %76)
store double %77, double* %8
br label %79
78: ; preds = %69
store i32 100, i32* %4
br label %79
79: ; preds = %78, %73
br label %80
80: ; preds = %79, %64
br label %81
81: ; preds = %80
%82 = load i32, i32* %4
%83 = add nsw i32 %82, 1
store i32 %83, i32* %4
br label %53
84: ; preds = %53
%85 = load double, double* %10
%86 = load double, double* %8
%87 = fcmp ogt double %85, %86
br i1 %87, label %88, label %90
88: ; preds = %84
%89 = load double, double* %10
store double %89, double* %2
br label %92
90: ; preds = %84
%91 = load double, double* %8
store double %91, double* %2
br label %92
92: ; preds = %90, %88
%93 = load double, double* %2
ret double %93
}

LLVM IR (-O2):
define double @ldmaxintensity(double* %0) {
br label %2
2: ; preds = %1, %16
%3 = phi double [ 0.000000e+00, %1 ], [ %20, %16 ]
%4 = phi double [ 0.000000e+00, %1 ], [ %19, %16 ]
%5 = phi double [ 0.000000e+00, %1 ], [ %18, %16 ]
%6 = phi double [ 0.000000e+00, %1 ], [ %21, %16 ]
%7 = phi double [ undef, %1 ], [ %17, %16 ]
%8 = tail call double @ldintensity(double %6, double* %0)
%9 = fcmp ogt double %8, %4
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = fcmp ogt double %8, %3
%12 = select i1 %11, double %5, double %6
%13 = select i1 %11, double %6, double %5
%14 = select i1 %11, double %3, double %8
%15 = select i1 %11, double %8, double %3
br label %16
16: ; preds = %10, %2
%17 = phi double [ %7, %2 ], [ %12, %10 ]
%18 = phi double [ %5, %2 ], [ %13, %10 ]
%19 = phi double [ %4, %2 ], [ %14, %10 ]
%20 = phi double [ %3, %2 ], [ %15, %10 ]
%21 = fadd double %6, 1.000000e-03
%22 = fcmp ugt double %21, 1.000000e+00
br i1 %22, label %23, label %2
23: ; preds = %16
%24 = fcmp ogt double %17, %18
%25 = select i1 %24, double %18, double %17
%26 = select i1 %24, double %17, double %18
%27 = tail call double @ldintensity(double %25, double* %0)
%28 = tail call double @ldintensity(double %26, double* %0)
br label %29
29: ; preds = %23, %44
%30 = phi double [ %28, %23 ], [ %48, %44 ]
%31 = phi double [ %27, %23 ], [ %47, %44 ]
%32 = phi double [ %26, %23 ], [ %46, %44 ]
%33 = phi double [ %25, %23 ], [ %45, %44 ]
%34 = phi i32 [ 0, %23 ], [ %49, %44 ]
%35 = fadd double %33, %32
%36 = fmul double %35, 5.000000e-01
%37 = fcmp ogt double %31, %30
br i1 %37, label %38, label %40
38: ; preds = %29
%39 = tail call double @ldintensity(double %36, double* %0)
br label %44
40: ; preds = %29
%41 = fcmp olt double %31, %30
br i1 %41, label %42, label %51
42: ; preds = %40
%43 = tail call double @ldintensity(double %36, double* %0)
br label %44
44: ; preds = %38, %42
%45 = phi double [ %33, %38 ], [ %36, %42 ]
%46 = phi double [ %36, %38 ], [ %32, %42 ]
%47 = phi double [ %31, %38 ], [ %43, %42 ]
%48 = phi double [ %39, %38 ], [ %30, %42 ]
%49 = add nuw nsw i32 %34, 1
%50 = icmp ult i32 %34, 99
br i1 %50, label %29, label %51
51: ; preds = %40, %44
%52 = phi double [ %48, %44 ], [ %30, %40 ]
%53 = phi double [ %47, %44 ], [ %31, %40 ]
%54 = fcmp ogt double %52, %53
%55 = select i1 %54, double %52, double %53
ret double %55
}