#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 log(double);
double designSPRTTest(double delta, double epsilon, double t_M, double m_S) {
  double An, C, K, prevAn;
  unsigned i;
  C = (1 - delta) * log((1 - delta) / (1 - epsilon)) +
      delta * log(delta / epsilon);
  K = t_M * C / m_S + 1;
  An = K;
  i = 0;
  do {
    prevAn = An;
    An = K + log(An);
  } while ((An - prevAn > 1.5e-8) && (++i < 10));
  return An;
}


x86 assembly (clang, -O0):
<designSPRTTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  0xecc(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xeba(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  0xead(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  0xe47(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x44(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
xor    %eax,%eax
movsd  0xdf2(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x69(%rbp)
jbe    1235 <designSPRTTest+0x125>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
cmp    $0xa,%eax
setb   %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    11d3 <designSPRTTest+0xc3>
movsd  -0x28(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<designSPRTTest>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm3,0x28(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
movsd  0xecc(%rip),%xmm3
movapd %xmm3,%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
subsd  %xmm1,%xmm3
movapd %xmm2,%xmm0
divsd  %xmm3,%xmm0
call   1030 <log@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
call   1030 <log@plt>
mulsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm1
divsd  0x28(%rsp),%xmm1
addsd  0xe6e(%rip),%xmm1
xor    %ebx,%ebx
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
xchg   %ax,%ax
movsd  %xmm0,(%rsp)
call   1030 <log@plt>
addsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
subsd  (%rsp),%xmm1
ucomisd 0xe47(%rip),%xmm1
jbe    11cd <designSPRTTest+0xbd>
lea    0x1(%rbx),%eax
cmp    $0x9,%ebx
mov    %eax,%ebx
jb     11a0 <designSPRTTest+0x90>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @designSPRTTest(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%14 = load double, double* %5
%15 = fsub double 1.000000e+00, %14
%16 = load double, double* %5
%17 = fsub double 1.000000e+00, %16
%18 = load double, double* %6
%19 = fsub double 1.000000e+00, %18
%20 = fdiv double %17, %19
%21 = call double @log(double %20)
%22 = load double, double* %5
%23 = load double, double* %5
%24 = load double, double* %6
%25 = fdiv double %23, %24
%26 = call double @log(double %25)
%27 = fmul double %22, %26
%28 = call double @llvm.fmuladd.f64(double %15, double %21, double %27)
store double %28, double* %10
%29 = load double, double* %7
%30 = load double, double* %10
%31 = fmul double %29, %30
%32 = load double, double* %8
%33 = fdiv double %31, %32
%34 = fadd double %33, 1.000000e+00
store double %34, double* %11
%35 = load double, double* %11
store double %35, double* %9
store i32 0, i32* %13
br label %36
36: ; preds = %51, %4
%37 = load double, double* %9
store double %37, double* %12
%38 = load double, double* %11
%39 = load double, double* %9
%40 = call double @log(double %39)
%41 = fadd double %38, %40
store double %41, double* %9
br label %42
42: ; preds = %36
%43 = load double, double* %9
%44 = load double, double* %12
%45 = fsub double %43, %44
%46 = fcmp ogt double %45, 1.500000e-08
br i1 %46, label %47, label %51
47: ; preds = %42
%48 = load i32, i32* %13
%49 = add i32 %48, 1
store i32 %49, i32* %13
%50 = icmp ult i32 %49, 10
br label %51
51: ; preds = %47, %42
%52 = phi i1 [ false, %42 ], [ %50, %47 ]
br i1 %52, label %36, label %53
53: ; preds = %51
%54 = load double, double* %9
ret double %54
}

LLVM IR (-O2):
define double @designSPRTTest(double %0, double %1, double %2, double %3) {
%5 = fsub double 1.000000e+00, %0
%6 = fsub double 1.000000e+00, %1
%7 = fdiv double %5, %6
%8 = tail call double @log(double %7)
%9 = fdiv double %0, %1
%10 = tail call double @log(double %9)
%11 = fmul double %10, %0
%12 = tail call double @llvm.fmuladd.f64(double %5, double %8, double %11)
%13 = fmul double %12, %2
%14 = fdiv double %13, %3
%15 = fadd double %14, 1.000000e+00
br label %16
16: ; preds = %16, %4
%17 = phi double [ %15, %4 ], [ %20, %16 ]
%18 = phi i32 [ 0, %4 ], [ %23, %16 ]
%19 = tail call double @log(double %17)
%20 = fadd double %15, %19
%21 = fsub double %20, %17
%22 = fcmp ogt double %21, 1.500000e-08
%23 = add nuw nsw i32 %18, 1
%24 = icmp ult i32 %18, 9
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %16, label %26
26: ; preds = %16
ret double %20
}