#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 division(int, int);
int multiplicacion(int, int);
int /*<<< orphan*/ printf(char *, ...);
int resta(int, int);
int /*<<< orphan*/ scanf(char *, int *);
int suma(int, int);
int main() {
  int numero1, numero2, multiplicar, sumar, restar, dividir, operacion;
  printf("Inserte el primer dato: ");
  scanf("%d%*c", &numero1);
  printf("Inserte el segundo dato: ");
  scanf("%d%*c", &numero2);
  printf("Seleccione la operacion que desea hacer\n");
  printf("1.suma \n2.resta \n3.multiplicacion \n4.division\n");
  scanf("%d%*c", &operacion);
  switch (operacion) {
  case 1:
    sumar = suma(numero1, numero2);
    printf("La respuesta es:[ %d]\n", sumar);
    break;
  case 2:
    restar = resta(numero1, numero2);
    printf("La respuesta es:[ %d]\n", restar);
    break;
  case 3:
    multiplicar = multiplicacion(numero1, numero2);
    printf("La respuesta es:[ %d]\n", multiplicar);
    break;
  case 4:
    dividir = division(numero1, numero2);
    printf("La respuesta es:[ %d]\n", dividir);
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x31(%rbp)
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    %rdi,-0x30(%rbp)
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x31(%rbp),%al
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x31(%rbp),%al
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x31(%rbp),%al
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     128f <main+0x12f>
mov    -0x28(%rbp),%rax
lea    0xe05(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <suma@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x12f>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <resta@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x12f>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <multiplicacion@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x12f>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <division@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9f(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     123d <main+0xcd>
lea    0xe16(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1050 <suma@plt>
jmp    122d <main+0xbd>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1090 <resta@plt>
jmp    122d <main+0xbd>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1070 <multiplicacion@plt>
jmp    122d <main+0xbd>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1060 <division@plt>
lea    0xe15(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Inserte el primer dato: \00"
@.str.1 = [6 x i8] c"%d%*c\00"
@.str.2 = [26 x i8] c"Inserte el segundo dato: \00"
@.str.3 = [41 x i8] c"Seleccione la operacion que desea hacer\0A\00"
@.str.4 = [47 x i8] c"1.suma \0A2.resta \0A3.multiplicacion \0A4.division\0A\00"
@.str.5 = [23 x i8] c"La respuesta es:[ %d]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%16 = load i32, i32* %8
switch i32 %16, label %41 [
i32 1, label %17
i32 2, label %23
i32 3, label %29
i32 4, label %35
]
17: ; preds = %0
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @suma(i32 %18, i32 %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %21)
br label %41
23: ; preds = %0
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @resta(i32 %24, i32 %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %27)
br label %41
29: ; preds = %0
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = call i32 @multiplicacion(i32 %30, i32 %31)
store i32 %32, i32* %4
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %33)
br label %41
35: ; preds = %0
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = call i32 @division(i32 %36, i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %0, %35, %29, %23, %17
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str = [25 x i8] c"Inserte el primer dato: \00"
@.str.1 = [6 x i8] c"%d%*c\00"
@.str.2 = [26 x i8] c"Inserte el segundo dato: \00"
@.str.5 = [23 x i8] c"La respuesta es:[ %d]\0A\00"
@str = [40 x i8] c"Seleccione la operacion que desea hacer\00"
@str.6 = [46 x i8] c"1.suma \0A2.resta \0A3.multiplicacion \0A4.division\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.6, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
switch i32 %14, label %34 [
i32 1, label %15
i32 2, label %19
i32 3, label %23
i32 4, label %27
]
15: ; preds = %0
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call i32 @suma(i32 %16, i32 %17)
br label %31
19: ; preds = %0
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = call i32 @resta(i32 %20, i32 %21)
br label %31
23: ; preds = %0
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = call i32 @multiplicacion(i32 %24, i32 %25)
br label %31
27: ; preds = %0
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = call i32 @division(i32 %28, i32 %29)
br label %31
31: ; preds = %15, %19, %23, %27
%32 = phi i32 [ %30, %27 ], [ %26, %23 ], [ %22, %19 ], [ %18, %15 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %0
ret i32 0
}