#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*/ fprintf(int /*<<< orphan*/, char *, double, double);
double sphere_volume(double);
int /*<<< orphan*/ stdout;
int main() {
  double dim = 0, delta = 1;
  while (((delta) > 0 ? (delta) : -(delta)) > .0000000001)
    if (sphere_volume(dim + delta) > sphere_volume(dim))
      dim += delta;
    else
      delta /= -2;
  fprintf(stdout, "max volume = %.10f at dimension %.10f\n", sphere_volume(dim),
          dim);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1165 <main+0x45>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1186 <main+0x66>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11fc <main+0xdc>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1030 <sphere_volume@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sphere_volume@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e1 <main+0xc1>
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11f7 <main+0xd7>
movsd  -0x18(%rbp),%xmm0
movsd  0xe22(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1144 <main+0x24>
mov    0x2ddd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sphere_volume@plt>
mov    -0x2c(%rbp),%edi
movsd  -0x10(%rbp),%xmm1
lea    0xdf7(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
xorpd  %xmm0,%xmm0
movsd  0xecf(%rip),%xmm4
jmp    1187 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpltsd %xmm2,%xmm0
movapd 0x20(%rsp),%xmm1
andpd  %xmm0,%xmm1
andnpd (%rsp),%xmm0
orpd   %xmm1,%xmm0
movapd %xmm4,%xmm3
xorpd  0xebc(%rip),%xmm3
xorpd  %xmm1,%xmm1
cmpltsd %xmm4,%xmm1
movapd %xmm1,%xmm2
andpd  %xmm4,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm2,%xmm1
ucomisd 0xe8b(%rip),%xmm1
jbe    11dc <main+0xbc>
movapd %xmm0,(%rsp)
movapd %xmm4,0x30(%rsp)
addsd  %xmm4,%xmm0
movapd %xmm0,0x20(%rsp)
call   1030 <sphere_volume@plt>
movsd  %xmm0,0x18(%rsp)
movapd (%rsp),%xmm0
call   1030 <sphere_volume@plt>
movsd  0x18(%rsp),%xmm2
movapd 0x30(%rsp),%xmm4
ucomisd %xmm0,%xmm2
movapd %xmm4,%xmm1
mulsd  0xe3b(%rip),%xmm1
ja     1140 <main+0x20>
movapd %xmm1,%xmm4
jmp    1140 <main+0x20>
mov    0x2dfd(%rip),%rax
mov    (%rax),%ebx
movapd %xmm0,(%rsp)
call   1030 <sphere_volume@plt>
lea    0xe3a(%rip),%rsi
mov    %ebx,%edi
movaps (%rsp),%xmm1
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [39 x i8] c"max volume = %.10f at dimension %.10f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 1.000000e+00, double* %3
br label %4
4: ; preds = %30, %0
%5 = load double, double* %3
%6 = fcmp ogt double %5, 0.000000e+00
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = load double, double* %3
br label %12
9: ; preds = %4
%10 = load double, double* %3
%11 = fneg double %10
br label %12
12: ; preds = %9, %7
%13 = phi double [ %8, %7 ], [ %11, %9 ]
%14 = fcmp ogt double %13, 1.000000e-10
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = load double, double* %2
%17 = load double, double* %3
%18 = fadd double %16, %17
%19 = call double @sphere_volume(double %18)
%20 = load double, double* %2
%21 = call double @sphere_volume(double %20)
%22 = fcmp ogt double %19, %21
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = load double, double* %3
%25 = load double, double* %2
%26 = fadd double %25, %24
store double %26, double* %2
br label %30
27: ; preds = %15
%28 = load double, double* %3
%29 = fdiv double %28, -2.000000e+00
store double %29, double* %3
br label %30
30: ; preds = %27, %23
br label %4
31: ; preds = %12
%32 = load i32, i32* @stdout
%33 = load double, double* %2
%34 = call double @sphere_volume(double %33)
%35 = load double, double* %2
%36 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), double %34, double %35)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [39 x i8] c"max volume = %.10f at dimension %.10f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi double [ 1.000000e+00, %0 ], [ %10, %1 ]
%3 = phi double [ 0.000000e+00, %0 ], [ %9, %1 ]
%4 = fadd double %3, %2
%5 = tail call double @sphere_volume(double %4)
%6 = tail call double @sphere_volume(double %3)
%7 = fcmp ogt double %5, %6
%8 = fmul double %2, -5.000000e-01
%9 = select i1 %7, double %4, double %3
%10 = select i1 %7, double %2, double %8
%11 = fcmp ogt double %10, 0.000000e+00
%12 = fneg double %10
%13 = select i1 %11, double %10, double %12
%14 = fcmp ogt double %13, 1.000000e-10
br i1 %14, label %1, label %15
15: ; preds = %1
%16 = load i32, i32* @stdout
%17 = tail call double @sphere_volume(double %9)
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), double %17, double %9)
ret i32 0
}