#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 main() {
  int num_a = 10;
  int num_b = 0;
  char op;
  float result;
  do {
    printf("Digite o número a:\n");
    scanf("%d", &num_a);
    printf("Digite o número b:\n");
    scanf("%d", &num_b);
    printf("Digite a operação (+,-,*,/):\n");
    scanf(" %c", &op);
    switch (op) {
    case '+':
      printf("Opção escolhida: %d + %d\n", num_a, num_b);
      result = (num_a + num_b);
      break;
    case '-':
      printf("Opção escolhida: %d - %d\n", num_a, num_b);
      result = (num_a - num_b);
      break;
    case '/':
      printf("Opção escolhida: %d / %d\n", num_a, num_b);
      result = (num_a / num_b);
      break;
    case '*':
      printf("Opção escolhida: %d * %d\n", num_a, num_b);
      result = (num_a * num_b);
      break;
    }
    printf("O resultado foi: %2.f\n", result);
    printf("Outra operação? (S/N):\n");
    scanf(" %c", &op);
  } while (op != 'N' && op != 'n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xed4(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xed5(%rip),%rdi
mov    %rdi,-0x30(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%al
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xec8(%rip),%rdi
lea    -0xd(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     126d <main+0x14d>
mov    -0x20(%rbp),%rax
lea    0xe39(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    126d <main+0x14d>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    126d <main+0x14d>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    126d <main+0x14d>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdcc(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x4e,%ecx
mov    %al,-0x31(%rbp)
je     12c3 <main+0x1a3>
movsbl -0xd(%rbp),%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    113d <main+0x1d>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0xa,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xec3(%rip),%rbx
lea    0xebf(%rip),%r14
lea    0xb(%rsp),%r15
lea    0xf27(%rip),%r12
lea    0xf7e(%rip),%r13
lea    0xe8a(%rip),%rbp
jmp    11e4 <main+0xb4>
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xee4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
imul   0x10(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x14(%rsp)
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzbl 0xb(%rsp),%eax
and    $0xdf,%al
cmp    $0x4e,%al
je     12d4 <main+0x1a4>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0xb(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     11ac <main+0x7c>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
add    0x10(%rsp),%eax
jmp    119f <main+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xdac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%eax
sub    0xc(%rsp),%eax
jmp    119f <main+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xd98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%eax
cltd
idivl  0xc(%rsp)
jmp    119f <main+0x6f>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Digite o n\C3\BAmero a:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Digite o n\C3\BAmero b:\0A\00"
@.str.3 = [32 x i8] c"Digite a opera\C3\A7\C3\A3o (+,-,*,/):\0A\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [28 x i8] c"Op\C3\A7\C3\A3o escolhida: %d + %d\0A\00"
@.str.6 = [28 x i8] c"Op\C3\A7\C3\A3o escolhida: %d - %d\0A\00"
@.str.7 = [28 x i8] c"Op\C3\A7\C3\A3o escolhida: %d / %d\0A\00"
@.str.8 = [28 x i8] c"Op\C3\A7\C3\A3o escolhida: %d * %d\0A\00"
@.str.9 = [23 x i8] c"O resultado foi: %2.f\0A\00"
@.str.10 = [26 x i8] c"Outra opera\C3\A7\C3\A3o? (S/N):\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca float
store i32 0, i32* %1
store i32 10, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %61, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
switch i32 %14, label %47 [
i32 43, label %15
i32 45, label %23
i32 47, label %31
i32 42, label %39
]
15: ; preds = %6
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %16, i32 %17)
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = add nsw i32 %19, %20
%22 = sitofp i32 %21 to float
store float %22, float* %5
br label %47
23: ; preds = %6
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = sub nsw i32 %27, %28
%30 = sitofp i32 %29 to float
store float %30, float* %5
br label %47
31: ; preds = %6
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %32, i32 %33)
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = sdiv i32 %35, %36
%38 = sitofp i32 %37 to float
store float %38, float* %5
br label %47
39: ; preds = %6
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %40, i32 %41)
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = mul nsw i32 %43, %44
%46 = sitofp i32 %45 to float
store float %46, float* %5
br label %47
47: ; preds = %6, %39, %31, %23, %15
%48 = load float, float* %5
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), double %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%52 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %53
53: ; preds = %47
%54 = load i8, i8* %4
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 78
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i8, i8* %4
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 110
br label %61
61: ; preds = %57, %53
%62 = phi i1 [ false, %53 ], [ %60, %57 ]
br i1 %62, label %6, label %63
63: ; preds = %61
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [28 x i8] c"Op\C3\A7\C3\A3o escolhida: %d + %d\0A\00"
@.str.6 = [28 x i8] c"Op\C3\A7\C3\A3o escolhida: %d - %d\0A\00"
@.str.7 = [28 x i8] c"Op\C3\A7\C3\A3o escolhida: %d / %d\0A\00"
@.str.8 = [28 x i8] c"Op\C3\A7\C3\A3o escolhida: %d * %d\0A\00"
@.str.9 = [23 x i8] c"O resultado foi: %2.f\0A\00"
@str = [20 x i8] c"Digite o n\C3\BAmero a:\00"
@str.11 = [20 x i8] c"Digite o n\C3\BAmero b:\00"
@str.12 = [31 x i8] c"Digite a opera\C3\A7\C3\A3o (+,-,*,/):\00"
@str.13 = [25 x i8] c"Outra opera\C3\A7\C3\A3o? (S/N):\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = bitcast i32* %1 to i8*
store i32 10, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %6
6: ; preds = %48, %0
%7 = phi float [ undef, %0 ], [ %49, %48 ]
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.12, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
switch i32 %15, label %48 [
i32 43, label %16
i32 45, label %24
i32 47, label %32
i32 42, label %40
]
16: ; preds = %6
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = add nsw i32 %21, %20
%23 = sitofp i32 %22 to float
br label %48
24: ; preds = %6
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %25, i32 %26)
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = sub nsw i32 %28, %29
%31 = sitofp i32 %30 to float
br label %48
32: ; preds = %6
%33 = load i32, i32* %1
%34 = load i32, i32* %2
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %33, i32 %34)
%36 = load i32, i32* %1
%37 = load i32, i32* %2
%38 = sdiv i32 %36, %37
%39 = sitofp i32 %38 to float
br label %48
40: ; preds = %6
%41 = load i32, i32* %1
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %41, i32 %42)
%44 = load i32, i32* %1
%45 = load i32, i32* %2
%46 = mul nsw i32 %45, %44
%47 = sitofp i32 %46 to float
br label %48
48: ; preds = %6, %40, %32, %24, %16
%49 = phi float [ %7, %6 ], [ %47, %40 ], [ %39, %32 ], [ %31, %24 ], [ %23, %16 ]
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), double %50)
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.13, i64 0, i64 0))
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%54 = load i8, i8* %3
%55 = and i8 %54, -33
%56 = icmp eq i8 %55, 78
br i1 %56, label %57, label %6
57: ; preds = %48
ret i32 0
}