#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*/ __fpurge(int /*<<< orphan*/);
int fat(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fibo(int);
int menu();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int sigma(int);
int /*<<< orphan*/ stdin;
main() {
  int opcao, num, result;
  char continuar;
  do {
    opcao = menu();
    printf("\n****************************");
    printf("\nEntre com numero:");
    scanf("%d", &num);
    switch (opcao) {
    case 1:
      fibo(num);
      break;
    case 2:
      result = fat(num);
      printf("\nFatorial de %d = %d", num, result);
      break;
    case 3:
      result = sigma(num);
      printf("\nSigma de %d = %d", num, result);
      break;
    }
    printf("\n***************************");
    printf("\nContinuar?(s/n) :");
    fflush(stdin);
    __fpurge(stdin);
    scanf("%c", &continuar);
  } while (continuar == 's' || continuar == 'S');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1050 <menu@plt>
mov    %eax,%ecx
mov    -0x19(%rbp),%al
mov    %ecx,-0x8(%rbp)
lea    0xe58(%rip),%rdi
call   1060 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe67(%rip),%rdi
call   1060 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe8f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     1205 <main+0x85>
jmp    11e3 <main+0x63>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1212 <main+0x92>
jmp    11f4 <main+0x74>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     1236 <main+0xb6>
jmp    1255 <main+0xd5>
mov    -0xc(%rbp),%edi
call   1090 <fibo@plt>
jmp    1255 <main+0xd5>
mov    -0xc(%rbp),%edi
call   10a0 <fat@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1255 <main+0xd5>
mov    -0xc(%rbp),%edi
call   1030 <sigma@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1040 <__fpurge@plt>
lea    0xdf4(%rip),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x73,%ecx
mov    %al,-0x1a(%rbp)
je     12be <main+0x13e>
movsbl -0x11(%rbp),%eax
cmp    $0x53,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    118f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xec6(%rip),%rbp
lea    0xedc(%rip),%r13
mov    0x2e48(%rip),%rbx
lea    0xee1(%rip),%r14
lea    0x3(%rsp),%r15
jmp    120b <main+0x8b>
xchg   %ax,%ax
mov    0x4(%rsp),%edi
call   10a0 <fat@plt>
mov    0x4(%rsp),%esi
lea    0xe6d(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    (%rbx),%edi
call   1040 <__fpurge@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
movzbl 0x3(%rsp),%eax
and    $0xdf,%al
cmp    $0x53,%al
jne    1289 <main+0x109>
xor    %eax,%eax
call   1050 <menu@plt>
mov    %eax,%r12d
lea    0xde4(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdf4(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe1d(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x3,%r12d
je     1270 <main+0xf0>
cmp    $0x2,%r12d
je     11b0 <main+0x30>
cmp    $0x1,%r12d
jne    11cd <main+0x4d>
mov    0x4(%rsp),%edi
call   1090 <fibo@plt>
jmp    11cd <main+0x4d>
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
call   1030 <sigma@plt>
mov    0x4(%rsp),%esi
lea    0xdc2(%rip),%rdi
jmp    11c4 <main+0x44>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0A****************************\00"
@.str.1 = [19 x i8] c"\0AEntre com numero:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"\0AFatorial de %d = %d\00"
@.str.4 = [18 x i8] c"\0ASigma de %d = %d\00"
@.str.5 = [29 x i8] c"\0A***************************\00"
@.str.6 = [19 x i8] c"\0AContinuar?(s/n) :\00"
@stdin = global i32 0
@.str.7 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
br label %6
6: ; preds = %43, %0
%7 = call i32 (...) @menu()
store i32 %7, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %2
switch i32 %11, label %27 [
i32 1, label %12
i32 2, label %15
i32 3, label %21
]
12: ; preds = %6
%13 = load i32, i32* %3
%14 = call i32 @fibo(i32 %13)
br label %27
15: ; preds = %6
%16 = load i32, i32* %3
%17 = call i32 @fat(i32 %16)
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 %19)
br label %27
21: ; preds = %6
%22 = load i32, i32* %3
%23 = call i32 @sigma(i32 %22)
store i32 %23, i32* %4
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %24, i32 %25)
br label %27
27: ; preds = %6, %21, %15, %12
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%30 = load i32, i32* @stdin
%31 = call i32 @fflush(i32 %30)
%32 = load i32, i32* @stdin
%33 = call i32 @__fpurge(i32 %32)
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %5)
br label %35
35: ; preds = %27
%36 = load i8, i8* %5
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 115
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = load i8, i8* %5
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 83
br label %43
43: ; preds = %39, %35
%44 = phi i1 [ true, %35 ], [ %42, %39 ]
br i1 %44, label %6, label %45
45: ; preds = %43
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"\0A****************************\00"
@.str.1 = [19 x i8] c"\0AEntre com numero:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"\0AFatorial de %d = %d\00"
@.str.4 = [18 x i8] c"\0ASigma de %d = %d\00"
@.str.5 = [29 x i8] c"\0A***************************\00"
@.str.6 = [19 x i8] c"\0AContinuar?(s/n) :\00"
@stdin = global i32 0
@.str.7 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
br label %4
4: ; preds = %22, %0
%5 = call i32 (...) @menu()
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
switch i32 %5, label %22 [
i32 1, label %9
i32 2, label %12
i32 3, label %17
]
9: ; preds = %4
%10 = load i32, i32* %1
%11 = call i32 @fibo(i32 %10)
br label %22
12: ; preds = %4
%13 = load i32, i32* %1
%14 = call i32 @fat(i32 %13)
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %14)
br label %22
17: ; preds = %4
%18 = load i32, i32* %1
%19 = call i32 @sigma(i32 %18)
%20 = load i32, i32* %1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %20, i32 %19)
br label %22
22: ; preds = %4, %17, %12, %9
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* @stdin
%26 = call i32 @fflush(i32 %25)
%27 = load i32, i32* @stdin
%28 = call i32 @__fpurge(i32 %27)
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%30 = load i8, i8* %2
%31 = and i8 %30, -33
%32 = icmp eq i8 %31, 83
br i1 %32, label %4, label %33
33: ; preds = %22
ret i32 0
}