#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 */
long double proba_n(int, int, long double);
int get_th(int size_window, long double threshold, long double proba) {
  int th_nb_gene = size_window + 1;
  long double p_t = 0.0;
  while (p_t <= threshold && th_nb_gene > 0) {
    th_nb_gene--;
    p_t = p_t + proba_n(size_window, th_nb_gene, proba);
  }
  return th_nb_gene;
}


x86 assembly (clang, -O0):
<get_th>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
mov    %edi,-0x4(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
fldz
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   -0x20(%rbp)
xor    %eax,%eax
fucomip %st(1),%st
fstp   %st(0)
mov    %al,-0x51(%rbp)
jb     1159 <get_th+0x49>
jmp    114f <get_th+0x3f>
cmpl   $0x0,-0x34(%rbp)
setg   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1169 <get_th+0x59>
jmp    1198 <get_th+0x88>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
fldt   -0x50(%rbp)
fstpt  -0x5c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x34(%rbp),%esi
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <proba_n@plt>
fldt   -0x5c(%rbp)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
jmp    1135 <get_th+0x25>
mov    -0x34(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_th>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edi,%r14d
fldt   0x60(%rsp)
fstpt  0x20(%rsp)
fldt   0x50(%rsp)
lea    0x1(%r14),%eax
fldz
fld    %st(1)
fstpt  0x14(%rsp)
fxch   %st(1)
fucomip %st(1),%st
jb     1177 <get_th+0x67>
test   %r14d,%r14d
js     117b <get_th+0x6b>
mov    %r14d,%ebx
fstpt  0x2c(%rsp)
fldt   0x20(%rsp)
fstpt  (%rsp)
mov    %r14d,%edi
mov    %ebx,%esi
call   1030 <proba_n@plt>
fldt   0x2c(%rsp)
faddp  %st,%st(1)
lea    -0x1(%rbx),%eax
fldt   0x14(%rsp)
fucomip %st(1),%st
jb     1170 <get_th+0x60>
add    $0x1,%ebx
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1140 <get_th+0x30>
fstp   %st(0)
add    $0x1,%eax
jmp    1179 <get_th+0x69>
fstp   %st(0)
fldz
fstp   %st(0)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @get_th(i32 %0, x86_fp80 %1, x86_fp80 %2) {
%4 = alloca i32
%5 = alloca x86_fp80
%6 = alloca x86_fp80
%7 = alloca i32
%8 = alloca x86_fp80
store i32 %0, i32* %4
store x86_fp80 %1, x86_fp80* %5
store x86_fp80 %2, x86_fp80* %6
%9 = load i32, i32* %4
%10 = add nsw i32 %9, 1
store i32 %10, i32* %7
store x86_fp80 0xK00000000000000000000, x86_fp80* %8
br label %11
11: ; preds = %20, %3
%12 = load x86_fp80, x86_fp80* %8
%13 = load x86_fp80, x86_fp80* %5
%14 = fcmp ole x86_fp80 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %7
%17 = icmp sgt i32 %16, 0
br label %18
18: ; preds = %15, %11
%19 = phi i1 [ false, %11 ], [ %17, %15 ]
br i1 %19, label %20, label %29
20: ; preds = %18
%21 = load i32, i32* %7
%22 = add nsw i32 %21, -1
store i32 %22, i32* %7
%23 = load x86_fp80, x86_fp80* %8
%24 = load i32, i32* %4
%25 = load i32, i32* %7
%26 = load x86_fp80, x86_fp80* %6
%27 = call x86_fp80 @proba_n(i32 %24, i32 %25, x86_fp80 %26)
%28 = fadd x86_fp80 %23, %27
store x86_fp80 %28, x86_fp80* %8
br label %11
29: ; preds = %18
%30 = load i32, i32* %7
ret i32 %30
}

LLVM IR (-O2):
define i32 @get_th(i32 %0, x86_fp80 %1, x86_fp80 %2) {
%4 = add nsw i32 %0, 1
%5 = fcmp oge x86_fp80 %1, 0xK00000000000000000000
%6 = icmp sgt i32 %0, -1
%7 = and i1 %5, %6
br i1 %7, label %8, label %17
8: ; preds = %3, %8
%9 = phi x86_fp80 [ %13, %8 ], [ 0xK00000000000000000000, %3 ]
%10 = phi i32 [ %11, %8 ], [ %4, %3 ]
%11 = add nsw i32 %10, -1
%12 = tail call x86_fp80 @proba_n(i32 %0, i32 %11, x86_fp80 %2)
%13 = fadd x86_fp80 %9, %12
%14 = fcmp ole x86_fp80 %13, %1
%15 = icmp ugt i32 %10, 1
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %8, label %17
17: ; preds = %8, %3
%18 = phi i32 [ %4, %3 ], [ %11, %8 ]
ret i32 %18
}