#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 quantity1;
  int quantity2;
  float price1;
  float price2;
  int itemtotal1;
  int itemtotal2;
  float taxrate;
  float taxtotal;
  float total;
  printf("How many of item 1?\n");
  scanf("%d", &quantity1);
  printf("What is the price of item 1?\n");
  scanf("%f", &price1);
  printf("How many of item 2?\n");
  scanf("%d", &quantity2);
  printf("What is the price of item 2?\n");
  scanf("%f", &price2);
  printf("What is the tax rate (in percent)?\n");
  scanf("%f", &taxrate);
  itemtotal1 = quantity1 * price1;
  itemtotal2 = quantity2 * price2;
  taxrate = taxrate / 100;
  taxtotal = (itemtotal1 + itemtotal2) * taxrate;
  total = (itemtotal1 + itemtotal2) + taxtotal;
  printf("\tChi Phi Inc.\n");
  printf("Invoice #1995\n");
  printf("Item 1: %d @ $%.2f per item \t$%d\n", quantity1, price1, itemtotal1);
  printf("Item 2: %d @ $%.2f per item \t$%d\n", quantity2, price2, itemtotal2);
  printf("Tax Amount: \t\t\t%.2f%\n", taxtotal);
  printf("Total Amount: \t\t\t$%.2f\n", total);
  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    0xed5(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
movss  -0x20(%rbp),%xmm0
movss  0xe02(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
cvtsi2ss %eax,%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x18(%rbp),%edx
lea    0xe51(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x1c(%rbp),%edx
lea    0xe56(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe60(%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    0xf3e(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%r14
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf30(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf26(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x1c(%rsp),%xmm0
movss  0x18(%rsp),%xmm1
unpcklps %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm0
movss  0x14(%rsp),%xmm1
movss  0x10(%rsp),%xmm2
unpcklps %xmm1,%xmm2
mulps  %xmm0,%xmm2
movss  0xc(%rsp),%xmm1
divss  0xe02(%rip),%xmm1
cvttps2dq %xmm2,%xmm0
movd   %xmm0,%r14d
pshufd $0x55,%xmm0,%xmm0
movd   %xmm0,%ebx
lea    (%r14,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm1,0xc(%rsp)
mulss  %xmm0,%xmm1
movss  %xmm1,0x20(%rsp)
addss  %xmm1,%xmm0
movss  %xmm0,0x24(%rsp)
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
mov    0x1c(%rsp),%esi
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda8(%rip),%rdi
mov    %ebx,%edx
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdac(%rip),%rdi
mov    %r14d,%edx
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x24(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.9 = [34 x i8] c"Item 1: %d @ $%.2f per item \09$%d\0A\00"
@.str.10 = [34 x i8] c"Item 2: %d @ $%.2f per item \09$%d\0A\00"
@.str.11 = [22 x i8] c"Tax Amount: \09\09\09%.2f%\0A\00"
@.str.12 = [24 x i8] c"Total Amount: \09\09\09$%.2f\0A\00"
@str = [20 x i8] c"How many of item 1?\00"
@str.13 = [29 x i8] c"What is the price of item 1?\00"
@str.14 = [20 x i8] c"How many of item 2?\00"
@str.15 = [29 x i8] c"What is the price of item 2?\00"
@str.16 = [35 x i8] c"What is the tax rate (in percent)?\00"
@str.17 = [14 x i8] c"\09Chi Phi Inc.\00"
@str.18 = [14 x i8] c"Invoice\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 ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.13, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.14, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.15, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.16, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%21 = load i32, i32* %1
%22 = load float, float* %3
%23 = load i32, i32* %2
%24 = insertelement <2 x i32> poison, i32 %23, i64 0
%25 = insertelement <2 x i32> %24, i32 %21, i64 1
%26 = sitofp <2 x i32> %25 to <2 x float>
%27 = load float, float* %4
%28 = insertelement <2 x float> poison, float %27, i64 0
%29 = insertelement <2 x float> %28, float %22, i64 1
%30 = fmul <2 x float> %29, %26
%31 = fptosi <2 x float> %30 to <2 x i32>
%32 = load float, float* %5
%33 = fdiv float %32, 1.000000e+02
store float %33, float* %5
%34 = extractelement <2 x i32> %31, i64 0
%35 = extractelement <2 x i32> %31, i64 1
%36 = add nsw i32 %34, %35
%37 = sitofp i32 %36 to float
%38 = fmul float %33, %37
%39 = fadd float %38, %37
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.17, i64 0, i64 0))
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.18, i64 0, i64 0))
%42 = load i32, i32* %1
%43 = load float, float* %3
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %42, double %44, i32 %35)
%46 = load i32, i32* %2
%47 = load float, float* %4
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i32 %46, double %48, i32 %34)
%50 = fpext float %38 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), double %50)
%52 = fpext float %39 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), double %52)
ret i32 0
}