#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_binomial(int, int);
double nb_iter(int n, int k, int w, int p, int l) {
  double x;
  x = 2 * log_binomial(k / 2, p);
  x += log_binomial(n - k - l, w - 2 * p);
  x = log_binomial(n, w) - x;
  return x;
}


x86 assembly (clang, -O0):
<nb_iter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x10(%rbp),%esi
call   1030 <log_binomial@plt>
movaps %xmm0,%xmm1
movsd  0xeb8(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
sub    -0x8(%rbp),%edi
sub    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
sub    %eax,%esi
call   1030 <log_binomial@plt>
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <log_binomial@plt>
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nb_iter>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r12d
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%r15d
mov    %esi,%edi
shr    $0x1f,%edi
add    %esi,%edi
sar    %edi
mov    %ecx,%esi
call   1030 <log_binomial@plt>
addsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
add    %ebx,%r12d
mov    %r15d,%edi
sub    %r12d,%edi
add    %ebp,%ebp
mov    %r14d,%esi
sub    %ebp,%esi
call   1030 <log_binomial@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r15d,%edi
mov    %r14d,%esi
call   1030 <log_binomial@plt>
subsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @nb_iter(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %7
%13 = sdiv i32 %12, 2
%14 = load i32, i32* %9
%15 = call double @log_binomial(i32 %13, i32 %14)
%16 = fmul double 2.000000e+00, %15
store double %16, double* %11
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = sub nsw i32 %17, %18
%20 = load i32, i32* %10
%21 = sub nsw i32 %19, %20
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = mul nsw i32 2, %23
%25 = sub nsw i32 %22, %24
%26 = call double @log_binomial(i32 %21, i32 %25)
%27 = load double, double* %11
%28 = fadd double %27, %26
store double %28, double* %11
%29 = load i32, i32* %6
%30 = load i32, i32* %8
%31 = call double @log_binomial(i32 %29, i32 %30)
%32 = load double, double* %11
%33 = fsub double %31, %32
store double %33, double* %11
%34 = load double, double* %11
ret double %34
}

LLVM IR (-O2):
define double @nb_iter(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = sdiv i32 %1, 2
%7 = tail call double @log_binomial(i32 %6, i32 %3)
%8 = fmul double %7, 2.000000e+00
%9 = add i32 %1, %4
%10 = sub i32 %0, %9
%11 = mul i32 %3, -2
%12 = add i32 %11, %2
%13 = tail call double @log_binomial(i32 %10, i32 %12)
%14 = fadd double %8, %13
%15 = tail call double @log_binomial(i32 %0, i32 %2)
%16 = fsub double %15, %14
ret double %16
}