#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 main(void) {
  char item;
  int commission, sale;
  printf("Choose an item: A or B: ");
  scanf("%c", &item);
  printf("\nEnter the value of your sales: ");
  scanf("%d", &sale);
  if (item == 'A') {
    if (sale <= 2000)
      commission = sale * 0.06;
    else
      commission = 2000 * 0.06 + (sale - 2000) * 0.07;
  } else {
    if (sale <= 4000)
      commission = sale * 0.1;
    else
      commission = 4000 * 0.1 + (sale - 4000) * 0.12;
  }
  printf("\nReport: Your commission is Rs.%d for the sale of an item %c with "
         "sale value Rs.%d",
         commission, item, sale);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf59(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jne    11d6 <main+0xb6>
cmpl   $0x7d0,-0x10(%rbp)
jg     11a6 <main+0x86>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe92(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
jmp    11d1 <main+0xb1>
mov    -0x10(%rbp),%eax
sub    $0x7d0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe5e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe5a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
jmp    1230 <main+0x110>
cmpl   $0xfa0,-0x10(%rbp)
jg     1200 <main+0xe0>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe20(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
jmp    122b <main+0x10b>
mov    -0x10(%rbp),%eax
sub    $0xfa0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdec(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xde8(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
jmp    1230 <main+0x110>
mov    -0xc(%rbp),%esi
movsbl -0x5(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf08(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf03(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf66(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsbl 0x3(%rsp),%edx
mov    0x4(%rsp),%ecx
cmp    $0x41,%edx
jne    1187 <main+0x67>
cmp    $0x7d0,%ecx
jg     119d <main+0x7d>
cvtsi2sd %ecx,%xmm0
mulsd  0xea3(%rip),%xmm0
jmp    11d3 <main+0xb3>
cmp    $0xfa0,%ecx
jg     11b9 <main+0x99>
cvtsi2sd %ecx,%xmm0
mulsd  0xe75(%rip),%xmm0
jmp    11d3 <main+0xb3>
lea    -0x7d0(%rcx),%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe69(%rip),%xmm0
addsd  0xe69(%rip),%xmm0
jmp    11d3 <main+0xb3>
lea    -0xfa0(%rcx),%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe35(%rip),%xmm0
addsd  0xe35(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Choose an item: A or B: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [33 x i8] c"\0AEnter the value of your sales: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [83 x i8] c"\0AReport: Your commission is Rs.%d for the sale of an item %c with sale value Rs.%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 65
br i1 %11, label %12, label %27
12: ; preds = %0
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 2000
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 6.000000e-02
%19 = fptosi double %18 to i32
store i32 %19, i32* %3
br label %26
20: ; preds = %12
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 2000
%23 = sitofp i32 %22 to double
%24 = call double @llvm.fmuladd.f64(double %23, double 7.000000e-02, double 1.200000e+02)
%25 = fptosi double %24 to i32
store i32 %25, i32* %3
br label %26
26: ; preds = %20, %15
br label %42
27: ; preds = %0
%28 = load i32, i32* %4
%29 = icmp sle i32 %28, 4000
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* %4
%32 = sitofp i32 %31 to double
%33 = fmul double %32, 1.000000e-01
%34 = fptosi double %33 to i32
store i32 %34, i32* %3
br label %41
35: ; preds = %27
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, 4000
%38 = sitofp i32 %37 to double
%39 = call double @llvm.fmuladd.f64(double %38, double 1.200000e-01, double 4.000000e+02)
%40 = fptosi double %39 to i32
store i32 %40, i32* %3
br label %41
41: ; preds = %35, %30
br label %42
42: ; preds = %41, %26
%43 = load i32, i32* %3
%44 = load i8, i8* %2
%45 = sext i8 %44 to i32
%46 = load i32, i32* %4
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.4, i64 0, i64 0), i32 %43, i32 %45, i32 %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Choose an item: A or B: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [33 x i8] c"\0AEnter the value of your sales: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [83 x i8] c"\0AReport: Your commission is Rs.%d for the sale of an item %c with sale value Rs.%d\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 65
%10 = load i32, i32* %2
br i1 %9, label %11, label %20
11: ; preds = %0
%12 = icmp slt i32 %10, 2001
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = sitofp i32 %10 to double
%15 = fmul double %14, 6.000000e-02
br label %29
16: ; preds = %11
%17 = add nsw i32 %10, -2000
%18 = sitofp i32 %17 to double
%19 = call double @llvm.fmuladd.f64(double %18, double 7.000000e-02, double 1.200000e+02)
br label %29
20: ; preds = %0
%21 = icmp slt i32 %10, 4001
br i1 %21, label %22, label %25
22: ; preds = %20
%23 = sitofp i32 %10 to double
%24 = fmul double %23, 1.000000e-01
br label %29
25: ; preds = %20
%26 = add nsw i32 %10, -4000
%27 = sitofp i32 %26 to double
%28 = call double @llvm.fmuladd.f64(double %27, double 1.200000e-01, double 4.000000e+02)
br label %29
29: ; preds = %22, %25, %13, %16
%30 = phi double [ %15, %13 ], [ %19, %16 ], [ %24, %22 ], [ %28, %25 ]
%31 = fptosi double %30 to i32
%32 = sext i8 %8 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %32, i32 %10)
ret i32 0
}