#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
unsigned long factorielle(unsigned long n, unsigned long accu) {
  if (n < 0)
    exit(EXIT_FAILURE);
  if (n == 1)
    return accu;
  else if (n == 0)
    return 1;
  if (accu == 0)
    accu = 1;
  return factorielle(n - 1, n * accu);
}


x86 assembly (clang, -O0):
<factorielle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jae    1149 <factorielle+0x29>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
call   1030 <exit@plt>
cmpq   $0x1,-0x10(%rbp)
jne    1161 <factorielle+0x41>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <factorielle+0x8b>
cmpq   $0x0,-0x10(%rbp)
jne    1179 <factorielle+0x59>
movq   $0x1,-0x8(%rbp)
jmp    11ab <factorielle+0x8b>
jmp    117e <factorielle+0x5e>
cmpq   $0x0,-0x18(%rbp)
jne    1191 <factorielle+0x71>
movq   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
mov    -0x10(%rbp),%rsi
imul   -0x18(%rbp),%rsi
call   1040 <factorielle@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factorielle>:
mov    %rsi,%rax
mov    $0x1,%ecx
test   %rdi,%rdi
je     112a <factorielle+0x2a>
nopl   (%rax)
cmp    $0x1,%rdi
je     112f <factorielle+0x2f>
test   %rax,%rax
cmove  %rcx,%rax
imul   %rdi,%rax
add    $0xffffffffffffffff,%rdi
test   %rdi,%rdi
jne    1110 <factorielle+0x10>
mov    $0x1,%eax
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define i64 @factorielle(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
%6 = load i64, i64* %4
%7 = icmp ult i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = load i64, i64* %4
%13 = icmp eq i64 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = load i64, i64* %5
store i64 %15, i64* %3
br label %32
16: ; preds = %11
%17 = load i64, i64* %4
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store i64 1, i64* %3
br label %32
20: ; preds = %16
br label %21
21: ; preds = %20
%22 = load i64, i64* %5
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i64 1, i64* %5
br label %25
25: ; preds = %24, %21
%26 = load i64, i64* %4
%27 = sub i64 %26, 1
%28 = load i64, i64* %4
%29 = load i64, i64* %5
%30 = mul i64 %28, %29
%31 = call i64 @factorielle(i64 %27, i64 %30)
store i64 %31, i64* %3
br label %32
32: ; preds = %25, %19, %14
%33 = load i64, i64* %3
ret i64 %33
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
define i64 @factorielle(i64 %0, i64 %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i64 [ %0, %2 ], [ %9, %6 ]
%5 = phi i64 [ %1, %2 ], [ %10, %6 ]
switch i64 %4, label %6 [
i64 1, label %11
i64 0, label %12
]
6: ; preds = %3
%7 = icmp eq i64 %5, 0
%8 = select i1 %7, i64 1, i64 %5
%9 = add i64 %4, -1
%10 = mul i64 %8, %4
br label %3
11: ; preds = %3
br label %12
12: ; preds = %3, %11
%13 = phi i64 [ %5, %11 ], [ 1, %3 ]
ret i64 %13
}