#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*/ IniciaCronometro();
unsigned long Soma(int);
unsigned long SomaRecursao(int);
int /*<<< orphan*/ TerminaCronometro();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int numero = 0;
  printf("Digite um numero entre 1 e %d:", 100000);
  scanf("%d", &numero);
  if (numero < 1 || numero > 100000) {
    printf("Numero invalido!\n");
    return 0;
  }
  unsigned long resultado;
  IniciaCronometro();
  resultado = Soma(numero);
  TerminaCronometro();
  printf("Soma Simples: %lu\n", resultado);
  IniciaCronometro();
  resultado = SomaRecursao(numero);
  TerminaCronometro();
  printf("Soma por Recursão: %lu\n", resultado);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x186a0,%esi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     11b0 <main+0x50>
cmpl   $0x186a0,-0x8(%rbp)
jle    11ca <main+0x6a>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1229 <main+0xc9>
mov    $0x0,%al
call   1030 <IniciaCronometro@plt>
mov    -0x8(%rbp),%edi
call   1060 <Soma@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <TerminaCronometro@plt>
mov    -0x10(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <IniciaCronometro@plt>
mov    -0x8(%rbp),%edi
call   1040 <SomaRecursao@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <TerminaCronometro@plt>
mov    -0x10(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe7c(%rip),%rdi
mov    $0x186a0,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe88(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    $0xfffe795f,%eax
add    0xc(%rsp),%eax
cmp    $0xfffe795f,%eax
ja     11bf <main+0x4f>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
jmp    1215 <main+0xa5>
xor    %eax,%eax
call   1040 <IniciaCronometro@plt>
mov    0xc(%rsp),%edi
call   1070 <Soma@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1090 <TerminaCronometro@plt>
lea    0xe42(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1040 <IniciaCronometro@plt>
mov    0xc(%rsp),%edi
call   1050 <SomaRecursao@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1090 <TerminaCronometro@plt>
lea    0xe2a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Digite um numero entre 1 e %d:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Numero invalido!\0A\00"
@.str.3 = [19 x i8] c"Soma Simples: %lu\0A\00"
@.str.4 = [25 x i8] c"Soma por Recurs\C3\A3o: %lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 100000)
%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, 1
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 100000
br i1 %10, label %11, label %13
11: ; preds = %8, %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %26
13: ; preds = %8
%14 = call i32 (...) @IniciaCronometro()
%15 = load i32, i32* %2
%16 = call i64 @Soma(i32 %15)
store i64 %16, i64* %3
%17 = call i32 (...) @TerminaCronometro()
%18 = load i64, i64* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %18)
%20 = call i32 (...) @IniciaCronometro()
%21 = load i32, i32* %2
%22 = call i64 @SomaRecursao(i32 %21)
store i64 %22, i64* %3
%23 = call i32 (...) @TerminaCronometro()
%24 = load i64, i64* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 %24)
store i32 0, i32* %1
br label %26
26: ; preds = %13, %11
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [31 x i8] c"Digite um numero entre 1 e %d:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"Soma Simples: %lu\0A\00"
@.str.4 = [25 x i8] c"Soma por Recurs\C3\A3o: %lu\0A\00"
@str = [17 x i8] c"Numero invalido!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 100000)
%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 = add i32 %5, -100001
%7 = icmp ult i32 %6, -100000
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %21
10: ; preds = %0
%11 = call i32 (...) @IniciaCronometro()
%12 = load i32, i32* %1
%13 = call i64 @Soma(i32 %12)
%14 = call i32 (...) @TerminaCronometro()
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %13)
%16 = call i32 (...) @IniciaCronometro()
%17 = load i32, i32* %1
%18 = call i64 @SomaRecursao(i32 %17)
%19 = call i32 (...) @TerminaCronometro()
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 %18)
br label %21
21: ; preds = %10, %8
ret i32 0
}