#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*/ EDOM;
int /*<<< orphan*/ errno;
long double CalculateFactorial(long double num) {
  if (num < 0.0L) {
    errno = EDOM;
    return 0.0;
  }
  if (num <= 1.0L) {
    return 1.0L;
  }
  return num * CalculateFactorial(num - 1.0L);
}


x86 assembly (clang, -O0):
<CalculateFactorial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    114e <CalculateFactorial+0x3e>
jmp    1132 <CalculateFactorial+0x22>
mov    0x2eaf(%rip),%rax
mov    (%rax),%ecx
mov    0x2e96(%rip),%rax
mov    %ecx,(%rax)
fldz
fstpt  -0x10(%rbp)
jmp    118c <CalculateFactorial+0x7c>
fldt   -0x20(%rbp)
fld1
fucomip %st(1),%st
fstp   %st(0)
jb     116c <CalculateFactorial+0x5c>
jmp    1162 <CalculateFactorial+0x52>
fld1
fstpt  -0x10(%rbp)
jmp    118c <CalculateFactorial+0x7c>
fldt   -0x20(%rbp)
fld    %st(0)
fstpt  -0x2c(%rbp)
fld1
fchs
faddp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <CalculateFactorial@plt>
fldt   -0x2c(%rbp)
fmulp  %st,%st(1)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateFactorial>:
sub    $0x28,%rsp
fldt   0x30(%rsp)
fldz
fucomi %st(1),%st
jbe    1134 <CalculateFactorial+0x24>
fstp   %st(1)
mov    0x2ec1(%rip),%rax
mov    (%rax),%eax
mov    0x2ea8(%rip),%rcx
mov    %eax,(%rcx)
jmp    1158 <CalculateFactorial+0x48>
fstp   %st(0)
fld1
fucomi %st(1),%st
fxch   %st(1)
jae    115a <CalculateFactorial+0x4a>
fstp   %st(1)
fld1
fchs
fadd   %st(1),%st
fstpt  (%rsp)
fstpt  0x1c(%rsp)
call   1030 <CalculateFactorial@plt>
fldt   0x1c(%rsp)
fmulp  %st,%st(1)
fldz
fstp   %st(0)
add    $0x28,%rsp
ret

LLVM IR (-O0):
@EDOM = global i32 0
@errno = global i32 0
define x86_fp80 @CalculateFactorial(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %3
%4 = load x86_fp80, x86_fp80* %3
%5 = fcmp olt x86_fp80 %4, 0xK00000000000000000000
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i32, i32* @EDOM
store i32 %7, i32* @errno
store x86_fp80 0xK00000000000000000000, x86_fp80* %2
br label %18
8: ; preds = %1
%9 = load x86_fp80, x86_fp80* %3
%10 = fcmp ole x86_fp80 %9, 0xK3FFF8000000000000000
br i1 %10, label %11, label %12
11: ; preds = %8
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %2
br label %18
12: ; preds = %8
%13 = load x86_fp80, x86_fp80* %3
%14 = load x86_fp80, x86_fp80* %3
%15 = fsub x86_fp80 %14, 0xK3FFF8000000000000000
%16 = call x86_fp80 @CalculateFactorial(x86_fp80 %15)
%17 = fmul x86_fp80 %13, %16
store x86_fp80 %17, x86_fp80* %2
br label %18
18: ; preds = %12, %11, %6
%19 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %19
}

LLVM IR (-O2):
@EDOM = global i32 0
@errno = global i32 0
define x86_fp80 @CalculateFactorial(x86_fp80 %0) {
%2 = fcmp olt x86_fp80 %0, 0xK00000000000000000000
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = load i32, i32* @EDOM
store i32 %4, i32* @errno
br label %7
5: ; preds = %1
%6 = fcmp ugt x86_fp80 %0, 0xK3FFF8000000000000000
br i1 %6, label %9, label %7
7: ; preds = %3, %5, %9
%8 = phi x86_fp80 [ %12, %9 ], [ 0xK00000000000000000000, %3 ], [ 0xK3FFF8000000000000000, %5 ]
ret x86_fp80 %8
9: ; preds = %5
%10 = fadd x86_fp80 %0, 0xKBFFF8000000000000000
%11 = tail call x86_fp80 @CalculateFactorial(x86_fp80 %10)
%12 = fmul x86_fp80 %11, %0
br label %7
}