#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 */
int /*<<< orphan*/ assert(int);
float expf(float);
int /*<<< orphan*/ isnan(float);
float logf(int);
float dnbinom_precalc_f(unsigned int x, float size, float p,
                        float log_n_combinations) {
  float c, p0, p1, val;
  c = log_n_combinations;
  p0 = logf(p) * x;
  p1 = logf(1 - p) * size;
  val = expf(c + p0 + p1);
  assert(!isnan(val));
  return val;
}


x86 assembly (clang, -O0):
<dnbinom_precalc_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
cvttss2si -0xc(%rbp),%edi
call   1030 <logf@plt>
mov    -0x4(%rbp),%eax
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe79(%rip),%xmm0
subss  -0xc(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <logf@plt>
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
call   1040 <expf@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
call   1060 <isnan@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movss  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dnbinom_precalc_f>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm2,(%rsp)
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0xc(%rsp)
mov    %edi,%ebx
cvttss2si %xmm1,%edi
call   1030 <logf@plt>
mov    %ebx,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0xe83(%rip),%xmm0
subss  0x8(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <logf@plt>
mulss  0xc(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
addss  (%rsp),%xmm1
addss  %xmm1,%xmm0
call   1040 <expf@plt>
movss  %xmm0,(%rsp)
call   1060 <isnan@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
movss  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @dnbinom_precalc_f(i32 %0, float %1, float %2, float %3) {
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store i32 %0, i32* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%13 = load float, float* %8
store float %13, float* %9
%14 = load float, float* %7
%15 = fptosi float %14 to i32
%16 = call float @logf(i32 %15)
%17 = load i32, i32* %5
%18 = uitofp i32 %17 to float
%19 = fmul float %16, %18
store float %19, float* %10
%20 = load float, float* %7
%21 = fsub float 1.000000e+00, %20
%22 = fptosi float %21 to i32
%23 = call float @logf(i32 %22)
%24 = load float, float* %6
%25 = fmul float %23, %24
store float %25, float* %11
%26 = load float, float* %9
%27 = load float, float* %10
%28 = fadd float %26, %27
%29 = load float, float* %11
%30 = fadd float %28, %29
%31 = call float @expf(float %30)
store float %31, float* %12
%32 = load float, float* %12
%33 = call i32 @isnan(float %32)
%34 = icmp ne i32 %33, 0
%35 = xor i1 %34, true
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load float, float* %12
ret float %38
}

LLVM IR (-O2):
define float @dnbinom_precalc_f(i32 %0, float %1, float %2, float %3) {
%5 = fptosi float %2 to i32
%6 = tail call float @logf(i32 %5)
%7 = uitofp i32 %0 to float
%8 = fmul float %6, %7
%9 = fsub float 1.000000e+00, %2
%10 = fptosi float %9 to i32
%11 = tail call float @logf(i32 %10)
%12 = fmul float %11, %1
%13 = fadd float %8, %3
%14 = fadd float %13, %12
%15 = tail call float @expf(float %14)
%16 = tail call i32 @isnan(float %15)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
ret float %15
}