#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 getint(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int sumaVendida, porciento;
  float sueldoSemanal;
  enum limites { PrimerLim = 1000, SegundoLim = 2000, TercerLim = 4000 };
  enum porcentajes { menPrimero = 0, menSegundo = 5, mTercero = 7, MayorT = 9 };
  while ((sumaVendida = getint("Ingrese suma de venta semanal: ")) < 0)
    printf("Suma erronea.\n");
  if (sumaVendida < PrimerLim)
    porciento = menPrimero;
  else if (sumaVendida < SegundoLim)
    porciento = menSegundo;
  else if (sumaVendida < TercerLim)
    porciento = mTercero;
  else
    porciento = MayorT;
  sueldoSemanal = 300 + sumaVendida * (porciento / 100.0);
  printf("Suma: %.2f.\n", sueldoSemanal);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1040 <getint@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    115a <main+0x3a>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
cmpl   $0x3e8,-0x8(%rbp)
jge    1173 <main+0x53>
movl   $0x0,-0xc(%rbp)
jmp    11b6 <main+0x96>
cmpl   $0x7d0,-0x8(%rbp)
jge    118c <main+0x6c>
movl   $0x5,-0xc(%rbp)
jmp    11b1 <main+0x91>
cmpl   $0xfa0,-0x8(%rbp)
jge    11a5 <main+0x85>
movl   $0x7,-0xc(%rbp)
jmp    11ac <main+0x8c>
movl   $0x9,-0xc(%rbp)
jmp    11b1 <main+0x91>
jmp    11b6 <main+0x96>
cvtsi2sdl -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe40(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe28(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeed(%rip),%rdi
call   1050 <getint@plt>
test   %eax,%eax
jns    1174 <main+0x44>
lea    0xf0a(%rip),%r14
lea    0xed6(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <getint@plt>
test   %eax,%eax
js     1160 <main+0x30>
xorpd  %xmm0,%xmm0
cmp    $0x3e8,%eax
jb     11a6 <main+0x76>
cmp    $0x7d0,%eax
jae    1190 <main+0x60>
movsd  0xe72(%rip),%xmm0
jmp    11a6 <main+0x76>
xor    %ecx,%ecx
cmp    $0xfa0,%eax
setb   %cl
lea    0xe77(%rip),%rdx
movsd  (%rdx,%rcx,8),%xmm0
cvtsi2sd %eax,%xmm1
divsd  0xe56(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xe52(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Ingrese suma de venta semanal: \00"
@.str.1 = [15 x i8] c"Suma erronea.\0A\00"
@.str.2 = [13 x i8] c"Suma: %.2f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
store i32 0, i32* %1
br label %5
5: ; preds = %8, %0
%6 = call i32 @getint(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %5
10: ; preds = %5
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 1000
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 0, i32* %3
br label %25
14: ; preds = %10
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 2000
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 5, i32* %3
br label %24
18: ; preds = %14
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 4000
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 7, i32* %3
br label %23
22: ; preds = %18
store i32 9, i32* %3
br label %23
23: ; preds = %22, %21
br label %24
24: ; preds = %23, %17
br label %25
25: ; preds = %24, %13
%26 = load i32, i32* %2
%27 = sitofp i32 %26 to double
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to double
%30 = fdiv double %29, 1.000000e+02
%31 = call double @llvm.fmuladd.f64(double %27, double %30, double 3.000000e+02)
%32 = fptrunc double %31 to float
store float %32, float* %4
%33 = load float, float* %4
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Ingrese suma de venta semanal: \00"
@.str.2 = [13 x i8] c"Suma: %.2f.\0A\00"
@str = [14 x i8] c"Suma erronea.\00"
define i32 @main() {
%1 = tail call i32 @getint(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0, %3
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @getint(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = icmp slt i32 %5, 0
br i1 %6, label %3, label %7
7: ; preds = %3, %0
%8 = phi i32 [ %1, %0 ], [ %5, %3 ]
%9 = icmp ult i32 %8, 1000
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = icmp ult i32 %8, 2000
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = icmp ult i32 %8, 4000
%14 = select i1 %13, double 7.000000e+00, double 9.000000e+00
br label %15
15: ; preds = %12, %10, %7
%16 = phi double [ 0.000000e+00, %7 ], [ 5.000000e+00, %10 ], [ %14, %12 ]
%17 = sitofp i32 %8 to double
%18 = fdiv double %16, 1.000000e+02
%19 = tail call double @llvm.fmuladd.f64(double %17, double %18, double 3.000000e+02)
%20 = fptrunc double %19 to float
%21 = fpext float %20 to double
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %21)
ret i32 0
}