#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 nro1, nro2, escolha, calc = 1;
  printf("Entre com a operacao desejada\n");
  printf("1-Divisao\n2-Resto da Divisao\n3-Adicao\n4-Multiplicacao\n5-Sair\n");
  do {
    scanf("%d", &escolha);
    switch (escolha) {
    case 1: {
      printf("Digite os valores desejados para a Divisao:");
      scanf("%d %d", &nro1, &nro2);
      printf("Resultado: %d\n", nro1 / nro2);
      break;
    }
    case 2: {
      printf("Digite os valores desejados para o Resto da Divisao: \n");
      scanf("%d %d", &nro1, &nro2);
      printf("Resultado: %d\n", nro1 % nro2);
      break;
    }
    case 3: {
      printf("Digite os valores desejados para a Adicao: \n");
      scanf("%d %d", &nro1, &nro2);
      printf("Resultado: %d\n", nro1 + nro2);
      break;
    }
    case 4: {
      printf("Digite os valores desejados para a Multiplicacao: \n");
      scanf("%d %d", &nro1, &nro2);
      printf("Resultado: %d\n", nro1 * nro2);
      break;
    }
    case 5: {
      calc = 0;
      break;
    }
    }
  } while (calc != 0);
  return 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    0xee8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf47(%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     128f <main+0x16f>
mov    -0x20(%rbp),%rax
lea    0xe7c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefb(%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    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x16f>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%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    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x16f>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7b(%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    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x16f>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3e(%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    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x16f>
movl   $0x0,-0x14(%rbp)
jmp    1294 <main+0x174>
cmpl   $0x0,-0x14(%rbp)
jne    1152 <main+0x32>
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
sub    $0x18,%rsp
lea    0xf10(%rip),%rdi
call   1030 <puts@plt>
lea    0xf22(%rip),%rdi
call   1030 <puts@plt>
lea    0xee6(%rip),%r14
lea    0x14(%rsp),%rbx
lea    0xe97(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbp
lea    0xecc(%rip),%r15
jmp    11b3 <main+0x83>
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaf(%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     11b3 <main+0x83>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xf33(%rip),%rdi
call   1030 <puts@plt>
lea    0xe58(%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    11a9 <main+0x79>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2b(%rip),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
add    0x10(%rsp),%esi
jmp    11a9 <main+0x79>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xdfe(%rip),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
imul   0x10(%rsp),%esi
jmp    11a9 <main+0x79>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Entre com a operacao desejada\0A\00"
@.str.1 = [62 x i8] c"1-Divisao\0A2-Resto da Divisao\0A3-Adicao\0A4-Multiplicacao\0A5-Sair\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [44 x i8] c"Digite os valores desejados para a Divisao:\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [15 x i8] c"Resultado: %d\0A\00"
@.str.6 = [55 x i8] c"Digite os valores desejados para o Resto da Divisao: \0A\00"
@.str.7 = [45 x i8] c"Digite os valores desejados para a Adicao: \0A\00"
@.str.8 = [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 ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %41, %0
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
switch i32 %10, label %40 [
i32 1, label %11
i32 2, label %18
i32 3, label %25
i32 4, label %32
i32 5, label %39
]
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3)
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = sdiv i32 %14, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %16)
br label %40
18: ; preds = %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3)
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = srem i32 %21, %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %23)
br label %40
25: ; preds = %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3)
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = add nsw i32 %28, %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %40
32: ; preds = %8
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0))
%34 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3)
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = mul nsw i32 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %37)
br label %40
39: ; preds = %8
store i32 0, i32* %5
br label %40
40: ; preds = %8, %39, %32, %25, %18, %11
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = icmp ne i32 %42, 0
br i1 %43, label %8, label %44
44: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [44 x i8] c"Digite os valores desejados para a Divisao:\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [15 x i8] c"Resultado: %d\0A\00"
@str = [30 x i8] c"Entre com a operacao desejada\00"
@str.9 = [61 x i8] c"1-Divisao\0A2-Resto da Divisao\0A3-Adicao\0A4-Multiplicacao\0A5-Sair\00"
@str.10 = [51 x i8] c"Digite os valores desejados para a Multiplicacao: \00"
@str.11 = [44 x i8] c"Digite os valores desejados para a Adicao: \00"
@str.12 = [54 x i8] c"Digite os valores desejados para o Resto da 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 ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.9, i64 0, i64 0))
br label %9
9: ; preds = %21, %0
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
switch i32 %11, label %21 [
i32 1, label %12
i32 2, label %22
i32 3, label %28
i32 4, label %34
i32 5, label %40
]
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %1, i32* %2)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = sdiv i32 %15, %16
br label %18
18: ; preds = %34, %28, %22, %12
%19 = phi i32 [ %17, %12 ], [ %27, %22 ], [ %33, %28 ], [ %39, %34 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %9
br label %9
22: ; preds = %9
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.12, i64 0, i64 0))
%24 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %1, i32* %2)
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = srem i32 %25, %26
br label %18
28: ; preds = %9
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.11, i64 0, i64 0))
%30 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %1, i32* %2)
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = add nsw i32 %32, %31
br label %18
34: ; preds = %9
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.10, i64 0, i64 0))
%36 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %1, i32* %2)
%37 = load i32, i32* %1
%38 = load i32, i32* %2
%39 = mul nsw i32 %38, %37
br label %18
40: ; preds = %9
ret i32 0
}