#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 iterative(int);
int /*<<< orphan*/ printf(char *, ...);
int recursive(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  while (1) {
    printf("Please enter a number bigger than 0. enter '-1' to end program\n");
    scanf("%d", &n);
    if (n == -1)
      break;
    if (n >= 13) {
      printf("overflow\n");
      continue;
    }
    int ans_i = iterative(n);
    printf("Iterative : %d\n", ans_i);
    int ans_r = recursive(n);
    printf("Recursive : %d\n", ans_r);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    117c <main+0x3c>
jmp    11d6 <main+0x96>
cmpl   $0xd,-0x8(%rbp)
jl     1199 <main+0x59>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114f <main+0xf>
mov    -0x8(%rbp),%edi
call   1060 <iterative@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <recursive@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
cmp    $0xffffffff,%edi
je     1201 <main+0xb1>
lea    0xed6(%rip),%r14
lea    0xe90(%rip),%r15
lea    0xe66(%rip),%r12
lea    0x4(%rsp),%rbx
lea    0xe5d(%rip),%r13
lea    0xe66(%rip),%rbp
jmp    11d4 <main+0x84>
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
cmp    $0xffffffff,%edi
je     1201 <main+0xb1>
cmp    $0xd,%edi
jge    11b0 <main+0x60>
call   1070 <iterative@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
call   1060 <recursive@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b8 <main+0x68>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Please enter a number bigger than 0. enter '-1' to end program\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"overflow\0A\00"
@.str.3 = [16 x i8] c"Iterative : %d\0A\00"
@.str.4 = [16 x i8] c"Recursive : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %0, %14, %16
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %5
br label %25
11: ; preds = %5
%12 = load i32, i32* %2
%13 = icmp sge i32 %12, 13
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %5
16: ; preds = %11
%17 = load i32, i32* %2
%18 = call i32 @iterative(i32 %17)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %2
%22 = call i32 @recursive(i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %23)
br label %5
25: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [16 x i8] c"Iterative : %d\0A\00"
@.str.4 = [16 x i8] c"Recursive : %d\0A\00"
@str = [63 x i8] c"Please enter a number bigger than 0. enter '-1' to end program\00"
@str.5 = [9 x i8] c"overflow\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, -1
br i1 %6, label %23, label %7
7: ; preds = %0, %12
%8 = phi i32 [ %15, %12 ], [ %5, %0 ]
%9 = icmp sgt i32 %8, 12
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0))
br label %12
12: ; preds = %10, %17
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, -1
br i1 %16, label %23, label %7
17: ; preds = %7
%18 = call i32 @iterative(i32 %8)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %1
%21 = call i32 @recursive(i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %12
23: ; preds = %12, %0
ret i32 0
}