#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int num1, num2, escolha, calculator = 1;
  printf("Bem Vindo a Calculator2000, uma calculadora basica mas eficiente.\n");
  printf("Voce deseja:\n");
  printf("(1)...Divisao\n(2)...Resto da "
         "Divisao\n(3)...Adicao\n(4)...Multiplicacao\n(5)...Sair\n\n");
  do {
    scanf("%d", &escolha);
    switch (escolha) {
    case 1: {
      printf("Digite os valores desejados para a Divisao: \n");
      scanf("%d %d", &num1, &num2);
      printf("Resultado: %d\n", num1 / num2);
      break;
    }
    case 2: {
      printf("Digite os valores desejados para o Resto da Divisao: \n");
      scanf("%d %d", &num1, &num2);
      printf("Resultado: %d\n", num1 % num2);
      break;
    }
    case 3: {
      printf("Digite os valores desejados para a Adicao: \n");
      scanf("%d %d", &num1, &num2);
      printf("Resultado: %d\n", num1 + num2);
      break;
    }
    case 4: {
      printf("Digite os valores desejados para a Multiplicacao: \n");
      scanf("%d %d", &num1, &num2);
      printf("Resultado: %d\n", num1 * num2);
      break;
    }
    case 5: {
      calculator = 0;
      break;
    }
    }
  } while (calculator != 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf82(%rip),%rdi
xor    %eax,%eax
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     129d <main+0x17d>
mov    -0x20(%rbp),%rax
lea    0xe6e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf36(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xf1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129d <main+0x17d>
lea    0xf19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129d <main+0x17d>
lea    0xf10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129d <main+0x17d>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129d <main+0x17d>
movl   $0x0,-0x14(%rbp)
jmp    12a2 <main+0x182>
cmpl   $0x0,-0x14(%rbp)
jne    1160 <main+0x40>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
lea    0xeae(%rip),%r14
lea    0x14(%rsp),%rbx
lea    0xe8b(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbp
lea    0xe94(%rip),%r15
jmp    11bd <main+0x8d>
lea    0xfd0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe79(%rip),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
cltd
idivl  0xc(%rsp)
mov    %eax,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11bd <main+0x8d>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xf43(%rip),%rdi
call   1030 <puts@plt>
lea    0xe22(%rip),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
cltd
idivl  0xc(%rsp)
mov    %edx,%esi
jmp    11b3 <main+0x83>
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf5(%rip),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
add    0x10(%rsp),%esi
jmp    11b3 <main+0x83>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
lea    0xdc8(%rip),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
imul   0x10(%rsp),%esi
jmp    11b3 <main+0x83>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"Bem Vindo a Calculator2000, uma calculadora basica mas eficiente.\0A\00"
@.str.1 = [14 x i8] c"Voce deseja:\0A\00"
@.str.2 = [83 x i8] c"(1)...Divisao\0A(2)...Resto da Divisao\0A(3)...Adicao\0A(4)...Multiplicacao\0A(5)...Sair\0A\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [46 x i8] c"Digite os valores desejados para a Divisao: \0A\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [15 x i8] c"Resultado: %d\0A\00"
@.str.7 = [55 x i8] c"Digite os valores desejados para o Resto da Divisao: \0A\00"
@.str.8 = [45 x i8] c"Digite os valores desejados para a Adicao: \0A\00"
@.str.9 = [52 x i8] c"Digite os valores desejados para a Multiplicacao: \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %42, %0
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%11 = load i32, i32* %4
switch i32 %11, label %41 [
i32 1, label %12
i32 2, label %19
i32 3, label %26
i32 4, label %33
i32 5, label %40
]
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %2, i32* %3)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = sdiv i32 %15, %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %17)
br label %41
19: ; preds = %9
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %2, i32* %3)
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = srem i32 %22, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %24)
br label %41
26: ; preds = %9
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %2, i32* %3)
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = add nsw i32 %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %31)
br label %41
33: ; preds = %9
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %2, i32* %3)
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = mul nsw i32 %36, %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %38)
br label %41
40: ; preds = %9
store i32 0, i32* %5
br label %41
41: ; preds = %9, %40, %33, %26, %19, %12
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = icmp ne i32 %43, 0
br i1 %44, label %9, label %45
45: ; preds = %42
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [15 x i8] c"Resultado: %d\0A\00"
@str = [66 x i8] c"Bem Vindo a Calculator2000, uma calculadora basica mas eficiente.\00"
@str.10 = [13 x i8] c"Voce deseja:\00"
@str.11 = [82 x i8] c"(1)...Divisao\0A(2)...Resto da Divisao\0A(3)...Adicao\0A(4)...Multiplicacao\0A(5)...Sair\0A\00"
@str.12 = [51 x i8] c"Digite os valores desejados para a Multiplicacao: \00"
@str.13 = [44 x i8] c"Digite os valores desejados para a Adicao: \00"
@str.14 = [54 x i8] c"Digite os valores desejados para o Resto da Divisao: \00"
@str.15 = [45 x i8] c"Digite os valores desejados para a Divisao: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.11, i64 0, i64 0))
br label %10
10: ; preds = %22, %0
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
switch i32 %12, label %22 [
i32 1, label %13
i32 2, label %23
i32 3, label %29
i32 4, label %35
i32 5, label %41
]
13: ; preds = %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.15, i64 0, i64 0))
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = sdiv i32 %16, %17
br label %19
19: ; preds = %35, %29, %23, %13
%20 = phi i32 [ %18, %13 ], [ %28, %23 ], [ %34, %29 ], [ %40, %35 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %10
br label %10
23: ; preds = %10
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.14, i64 0, i64 0))
%25 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = srem i32 %26, %27
br label %19
29: ; preds = %10
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.13, i64 0, i64 0))
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%32 = load i32, i32* %1
%33 = load i32, i32* %2
%34 = add nsw i32 %33, %32
br label %19
35: ; preds = %10
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.12, i64 0, i64 0))
%37 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%38 = load i32, i32* %1
%39 = load i32, i32* %2
%40 = mul nsw i32 %39, %38
br label %19
41: ; preds = %10
ret i32 0
}