int main() {
  int s;
  printf("Cuantos numeros de fibonacci? ");
  scanf("%d", &s);
  for (int i = 0; i < s; i++)
    printf("%lu%s", fibonacci(i), (i == s - 1) ? "\n" : ", ");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b7 <main+0x87>
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1040 <fibonacci@plt>
mov    %eax,%esi
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
lea    0xe9c(%rip),%rdx
lea    0xe93(%rip),%rax
cmp    %edi,%ecx
cmove  %rax,%rdx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x36>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11ae <main+0x7e>
lea    0xec2(%rip),%r14
lea    0xebd(%rip),%r15
lea    0xeae(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fibonacci@plt>
mov    0x4(%rsp),%ecx
add    $0xffffffff,%ecx
cmp    %ecx,%ebp
mov    %r15,%rdx
cmove  %r14,%rdx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Cuantos numeros de fibonacci? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"%lu%s\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c", \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %23
10: ; preds = %6
%11 = load i32, i32* %3
%12 = call i32 (i32, ...) bitcast (i32 (...)* @fibonacci to i32 (i32, ...)*)(i32 %11)
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = sub nsw i32 %14, 1
%16 = icmp eq i32 %13, %15
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %12, i8* %18)
br label %20
20: ; preds = %10
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %6
23: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Cuantos numeros de fibonacci? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"%lu%s\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c", \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @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 sgt i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %8, %0
ret i32 0
8: ; preds = %0, %8
%9 = phi i32 [ %16, %8 ], [ 0, %0 ]
%10 = call i32 (i32, ...) bitcast (i32 (...)* @fibonacci to i32 (i32, ...)*)(i32 %9)
%11 = load i32, i32* %1
%12 = add nsw i32 %11, -1
%13 = icmp eq i32 %9, %12
%14 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %10, i8* %14)
%16 = add nuw nsw i32 %9, 1
%17 = load i32, i32* %1
%18 = icmp slt i32 %16, %17
br i1 %18, label %8, label %7
}