#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 *, double *);
void practice_2(void) {
  double i;
  double bonus1, bonus2, bonus4, bonus6, bonus10, bonus;
  printf("Net income:");
  scanf("%lf", &i);
  bonus1 = 100000 * 0.1;
  bonus2 = bonus1 + 100000 * 0.075;
  bonus4 = bonus2 + 200000 * 0.05;
  bonus6 = bonus4 + 200000 * 0.03;
  bonus10 = bonus6 + 400000 * 0.015;
  if (i <= 100000) {
    bonus = i * 0.1;
  } else if (i <= 200000) {
    bonus = bonus1 + (i - 100000) * 0.075;
  } else if (i <= 400000) {
    bonus = bonus2 + (i - 200000) * 0.05;
  } else if (i <= 600000) {
    bonus = bonus4 + (i - 400000) * 0.03;
  } else if (i <= 1000000) {
    bonus = bonus6 + (i - 600000) * 0.015;
  } else if (i > 1000000) {
    bonus = bonus10 + (i - 1000000) * 0.01;
  }
  printf("royalties: bonus=%lf", bonus);
  printf("\n");
}


x86 assembly (clang, -O0):
<practice_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xf41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf50(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movsd  0xec2(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xebd(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea3(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe89(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe77(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe5d(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     11c5 <practice_2+0xa5>
movsd  0xeb2(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    132c <practice_2+0x20c>
movsd  0xe53(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     1208 <practice_2+0xe8>
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xe16(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xe6a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1327 <practice_2+0x207>
movsd  0xe18(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     124b <practice_2+0x12b>
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xdf3(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xe1f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1322 <practice_2+0x202>
movsd  0xddd(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     128e <practice_2+0x16e>
movsd  -0x20(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xdb8(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xdd4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    131d <practice_2+0x1fd>
movsd  0xda2(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     12d1 <practice_2+0x1b1>
movsd  -0x28(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xd7d(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xd89(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1318 <practice_2+0x1f8>
movsd  -0x8(%rbp),%xmm0
movsd  0xd5a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1313 <practice_2+0x1f3>
movsd  -0x30(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xd3e(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xd3a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1318 <practice_2+0x1f8>
jmp    131d <practice_2+0x1fd>
jmp    1322 <practice_2+0x202>
jmp    1327 <practice_2+0x207>
jmp    132c <practice_2+0x20c>
movsd  -0x38(%rbp),%xmm0
lea    0xd44(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<practice_2>:
push   %rax
lea    0xf70(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf7f(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
movsd  0xea5(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11b3 <practice_2+0x83>
movsd  0xea7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bd <practice_2+0x8d>
movsd  0xeb9(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11d7 <practice_2+0xa7>
movsd  0xecb(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11f1 <practice_2+0xc1>
movsd  0xedd(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    120b <practice_2+0xdb>
addsd  0xeef(%rip),%xmm0
mulsd  0xeef(%rip),%xmm0
addsd  0xeef(%rip),%xmm0
jmp    1223 <practice_2+0xf3>
mulsd  0xe4d(%rip),%xmm0
jmp    1223 <practice_2+0xf3>
addsd  0xe53(%rip),%xmm0
mulsd  0xe53(%rip),%xmm0
addsd  0xe53(%rip),%xmm0
jmp    1223 <practice_2+0xf3>
addsd  0xe59(%rip),%xmm0
mulsd  0xe59(%rip),%xmm0
addsd  0xe59(%rip),%xmm0
jmp    1223 <practice_2+0xf3>
addsd  0xe5f(%rip),%xmm0
mulsd  0xe5f(%rip),%xmm0
addsd  0xe5f(%rip),%xmm0
jmp    1223 <practice_2+0xf3>
addsd  0xe65(%rip),%xmm0
mulsd  0xe65(%rip),%xmm0
addsd  0xe65(%rip),%xmm0
lea    0xe8a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Net income:\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [21 x i8] c"royalties: bonus=%lf\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @practice_2() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
store double 1.000000e+04, double* %2
%10 = load double, double* %2
%11 = fadd double %10, 7.500000e+03
store double %11, double* %3
%12 = load double, double* %3
%13 = fadd double %12, 1.000000e+04
store double %13, double* %4
%14 = load double, double* %4
%15 = fadd double %14, 6.000000e+03
store double %15, double* %5
%16 = load double, double* %5
%17 = fadd double %16, 6.000000e+03
store double %17, double* %6
%18 = load double, double* %1
%19 = fcmp ole double %18, 1.000000e+05
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = load double, double* %1
%22 = fmul double %21, 1.000000e-01
store double %22, double* %7
br label %68
23: ; preds = %0
%24 = load double, double* %1
%25 = fcmp ole double %24, 2.000000e+05
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load double, double* %2
%28 = load double, double* %1
%29 = fsub double %28, 1.000000e+05
%30 = call double @llvm.fmuladd.f64(double %29, double 0x3FB3333333333333, double %27)
store double %30, double* %7
br label %67
31: ; preds = %23
%32 = load double, double* %1
%33 = fcmp ole double %32, 4.000000e+05
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load double, double* %3
%36 = load double, double* %1
%37 = fsub double %36, 2.000000e+05
%38 = call double @llvm.fmuladd.f64(double %37, double 5.000000e-02, double %35)
store double %38, double* %7
br label %66
39: ; preds = %31
%40 = load double, double* %1
%41 = fcmp ole double %40, 6.000000e+05
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load double, double* %4
%44 = load double, double* %1
%45 = fsub double %44, 4.000000e+05
%46 = call double @llvm.fmuladd.f64(double %45, double 3.000000e-02, double %43)
store double %46, double* %7
br label %65
47: ; preds = %39
%48 = load double, double* %1
%49 = fcmp ole double %48, 1.000000e+06
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = load double, double* %5
%52 = load double, double* %1
%53 = fsub double %52, 6.000000e+05
%54 = call double @llvm.fmuladd.f64(double %53, double 1.500000e-02, double %51)
store double %54, double* %7
br label %64
55: ; preds = %47
%56 = load double, double* %1
%57 = fcmp ogt double %56, 1.000000e+06
br i1 %57, label %58, label %63
58: ; preds = %55
%59 = load double, double* %6
%60 = load double, double* %1
%61 = fsub double %60, 1.000000e+06
%62 = call double @llvm.fmuladd.f64(double %61, double 1.000000e-02, double %59)
store double %62, double* %7
br label %63
63: ; preds = %58, %55
br label %64
64: ; preds = %63, %50
br label %65
65: ; preds = %64, %42
br label %66
66: ; preds = %65, %34
br label %67
67: ; preds = %66, %26
br label %68
68: ; preds = %67, %20
%69 = load double, double* %7
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Net income:\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [21 x i8] c"royalties: bonus=%lf\00"
define void @practice_2() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp ugt double %5, 1.000000e+05
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = fmul double %5, 1.000000e-01
br label %33
9: ; preds = %0
%10 = fcmp ugt double %5, 2.000000e+05
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = fadd double %5, -1.000000e+05
%13 = call double @llvm.fmuladd.f64(double %12, double 0x3FB3333333333333, double 1.000000e+04)
br label %33
14: ; preds = %9
%15 = fcmp ugt double %5, 4.000000e+05
br i1 %15, label %19, label %16
16: ; preds = %14
%17 = fadd double %5, -2.000000e+05
%18 = call double @llvm.fmuladd.f64(double %17, double 5.000000e-02, double 1.750000e+04)
br label %33
19: ; preds = %14
%20 = fcmp ugt double %5, 6.000000e+05
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = fadd double %5, -4.000000e+05
%23 = call double @llvm.fmuladd.f64(double %22, double 3.000000e-02, double 2.750000e+04)
br label %33
24: ; preds = %19
%25 = fcmp ugt double %5, 1.000000e+06
br i1 %25, label %29, label %26
26: ; preds = %24
%27 = fadd double %5, -6.000000e+05
%28 = call double @llvm.fmuladd.f64(double %27, double 1.500000e-02, double 3.350000e+04)
br label %33
29: ; preds = %24
%30 = fcmp ogt double %5, 1.000000e+06
%31 = fadd double %5, -1.000000e+06
%32 = call double @llvm.fmuladd.f64(double %31, double 1.000000e-02, double 3.950000e+04)
br label %33
33: ; preds = %11, %21, %29, %26, %16, %7
%34 = phi double [ %8, %7 ], [ %13, %11 ], [ %18, %16 ], [ %23, %21 ], [ %28, %26 ], [ %32, %29 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %34)
%36 = call i32 @putchar(i32 10)
ret void
}