#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 soma(int, int);
int subt(int, int);
int main() {
  int a, b, ope;
  printf("Digite os valores:\n");
  scanf("%d %d", &a, &b);
  printf("Escolha a operação:\n0 - Soma\n1 - Subtração\n");
  scanf("%d", &ope);
  if (ope == 0) {
    printf("%d\n", soma(a, b));
  } else {
    if (ope == 1) {
      printf("%d\n", subt(a, b));
    } else {
      printf("Operação invalida!\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11bd <main+0x7d>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <soma@plt>
mov    %eax,%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fa <main+0xba>
cmpl   $0x1,-0x10(%rbp)
jne    11e7 <main+0xa7>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <subt@plt>
mov    %eax,%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f5 <main+0xb5>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fa <main+0xba>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
lea    0xe99(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe9e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe78(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x1,%eax
je     11b3 <main+0x63>
test   %eax,%eax
jne    11d2 <main+0x82>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1060 <soma@plt>
jmp    11c0 <main+0x70>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1030 <subt@plt>
lea    0xe3f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11de <main+0x8e>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Digite os valores:\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [48 x i8] c"Escolha a opera\C3\A7\C3\A3o:\0A0 - Soma\0A1 - Subtra\C3\A7\C3\A3o\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [22 x i8] c"Opera\C3\A7\C3\A3o invalida!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 @soma(i32 %12, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %14)
br label %27
16: ; preds = %0
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @subt(i32 %20, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %22)
br label %26
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %24, %19
br label %27
27: ; preds = %26, %11
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [19 x i8] c"Digite os valores:\00"
@str.6 = [47 x i8] c"Escolha a opera\C3\A7\C3\A3o:\0A0 - Soma\0A1 - Subtra\C3\A7\C3\A3o\00"
@str.7 = [21 x i8] c"Opera\C3\A7\C3\A3o invalida!\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 ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
switch i32 %11, label %22 [
i32 0, label %12
i32 1, label %17
]
12: ; preds = %0
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @soma(i32 %13, i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %15)
br label %24
17: ; preds = %0
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 @subt(i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %24
22: ; preds = %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
br label %24
24: ; preds = %17, %22, %12
ret i32 0
}