#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 */
float ceil(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int ej3() {
  int temp1 = 5, temp2 = 3, temp3 = 2;
  float tarif1 = 0.8, tarif2 = 0.7, tarif3 = 0.5, tiempo, costo = 0;
  printf("Ingrese duración de la llamada en segundos: \n");
  scanf("%f", &tiempo);
  tiempo = ceil(tiempo / 60);
  if (tiempo <= temp1) {
    costo = tiempo;
  } else if (tiempo <= (temp1 + temp2)) {
    costo = temp1 + (tiempo - temp1) * tarif1;
  } else if (tiempo <= (temp1 + temp2 + temp3)) {
    costo = temp1 + temp2 * tarif1 + (tiempo - (temp1 + temp2)) * tarif2;
  } else if (tiempo >= (temp1 + temp2 + temp3)) {
    costo = temp1 + temp2 * tarif1 + temp3 * tarif2 +
            (tiempo - (temp1 + temp2 + temp3)) * tarif3;
  }
  printf("El costo de la llamada es: $%.2f \n", costo);
  return 0;
}


x86 assembly (clang, -O0):
<ej3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x5,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movss  0xeb7(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xea6(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe95(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0x1c(%rbp),%xmm0
movss  0xe59(%rip),%xmm1
divss  %xmm1,%xmm0
call   1030 <ceil@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
cvtsi2ssl -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     11d7 <ej3+0xa7>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    12f0 <ej3+0x1c0>
movss  -0x1c(%rbp),%xmm1
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
ucomiss %xmm1,%xmm0
jb     1219 <ej3+0xe9>
cvtsi2ssl -0x4(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x4(%rbp),%xmm2
subss  %xmm2,%xmm0
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    12eb <ej3+0x1bb>
movss  -0x1c(%rbp),%xmm1
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
ucomiss %xmm1,%xmm0
jb     1275 <ej3+0x145>
cvtsi2ssl -0x4(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm2
subss  %xmm2,%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    12e6 <ej3+0x1b6>
movss  -0x1c(%rbp),%xmm0
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm1
ucomiss %xmm1,%xmm0
jb     12e1 <ej3+0x1b1>
cvtsi2ssl -0x4(%rbp),%xmm1
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm2
subss  %xmm2,%xmm0
movss  -0x18(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    12e6 <ej3+0x1b6>
jmp    12eb <ej3+0x1bb>
jmp    12f0 <ej3+0x1c0>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd42(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ej3>:
push   %rax
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
lea    0xedc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
movss  0x4(%rsp),%xmm0
divss  0xe94(%rip),%xmm0
call   1050 <ceilf@plt>
movss  %xmm0,0x4(%rsp)
movss  0xe85(%rip),%xmm1
ucomiss %xmm0,%xmm1
movaps %xmm0,%xmm1
jae    11fc <ej3+0xbc>
movss  0xe79(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    11c7 <ej3+0x87>
movss  0xe78(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    11e1 <ej3+0xa1>
xorps  %xmm1,%xmm1
ucomiss 0xe69(%rip),%xmm0
jb     11fc <ej3+0xbc>
addss  0xe6f(%rip),%xmm0
mulss  0xe6b(%rip),%xmm0
addss  0xe67(%rip),%xmm0
jmp    11f9 <ej3+0xb9>
addss  0xe3d(%rip),%xmm0
mulss  0xe39(%rip),%xmm0
addss  0xe25(%rip),%xmm0
jmp    11f9 <ej3+0xb9>
addss  0xe2f(%rip),%xmm0
mulss  0xe2b(%rip),%xmm0
addss  0xe27(%rip),%xmm0
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe29(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Ingrese duraci\C3\B3n de la llamada en segundos: \0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [35 x i8] c"El costo de la llamada es: $%.2f \0A\00"
define i32 @ej3() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store i32 5, i32* %1
store i32 3, i32* %2
store i32 2, i32* %3
store float 0x3FE99999A0000000, float* %4
store float 0x3FE6666660000000, float* %5
store float 5.000000e-01, float* %6
store float 0.000000e+00, float* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %7)
%11 = load float, float* %7
%12 = fdiv float %11, 6.000000e+01
%13 = call float @ceil(float %12)
store float %13, float* %7
%14 = load float, float* %7
%15 = load i32, i32* %1
%16 = sitofp i32 %15 to float
%17 = fcmp ole float %14, %16
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = load float, float* %7
store float %19, float* %8
br label %93
20: ; preds = %0
%21 = load float, float* %7
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = add nsw i32 %22, %23
%25 = sitofp i32 %24 to float
%26 = fcmp ole float %21, %25
br i1 %26, label %27, label %36
27: ; preds = %20
%28 = load i32, i32* %1
%29 = sitofp i32 %28 to float
%30 = load float, float* %7
%31 = load i32, i32* %1
%32 = sitofp i32 %31 to float
%33 = fsub float %30, %32
%34 = load float, float* %4
%35 = call float @llvm.fmuladd.f32(float %33, float %34, float %29)
store float %35, float* %8
br label %92
36: ; preds = %20
%37 = load float, float* %7
%38 = load i32, i32* %1
%39 = load i32, i32* %2
%40 = add nsw i32 %38, %39
%41 = load i32, i32* %3
%42 = add nsw i32 %40, %41
%43 = sitofp i32 %42 to float
%44 = fcmp ole float %37, %43
br i1 %44, label %45, label %60
45: ; preds = %36
%46 = load i32, i32* %1
%47 = sitofp i32 %46 to float
%48 = load i32, i32* %2
%49 = sitofp i32 %48 to float
%50 = load float, float* %4
%51 = call float @llvm.fmuladd.f32(float %49, float %50, float %47)
%52 = load float, float* %7
%53 = load i32, i32* %1
%54 = load i32, i32* %2
%55 = add nsw i32 %53, %54
%56 = sitofp i32 %55 to float
%57 = fsub float %52, %56
%58 = load float, float* %5
%59 = call float @llvm.fmuladd.f32(float %57, float %58, float %51)
store float %59, float* %8
br label %91
60: ; preds = %36
%61 = load float, float* %7
%62 = load i32, i32* %1
%63 = load i32, i32* %2
%64 = add nsw i32 %62, %63
%65 = load i32, i32* %3
%66 = add nsw i32 %64, %65
%67 = sitofp i32 %66 to float
%68 = fcmp oge float %61, %67
br i1 %68, label %69, label %90
69: ; preds = %60
%70 = load i32, i32* %1
%71 = sitofp i32 %70 to float
%72 = load i32, i32* %2
%73 = sitofp i32 %72 to float
%74 = load float, float* %4
%75 = call float @llvm.fmuladd.f32(float %73, float %74, float %71)
%76 = load i32, i32* %3
%77 = sitofp i32 %76 to float
%78 = load float, float* %5
%79 = call float @llvm.fmuladd.f32(float %77, float %78, float %75)
%80 = load float, float* %7
%81 = load i32, i32* %1
%82 = load i32, i32* %2
%83 = add nsw i32 %81, %82
%84 = load i32, i32* %3
%85 = add nsw i32 %83, %84
%86 = sitofp i32 %85 to float
%87 = fsub float %80, %86
%88 = load float, float* %6
%89 = call float @llvm.fmuladd.f32(float %87, float %88, float %79)
store float %89, float* %8
br label %90
90: ; preds = %69, %60
br label %91
91: ; preds = %90, %45
br label %92
92: ; preds = %91, %27
br label %93
93: ; preds = %92, %18
%94 = load float, float* %8
%95 = fpext float %94 to double
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), double %95)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [35 x i8] c"El costo de la llamada es: $%.2f \0A\00"
@str = [46 x i8] c"Ingrese duraci\C3\B3n de la llamada en segundos: \00"
define i32 @ej3() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fdiv float %5, 6.000000e+01
%7 = call float @llvm.ceil.f32(float %6)
store float %7, float* %1
%8 = fcmp ugt float %7, 5.000000e+00
br i1 %8, label %9, label %24
9: ; preds = %0
%10 = fcmp ugt float %7, 8.000000e+00
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = fadd float %7, -5.000000e+00
%13 = call float @llvm.fmuladd.f32(float %12, float 0x3FE99999A0000000, float 5.000000e+00)
br label %24
14: ; preds = %9
%15 = fcmp ugt float %7, 1.000000e+01
br i1 %15, label %19, label %16
16: ; preds = %14
%17 = fadd float %7, -8.000000e+00
%18 = call float @llvm.fmuladd.f32(float %17, float 0x3FE6666660000000, float 0x401D9999A0000000)
br label %24
19: ; preds = %14
%20 = fcmp ult float %7, 1.000000e+01
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = fadd float %7, -1.000000e+01
%23 = call float @llvm.fmuladd.f32(float %22, float 5.000000e-01, float 0x40219999A0000000)
br label %24
24: ; preds = %0, %11, %19, %21, %16
%25 = phi float [ %13, %11 ], [ %18, %16 ], [ %23, %21 ], [ 0.000000e+00, %19 ], [ %7, %0 ]
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), double %26)
ret i32 0
}