#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*/ error(char *);
int log10(int);
double NFAc(int n, double k, double logNT) {
  if (n < 0)
    error("NFAc: 'n' must be strictly positive.");
  if (n == 0)
    return -logNT;
  double logNFAC = logNT;
  k = (((k) > (0.01)) ? (k) : (0.01));
  logNFAC = logNT + n * log10(k) - 0.39908993418 - (n + 0.5) * log10(n) +
            n * 0.43429448190;
  return -logNFAC;
}


x86 assembly (clang, -O0):
<NFAc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    114b <NFAc+0x2b>
lea    0xeda(%rip),%rdi
call   1030 <error@plt>
cmpl   $0x0,-0xc(%rbp)
jne    117b <NFAc+0x5b>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <NFAc+0x16d>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe6e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ab <NFAc+0x8b>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11bd <NFAc+0x9d>
movsd  0xe4d(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11bd <NFAc+0x9d>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x44(%rbp)
cvttsd2si -0x18(%rbp),%edi
call   1040 <log10@plt>
movsd  -0x50(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe1a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xdfc(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <log10@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xda9(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NFAc>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
test   %edi,%edi
movapd %xmm1,0x10(%rsp)
js     113e <NFAc+0x1e>
jne    1156 <NFAc+0x36>
movapd 0x10(%rsp),%xmm0
jmp    11d4 <NFAc+0xb4>
lea    0xeeb(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
call   1030 <error@plt>
movsd  0x8(%rsp),%xmm0
maxsd  0xea2(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log10@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x10(%rsp),%xmm0
addsd  0xe89(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  0xe76(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%rsp)
mov    %ebx,%edi
call   1040 <log10@plt>
movapd 0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x28(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm1,%xmm2
mulsd  0xe48(%rip),%xmm0
addsd  %xmm2,%xmm0
xorpd  0xe44(%rip),%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"NFAc: 'n' must be strictly positive.\00"
define double @NFAc(i32 %0, double %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %5
store double %1, double* %6
store double %2, double* %7
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %3
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load double, double* %7
%18 = fneg double %17
store double %18, double* %4
br label %50
19: ; preds = %13
%20 = load double, double* %7
store double %20, double* %8
%21 = load double, double* %6
%22 = fcmp ogt double %21, 1.000000e-02
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = load double, double* %6
br label %26
25: ; preds = %19
br label %26
26: ; preds = %25, %23
%27 = phi double [ %24, %23 ], [ 1.000000e-02, %25 ]
store double %27, double* %6
%28 = load double, double* %7
%29 = load i32, i32* %5
%30 = load double, double* %6
%31 = fptosi double %30 to i32
%32 = call i32 @log10(i32 %31)
%33 = mul nsw i32 %29, %32
%34 = sitofp i32 %33 to double
%35 = fadd double %28, %34
%36 = fsub double %35, 0x3FD98AB081DDD12F
%37 = load i32, i32* %5
%38 = sitofp i32 %37 to double
%39 = fadd double %38, 5.000000e-01
%40 = load i32, i32* %5
%41 = call i32 @log10(i32 %40)
%42 = sitofp i32 %41 to double
%43 = fneg double %39
%44 = call double @llvm.fmuladd.f64(double %43, double %42, double %36)
%45 = load i32, i32* %5
%46 = sitofp i32 %45 to double
%47 = call double @llvm.fmuladd.f64(double %46, double 0x3FDBCB7B1526003A, double %44)
store double %47, double* %8
%48 = load double, double* %8
%49 = fneg double %48
store double %49, double* %4
br label %50
50: ; preds = %26, %16
%51 = load double, double* %4
ret double %51
}

LLVM IR (-O2):
@.str = [37 x i8] c"NFAc: 'n' must be strictly positive.\00"
define double @NFAc(i32 %0, double %1, double %2) {
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %3
%8 = icmp eq i32 %0, 0
br i1 %8, label %25, label %9
9: ; preds = %5, %7
%10 = fcmp ogt double %1, 1.000000e-02
%11 = select i1 %10, double %1, double 1.000000e-02
%12 = fptosi double %11 to i32
%13 = tail call i32 @log10(i32 %12)
%14 = mul nsw i32 %13, %0
%15 = sitofp i32 %14 to double
%16 = fadd double %15, %2
%17 = fadd double %16, 0xBFD98AB081DDD12F
%18 = sitofp i32 %0 to double
%19 = fadd double %18, 5.000000e-01
%20 = tail call i32 @log10(i32 %0)
%21 = sitofp i32 %20 to double
%22 = fneg double %19
%23 = tail call double @llvm.fmuladd.f64(double %22, double %21, double %17)
%24 = tail call double @llvm.fmuladd.f64(double %18, double 0x3FDBCB7B1526003A, double %23)
br label %25
25: ; preds = %7, %9
%26 = phi double [ %24, %9 ], [ %2, %7 ]
%27 = fneg double %26
ret double %27
}