#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_less(int size_window, long double threshold, long double proba) {
  int th_nb_gene = -1;
  long double p_t = 0.0;
  while (p_t <= threshold && th_nb_gene < size_window) {
    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_less>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
mov    %edi,-0x4(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
movl   $0xffffffff,-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_less+0x49>
jmp    114d <get_th_less+0x3d>
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
setl   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1169 <get_th_less+0x59>
jmp    1198 <get_th_less+0x88>
mov    -0x34(%rbp),%eax
add    $0x1,%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    1133 <get_th_less+0x23>
mov    -0x34(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_th_less>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
fldt   0x60(%rsp)
fstpt  0x20(%rsp)
fldt   0x50(%rsp)
mov    $0xffffffff,%ebx
test   %edi,%edi
js     116f <get_th_less+0x5f>
fldz
fxch   %st(1)
fucomi %st(1),%st
jb     1177 <get_th_less+0x67>
mov    %edi,%ebp
mov    $0xffffffff,%ebx
fstpt  0x14(%rsp)
fldz
fstp   %st(0)
fstpt  0x2c(%rsp)
add    $0x1,%ebx
fldt   0x20(%rsp)
fstpt  (%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <proba_n@plt>
fldt   0x2c(%rsp)
faddp  %st,%st(1)
cmp    %ebp,%ebx
jge    116f <get_th_less+0x5f>
fldt   0x14(%rsp)
fucomip %st(1),%st
fldz
jae    1140 <get_th_less+0x30>
jmp    1177 <get_th_less+0x67>
fstp   %st(0)
fldz
fldz
fxch   %st(1)
fstp   %st(0)
fstp   %st(0)
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

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

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