#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*/ adicao(int, int);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ subtracao(int, int);
int /*<<< orphan*/ system(char *);
main() {
  int x, y, s;
  printf("Entre com os valores das matrizes: ");
  scanf("%d %d", &x, &y);
  printf("Selecione a operacao desejada:\n1 - adicao\n2 - subtracao\n\n");
  scanf("%d", &s);
  switch (s) {
  case 1:
    adicao(x, y);
    break;
  case 2:
    subtracao(x, y);
    break;
  default:
    printf("\nEntrada invalida!");
    break;
  }
  system("pause");
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x15(%rbp)
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1070 <scanf@plt>
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xe7d(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     11d8 <main+0x78>
jmp    11c7 <main+0x67>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11e8 <main+0x88>
jmp    11f8 <main+0x98>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <adicao@plt>
jmp    1204 <main+0xa4>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <subtracao@plt>
jmp    1204 <main+0xa4>
lea    0xe65(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6c(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1080 <getch@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xe85(%rip),%rdi
call   1060 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     11d4 <main+0x64>
cmp    $0x1,%eax
jne    11e3 <main+0x73>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1040 <adicao@plt>
jmp    11ef <main+0x7f>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1070 <subtracao@plt>
jmp    11ef <main+0x7f>
lea    0xe40(%rip),%rdi
call   1060 <printf@plt>
lea    0xe47(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1090 <getch@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Entre com os valores das matrizes: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [58 x i8] c"Selecione a operacao desejada:\0A1 - adicao\0A2 - subtracao\0A\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [19 x i8] c"\0AEntrada invalida!\00"
@.str.5 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 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 @printf(i8* getelementptr inbounds ([58 x i8], [58 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
switch i32 %9, label %18 [
i32 1, label %10
i32 2, label %14
]
10: ; preds = %0
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @adicao(i32 %11, i32 %12)
br label %20
14: ; preds = %0
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @subtracao(i32 %15, i32 %16)
br label %20
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %18, %14, %10
%21 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"Entre com os valores das matrizes: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [19 x i8] c"\0AEntrada invalida!\00"
@.str.5 = [6 x i8] c"pause\00"
@str = [57 x i8] c"Selecione a operacao desejada:\0A1 - adicao\0A2 - subtracao\0A\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 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 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 ([57 x i8], [57 x i8]* @str, 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 %20 [
i32 1, label %12
i32 2, label %16
]
12: ; preds = %0
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @adicao(i32 %13, i32 %14)
br label %22
16: ; preds = %0
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 @subtracao(i32 %17, i32 %18)
br label %22
20: ; preds = %0
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %16, %12
%23 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (...) @getch()
ret i32 0
}