#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 symrange(double);
double confidence2x(double confidence) {
  double i, j, k, rj;
  int x;
  i = 0;
  j = 3;
  k = 6;
  for (x = 0; x < 32; x++) {
    rj = symrange(j);
    if (confidence > rj) {
      i = j;
    } else {
      k = j;
    }
    j = (i + k) / 2;
  }
  return j;
}


x86 assembly (clang, -O0):
<confidence2x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xec6(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x20,-0x2c(%rbp)
jge    11b1 <confidence2x+0xa1>
movsd  -0x18(%rbp),%xmm0
call   1030 <symrange@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    117e <confidence2x+0x6e>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1188 <confidence2x+0x78>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe76(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1146 <confidence2x+0x36>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<confidence2x>:
push   %rbx
sub    $0x30,%rsp
movapd %xmm0,%xmm2
movsd  0xedf(%rip),%xmm0
movsd  0xedf(%rip),%xmm3
xorpd  %xmm1,%xmm1
mov    $0x20,%ebx
movsd  %xmm2,(%rsp)
jmp    116c <confidence2x+0x5c>
nopl   0x0(%rax)
cmpltsd %xmm2,%xmm0
movapd 0x20(%rsp),%xmm3
andpd  %xmm0,%xmm3
andnpd %xmm4,%xmm0
orpd   %xmm0,%xmm3
movapd %xmm3,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xea9(%rip),%xmm0
add    $0xffffffff,%ebx
je     11a0 <confidence2x+0x90>
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,0x10(%rsp)
movapd %xmm3,0x20(%rsp)
call   1030 <symrange@plt>
movapd 0x10(%rsp),%xmm4
movsd  (%rsp),%xmm2
ucomisd %xmm0,%xmm2
movapd %xmm4,%xmm1
ja     1140 <confidence2x+0x30>
movsd  0x8(%rsp),%xmm1
jmp    1140 <confidence2x+0x30>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @confidence2x(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %2
store double 0.000000e+00, double* %3
store double 3.000000e+00, double* %4
store double 6.000000e+00, double* %5
store i32 0, i32* %7
br label %8
8: ; preds = %26, %1
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load double, double* %4
%13 = call double @symrange(double %12)
store double %13, double* %6
%14 = load double, double* %2
%15 = load double, double* %6
%16 = fcmp ogt double %14, %15
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load double, double* %4
store double %18, double* %3
br label %21
19: ; preds = %11
%20 = load double, double* %4
store double %20, double* %5
br label %21
21: ; preds = %19, %17
%22 = load double, double* %3
%23 = load double, double* %5
%24 = fadd double %22, %23
%25 = fdiv double %24, 2.000000e+00
store double %25, double* %4
br label %26
26: ; preds = %21
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %8
29: ; preds = %8
%30 = load double, double* %4
ret double %30
}

LLVM IR (-O2):
define double @confidence2x(double %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %13, %2 ]
%4 = phi double [ 0.000000e+00, %1 ], [ %10, %2 ]
%5 = phi double [ 6.000000e+00, %1 ], [ %9, %2 ]
%6 = phi double [ 3.000000e+00, %1 ], [ %12, %2 ]
%7 = tail call double @symrange(double %6)
%8 = fcmp olt double %7, %0
%9 = select i1 %8, double %5, double %6
%10 = select i1 %8, double %6, double %4
%11 = fadd double %10, %9
%12 = fmul double %11, 5.000000e-01
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %2
15: ; preds = %2
ret double %12
}