#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 */
typedef float beforetax;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int item1, item2;
  float item1price, item2price;
  float taxrate, beforetax, totalprice;
  float item1total, item2total, taxamount;
  printf("Enter item 1 quantity: \n");
  scanf("%d", &item1);
  printf("Enter item 1 price: \n");
  scanf("%f", &item1price);
  printf("Enter item2 quantity: \n");
  scanf("%d", &item2);
  printf("Enter item 2 price: \n");
  scanf("%f", &item2price);
  printf("Enter tax rate (in percent): \n");
  scanf("%f", &taxrate);
  beforetax = ((item1price * item1) + (item2price * item2));
  totalprice = (beforetax) + (beforetax * (taxrate / 100));
  item1total = (item1 * item1price);
  item2total = (item2 * item2price);
  taxamount = (beforetax * (taxrate / 100));
  printf(" Invoice Number #49045 \n ");
  printf("Item 1: %d @ $ %.2f per item \t %.2f \n", item1, item1price,
         item1total);
  printf("Item 2: %d @ $ %.2f per item \t %.2f \n", item2, item2price,
         item2total);
  printf(" Tax rate: \t \t \t %.2f \n", taxrate);
  printf("Tax amount: \t \t \t %.2f \n", taxamount);
  printf("Total cost: \t \t \t %.2f \n", totalprice);
  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    0xed9(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe92(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe72(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
cvtsi2ssl -0xc(%rbp),%xmm3
mulss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movss  0xdf5(%rip),%xmm3
divss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  0xdb4(%rip),%xmm2
divss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe1d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe20(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe30(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe32(%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    0xf7c(%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    0xf72(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf65(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf61(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf5b(%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),%xmm1
mulss  0x8(%rsp),%xmm1
movss  %xmm1,0x1c(%rsp)
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0x18(%rsp)
addss  %xmm1,%xmm0
movss  0x4(%rsp),%xmm1
divss  0xdfe(%rip),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x20(%rsp)
addss  %xmm1,%xmm0
movss  %xmm0,0x24(%rsp)
lea    0xded(%rip),%rdi
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    0xde1(%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    0xde1(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x24(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf0(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter item 1 quantity: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"Enter item 1 price: \0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [24 x i8] c"Enter item2 quantity: \0A\00"
@.str.5 = [22 x i8] c"Enter item 2 price: \0A\00"
@.str.6 = [31 x i8] c"Enter tax rate (in percent): \0A\00"
@.str.7 = [26 x i8] c" Invoice Number \0A \00"
@.str.8 = [38 x i8] c"Item 1: %d @ $ %.2f per item \09 %.2f \0A\00"
@.str.9 = [38 x i8] c"Item 2: %d @ $ %.2f per item \09 %.2f \0A\00"
@.str.10 = [24 x i8] c" Tax rate: \09 \09 \09 %.2f \0A\00"
@.str.11 = [25 x i8] c"Tax amount: \09 \09 \09 %.2f \0A\00"
@.str.12 = [25 x i8] c"Total cost: \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 float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store i32 0, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, 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* %4)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%22 = load float, float* %4
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to float
%25 = load float, float* %5
%26 = load i32, i32* %3
%27 = sitofp i32 %26 to float
%28 = fmul float %25, %27
%29 = call float @llvm.fmuladd.f32(float %22, float %24, float %28)
store float %29, float* %7
%30 = load float, float* %7
%31 = load float, float* %7
%32 = load float, float* %6
%33 = fdiv float %32, 1.000000e+02
%34 = call float @llvm.fmuladd.f32(float %31, float %33, float %30)
store float %34, float* %8
%35 = load i32, i32* %2
%36 = sitofp i32 %35 to float
%37 = load float, float* %4
%38 = fmul float %36, %37
store float %38, float* %9
%39 = load i32, i32* %3
%40 = sitofp i32 %39 to float
%41 = load float, float* %5
%42 = fmul float %40, %41
store float %42, float* %10
%43 = load float, float* %7
%44 = load float, float* %6
%45 = fdiv float %44, 1.000000e+02
%46 = fmul float %43, %45
store float %46, float* %11
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%48 = load i32, i32* %2
%49 = load float, float* %4
%50 = fpext float %49 to double
%51 = load float, float* %9
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %48, double %50, double %52)
%54 = load i32, i32* %3
%55 = load float, float* %5
%56 = fpext float %55 to double
%57 = load float, float* %10
%58 = fpext float %57 to double
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %54, double %56, double %58)
%60 = load float, float* %6
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), double %61)
%63 = load float, float* %11
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), double %64)
%66 = load float, float* %8
%67 = fpext float %66 to double
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), double %67)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.7 = [26 x i8] c" Invoice Number \0A \00"
@.str.8 = [38 x i8] c"Item 1: %d @ $ %.2f per item \09 %.2f \0A\00"
@.str.9 = [38 x i8] c"Item 2: %d @ $ %.2f per item \09 %.2f \0A\00"
@.str.10 = [24 x i8] c" Tax rate: \09 \09 \09 %.2f \0A\00"
@.str.11 = [25 x i8] c"Tax amount: \09 \09 \09 %.2f \0A\00"
@.str.12 = [25 x i8] c"Total cost: \09 \09 \09 %.2f \0A\00"
@str = [24 x i8] c"Enter item 1 quantity: \00"
@str.13 = [21 x i8] c"Enter item 1 price: \00"
@str.14 = [23 x i8] c"Enter item2 quantity: \00"
@str.15 = [21 x i8] c"Enter item 2 price: \00"
@str.16 = [30 x i8] c"Enter tax rate (in percent): \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 ([24 x i8], [24 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 ([21 x i8], [21 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 ([23 x i8], [23 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 ([21 x i8], [21 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 ([30 x i8], [30 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 float, float* %3
%22 = load i32, i32* %1
%23 = sitofp i32 %22 to float
%24 = load float, float* %4
%25 = load i32, i32* %2
%26 = sitofp i32 %25 to float
%27 = fmul float %24, %26
%28 = call float @llvm.fmuladd.f32(float %21, float %23, float %27)
%29 = load float, float* %5
%30 = fdiv float %29, 1.000000e+02
%31 = call float @llvm.fmuladd.f32(float %28, float %30, float %28)
%32 = fmul float %21, %23
%33 = fmul float %30, %28
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%35 = load i32, i32* %1
%36 = load float, float* %3
%37 = fpext float %36 to double
%38 = fpext float %32 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %35, double %37, double %38)
%40 = load i32, i32* %2
%41 = load float, float* %4
%42 = fpext float %41 to double
%43 = fpext float %27 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %40, double %42, double %43)
%45 = load float, float* %5
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), double %46)
%48 = fpext float %33 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), double %48)
%50 = fpext float %31 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), double %50)
ret i32 0
}