#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 item1quantity, item2quantity;
  float item1price, item2price, taxrate, beforetax, netsales;
  float item1total;
  float item2total;
  float totalamount;
  printf("%s\n", "Nix Company");
  printf("Invoice: %d\n\n", 54321);
  printf("Enter item 1 quantity: ");
  scanf("%d", &item1quantity);
  printf("Enter item 1 price: ");
  scanf("%f", &item1price);
  printf("Enter item 2 quantity: ");
  scanf("%d", &item2quantity);
  printf("Enter item 2 price: ");
  scanf("%f", &item2price);
  printf("Enter tax rate (in percent): ");
  scanf("%f", &taxrate);
  taxrate = taxrate / 100.0;
  beforetax = (item1quantity * item1price) + (item2quantity * item2price);
  totalamount = (taxrate * beforetax) + beforetax;
  printf("Item 1: %d @ %.2f per item is %.2f\n", item1quantity, item1price,
         item1quantity * item1price);
  printf("Item 2: %d @ %.2f per item is %.2f\n", item2quantity, item2price,
         item2quantity * item2price);
  printf("Tax Rate: %.2f\n", taxrate);
  printf("Tax Amount: %.2f\n", taxrate * beforetax);
  printf("Total cost: %.2f\n", totalamount);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0xd431,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x10(%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    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdf8(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
cvtsi2ssl -0xc(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe31(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe2d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe29(%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    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0xec6(%rip),%rdi
mov    $0xd431,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%r14
lea    0x24(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebf(%rip),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm2
divss  0xdfd(%rip),%xmm2
movss  %xmm2,0xc(%rsp)
mov    0x24(%rsp),%esi
cvtsi2ss %esi,%xmm1
movss  0x20(%rsp),%xmm0
cvtsi2ssl 0x14(%rsp),%xmm3
mulss  0x10(%rsp),%xmm3
mulss  %xmm0,%xmm1
addss  %xmm1,%xmm3
movss  %xmm3,0x18(%rsp)
mulss  %xmm3,%xmm2
addss  %xmm3,%xmm2
movss  %xmm2,0x1c(%rsp)
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xe4e(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
xorps  %xmm1,%xmm1
cvtsi2ss %esi,%xmm1
movss  0x10(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mulss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe44(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe50(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x18(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe42(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

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