#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() {
  int iQuantity;
  float fDiscRate, fDiscAmount, fUnitPrice, fSubTotal;
  float fSubTaxable, fTaxAm, fTotal;
  printf("\nEnter the number of items sold...\t:");
  scanf("%d", &iQuantity);
  printf("\nEnter the unit price... \t\t:");
  scanf("%f", &fUnitPrice);
  printf("\nEnter the discount rate (%%)... \t\t:");
  scanf("%f", &fDiscRate);
  fSubTotal = iQuantity * fUnitPrice;
  fDiscAmount = fSubTotal * fDiscRate / 100.0;
  fSubTaxable = fSubTotal - fDiscAmount;
  fTaxAm = fSubTaxable * 8.5 / 100.0;
  fTotal = fSubTaxable + fTaxAm;
  printf("\nQuantity sold:    \t%3d\n", iQuantity);
  printf("Unit Price of items: %9.2f\n", fUnitPrice);
  printf("                    ----------------\n");
  printf("SubTotal :           %9.2f\n", fSubTotal);
  printf("Discount :           -%8.2f\n", fDiscAmount);
  printf("Discounted total :   %9.2f\n", fSubTaxable);
  printf("Sales Tax :          +%8.2f\n", fTaxAm);
  printf("Total sales :        %9.2f\n", fTotal);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe4c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe27(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe13(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe89(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe94(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe99(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef3(%rip),%rdi
lea    0x24(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xee3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef2(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x24(%rsp),%esi
cvtsi2ss %esi,%xmm0
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x20(%rsp),%xmm1
mulss  %xmm0,%xmm1
divss  0xe43(%rip),%xmm1
movss  %xmm1,0x14(%rsp)
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,0x28(%rsp)
movaps %xmm0,%xmm1
movsd  0xe2c(%rip),%xmm0
mulsd  %xmm2,%xmm0
divsd  0xe28(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x18(%rsp)
addss  %xmm0,%xmm1
movss  %xmm1,0x1c(%rsp)
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe83(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xf1f(%rip),%rdi
call   1030 <puts@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
movsd  0x28(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe91(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"\0AEnter the number of items sold...\09:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\0AEnter the unit price... \09\09:\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [37 x i8] c"\0AEnter the discount rate (%%)... \09\09:\00"
@.str.5 = [25 x i8] c"\0AQuantity sold: \09%3d\0A\00"
@.str.6 = [28 x i8] c"Unit Price of items: %9.2f\0A\00"
@.str.7 = [38 x i8] c" ----------------\0A\00"
@.str.8 = [28 x i8] c"SubTotal : %9.2f\0A\00"
@.str.9 = [29 x i8] c"Discount : -%8.2f\0A\00"
@.str.10 = [28 x i8] c"Discounted total : %9.2f\0A\00"
@.str.11 = [29 x i8] c"Sales Tax : +%8.2f\0A\00"
@.str.12 = [28 x i8] c"Total sales : %9.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%16 = load i32, i32* %2
%17 = sitofp i32 %16 to float
%18 = load float, float* %5
%19 = fmul float %17, %18
store float %19, float* %6
%20 = load float, float* %6
%21 = load float, float* %3
%22 = fmul float %20, %21
%23 = fpext float %22 to double
%24 = fdiv double %23, 1.000000e+02
%25 = fptrunc double %24 to float
store float %25, float* %4
%26 = load float, float* %6
%27 = load float, float* %4
%28 = fsub float %26, %27
store float %28, float* %7
%29 = load float, float* %7
%30 = fpext float %29 to double
%31 = fmul double %30, 8.500000e+00
%32 = fdiv double %31, 1.000000e+02
%33 = fptrunc double %32 to float
store float %33, float* %8
%34 = load float, float* %7
%35 = load float, float* %8
%36 = fadd float %34, %35
store float %36, float* %9
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %37)
%39 = load float, float* %5
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), double %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
%43 = load float, float* %6
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), double %44)
%46 = load float, float* %4
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), double %47)
%49 = load float, float* %7
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), double %50)
%52 = load float, float* %8
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), double %53)
%55 = load float, float* %9
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0), double %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"\0AEnter the number of items sold...\09:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\0AEnter the unit price... \09\09:\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [37 x i8] c"\0AEnter the discount rate (%%)... \09\09:\00"
@.str.5 = [25 x i8] c"\0AQuantity sold: \09%3d\0A\00"
@.str.6 = [28 x i8] c"Unit Price of items: %9.2f\0A\00"
@.str.8 = [28 x i8] c"SubTotal : %9.2f\0A\00"
@.str.9 = [29 x i8] c"Discount : -%8.2f\0A\00"
@.str.10 = [28 x i8] c"Discounted total : %9.2f\0A\00"
@.str.11 = [29 x i8] c"Sales Tax : +%8.2f\0A\00"
@.str.12 = [28 x i8] c"Total sales : %9.2f\0A\00"
@str = [37 x i8] c" ----------------\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = bitcast i32* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%13 = load i32, i32* %1
%14 = sitofp i32 %13 to float
%15 = load float, float* %3
%16 = fmul float %15, %14
%17 = load float, float* %2
%18 = fmul float %16, %17
%19 = fdiv float %18, 1.000000e+02
%20 = fsub float %16, %19
%21 = fpext float %20 to double
%22 = fmul double %21, 8.500000e+00
%23 = fdiv double %22, 1.000000e+02
%24 = fptrunc double %23 to float
%25 = fadd float %20, %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %13)
%27 = load float, float* %3
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), double %28)
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%31 = fpext float %16 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), double %31)
%33 = fpext float %19 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), double %33)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), double %21)
%36 = fpext float %24 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), double %36)
%38 = fpext float %25 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0), double %38)
ret i32 0
}