#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 menu();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float a, b, c;
  int t = menu();
  while (t != 4) {
    switch (t) {
    case 1:
      printf("Ingrese la longitud del lado a: ");
      scanf("%f", &a);
      printf("Ingrese la longitud del lado b: ");
      scanf("%f", &b);
      printf("Ingrese la longitud del lado c: ");
      scanf("%f", &c);
      printf("\nPerimetro: %.2f\n", a + b + c);
      break;
    case 2:
      printf("Ingrese la longitud de un lado: ");
      scanf("%f", &a);
      printf("\nPerimetro: %.2f\n", a * 3);
      break;
    case 3:
      printf("Ingrese la longitud de los lados iguales: ");
      scanf("%f", &a);
      printf("Ingrese la longitud del lado desigual: ");
      scanf("%f", &b);
      printf("\nPerimetro: %.2f\n", (a * 2) + b);
      break;
    default:
      printf("Opcion incorrecta\n");
      break;
    }
    t = menu();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <menu@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
je     12cd <main+0x19d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     1189 <main+0x59>
jmp    1167 <main+0x37>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1209 <main+0xd9>
jmp    1178 <main+0x48>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     124b <main+0x11b>
jmp    12b0 <main+0x180>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12be <main+0x18e>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe07(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movss  0xdd1(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12be <main+0x18e>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12be <main+0x18e>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <menu@plt>
mov    %eax,-0x14(%rbp)
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1040 <menu@plt>
lea    0xea8(%rip),%r15
lea    0xed2(%rip),%rbx
lea    0xc(%rsp),%r12
lea    0x10(%rsp),%rbp
lea    0xf06(%rip),%r13
lea    0xf5d(%rip),%r14
jmp    11bc <main+0x7c>
nopl   (%rax)
lea    0xf05(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
mulss  0xe59(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <menu@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1240 <main+0x100>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
jmp    11a7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
jmp    11b5 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
addss  %xmm0,%xmm0
addss  0x10(%rsp),%xmm0
jmp    11a7 <main+0x67>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Ingrese la longitud del lado a: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [33 x i8] c"Ingrese la longitud del lado b: \00"
@.str.3 = [33 x i8] c"Ingrese la longitud del lado c: \00"
@.str.4 = [18 x i8] c"\0APerimetro: %.2f\0A\00"
@.str.5 = [33 x i8] c"Ingrese la longitud de un lado: \00"
@.str.6 = [43 x i8] c"Ingrese la longitud de los lados iguales: \00"
@.str.7 = [40 x i8] c"Ingrese la longitud del lado desigual: \00"
@.str.8 = [19 x i8] c"Opcion incorrecta\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @menu()
store i32 %6, i32* %5
br label %7
7: ; preds = %45, %0
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %47
10: ; preds = %7
%11 = load i32, i32* %5
switch i32 %11, label %43 [
i32 1, label %12
i32 2, label %26
i32 3, label %33
]
12: ; preds = %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%19 = load float, float* %2
%20 = load float, float* %3
%21 = fadd float %19, %20
%22 = load float, float* %4
%23 = fadd float %21, %22
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %24)
br label %45
26: ; preds = %10
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%29 = load float, float* %2
%30 = fmul float %29, 3.000000e+00
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %31)
br label %45
33: ; preds = %10
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%38 = load float, float* %2
%39 = load float, float* %3
%40 = call float @llvm.fmuladd.f32(float %38, float 2.000000e+00, float %39)
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %41)
br label %45
43: ; preds = %10
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %45
45: ; preds = %43, %33, %26, %12
%46 = call i32 (...) @menu()
store i32 %46, i32* %5
br label %7
47: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Ingrese la longitud del lado a: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [33 x i8] c"Ingrese la longitud del lado b: \00"
@.str.3 = [33 x i8] c"Ingrese la longitud del lado c: \00"
@.str.4 = [18 x i8] c"\0APerimetro: %.2f\0A\00"
@.str.5 = [33 x i8] c"Ingrese la longitud de un lado: \00"
@.str.6 = [43 x i8] c"Ingrese la longitud de los lados iguales: \00"
@.str.7 = [40 x i8] c"Ingrese la longitud del lado desigual: \00"
@str = [18 x i8] c"Opcion incorrecta\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (...) @menu()
br label %8
8: ; preds = %43, %0
%9 = phi i32 [ %7, %0 ], [ %44, %43 ]
switch i32 %9, label %41 [
i32 4, label %45
i32 1, label %10
i32 2, label %24
i32 3, label %31
]
10: ; preds = %8
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%17 = load float, float* %1
%18 = load float, float* %2
%19 = fadd float %17, %18
%20 = load float, float* %3
%21 = fadd float %19, %20
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %22)
br label %43
24: ; preds = %8
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%27 = load float, float* %1
%28 = fmul float %27, 3.000000e+00
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %29)
br label %43
31: ; preds = %8
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%36 = load float, float* %1
%37 = load float, float* %2
%38 = call float @llvm.fmuladd.f32(float %36, float 2.000000e+00, float %37)
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %39)
br label %43
41: ; preds = %8
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %43
43: ; preds = %41, %31, %24, %10
%44 = call i32 (...) @menu()
br label %8
45: ; preds = %8
ret i32 0
}