#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 *, int);
int strlen(char *);
int fib(int x) {
  int z;
  if (x > 1) {
    x = fib(x - 1);
    z = fib(x - 1);
    printf("%d", x + z);
    return x;
  } else {
    if (x == 1)
      return strlen("x");
    else
      return (x);
  }
}


x86 assembly (clang, -O0):
<fib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    117e <fib+0x4e>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1050 <fib@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1050 <fib@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <fib+0x72>
cmpl   $0x1,-0x8(%rbp)
jne    119c <fib+0x6c>
lea    0xe74(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4(%rbp)
jmp    11a2 <fib+0x72>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib>:
push   %rbx
mov    %edi,%ebx
cmp    $0x1,%edi
jle    115e <fib+0x2e>
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1050 <fib@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%edi
call   1050 <fib@plt>
mov    %ebx,%esi
add    %eax,%esi
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
jmp    116d <fib+0x3d>
jne    116d <fib+0x3d>
lea    0xe9c(%rip),%rdi
pop    %rbx
jmp    1030 <strlen@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"x\00"
define i32 @fib(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
%10 = call i32 @fib(i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 1
%13 = call i32 @fib(i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = add nsw i32 %14, %15
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
store i32 %18, i32* %2
br label %26
19: ; preds = %1
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 %23, i32* %2
br label %26
24: ; preds = %19
%25 = load i32, i32* %3
store i32 %25, i32* %2
br label %26
26: ; preds = %24, %22, %7
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"x\00"
define i32 @fib(i32 %0) {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %5, label %12
3: ; preds = %14, %12, %5
%4 = phi i32 [ %7, %5 ], [ %15, %14 ], [ %0, %12 ]
ret i32 %4
5: ; preds = %1
%6 = add nsw i32 %0, -1
%7 = tail call i32 @fib(i32 %6)
%8 = add nsw i32 %7, -1
%9 = tail call i32 @fib(i32 %8)
%10 = add nsw i32 %9, %7
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %3
12: ; preds = %1
%13 = icmp eq i32 %0, 1
br i1 %13, label %14, label %3
14: ; preds = %12
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %3
}