#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 */
unsigned int ceil(int);
int log(double);
int pow(double, double);
unsigned sacCalcIterBound(double confidence, double inlierRate,
                          unsigned sampleSize, unsigned maxIterBound) {
  unsigned retVal;
  double atLeastOneOutlierProbability =
      1. - pow(inlierRate, (double)sampleSize);
  if (atLeastOneOutlierProbability == 1.) {
    retVal = maxIterBound;
  } else if (atLeastOneOutlierProbability == 0.) {
    retVal = 0;
  } else {
    retVal = ceil(log(1. - confidence) / log(atLeastOneOutlierProbability));
  }
  return retVal <= maxIterBound ? retVal : maxIterBound;
}


x86 assembly (clang, -O0):
<sacCalcIterBound>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm1
call   1050 <pow@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe9a(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1197 <sacCalcIterBound+0x67>
jp     1197 <sacCalcIterBound+0x67>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11f1 <sacCalcIterBound+0xc1>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11bb <sacCalcIterBound+0x8b>
jp     11bb <sacCalcIterBound+0x8b>
movl   $0x0,-0x1c(%rbp)
jmp    11ec <sacCalcIterBound+0xbc>
movsd  0xe3d(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1040 <log@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <ceil@plt>
mov    %eax,-0x1c(%rbp)
jmp    11f1 <sacCalcIterBound+0xc1>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
ja     1208 <sacCalcIterBound+0xd8>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    120e <sacCalcIterBound+0xde>
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sacCalcIterBound>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
movaps %xmm1,%xmm2
movsd  %xmm0,(%rsp)
mov    %edi,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movaps %xmm2,%xmm0
call   1050 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xea2(%rip),%xmm0
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
ucomisd %xmm0,%xmm2
mov    %ebx,%eax
jne    1170 <sacCalcIterBound+0x40>
jnp    11a7 <sacCalcIterBound+0x77>
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jne    117e <sacCalcIterBound+0x4e>
jnp    11a7 <sacCalcIterBound+0x77>
subsd  (%rsp),%xmm0
movsd  %xmm2,(%rsp)
call   1040 <log@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <ceil@plt>
cmp    %ebx,%eax
cmova  %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sacCalcIterBound(double %0, double %1, i32 %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load double, double* %6
%12 = load i32, i32* %7
%13 = uitofp i32 %12 to double
%14 = call i32 @pow(double %11, double %13)
%15 = sitofp i32 %14 to double
%16 = fsub double 1.000000e+00, %15
store double %16, double* %10
%17 = load double, double* %10
%18 = fcmp oeq double %17, 1.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = load i32, i32* %8
store i32 %20, i32* %9
br label %34
21: ; preds = %4
%22 = load double, double* %10
%23 = fcmp oeq double %22, 0.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 0, i32* %9
br label %33
25: ; preds = %21
%26 = load double, double* %5
%27 = fsub double 1.000000e+00, %26
%28 = call i32 @log(double %27)
%29 = load double, double* %10
%30 = call i32 @log(double %29)
%31 = sdiv i32 %28, %30
%32 = call i32 @ceil(i32 %31)
store i32 %32, i32* %9
br label %33
33: ; preds = %25, %24
br label %34
34: ; preds = %33, %19
%35 = load i32, i32* %9
%36 = load i32, i32* %8
%37 = icmp ule i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = load i32, i32* %9
br label %42
40: ; preds = %34
%41 = load i32, i32* %8
br label %42
42: ; preds = %40, %38
%43 = phi i32 [ %39, %38 ], [ %41, %40 ]
ret i32 %43
}

LLVM IR (-O2):
define i32 @sacCalcIterBound(double %0, double %1, i32 %2, i32 %3) {
%5 = uitofp i32 %2 to double
%6 = tail call i32 @pow(double %1, double %5)
%7 = sitofp i32 %6 to double
%8 = fsub double 1.000000e+00, %7
%9 = fcmp oeq double %8, 1.000000e+00
br i1 %9, label %18, label %10
10: ; preds = %4
%11 = fcmp oeq double %8, 0.000000e+00
br i1 %11, label %18, label %12
12: ; preds = %10
%13 = fsub double 1.000000e+00, %0
%14 = tail call i32 @log(double %13)
%15 = tail call i32 @log(double %8)
%16 = sdiv i32 %14, %15
%17 = tail call i32 @ceil(i32 %16)
br label %18
18: ; preds = %10, %4, %12
%19 = phi i32 [ %17, %12 ], [ %3, %4 ], [ 0, %10 ]
%20 = icmp ugt i32 %19, %3
%21 = select i1 %20, i32 %3, i32 %19
ret i32 %21
}