#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 pow(int, double);
extern size_t estimate_sample(double cov, double probthresh) {
  size_t i = 0;
  double prob = 1;
  if (probthresh == 0)
    return -1;
  while (prob > probthresh)
    prob = pow((1 - cov), (double)(++i));
  return i;
}


x86 assembly (clang, -O0):
<estimate_sample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115c <estimate_sample+0x4c>
jp     115c <estimate_sample+0x4c>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11d0 <estimate_sample+0xc0>
jmp    1161 <estimate_sample+0x51>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11c8 <estimate_sample+0xb8>
movsd  -0x10(%rbp),%xmm1
movsd  0xe82(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
movq   %rax,%xmm0
movaps 0xe72(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xe76(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1030 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1161 <estimate_sample+0x51>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<estimate_sample>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffffffffffff,%rbx
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    1126 <estimate_sample+0x16>
jnp    118b <estimate_sample+0x7b>
movsd  0xed2(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    1189 <estimate_sample+0x79>
subsd  %xmm0,%xmm2
cvttsd2si %xmm2,%ebp
xor    %ebx,%ebx
movsd  %xmm1,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
movq   %rbx,%xmm2
punpckldq 0xeaf(%rip),%xmm2
subpd  0xeb7(%rip),%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
addsd  %xmm2,%xmm0
mov    %ebp,%edi
call   1030 <pow@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
ja     1150 <estimate_sample+0x40>
jmp    118b <estimate_sample+0x7b>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i64 @estimate_sample(double %0, double %1) {
%3 = alloca i64
%4 = alloca double
%5 = alloca double
%6 = alloca i64
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store i64 0, i64* %6
store double 1.000000e+00, double* %7
%8 = load double, double* %5
%9 = fcmp oeq double %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %2
store i64 -1, i64* %3
br label %26
11: ; preds = %2
br label %12
12: ; preds = %16, %11
%13 = load double, double* %7
%14 = load double, double* %5
%15 = fcmp ogt double %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load double, double* %4
%18 = fsub double 1.000000e+00, %17
%19 = fptosi double %18 to i32
%20 = load i64, i64* %6
%21 = add i64 %20, 1
store i64 %21, i64* %6
%22 = uitofp i64 %21 to double
%23 = call double @pow(i32 %19, double %22)
store double %23, double* %7
br label %12
24: ; preds = %12
%25 = load i64, i64* %6
store i64 %25, i64* %3
br label %26
26: ; preds = %24, %10
%27 = load i64, i64* %3
ret i64 %27
}

LLVM IR (-O2):
define i64 @estimate_sample(double %0, double %1) {
%3 = fcmp oeq double %1, 0.000000e+00
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = fcmp olt double %1, 1.000000e+00
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = fsub double 1.000000e+00, %0
%8 = fptosi double %7 to i32
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %11, %9 ]
%11 = add i64 %10, 1
%12 = uitofp i64 %11 to double
%13 = tail call double @pow(i32 %8, double %12)
%14 = fcmp ogt double %13, %1
br i1 %14, label %9, label %15
15: ; preds = %9, %4, %2
%16 = phi i64 [ -1, %2 ], [ 0, %4 ], [ %11, %9 ]
ret i64 %16
}