#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 item1_quantity, item2_quantity;
  float item1_price, item2_price;
  float tax_rate;
  printf("What is the quantity of item 1?\n");
  scanf(" %d", &item1_quantity);
  printf("What is the price of item 1?\n$");
  scanf(" %f", &item1_price);
  printf("What is the quantity of item 2?\n");
  scanf(" %d", &item2_quantity);
  printf("What is the price of item 2?\n$");
  scanf(" %f", &item2_price);
  printf("What is the tax rate for item1?(as percentage)\n");
  scanf(" %f", &tax_rate);
  float item1_total = item1_quantity * item1_price;
  float item2_total = item2_quantity * item2_price;
  float tax_total = (item1_total + item2_total) * tax_rate / 100;
  float total_cost = tax_total + item1_total + item2_total;
  printf("\n\t%s\n", "Tru Inc.");
  printf("Invoice #%d\n\n", 2313270);
  printf("Item1: %d @ $%.2f per item\t$%.2f\n", item1_quantity, item1_price,
         item1_total);
  printf("Item2: %d @ $%.2f per item\t$%.2f\n", item2_quantity, item2_price,
         item2_total);
  printf("Tax rate:\t%.2f%%\n", tax_rate);
  printf("Tax amount:\t%.2f\n", tax_total);
  printf("Total cost:\t%.2f\n", total_cost);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe84(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  0xdfc(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
lea    0xe94(%rip),%rdi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x234c36,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe74(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe73(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe79(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xfa3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%r14
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf7d(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf65(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
cvtsi2ssl 0x14(%rsp),%xmm0
cvtsi2ssl 0x10(%rsp),%xmm2
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0x18(%rsp)
mulss  0x8(%rsp),%xmm2
movss  %xmm2,0x1c(%rsp)
movaps %xmm0,%xmm1
addss  %xmm2,%xmm1
mulss  0x4(%rsp),%xmm1
divss  0xdf7(%rip),%xmm1
movss  %xmm1,0x20(%rsp)
addss  %xmm1,%xmm0
addss  %xmm2,%xmm0
movss  %xmm0,0x24(%rsp)
lea    0xe26(%rip),%rdi
lea    0xe25(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe20(%rip),%rdi
mov    $0x234c36,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x18(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe03(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x1c(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdff(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe09(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe03(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x24(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"What is the quantity of item 1?\0A\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [31 x i8] c"What is the price of item 1?\0A$\00"
@.str.3 = [4 x i8] c" %f\00"
@.str.4 = [33 x i8] c"What is the quantity of item 2?\0A\00"
@.str.5 = [31 x i8] c"What is the price of item 2?\0A$\00"
@.str.6 = [48 x i8] c"What is the tax rate for item1?(as percentage)\0A\00"
@.str.7 = [6 x i8] c"\0A\09%s\0A\00"
@.str.8 = [9 x i8] c"Tru Inc.\00"
@.str.9 = [14 x i8] c"Invoice #%d\0A\0A\00"
@.str.10 = [34 x i8] c"Item1: %d @ $%.2f per item\09$%.2f\0A\00"
@.str.11 = [34 x i8] c"Item2: %d @ $%.2f per item\09$%.2f\0A\00"
@.str.12 = [18 x i8] c"Tax rate:\09%.2f%%\0A\00"
@.str.13 = [18 x i8] c"Tax amount:\09%.2f\0A\00"
@.str.14 = [18 x i8] c"Total cost:\09%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), float* %4)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), float* %5)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), float* %6)
%21 = load i32, i32* %2
%22 = sitofp i32 %21 to float
%23 = load float, float* %4
%24 = fmul float %22, %23
store float %24, float* %7
%25 = load i32, i32* %3
%26 = sitofp i32 %25 to float
%27 = load float, float* %5
%28 = fmul float %26, %27
store float %28, float* %8
%29 = load float, float* %7
%30 = load float, float* %8
%31 = fadd float %29, %30
%32 = load float, float* %6
%33 = fmul float %31, %32
%34 = fdiv float %33, 1.000000e+02
store float %34, float* %9
%35 = load float, float* %9
%36 = load float, float* %7
%37 = fadd float %35, %36
%38 = load float, float* %8
%39 = fadd float %37, %38
store float %39, float* %10
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 2313270)
%42 = load i32, i32* %2
%43 = load float, float* %4
%44 = fpext float %43 to double
%45 = load float, float* %7
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i32 %42, double %44, double %46)
%48 = load i32, i32* %3
%49 = load float, float* %5
%50 = fpext float %49 to double
%51 = load float, float* %8
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %48, double %50, double %52)
%54 = load float, float* %6
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0), double %55)
%57 = load float, float* %9
%58 = fpext float %57 to double
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), double %58)
%60 = load float, float* %10
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), double %61)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [31 x i8] c"What is the price of item 1?\0A$\00"
@.str.3 = [4 x i8] c" %f\00"
@.str.5 = [31 x i8] c"What is the price of item 2?\0A$\00"
@.str.7 = [6 x i8] c"\0A\09%s\0A\00"
@.str.8 = [9 x i8] c"Tru Inc.\00"
@.str.9 = [14 x i8] c"Invoice #%d\0A\0A\00"
@.str.10 = [34 x i8] c"Item1: %d @ $%.2f per item\09$%.2f\0A\00"
@.str.11 = [34 x i8] c"Item2: %d @ $%.2f per item\09$%.2f\0A\00"
@.str.12 = [18 x i8] c"Tax rate:\09%.2f%%\0A\00"
@.str.13 = [18 x i8] c"Tax amount:\09%.2f\0A\00"
@.str.14 = [18 x i8] c"Total cost:\09%.2f\0A\00"
@str = [32 x i8] c"What is the quantity of item 1?\00"
@str.15 = [32 x i8] c"What is the quantity of item 2?\00"
@str.16 = [47 x i8] c"What is the tax rate for item1?(as percentage)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast float* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), float* %3)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.15, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), float* %4)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.16, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), float* %5)
%21 = load i32, i32* %1
%22 = sitofp i32 %21 to float
%23 = load float, float* %3
%24 = fmul float %23, %22
%25 = load i32, i32* %2
%26 = sitofp i32 %25 to float
%27 = load float, float* %4
%28 = fmul float %27, %26
%29 = fadd float %24, %28
%30 = load float, float* %5
%31 = fmul float %30, %29
%32 = fdiv float %31, 1.000000e+02
%33 = fadd float %24, %32
%34 = fadd float %28, %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 2313270)
%37 = load i32, i32* %1
%38 = load float, float* %3
%39 = fpext float %38 to double
%40 = fpext float %24 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i32 %37, double %39, double %40)
%42 = load i32, i32* %2
%43 = load float, float* %4
%44 = fpext float %43 to double
%45 = fpext float %28 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %42, double %44, double %45)
%47 = load float, float* %5
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0), double %48)
%50 = fpext float %32 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), double %50)
%52 = fpext float %34 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), double %52)
ret i32 0
}