#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 *, int *);
int main() {
  int i;
  double bonus, bon1, bon2, bon4, bon6, bon10;
  int branch;
  bon1 = 100000 * 0.1;
  bon2 = bon1 + 100000 * 0.075;
  bon4 = bon2 + 200000 * 0.05;
  bon6 = bon4 + 200000 * 0.03;
  bon10 = bon6 + 400000 * 0.015;
  printf("请输入利润：");
  scanf("%d", &i);
  branch = i / 100000;
  if (branch > 10)
    branch = 10;
  switch (branch) {
  case 0:
    bonus = i * 0.1;
    break;
  case 1:
    bonus = bon1 + (i - 100000) * 0.075;
    break;
  case 2:
  case 3:
    bonus = bon2 + (i - 200000) * 0.05;
    break;
  case 4:
  case 6:
    bonus = bon4 + (i - 400000) * 0.03;
    break;
  case 7:
  case 8:
  case 9:
    bonus = bon6 + (i - 600000) * 0.015;
    break;
  case 10:
    bonus = bon10 + (i - 1000000) * 0.01;
    break;
  }
  printf("奖金是%10.2f\n", bonus);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xecc(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb2(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe98(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe86(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0x186a0,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jle    11c1 <main+0xa1>
movl   $0xa,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0xa,%rax
ja     12d3 <main+0x1b3>
mov    -0x48(%rbp),%rax
lea    0xe6b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    12d3 <main+0x1b3>
movsd  -0x18(%rbp),%xmm1
mov    -0x8(%rbp),%eax
sub    $0x186a0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe1e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    12d3 <main+0x1b3>
movsd  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%eax
sub    $0x30d40,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdeb(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    12d3 <main+0x1b3>
movsd  -0x28(%rbp),%xmm1
mov    -0x8(%rbp),%eax
sub    $0x61a80,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdb8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    12d3 <main+0x1b3>
movsd  -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%eax
sub    $0x927c0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd85(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    12d3 <main+0x1b3>
movsd  -0x38(%rbp),%xmm1
mov    -0x8(%rbp),%eax
sub    $0xf4240,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd52(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xdab(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf5c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf61(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rax
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2d,%rcx
add    %edx,%ecx
cmp    $0xa,%ecx
mov    $0xa,%edx
cmovl  %ecx,%edx
lea    0xeed(%rip),%rcx
movslq (%rcx,%rdx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
add    $0xfff6d840,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe8b(%rip),%xmm0
addsd  0xe8b(%rip),%xmm0
jmp    1207 <main+0xe7>
add    $0xfff9e580,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe80(%rip),%xmm0
addsd  0xe80(%rip),%xmm0
jmp    1207 <main+0xe7>
add    $0xfffcf2c0,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe75(%rip),%xmm0
addsd  0xe75(%rip),%xmm0
jmp    1207 <main+0xe7>
add    $0xfff0bdc0,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe2a(%rip),%xmm0
addsd  0xe2a(%rip),%xmm0
jmp    1207 <main+0xe7>
cvtsi2sd %eax,%xmm0
mulsd  0xe64(%rip),%xmm0
jmp    1207 <main+0xe7>
add    $0xfffe7960,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe41(%rip),%xmm0
addsd  0xe41(%rip),%xmm0
lea    0xe8c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\88\A9\E6\B6\A6\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"\E5\A5\96\E9\87\91\E6\98\AF%10.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i32 0, i32* %1
store double 1.000000e+04, double* %4
%10 = load double, double* %4
%11 = fadd double %10, 7.500000e+03
store double %11, double* %5
%12 = load double, double* %5
%13 = fadd double %12, 1.000000e+04
store double %13, double* %6
%14 = load double, double* %6
%15 = fadd double %14, 6.000000e+03
store double %15, double* %7
%16 = load double, double* %7
%17 = fadd double %16, 6.000000e+03
store double %17, double* %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 100000
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = icmp sgt i32 %22, 10
br i1 %23, label %24, label %25
24: ; preds = %0
store i32 10, i32* %9
br label %25
25: ; preds = %24, %0
%26 = load i32, i32* %9
switch i32 %26, label %61 [
i32 0, label %27
i32 1, label %31
i32 2, label %37
i32 3, label %37
i32 4, label %43
i32 6, label %43
i32 7, label %49
i32 8, label %49
i32 9, label %49
i32 10, label %55
]
27: ; preds = %25
%28 = load i32, i32* %2
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 1.000000e-01
store double %30, double* %3
br label %61
31: ; preds = %25
%32 = load double, double* %4
%33 = load i32, i32* %2
%34 = sub nsw i32 %33, 100000
%35 = sitofp i32 %34 to double
%36 = call double @llvm.fmuladd.f64(double %35, double 0x3FB3333333333333, double %32)
store double %36, double* %3
br label %61
37: ; preds = %25, %25
%38 = load double, double* %5
%39 = load i32, i32* %2
%40 = sub nsw i32 %39, 200000
%41 = sitofp i32 %40 to double
%42 = call double @llvm.fmuladd.f64(double %41, double 5.000000e-02, double %38)
store double %42, double* %3
br label %61
43: ; preds = %25, %25
%44 = load double, double* %6
%45 = load i32, i32* %2
%46 = sub nsw i32 %45, 400000
%47 = sitofp i32 %46 to double
%48 = call double @llvm.fmuladd.f64(double %47, double 3.000000e-02, double %44)
store double %48, double* %3
br label %61
49: ; preds = %25, %25, %25
%50 = load double, double* %7
%51 = load i32, i32* %2
%52 = sub nsw i32 %51, 600000
%53 = sitofp i32 %52 to double
%54 = call double @llvm.fmuladd.f64(double %53, double 1.500000e-02, double %50)
store double %54, double* %3
br label %61
55: ; preds = %25
%56 = load double, double* %8
%57 = load i32, i32* %2
%58 = sub nsw i32 %57, 1000000
%59 = sitofp i32 %58 to double
%60 = call double @llvm.fmuladd.f64(double %59, double 1.000000e-02, double %56)
store double %60, double* %3
br label %61
61: ; preds = %25, %55, %49, %43, %37, %31, %27
%62 = load double, double* %3
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\88\A9\E6\B6\A6\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"\E5\A5\96\E9\87\91\E6\98\AF%10.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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), i32* %1)
%5 = load i32, i32* %1
%6 = sdiv i32 %5, 100000
%7 = icmp slt i32 %6, 10
%8 = select i1 %7, i32 %6, i32 10
switch i32 %8, label %32 [
i32 0, label %9
i32 1, label %12
i32 2, label %16
i32 3, label %16
i32 4, label %20
i32 6, label %20
i32 7, label %24
i32 8, label %24
i32 9, label %24
i32 10, label %28
]
9: ; preds = %0
%10 = sitofp i32 %5 to double
%11 = fmul double %10, 1.000000e-01
br label %33
12: ; preds = %0
%13 = add nsw i32 %5, -100000
%14 = sitofp i32 %13 to double
%15 = call double @llvm.fmuladd.f64(double %14, double 0x3FB3333333333333, double 1.000000e+04)
br label %33
16: ; preds = %0, %0
%17 = add nsw i32 %5, -200000
%18 = sitofp i32 %17 to double
%19 = call double @llvm.fmuladd.f64(double %18, double 5.000000e-02, double 1.750000e+04)
br label %33
20: ; preds = %0, %0
%21 = add nsw i32 %5, -400000
%22 = sitofp i32 %21 to double
%23 = call double @llvm.fmuladd.f64(double %22, double 3.000000e-02, double 2.750000e+04)
br label %33
24: ; preds = %0, %0, %0
%25 = add nsw i32 %5, -600000
%26 = sitofp i32 %25 to double
%27 = call double @llvm.fmuladd.f64(double %26, double 1.500000e-02, double 3.350000e+04)
br label %33
28: ; preds = %0
%29 = add nsw i32 %5, -1000000
%30 = sitofp i32 %29 to double
%31 = call double @llvm.fmuladd.f64(double %30, double 1.000000e-02, double 3.950000e+04)
br label %33
32: ; preds = %0
unreachable
33: ; preds = %28, %24, %20, %16, %12, %9
%34 = phi double [ %31, %28 ], [ %27, %24 ], [ %23, %20 ], [ %19, %16 ], [ %15, %12 ], [ %11, %9 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %34)
ret i32 0
}