#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
void extractFunction() {
  int i, n, x, y, t;
  printf("Enter n: ");
  fflush(stdout);
  fscanf(stdin, " %d", &n);
  x = 0;
  y = 1;
  for (i = 0; i < n; i++) {
    t = x + y;
    x = y;
    y = t;
  }
  printf("%d-th fib == %d\n", n, x);
}


x86 assembly (clang, -O0):
<extractFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <fscanf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b1 <extractFunction+0x81>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1182 <extractFunction+0x52>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractFunction>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <fscanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11cd <extractFunction+0x9d>
lea    -0x1(%rsi),%ecx
mov    %esi,%eax
and    $0x7,%eax
cmp    $0x7,%ecx
jae    118b <extractFunction+0x5b>
xor    %ecx,%ecx
mov    $0x1,%edx
jmp    11b5 <extractFunction+0x85>
mov    %esi,%edi
and    $0xfffffff8,%edi
xor    %ecx,%ecx
mov    $0x1,%edx
nopw   0x0(%rax,%rax,1)
add    %edx,%ecx
add    %ecx,%edx
add    %edx,%ecx
add    %ecx,%edx
add    %edx,%ecx
add    %ecx,%edx
add    %edx,%ecx
add    %ecx,%edx
add    $0xfffffff8,%edi
jne    11a0 <extractFunction+0x70>
mov    %ecx,%ebx
test   %eax,%eax
je     11cd <extractFunction+0x9d>
nopl   0x0(%rax,%rax,1)
mov    %edx,%ebx
add    %edx,%ecx
mov    %ecx,%edx
mov    %ebx,%ecx
add    $0xffffffff,%eax
jne    11c0 <extractFunction+0x90>
lea    0xe3a(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"Enter n: \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [17 x i8] c"%d-th fib == %d\0A\00"
define void @extractFunction() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = tail call i32 @fflush(i32 %4)
%6 = load i32, i32* @stdin
%7 = call i32 @fscanf(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %42
10: ; preds = %0
%11 = add i32 %8, -1
%12 = and i32 %8, 7
%13 = icmp ult i32 %11, 7
br i1 %13, label %30, label %14
14: ; preds = %10
%15 = and i32 %8, -8
br label %16
16: ; preds = %16, %14
%17 = phi i32 [ 1, %14 ], [ %27, %16 ]
%18 = phi i32 [ 0, %14 ], [ %26, %16 ]
%19 = phi i32 [ 0, %14 ], [ %28, %16 ]
%20 = add nsw i32 %17, %18
%21 = add nsw i32 %20, %17
%22 = add nsw i32 %21, %20
%23 = add nsw i32 %22, %21
%24 = add nsw i32 %23, %22
%25 = add nsw i32 %24, %23
%26 = add nsw i32 %25, %24
%27 = add nsw i32 %26, %25
%28 = add i32 %19, 8
%29 = icmp eq i32 %28, %15
br i1 %29, label %30, label %16
30: ; preds = %16, %10
%31 = phi i32 [ undef, %10 ], [ %26, %16 ]
%32 = phi i32 [ 1, %10 ], [ %27, %16 ]
%33 = phi i32 [ 0, %10 ], [ %26, %16 ]
%34 = icmp eq i32 %12, 0
br i1 %34, label %42, label %35
35: ; preds = %30, %35
%36 = phi i32 [ %39, %35 ], [ %32, %30 ]
%37 = phi i32 [ %36, %35 ], [ %33, %30 ]
%38 = phi i32 [ %40, %35 ], [ 0, %30 ]
%39 = add nsw i32 %36, %37
%40 = add i32 %38, 1
%41 = icmp eq i32 %40, %12
br i1 %41, label %42, label %35
42: ; preds = %30, %35, %0
%43 = phi i32 [ 0, %0 ], [ %31, %30 ], [ %36, %35 ]
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %43)
ret void
}