#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 */
scalar_t__ pow(float, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ sqrt(scalar_t__);
int main(void) {
  float lado, base;
  int opcion;
  printf("Introduzca lado del triángulo:");
  scanf("%f", &lado);
  printf("Introduzca base del triángulo:");
  scanf("%f", &base);
  printf("Seleccione opción:\n");
  printf("1 - Equilátero\n");
  printf("2 - Isósceles\n");
  printf("3 - Escaleno\n");
  scanf("%d", &opcion);
  switch (opcion) {
  case 1:
    printf("El perímetro es:%.2f\n", 3 * lado);
    break;
  case 2:
    printf("El perímetro es:%.2f\n", (2 * lado) + base);
    break;
  case 3:
    printf("El perímetro es:%.2f\n",
           lado + base + sqrt(pow(lado, 2) + pow(base, 2)));
    break;
  default:
    printf("Opción no válida.");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeae(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x15(%rbp)
call   1030 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xeba(%rip),%rdi
mov    %rdi,-0x20(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x15(%rbp),%al
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x15(%rbp),%al
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x15(%rbp),%al
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xeaf(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     121b <main+0xdb>
jmp    11f9 <main+0xb9>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     123f <main+0xff>
jmp    120a <main+0xca>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     1268 <main+0x128>
jmp    12c9 <main+0x189>
movss  0xddd(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d7 <main+0x197>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe32(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d7 <main+0x197>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %rax,-0x30(%rbp)
movss  -0xc(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1060 <sqrt@plt>
movss  -0x24(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d7 <main+0x197>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     11fa <main+0xaa>
cmp    $0x2,%eax
je     1245 <main+0xf5>
cmp    $0x1,%eax
jne    1268 <main+0x118>
movss  0x4(%rsp),%xmm0
mulss  0xe08(%rip),%xmm0
jmp    1254 <main+0x104>
movss  0x4(%rsp),%xmm0
movss  (%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %rax,%rbx
movss  (%rsp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1070 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x8(%rsp),%xmm0
jmp    1254 <main+0x104>
movss  0x4(%rsp),%xmm0
addss  %xmm0,%xmm0
addss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdeb(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1276 <main+0x126>
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Introduzca lado del tri\C3\A1ngulo:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [32 x i8] c"Introduzca base del tri\C3\A1ngulo:\00"
@.str.3 = [21 x i8] c"Seleccione opci\C3\B3n:\0A\00"
@.str.4 = [17 x i8] c"1 - Equil\C3\A1tero\0A\00"
@.str.5 = [16 x i8] c"2 - Is\C3\B3sceles\0A\00"
@.str.6 = [14 x i8] c"3 - Escaleno\0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [23 x i8] c"El per\C3\ADmetro es:%.2f\0A\00"
@.str.9 = [20 x i8] c"Opci\C3\B3n no v\C3\A1lida.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
switch i32 %14, label %40 [
i32 1, label %15
i32 2, label %20
i32 3, label %26
]
15: ; preds = %0
%16 = load float, float* %2
%17 = fmul float 3.000000e+00, %16
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), double %18)
br label %42
20: ; preds = %0
%21 = load float, float* %2
%22 = load float, float* %3
%23 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %21, float %22)
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), double %24)
br label %42
26: ; preds = %0
%27 = load float, float* %2
%28 = load float, float* %3
%29 = fadd float %27, %28
%30 = load float, float* %2
%31 = call i64 @pow(float %30, i32 2)
%32 = load float, float* %3
%33 = call i64 @pow(float %32, i32 2)
%34 = add nsw i64 %31, %33
%35 = call i32 @sqrt(i64 %34)
%36 = sitofp i32 %35 to float
%37 = fadd float %29, %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), double %38)
br label %42
40: ; preds = %0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %42
42: ; preds = %40, %26, %20, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Introduzca lado del tri\C3\A1ngulo:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [32 x i8] c"Introduzca base del tri\C3\A1ngulo:\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [23 x i8] c"El per\C3\ADmetro es:%.2f\0A\00"
@.str.9 = [20 x i8] c"Opci\C3\B3n no v\C3\A1lida.\00"
@str = [20 x i8] c"Seleccione opci\C3\B3n:\00"
@str.10 = [16 x i8] c"1 - Equil\C3\A1tero\00"
@str.11 = [15 x i8] c"2 - Is\C3\B3sceles\00"
@str.12 = [13 x i8] c"3 - Escaleno\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i32
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
switch i32 %16, label %41 [
i32 1, label %17
i32 2, label %22
i32 3, label %28
]
17: ; preds = %0
%18 = load float, float* %1
%19 = fmul float %18, 3.000000e+00
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), double %20)
br label %43
22: ; preds = %0
%23 = load float, float* %1
%24 = load float, float* %2
%25 = call float @llvm.fmuladd.f32(float %23, float 2.000000e+00, float %24)
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), double %26)
br label %43
28: ; preds = %0
%29 = load float, float* %1
%30 = load float, float* %2
%31 = fadd float %29, %30
%32 = call i64 @pow(float %29, i32 2)
%33 = load float, float* %2
%34 = call i64 @pow(float %33, i32 2)
%35 = add nsw i64 %34, %32
%36 = call i32 @sqrt(i64 %35)
%37 = sitofp i32 %36 to float
%38 = fadd float %31, %37
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), double %39)
br label %43
41: ; preds = %0
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %43
43: ; preds = %41, %28, %22, %17
ret i32 0
}