#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 fib(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int ej14() {
  int m, i;
  printf("Ingrese el término hasta el cual quiere saber la sucesión de "
         "Fibonacci (el primer término es el término 0)\n");
  scanf("%d", &m);
  if (m < 0) {
    printf("Ingrese un valor mayor o igual a 0\n");
    return 0;
  }
  printf("La sucesión hasta el término %d es:\n", m);
  for (i = 0; i <= m; i++) {
    printf("%d ", fib(i));
    if (i == (m)) {
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<ej14>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf23(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    117a <ej14+0x4a>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <ej14+0xba>
mov    -0x8(%rbp),%esi
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11e3 <ej14+0xb3>
mov    -0xc(%rbp),%edi
call   1050 <fib@plt>
mov    %eax,%esi
lea    0xf0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11d0 <ej14+0xa0>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <ej14+0xa5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <ej14+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ej14>:
push   %r14
push   %rbx
push   %rax
lea    0xed3(%rip),%rdi
call   1040 <puts@plt>
lea    0xe99(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
js     11d2 <ej14+0x82>
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
js     11de <ej14+0x8e>
mov    $0xffffffff,%ebx
lea    0xe90(%rip),%r14
jmp    11a4 <ej14+0x54>
nopl   0x0(%rax)
cmp    %eax,%ebx
jge    11de <ej14+0x8e>
add    $0x1,%ebx
mov    %ebx,%edi
call   1070 <fib@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
jne    11a0 <ej14+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
jmp    11a0 <ej14+0x50>
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [112 x i8] c"Ingrese el t\C3\A9rmino hasta el cual quiere saber la sucesi\C3\B3n de Fibonacci (el primer t\C3\A9rmino es el t\C3\A9rmino 0)\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"Ingrese un valor mayor o igual a 0\0A\00"
@.str.3 = [39 x i8] c"La sucesi\C3\B3n hasta el t\C3\A9rmino %d es:\0A\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @ej14() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %31
10: ; preds = %0
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %11)
store i32 0, i32* %3
br label %13
13: ; preds = %27, %10
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i32, i32* %3
%19 = call i32 @fib(i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %24, %17
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %13
30: ; preds = %13
store i32 0, i32* %1
br label %31
31: ; preds = %30, %8
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [39 x i8] c"La sucesi\C3\B3n hasta el t\C3\A9rmino %d es:\0A\00"
@.str.4 = [4 x i8] c"%d \00"
@str = [111 x i8] c"Ingrese el t\C3\A9rmino hasta el cual quiere saber la sucesi\C3\B3n de Fibonacci (el primer t\C3\A9rmino es el t\C3\A9rmino 0)\00"
@str.6 = [35 x i8] c"Ingrese un valor mayor o igual a 0\00"
define i32 @ej14() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([111 x i8], [111 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 slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.6, i64 0, i64 0))
br label %26
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %9, %22
%14 = phi i32 [ %24, %22 ], [ 0, %9 ]
%15 = call i32 @fib(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %1
%18 = icmp eq i32 %14, %17
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = call i32 @putchar(i32 10)
%21 = load i32, i32* %1
br label %22
22: ; preds = %13, %19
%23 = phi i32 [ %17, %13 ], [ %21, %19 ]
%24 = add nuw nsw i32 %14, 1
%25 = icmp slt i32 %14, %23
br i1 %25, label %13, label %26
26: ; preds = %22, %9, %7
ret i32 0
}