#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 p, n;
  float d, amt;
  printf("Type: (1 For Mild Cloth) (2 For Handloom Items): ");
  scanf("%d", &n);
  printf("Enter the Price of The Article: ");
  scanf("%d", &p);
  if (n == 1) {
    if (p <= 100)
      d = 0;
    else if (p <= 200)
      d = 5;
    else if (p <= 300)
      d = 7.5;
    else
      d = 10;
  }
  if (n == 2) {
    if (p <= 100)
      d = 5;
    else if (p <= 200)
      d = 7.5;
    else if (p <= 300)
      d = 10;
    else
      d = 15;
  }
  amt = p - (p * d) / 100;
  printf("Amount to Be Paid: %.2f \nAfter a Discount of %.2f% \n", amt, d);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xef5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11e6 <main+0xc6>
cmpl   $0x64,-0x8(%rbp)
jg     118c <main+0x6c>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11e1 <main+0xc1>
cmpl   $0xc8,-0x8(%rbp)
jg     11ab <main+0x8b>
movss  0xe67(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11dc <main+0xbc>
cmpl   $0x12c,-0x8(%rbp)
jg     11ca <main+0xaa>
movss  0xe44(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11d7 <main+0xb7>
movss  0xe2e(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11dc <main+0xbc>
jmp    11e1 <main+0xc1>
jmp    11e6 <main+0xc6>
cmpl   $0x2,-0xc(%rbp)
jne    1266 <main+0x146>
cmpl   $0x64,-0x8(%rbp)
jg     120c <main+0xec>
movss  0xe06(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1261 <main+0x141>
cmpl   $0xc8,-0x8(%rbp)
jg     122b <main+0x10b>
movss  0xde3(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    125c <main+0x13c>
cmpl   $0x12c,-0x8(%rbp)
jg     124a <main+0x12a>
movss  0xdc0(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1257 <main+0x137>
movss  0xdba(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    125c <main+0x13c>
jmp    1261 <main+0x141>
jmp    1266 <main+0x146>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
movss  0xd93(%rip),%xmm2
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdc7(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xef0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf14(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xf03(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     118a <main+0x6a>
cmp    $0x2,%eax
jne    11a7 <main+0x87>
mov    0x8(%rsp),%eax
cmp    $0x65,%eax
jl     119d <main+0x7d>
cmp    $0xc9,%eax
jae    11ad <main+0x8d>
movss  0xe7c(%rip),%xmm0
jmp    11d6 <main+0xb6>
mov    0x8(%rsp),%eax
xorps  %xmm0,%xmm0
cmp    $0x65,%eax
jl     11d6 <main+0xb6>
cmp    $0xc9,%eax
jae    11c0 <main+0xa0>
movss  0xe5b(%rip),%xmm0
jmp    11d6 <main+0xb6>
mov    0x8(%rsp),%eax
jmp    11d6 <main+0xb6>
xor    %ecx,%ecx
cmp    $0x12d,%eax
setb   %cl
lea    0xe4e(%rip),%rdx
jmp    11d1 <main+0xb1>
xor    %ecx,%ecx
cmp    $0x12d,%eax
setb   %cl
lea    0xe43(%rip),%rdx
movss  (%rdx,%rcx,4),%xmm0
cvtsi2ss %eax,%xmm2
cvtss2sd %xmm0,%xmm1
mulss  %xmm2,%xmm0
divss  0xe1e(%rip),%xmm0
addss  %xmm2,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe79(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Type: (1 For Mild Cloth) (2 For Handloom Items): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Enter the Price of The Article: \00"
@.str.3 = [53 x i8] c"Amount to Be Paid: %.2f \0AAfter a Discount of %.2f% \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 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), i32* %3)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %28
12: ; preds = %0
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 100
br i1 %14, label %15, label %16
15: ; preds = %12
store float 0.000000e+00, float* %4
br label %27
16: ; preds = %12
%17 = load i32, i32* %2
%18 = icmp sle i32 %17, 200
br i1 %18, label %19, label %20
19: ; preds = %16
store float 5.000000e+00, float* %4
br label %26
20: ; preds = %16
%21 = load i32, i32* %2
%22 = icmp sle i32 %21, 300
br i1 %22, label %23, label %24
23: ; preds = %20
store float 7.500000e+00, float* %4
br label %25
24: ; preds = %20
store float 1.000000e+01, float* %4
br label %25
25: ; preds = %24, %23
br label %26
26: ; preds = %25, %19
br label %27
27: ; preds = %26, %15
br label %28
28: ; preds = %27, %0
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 2
br i1 %30, label %31, label %47
31: ; preds = %28
%32 = load i32, i32* %2
%33 = icmp sle i32 %32, 100
br i1 %33, label %34, label %35
34: ; preds = %31
store float 5.000000e+00, float* %4
br label %46
35: ; preds = %31
%36 = load i32, i32* %2
%37 = icmp sle i32 %36, 200
br i1 %37, label %38, label %39
38: ; preds = %35
store float 7.500000e+00, float* %4
br label %45
39: ; preds = %35
%40 = load i32, i32* %2
%41 = icmp sle i32 %40, 300
br i1 %41, label %42, label %43
42: ; preds = %39
store float 1.000000e+01, float* %4
br label %44
43: ; preds = %39
store float 1.500000e+01, float* %4
br label %44
44: ; preds = %43, %42
br label %45
45: ; preds = %44, %38
br label %46
46: ; preds = %45, %34
br label %47
47: ; preds = %46, %28
%48 = load i32, i32* %2
%49 = sitofp i32 %48 to float
%50 = load i32, i32* %2
%51 = sitofp i32 %50 to float
%52 = load float, float* %4
%53 = fmul float %51, %52
%54 = fdiv float %53, 1.000000e+02
%55 = fsub float %49, %54
store float %55, float* %5
%56 = load float, float* %5
%57 = fpext float %56 to double
%58 = load float, float* %4
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), double %57, double %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"Type: (1 For Mild Cloth) (2 For Handloom Items): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Enter the Price of The Article: \00"
@.str.3 = [53 x i8] c"Amount to Be Paid: %.2f \0AAfter a Discount of %.2f% \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %2
switch i32 %9, label %10 [
i32 1, label %12
i32 2, label %20
]
10: ; preds = %0
%11 = load i32, i32* %1
br label %28
12: ; preds = %0
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 101
br i1 %14, label %28, label %15
15: ; preds = %12
%16 = icmp ult i32 %13, 201
br i1 %16, label %28, label %17
17: ; preds = %15
%18 = icmp ult i32 %13, 301
%19 = select i1 %18, float 7.500000e+00, float 1.000000e+01
br label %28
20: ; preds = %0
%21 = load i32, i32* %1
%22 = icmp slt i32 %21, 101
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = icmp ult i32 %21, 201
br i1 %24, label %28, label %25
25: ; preds = %23
%26 = icmp ult i32 %21, 301
%27 = select i1 %26, float 1.000000e+01, float 1.500000e+01
br label %28
28: ; preds = %10, %12, %15, %17, %25, %23, %20
%29 = phi i32 [ %21, %20 ], [ %21, %23 ], [ %21, %25 ], [ %13, %17 ], [ %13, %15 ], [ %13, %12 ], [ %11, %10 ]
%30 = phi float [ 5.000000e+00, %20 ], [ 7.500000e+00, %23 ], [ %27, %25 ], [ %19, %17 ], [ 5.000000e+00, %15 ], [ 0.000000e+00, %12 ], [ undef, %10 ]
%31 = sitofp i32 %29 to float
%32 = fmul float %30, %31
%33 = fdiv float %32, 1.000000e+02
%34 = fsub float %31, %33
%35 = fpext float %34 to double
%36 = fpext float %30 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), double %35, double %36)
ret i32 0
}