#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 *, long);
int /*<<< orphan*/ scanf(char *, long *);
void main() {
  long int profit;
  long int bonus1, bonus2, bonus4, bonus6, bonus10, bonus;
  scanf("%d", &profit);
  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 (profit >= 0 && profit <= 100000)
    bonus = profit * 0.1;
  else if (profit <= 200000)
    bonus = bonus1 + (profit - 100000) * 0.075;
  else if (profit <= 400000)
    bonus = bonus2 + (profit - 200000) * 0.05;
  else if (profit <= 600000)
    bonus = bonus4 + (profit - 40000) * 0.03;
  else if (profit <= 100000)
    bonus = bonus6 + (profit - 60000) * 0.015;
  else
    bonus = bonus10 + (profit - 1000000) * 0.01;
  printf("The total bonus is: %d\n", bonus);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xf19(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movq   $0x2710,-0x10(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0xec2(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x18(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x20(%rbp)
cvtsi2sdq -0x20(%rbp),%xmm0
movsd  0xe7c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
cvtsi2sdq -0x28(%rbp),%xmm0
movsd  0xe61(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
jl     11e5 <main+0xc5>
cmpq   $0x186a0,-0x8(%rbp)
jg     11e5 <main+0xc5>
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x38(%rbp)
jmp    132b <main+0x20b>
cmpq   $0x30d40,-0x8(%rbp)
jg     1226 <main+0x106>
cvtsi2sdq -0x10(%rbp),%xmm1
mov    -0x8(%rbp),%rax
sub    $0x186a0,%rax
cvtsi2sd %rax,%xmm0
movsd  0xe28(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x38(%rbp)
jmp    1326 <main+0x206>
cmpq   $0x61a80,-0x8(%rbp)
jg     1267 <main+0x147>
cvtsi2sdq -0x18(%rbp),%xmm1
mov    -0x8(%rbp),%rax
sub    $0x30d40,%rax
cvtsi2sd %rax,%xmm0
movsd  0xddf(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x38(%rbp)
jmp    1321 <main+0x201>
cmpq   $0x927c0,-0x8(%rbp)
jg     12a8 <main+0x188>
cvtsi2sdq -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%rax
sub    $0x9c40,%rax
cvtsi2sd %rax,%xmm0
movsd  0xd96(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x38(%rbp)
jmp    131c <main+0x1fc>
cmpq   $0x186a0,-0x8(%rbp)
jg     12e9 <main+0x1c9>
cvtsi2sdq -0x28(%rbp),%xmm1
mov    -0x8(%rbp),%rax
sub    $0xea60,%rax
cvtsi2sd %rax,%xmm0
movsd  0xd4d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x38(%rbp)
jmp    1317 <main+0x1f7>
cvtsi2sdq -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%rax
sub    $0xf4240,%rax
cvtsi2sd %rax,%xmm0
movsd  0xd12(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x38(%rbp)
jmp    131c <main+0x1fc>
jmp    1321 <main+0x201>
jmp    1326 <main+0x206>
jmp    132b <main+0x20b>
mov    -0x38(%rbp),%rsi
lea    0xd15(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf20(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rax
cmp    $0x186a0,%rax
ja     114e <main+0x2e>
cvtsi2sd %rax,%xmm0
mulsd  0xef7(%rip),%xmm0
jmp    11d8 <main+0xb8>
cmp    $0x30d40,%rax
jg     1173 <main+0x53>
add    $0xfffffffffffe7960,%rax
cvtsi2sd %rax,%xmm0
mulsd  0xec7(%rip),%xmm0
addsd  0xec7(%rip),%xmm0
jmp    11d8 <main+0xb8>
cmp    $0x61a80,%rax
ja     1198 <main+0x78>
add    $0xfffffffffffcf2c0,%rax
cvtsi2sd %rax,%xmm0
mulsd  0xe92(%rip),%xmm0
addsd  0xe92(%rip),%xmm0
jmp    11d8 <main+0xb8>
cmp    $0x927c0,%rax
ja     11bd <main+0x9d>
add    $0xffffffffffff63c0,%rax
cvtsi2sd %rax,%xmm0
mulsd  0xe5d(%rip),%xmm0
addsd  0xe5d(%rip),%xmm0
jmp    11d8 <main+0xb8>
add    $0xfffffffffff0bdc0,%rax
cvtsi2sd %rax,%xmm0
mulsd  0xe30(%rip),%xmm0
addsd  0xe30(%rip),%xmm0
cvttsd2si %xmm0,%rsi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [24 x i8] c"The total bonus is: %d\0A\00"
define void @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64* %1)
store i64 10000, i64* %2
%9 = load i64, i64* %2
%10 = sitofp i64 %9 to double
%11 = fadd double %10, 7.500000e+03
%12 = fptosi double %11 to i64
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = sitofp i64 %13 to double
%15 = fadd double %14, 1.000000e+04
%16 = fptosi double %15 to i64
store i64 %16, i64* %4
%17 = load i64, i64* %4
%18 = sitofp i64 %17 to double
%19 = fadd double %18, 6.000000e+03
%20 = fptosi double %19 to i64
store i64 %20, i64* %5
%21 = load i64, i64* %5
%22 = sitofp i64 %21 to double
%23 = fadd double %22, 6.000000e+03
%24 = fptosi double %23 to i64
store i64 %24, i64* %6
%25 = load i64, i64* %1
%26 = icmp sge i64 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %0
%28 = load i64, i64* %1
%29 = icmp sle i64 %28, 100000
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i64, i64* %1
%32 = sitofp i64 %31 to double
%33 = fmul double %32, 1.000000e-01
%34 = fptosi double %33 to i64
store i64 %34, i64* %7
br label %91
35: ; preds = %27, %0
%36 = load i64, i64* %1
%37 = icmp sle i64 %36, 200000
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = load i64, i64* %2
%40 = sitofp i64 %39 to double
%41 = load i64, i64* %1
%42 = sub nsw i64 %41, 100000
%43 = sitofp i64 %42 to double
%44 = call double @llvm.fmuladd.f64(double %43, double 0x3FB3333333333333, double %40)
%45 = fptosi double %44 to i64
store i64 %45, i64* %7
br label %90
46: ; preds = %35
%47 = load i64, i64* %1
%48 = icmp sle i64 %47, 400000
br i1 %48, label %49, label %57
49: ; preds = %46
%50 = load i64, i64* %3
%51 = sitofp i64 %50 to double
%52 = load i64, i64* %1
%53 = sub nsw i64 %52, 200000
%54 = sitofp i64 %53 to double
%55 = call double @llvm.fmuladd.f64(double %54, double 5.000000e-02, double %51)
%56 = fptosi double %55 to i64
store i64 %56, i64* %7
br label %89
57: ; preds = %46
%58 = load i64, i64* %1
%59 = icmp sle i64 %58, 600000
br i1 %59, label %60, label %68
60: ; preds = %57
%61 = load i64, i64* %4
%62 = sitofp i64 %61 to double
%63 = load i64, i64* %1
%64 = sub nsw i64 %63, 40000
%65 = sitofp i64 %64 to double
%66 = call double @llvm.fmuladd.f64(double %65, double 3.000000e-02, double %62)
%67 = fptosi double %66 to i64
store i64 %67, i64* %7
br label %88
68: ; preds = %57
%69 = load i64, i64* %1
%70 = icmp sle i64 %69, 100000
br i1 %70, label %71, label %79
71: ; preds = %68
%72 = load i64, i64* %5
%73 = sitofp i64 %72 to double
%74 = load i64, i64* %1
%75 = sub nsw i64 %74, 60000
%76 = sitofp i64 %75 to double
%77 = call double @llvm.fmuladd.f64(double %76, double 1.500000e-02, double %73)
%78 = fptosi double %77 to i64
store i64 %78, i64* %7
br label %87
79: ; preds = %68
%80 = load i64, i64* %6
%81 = sitofp i64 %80 to double
%82 = load i64, i64* %1
%83 = sub nsw i64 %82, 1000000
%84 = sitofp i64 %83 to double
%85 = call double @llvm.fmuladd.f64(double %84, double 1.000000e-02, double %81)
%86 = fptosi double %85 to i64
store i64 %86, i64* %7
br label %87
87: ; preds = %79, %71
br label %88
88: ; preds = %87, %60
br label %89
89: ; preds = %88, %49
br label %90
90: ; preds = %89, %38
br label %91
91: ; preds = %90, %30
%92 = load i64, i64* %7
%93 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %92)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [24 x i8] c"The total bonus is: %d\0A\00"
define void @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* %1
%5 = icmp ult i64 %4, 100001
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = sitofp i64 %4 to double
%8 = fmul double %7, 1.000000e-01
br label %31
9: ; preds = %0
%10 = icmp slt i64 %4, 200001
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = add nsw i64 %4, -100000
%13 = sitofp i64 %12 to double
%14 = call double @llvm.fmuladd.f64(double %13, double 0x3FB3333333333333, double 1.000000e+04)
br label %31
15: ; preds = %9
%16 = icmp ult i64 %4, 400001
br i1 %16, label %17, label %21
17: ; preds = %15
%18 = add nsw i64 %4, -200000
%19 = sitofp i64 %18 to double
%20 = call double @llvm.fmuladd.f64(double %19, double 5.000000e-02, double 1.750000e+04)
br label %31
21: ; preds = %15
%22 = icmp ult i64 %4, 600001
br i1 %22, label %23, label %27
23: ; preds = %21
%24 = add nsw i64 %4, -40000
%25 = sitofp i64 %24 to double
%26 = call double @llvm.fmuladd.f64(double %25, double 3.000000e-02, double 2.750000e+04)
br label %31
27: ; preds = %21
%28 = add nsw i64 %4, -1000000
%29 = sitofp i64 %28 to double
%30 = call double @llvm.fmuladd.f64(double %29, double 1.000000e-02, double 3.950000e+04)
br label %31
31: ; preds = %11, %23, %27, %17, %6
%32 = phi double [ %8, %6 ], [ %14, %11 ], [ %20, %17 ], [ %26, %23 ], [ %30, %27 ]
%33 = fptosi double %32 to i64
%34 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %33)
ret void
}