#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, weight = 0, costPerPound = 0.99;
  unsigned short quantity = 0, taxed = 0;
  printf("Enter the price of the item (in dollars):\n> ");
  scanf("%f", &price);
  printf("Enter the weight of the item (in pounds):\n> ");
  scanf("%f", &weight);
  printf("Enter the quantity of the item you are buying:\n> ");
  scanf("%hd", &quantity);
  printf("Is this item taxed (1 = yes, 0 = no)?\n> ");
  scanf("%hd", &taxed);
  weight *= quantity;
  if (weight < 10)
    costPerPound = 4;
  else if (weight < 30)
    costPerPound = 2.5;
  else if (weight < 50)
    costPerPound = 1.5;
  float total = price * quantity + weight * costPerPound;
  total += total * TAX_RATE * taxed;
  printf("Your total purchase, with shipping, 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  0xed1(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeb0(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movw   $0x0,-0x16(%rbp)
movw   $0x0,-0x18(%rbp)
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
lea    -0x16(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movzwl -0x16(%rbp),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe01(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    121b <main+0xfb>
movss  0xe0b(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1268 <main+0x148>
movss  0xde9(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    123f <main+0x11f>
movss  0xde3(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1263 <main+0x143>
movss  0xdc9(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    125e <main+0x13e>
movss  0xdbb(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1263 <main+0x143>
jmp    1268 <main+0x148>
movss  -0xc(%rbp),%xmm0
movzwl -0x16(%rbp),%eax
cvtsi2ss %eax,%xmm2
movss  -0x10(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xd74(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movzwl -0x18(%rbp),%eax
cvtsi2ss %eax,%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe19(%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)
movl   $0x0,0x8(%rsp)
movw   $0x0,0x6(%rsp)
movw   $0x0,0x4(%rsp)
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef5(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xee2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xef2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf16(%rip),%rbx
lea    0x6(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf04(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
movzwl 0x6(%rsp),%eax
cvtsi2ss %eax,%xmm0
movss  0x8(%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  0xe1e(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    11f5 <main+0xd5>
movss  0xe0d(%rip),%xmm2
jmp    122b <main+0x10b>
movss  0xe0f(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    120c <main+0xec>
movss  0xdfe(%rip),%xmm2
jmp    122b <main+0x10b>
movss  0xe00(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    1223 <main+0x103>
movss  0xdf7(%rip),%xmm2
jmp    122b <main+0x10b>
movss  0xde5(%rip),%xmm2
mulss  %xmm2,%xmm1
mulss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  0xddb(%rip),%xmm1
movzwl 0x4(%rsp),%eax
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
mulss  %xmm0,%xmm1
mulss  %xmm1,%xmm2
addss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Enter the price of the item (in dollars):\0A> \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [45 x i8] c"Enter the weight of the item (in pounds):\0A> \00"
@.str.3 = [50 x i8] c"Enter the quantity of the item you are buying:\0A> \00"
@.str.4 = [4 x i8] c"%hd\00"
@.str.5 = [41 x i8] c"Is this item taxed (1 = yes, 0 = no)?\0A> \00"
@.str.6 = [54 x i8] c"Your total purchase, with shipping, will cost $%.2f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i16
%7 = alloca i16
%8 = alloca float
store i32 0, i32* %1
store float 0x3FB0A3D700000000, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0x3FEFAE1480000000, float* %5
store i16 0, i16* %6
store i16 0, i16* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i16* %6)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i16* %7)
%17 = load i16, i16* %6
%18 = zext i16 %17 to i32
%19 = sitofp i32 %18 to float
%20 = load float, float* %4
%21 = fmul float %20, %19
store float %21, float* %4
%22 = load float, float* %4
%23 = fcmp olt float %22, 1.000000e+01
br i1 %23, label %24, label %25
24: ; preds = %0
store float 4.000000e+00, float* %5
br label %35
25: ; preds = %0
%26 = load float, float* %4
%27 = fcmp olt float %26, 3.000000e+01
br i1 %27, label %28, label %29
28: ; preds = %25
store float 2.500000e+00, float* %5
br label %34
29: ; preds = %25
%30 = load float, float* %4
%31 = fcmp olt float %30, 5.000000e+01
br i1 %31, label %32, label %33
32: ; preds = %29
store float 1.500000e+00, float* %5
br label %33
33: ; preds = %32, %29
br label %34
34: ; preds = %33, %28
br label %35
35: ; preds = %34, %24
%36 = load float, float* %3
%37 = load i16, i16* %6
%38 = zext i16 %37 to i32
%39 = sitofp i32 %38 to float
%40 = load float, float* %4
%41 = load float, float* %5
%42 = fmul float %40, %41
%43 = call float @llvm.fmuladd.f32(float %36, float %39, float %42)
store float %43, float* %8
%44 = load float, float* %8
%45 = fmul float %44, 0x3FB0A3D700000000
%46 = load i16, i16* %7
%47 = zext i16 %46 to i32
%48 = sitofp i32 %47 to float
%49 = load float, float* %8
%50 = call float @llvm.fmuladd.f32(float %45, float %48, float %49)
store float %50, float* %8
%51 = load float, float* %8
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), double %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [45 x i8] c"Enter the price of the item (in dollars):\0A> \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [45 x i8] c"Enter the weight of the item (in pounds):\0A> \00"
@.str.3 = [50 x i8] c"Enter the quantity of the item you are buying:\0A> \00"
@.str.4 = [4 x i8] c"%hd\00"
@.str.5 = [41 x i8] c"Is this item taxed (1 = yes, 0 = no)?\0A> \00"
@.str.6 = [54 x i8] c"Your total purchase, with shipping, will cost $%.2f.\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i16
%4 = alloca i16
%5 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%6 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%7 = bitcast i16* %3 to i8*
store i16 0, i16* %3
%8 = bitcast i16* %4 to i8*
store i16 0, i16* %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i16* %3)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i16* %4)
%17 = load i16, i16* %3
%18 = uitofp i16 %17 to float
%19 = load float, float* %2
%20 = fmul float %19, %18
store float %20, float* %2
%21 = fcmp olt float %20, 1.000000e+01
br i1 %21, label %27, label %22
22: ; preds = %0
%23 = fcmp olt float %20, 3.000000e+01
br i1 %23, label %27, label %24
24: ; preds = %22
%25 = fcmp olt float %20, 5.000000e+01
br i1 %25, label %26, label %27
26: ; preds = %24
br label %27
27: ; preds = %22, %0, %26, %24
%28 = phi float [ 1.500000e+00, %26 ], [ 0x3FEFAE1480000000, %24 ], [ 4.000000e+00, %0 ], [ 2.500000e+00, %22 ]
%29 = load float, float* %1
%30 = fmul float %20, %28
%31 = call float @llvm.fmuladd.f32(float %29, float %18, float %30)
%32 = fmul float %31, 0x3FB0A3D700000000
%33 = load i16, i16* %4
%34 = uitofp i16 %33 to float
%35 = call float @llvm.fmuladd.f32(float %32, float %34, float %31)
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), double %36)
ret i32 0
}