#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 */
typedef int uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ startFibonacci(int, int);
int main() {
  int type;
  printf("Pretende usar numero maximo de valores(1) ou valor maximo(2)? ");
  scanf("%d", &type);
  uint64_t until;
  if (type == 1) {
    printf("Introduza um numero de valores da sequência: ");
    scanf("%lu", &until);
  } else {
    printf("Introduza o valor máximo: ");
    scanf("%lu", &until);
  }
  startFibonacci(type, until);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1186 <main+0x56>
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
jmp    11a2 <main+0x72>
lea    0xee8(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <startFibonacci@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmpl   $0x1,(%rsp)
lea    0xeeb(%rip),%rax
lea    0xf17(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%esi
call   1040 <startFibonacci@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [63 x i8] c"Pretende usar numero maximo de valores(1) ou valor maximo(2)? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [47 x i8] c"Introduza um numero de valores da sequ\C3\AAncia: \00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [28 x i8] c"Introduza o valor m\C3\A1ximo: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 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 eq i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %3)
br label %14
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %3)
br label %14
14: ; preds = %11, %8
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @startFibonacci(i32 %15, i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [63 x i8] c"Pretende usar numero maximo de valores(1) ou valor maximo(2)? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [47 x i8] c"Introduza um numero de valores da sequ\C3\AAncia: \00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [28 x i8] c"Introduza o valor m\C3\A1ximo: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 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* %1)
%6 = bitcast i32* %2 to i8*
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0)
%10 = call i32 @printf(i8* dereferenceable(1) %9)
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = call i32 @startFibonacci(i32 %12, i32 %13)
ret i32 0
}