#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float venda, premio, percentual, comissao;
  printf("Total de Venda: R$ ");
  scanf("%f", &venda);
  if (venda > 100000) {
    percentual = 0.16;
    premio = 700;
  } else {
    percentual = 0.14;
    if (venda < 20000) {
      premio = 400;
    }
    if (venda >= 20000 && venda < 40000) {
      premio = 500;
    }
    if (venda >= 40000 && venda < 60000) {
      premio = 550;
    }
    if (venda >= 60000 && venda < 80000) {
      premio = 600;
    }
    if (venda >= 80000 && venda < 100000) {
      premio = 650;
    }
  }
  printf("Prêmio: R$ %.2f\n", premio);
  printf("Percentual: %.2f\n", percentual);
  printf("Comissão: R$ %.2f\n\n", premio + venda * percentual);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  0xea6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1182 <main+0x62>
movss  0xec5(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeb4(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1287 <main+0x167>
movss  0xe7e(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe6d(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11ae <main+0x8e>
movss  0xe63(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xe49(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11e3 <main+0xc3>
movss  0xe44(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11e3 <main+0xc3>
movss  0xe36(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xe20(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1218 <main+0xf8>
movss  0xe17(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1218 <main+0xf8>
movss  0xe09(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xdf3(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     124d <main+0x12d>
movss  0xdea(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    124d <main+0x12d>
movss  0xddc(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xdc6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1282 <main+0x162>
movss  0xd95(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1282 <main+0x162>
movss  0xdab(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1287 <main+0x167>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdaf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd98(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xf0d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0xeb8(%rip),%xmm0
jbe    1167 <main+0x47>
movss  0xea6(%rip),%xmm3
movss  0xea2(%rip),%xmm0
jmp    1232 <main+0x112>
movss  0xe9d(%rip),%xmm1
xor    %eax,%eax
ucomiss %xmm0,%xmm1
seta   %al
lea    0xeb2(%rip),%rcx
movss  (%rcx,%rax,4),%xmm2
movss  0xe85(%rip),%xmm3
cmpless %xmm0,%xmm3
andps  %xmm3,%xmm2
movss  0xe79(%rip),%xmm4
andnps %xmm4,%xmm3
orps   %xmm2,%xmm3
cmpless %xmm0,%xmm1
movss  0xe6a(%rip),%xmm2
movaps %xmm0,%xmm4
cmpltss %xmm2,%xmm4
movss  0xe5e(%rip),%xmm5
andps  %xmm4,%xmm5
andnps %xmm3,%xmm4
orps   %xmm4,%xmm5
andps  %xmm1,%xmm5
andnps %xmm3,%xmm1
orps   %xmm1,%xmm5
cmpless %xmm0,%xmm2
movss  0xe43(%rip),%xmm1
movaps %xmm0,%xmm3
cmpltss %xmm1,%xmm3
movss  0xe37(%rip),%xmm4
andps  %xmm3,%xmm4
andnps %xmm5,%xmm3
orps   %xmm3,%xmm4
andps  %xmm2,%xmm4
andnps %xmm5,%xmm2
orps   %xmm2,%xmm4
cmpless %xmm0,%xmm1
cmpltss 0xdfb(%rip),%xmm0
movaps %xmm0,%xmm2
andnps %xmm4,%xmm2
movss  0xe0d(%rip),%xmm3
andps  %xmm0,%xmm3
orps   %xmm2,%xmm3
andps  %xmm1,%xmm3
andnps %xmm4,%xmm1
orps   %xmm1,%xmm3
movss  0xdfa(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
movaps %xmm3,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfe(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdec(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Total de Venda: R$ \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [18 x i8] c"Pr\C3\AAmio: R$ %.2f\0A\00"
@.str.3 = [18 x i8] c"Percentual: %.2f\0A\00"
@.str.4 = [21 x i8] c"Comiss\C3\A3o: R$ %.2f\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 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), float* %2)
%8 = load float, float* %2
%9 = fcmp ogt float %8, 1.000000e+05
br i1 %9, label %10, label %11
10: ; preds = %0
store float 0x3FC47AE140000000, float* %4
store float 7.000000e+02, float* %3
br label %44
11: ; preds = %0
store float 0x3FC1EB8520000000, float* %4
%12 = load float, float* %2
%13 = fcmp olt float %12, 2.000000e+04
br i1 %13, label %14, label %15
14: ; preds = %11
store float 4.000000e+02, float* %3
br label %15
15: ; preds = %14, %11
%16 = load float, float* %2
%17 = fcmp oge float %16, 2.000000e+04
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load float, float* %2
%20 = fcmp olt float %19, 4.000000e+04
br i1 %20, label %21, label %22
21: ; preds = %18
store float 5.000000e+02, float* %3
br label %22
22: ; preds = %21, %18, %15
%23 = load float, float* %2
%24 = fcmp oge float %23, 4.000000e+04
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load float, float* %2
%27 = fcmp olt float %26, 6.000000e+04
br i1 %27, label %28, label %29
28: ; preds = %25
store float 5.500000e+02, float* %3
br label %29
29: ; preds = %28, %25, %22
%30 = load float, float* %2
%31 = fcmp oge float %30, 6.000000e+04
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load float, float* %2
%34 = fcmp olt float %33, 8.000000e+04
br i1 %34, label %35, label %36
35: ; preds = %32
store float 6.000000e+02, float* %3
br label %36
36: ; preds = %35, %32, %29
%37 = load float, float* %2
%38 = fcmp oge float %37, 8.000000e+04
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load float, float* %2
%41 = fcmp olt float %40, 1.000000e+05
br i1 %41, label %42, label %43
42: ; preds = %39
store float 6.500000e+02, float* %3
br label %43
43: ; preds = %42, %39, %36
br label %44
44: ; preds = %43, %10
%45 = load float, float* %3
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %46)
%48 = load float, float* %4
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %49)
%51 = load float, float* %3
%52 = load float, float* %2
%53 = load float, float* %4
%54 = call float @llvm.fmuladd.f32(float %52, float %53, float %51)
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Total de Venda: R$ \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [18 x i8] c"Pr\C3\AAmio: R$ %.2f\0A\00"
@.str.3 = [18 x i8] c"Percentual: %.2f\0A\00"
@.str.4 = [21 x i8] c"Comiss\C3\A3o: R$ %.2f\0A\0A\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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 = fcmp ogt float %5, 1.000000e+05
br i1 %6, label %24, label %7
7: ; preds = %0
%8 = fcmp oge float %5, 2.000000e+04
%9 = fcmp olt float %5, 4.000000e+04
%10 = and i1 %8, %9
%11 = select i1 %10, float 5.000000e+02, float 4.000000e+02
%12 = fcmp oge float %5, 4.000000e+04
%13 = fcmp olt float %5, 6.000000e+04
%14 = and i1 %12, %13
%15 = select i1 %14, float 5.500000e+02, float %11
%16 = fcmp oge float %5, 6.000000e+04
%17 = fcmp olt float %5, 8.000000e+04
%18 = and i1 %16, %17
%19 = select i1 %18, float 6.000000e+02, float %15
%20 = fcmp oge float %5, 8.000000e+04
%21 = fcmp olt float %5, 1.000000e+05
%22 = and i1 %20, %21
%23 = select i1 %22, float 6.500000e+02, float %19
br label %24
24: ; preds = %7, %0
%25 = phi float [ 0x3FC47AE140000000, %0 ], [ 0x3FC1EB8520000000, %7 ]
%26 = phi float [ 7.000000e+02, %0 ], [ %23, %7 ]
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = fpext float %25 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = load float, float* %1
%32 = call float @llvm.fmuladd.f32(float %31, float %25, float %26)
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %33)
ret i32 0
}