#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() {
  const float TAX_RATE = 0.065;
  float price = 0;
  unsigned short int quantity = 0, taxed = 0;
  printf("Enter the price of your item:\n> ");
  scanf("%f", &price);
  printf("Enter the quantity of the item you are buying:\n> ");
  scanf("%hd", &quantity);
  printf("Is this item taxed?\n> ");
  scanf("%hd", &taxed);
  float total = price * quantity;
  total += total * TAX_RATE * taxed;
  printf("Your total purchase will cost $%.2f.\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movw   $0x0,-0xe(%rbp)
movw   $0x0,-0x10(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0xe(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movzwl -0xe(%rbp),%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe32(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movzwl -0x10(%rbp),%eax
cvtsi2ss %eax,%xmm2
movss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe78(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movw   $0x0,0xa(%rsp)
movw   $0x0,0x8(%rsp)
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee9(%rip),%rbx
lea    0xa(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
movzwl 0xa(%rsp),%eax
cvtsi2ss %eax,%xmm0
mulss  0xc(%rsp),%xmm0
movss  0xe4c(%rip),%xmm1
movzwl 0x8(%rsp),%eax
cvtsi2ss %eax,%xmm2
mulss  %xmm0,%xmm1
mulss  %xmm1,%xmm2
addss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe9e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter the price of your item:\0A> \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [50 x i8] c"Enter the quantity of the item you are buying:\0A> \00"
@.str.3 = [4 x i8] c"%hd\00"
@.str.4 = [23 x i8] c"Is this item taxed?\0A> \00"
@.str.5 = [38 x i8] c"Your total purchase will cost $%.2f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i16
%5 = alloca i16
%6 = alloca float
store i32 0, i32* %1
store float 0x3FB0A3D700000000, float* %2
store float 0.000000e+00, float* %3
store i16 0, i16* %4
store i16 0, i16* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 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), float* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %4)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %5)
%13 = load float, float* %3
%14 = load i16, i16* %4
%15 = zext i16 %14 to i32
%16 = sitofp i32 %15 to float
%17 = fmul float %13, %16
store float %17, float* %6
%18 = load float, float* %6
%19 = fmul float %18, 0x3FB0A3D700000000
%20 = load i16, i16* %5
%21 = zext i16 %20 to i32
%22 = sitofp i32 %21 to float
%23 = load float, float* %6
%24 = call float @llvm.fmuladd.f32(float %19, float %22, float %23)
store float %24, float* %6
%25 = load float, float* %6
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), double %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter the price of your item:\0A> \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [50 x i8] c"Enter the quantity of the item you are buying:\0A> \00"
@.str.3 = [4 x i8] c"%hd\00"
@.str.4 = [23 x i8] c"Is this item taxed?\0A> \00"
@.str.5 = [38 x i8] c"Your total purchase will cost $%.2f.\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i16
%3 = alloca i16
%4 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%5 = bitcast i16* %2 to i8*
store i16 0, i16* %2
%6 = bitcast i16* %3 to i8*
store i16 0, i16* %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 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), float* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %3)
%13 = load float, float* %1
%14 = load i16, i16* %2
%15 = uitofp i16 %14 to float
%16 = fmul float %13, %15
%17 = fmul float %16, 0x3FB0A3D700000000
%18 = load i16, i16* %3
%19 = uitofp i16 %18 to float
%20 = call float @llvm.fmuladd.f32(float %17, float %19, float %16)
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), double %21)
ret i32 0
}