#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*/ printf(char *, unsigned long long, int);
unsigned long long int factoriel(int n) {
  if (n <= 1) {
    return 1;
  } else {
    unsigned long long int temp = 0;
    printf("Avant fact: temp=%llu, n=%i\n", temp, n);
    temp = factoriel(n - 1) * n;
    printf("Après fact: temp=%llu, n=%i\n", temp, n);
    return temp;
  }
}


x86 assembly (clang, -O0):
<factoriel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jg     1142 <factoriel+0x22>
movq   $0x1,-0x8(%rbp)
jmp    118f <factoriel+0x6f>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
call   1040 <factoriel@plt>
movslq -0xc(%rbp),%rcx
imul   %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factoriel>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
cmp    $0x1,%edi
jle    1164 <factoriel+0x44>
mov    %edi,%r14d
lea    0xec8(%rip),%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1030 <printf@plt>
lea    -0x1(%r14),%edi
call   1040 <factoriel@plt>
mov    %r14d,%ebx
imul   %rax,%rbx
lea    0xec4(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <printf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Avant fact: temp=%llu, n=%i\0A\00"
@.str.1 = [30 x i8] c"Apr\C3\A8s fact: temp=%llu, n=%i\0A\00"
define i64 @factoriel(i32 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 1
br i1 %6, label %7, label %8
7: ; preds = %1
store i64 1, i64* %2
br label %22
8: ; preds = %1
store i64 0, i64* %4
%9 = load i64, i64* %4
%10 = load i32, i32* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %9, i32 %10)
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = call i64 @factoriel(i32 %13)
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = mul i64 %14, %16
store i64 %17, i64* %4
%18 = load i64, i64* %4
%19 = load i32, i32* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i64 %18, i32 %19)
%21 = load i64, i64* %4
store i64 %21, i64* %2
br label %22
22: ; preds = %8, %7
%23 = load i64, i64* %2
ret i64 %23
}

LLVM IR (-O2):
@.str = [29 x i8] c"Avant fact: temp=%llu, n=%i\0A\00"
@.str.1 = [30 x i8] c"Apr\C3\A8s fact: temp=%llu, n=%i\0A\00"
define i64 @factoriel(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %3, label %5
3: ; preds = %1, %5
%4 = phi i64 [ %10, %5 ], [ 1, %1 ]
ret i64 %4
5: ; preds = %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 0, i32 %0)
%7 = add nsw i32 %0, -1
%8 = tail call i64 @factoriel(i32 %7)
%9 = zext i32 %0 to i64
%10 = mul i64 %8, %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i64 %10, i32 %0)
br label %3
}