#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 f(int m) {
  if (m <= 0) {
    printf("Invalid Number %d. It must be positive.\n", m);
    return -1;
  }
  if (m == 1) {
    return 2;
  }
  if (m == 2) {
    return 3;
  }
  int a;
  int b;
  a = f(m - 1);
  b = f(m - 2);
  return (a + b);
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1150 <f+0x30>
mov    -0x8(%rbp),%esi
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a1 <f+0x81>
cmpl   $0x1,-0x8(%rbp)
jne    1166 <f+0x46>
movl   $0x2,-0x4(%rbp)
jmp    11a1 <f+0x81>
cmpl   $0x2,-0x8(%rbp)
jne    117c <f+0x5c>
movl   $0x3,-0x4(%rbp)
jmp    11a1 <f+0x81>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1030 <f@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
call   1030 <f@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
test   %edi,%edi
jle    114e <f+0x2e>
xor    %ebp,%ebp
cmp    $0x1,%ebx
je     1147 <f+0x27>
cmp    $0x2,%ebx
je     1165 <f+0x45>
lea    -0x1(%rbx),%edi
call   1030 <f@plt>
add    %eax,%ebp
add    $0xfffffffe,%ebx
cmp    $0x1,%ebx
jne    1130 <f+0x10>
mov    $0x2,%eax
jmp    116a <f+0x4a>
lea    0xeab(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
xor    %ebp,%ebp
jmp    116a <f+0x4a>
mov    $0x3,%eax
add    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Invalid Number %d. It must be positive.\0A\00"
define i32 @f(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 sle i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 -1, i32* %2
br label %29
11: ; preds = %1
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 2, i32* %2
br label %29
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 3, i32* %2
br label %29
19: ; preds = %15
%20 = load i32, i32* %3
%21 = sub nsw i32 %20, 1
%22 = call i32 @f(i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 2
%25 = call i32 @f(i32 %24)
store i32 %25, i32* %5
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = add nsw i32 %26, %27
store i32 %28, i32* %2
br label %29
29: ; preds = %19, %18, %14, %8
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@.str = [41 x i8] c"Invalid Number %d. It must be positive.\0A\00"
define i32 @f(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %14
5: ; preds = %1, %8
%6 = phi i32 [ %11, %8 ], [ %0, %1 ]
%7 = phi i32 [ %12, %8 ], [ 0, %1 ]
switch i32 %6, label %8 [
i32 1, label %13
i32 2, label %14
]
8: ; preds = %5
%9 = add nsw i32 %6, -1
%10 = tail call i32 @f(i32 %9)
%11 = add nsw i32 %6, -2
%12 = add nsw i32 %10, %7
br label %5
13: ; preds = %5
br label %14
14: ; preds = %5, %13, %3
%15 = phi i32 [ 0, %3 ], [ %7, %13 ], [ %7, %5 ]
%16 = phi i32 [ -1, %3 ], [ 2, %13 ], [ 3, %5 ]
%17 = add nsw i32 %16, %15
ret i32 %17
}