#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*/ getchar();
float mult(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
float suma(int, int);
int main(void) {
  int val1, val2;
  float res;
  int opc;
  printf(" 1-suma, 2-mult\n");
  scanf("%d", &opc);
  getchar();
  printf("valor 1\n");
  scanf("%d", &val1);
  printf("valor 2\n");
  scanf("%d", &val2);
  if (opc == 1) {
    res = suma(val1, val2);
  } else {
    if (opc == 2) {
      res = mult(val1, val2);
    } else
      printf("opcion no valida \n");
  }
  printf("el valor es %f \n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe78(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    11df <main+0x8f>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <suma@plt>
movss  %xmm0,-0x10(%rbp)
jmp    1211 <main+0xc1>
cmpl   $0x2,-0x14(%rbp)
jne    11fe <main+0xae>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <mult@plt>
movss  %xmm0,-0x10(%rbp)
jmp    120c <main+0xbc>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1211 <main+0xc1>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe18(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     11db <main+0x7b>
cmp    $0x1,%eax
jne    11ea <main+0x8a>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1050 <suma@plt>
jmp    11f6 <main+0x96>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1070 <mult@plt>
jmp    11f6 <main+0x96>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe02(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c" 1-suma, 2-mult\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"valor 1\0A\00"
@.str.3 = [9 x i8] c"valor 2\0A\00"
@.str.4 = [19 x i8] c"opcion no valida \0A\00"
@.str.5 = [17 x i8] c"el valor es %f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = call i32 (...) @getchar()
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call float @suma(i32 %16, i32 %17)
store float %18, float* %4
br label %29
19: ; preds = %0
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = call float @mult(i32 %23, i32 %24)
store float %25, float* %4
br label %28
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
br label %29
29: ; preds = %28, %15
%30 = load float, float* %4
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %31)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [17 x i8] c"el valor es %f \0A\00"
@str = [16 x i8] c" 1-suma, 2-mult\00"
@str.6 = [8 x i8] c"valor 1\00"
@str.7 = [8 x i8] c"valor 2\00"
@str.8 = [18 x i8] c"opcion no valida \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 ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = call i32 (...) @getchar()
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.7, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %3
switch i32 %14, label %23 [
i32 1, label %15
i32 2, label %19
]
15: ; preds = %0
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call float @suma(i32 %16, i32 %17)
br label %25
19: ; preds = %0
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = call float @mult(i32 %20, i32 %21)
br label %25
23: ; preds = %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
br label %25
25: ; preds = %19, %23, %15
%26 = phi float [ %18, %15 ], [ %22, %19 ], [ undef, %23 ]
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %27)
ret i32 0
}