#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(int);
int /*<<< orphan*/ printf(char *);
int eval_catalan(int n) {
  if (n < 0) {
    printf("Nombre négatif");
    exit(1);
  }
  if (n == 0)
    return 1;
  int nb_catalan = 0, k;
  for (k = 0; k <= n - 1; k++) {
    nb_catalan += eval_catalan(k) * eval_catalan((n - 1) - k);
  }
  return nb_catalan;
}


x86 assembly (clang, -O0):
<eval_catalan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    115b <eval_catalan+0x2b>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1171 <eval_catalan+0x41>
movl   $0x1,-0x4(%rbp)
jmp    11cb <eval_catalan+0x9b>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11c5 <eval_catalan+0x95>
mov    -0x10(%rbp),%edi
call   1040 <eval_catalan@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
sub    -0x10(%rbp),%edi
call   1040 <eval_catalan@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117f <eval_catalan+0x4f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_catalan>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
js     1186 <eval_catalan+0x56>
je     1172 <eval_catalan+0x42>
mov    %edi,%ebx
add    $0xffffffff,%ebx
xor    %ebp,%ebp
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1040 <eval_catalan@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   1040 <eval_catalan@plt>
imul   %r15d,%eax
add    %eax,%r14d
add    $0x1,%ebp
add    $0xffffffff,%ebx
jb     1150 <eval_catalan+0x20>
jmp    1178 <eval_catalan+0x48>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"Nombre n\C3\A9gatif\00"
define i32 @eval_catalan(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %2
br label %37
15: ; preds = %11
store i32 0, i32* %4
store i32 0, i32* %5
br label %16
16: ; preds = %32, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
%20 = icmp sle i32 %17, %19
br i1 %20, label %21, label %35
21: ; preds = %16
%22 = load i32, i32* %5
%23 = call i32 @eval_catalan(i32 %22)
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 1
%26 = load i32, i32* %5
%27 = sub nsw i32 %25, %26
%28 = call i32 @eval_catalan(i32 %27)
%29 = mul nsw i32 %23, %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, %29
store i32 %31, i32* %4
br label %32
32: ; preds = %21
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %16
35: ; preds = %16
%36 = load i32, i32* %4
store i32 %36, i32* %2
br label %37
37: ; preds = %35, %14
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [16 x i8] c"Nombre n\C3\A9gatif\00"
define i32 @eval_catalan(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %1
%7 = icmp eq i32 %0, 0
br i1 %7, label %19, label %8
8: ; preds = %6, %8
%9 = phi i32 [ %17, %8 ], [ 0, %6 ]
%10 = phi i32 [ %16, %8 ], [ 0, %6 ]
%11 = tail call i32 @eval_catalan(i32 %9)
%12 = xor i32 %9, -1
%13 = add i32 %12, %0
%14 = tail call i32 @eval_catalan(i32 %13)
%15 = mul nsw i32 %14, %11
%16 = add nsw i32 %15, %10
%17 = add nuw nsw i32 %9, 1
%18 = icmp eq i32 %17, %0
br i1 %18, label %19, label %8
19: ; preds = %8, %6
%20 = phi i32 [ 1, %6 ], [ %16, %8 ]
ret i32 %20
}