#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;
  float price1;
  int quantity2;
  float price2;
  float taxinformation;
  printf("what is the quantity of item1 ?\n");
  scanf("%d", &quantity1);
  printf("what is the price of item1 ?\n");
  scanf("%f", &price1);
  printf("what is the quantity of item2 ?\n");
  scanf("%d", &quantity2);
  printf("what is the price of item2 ?\n");
  scanf("%f", &price2);
  printf("enter the tax rate (in percent):");
  scanf("%f", &taxinformation);
  float subtotal = (quantity1 * price1) + (quantity2 * price2);
  float taxdollars = (taxinformation / 100.0) * subtotal;
  float totalcost = subtotal + taxdollars;
  printf("\t%s\n", "my company");
  printf("\t%s\n", "invoice #12345");
  float item1p = quantity1 * price1;
  float item2p = quantity2 * price2;
  printf("item1: %d @ %.2f per item\t$%.2f\n", quantity1, price1, item1p);
  printf("item2: %d @ %.2f per item\t$%.2f\n", quantity2, price2, item2p);
  printf("tax rate:\t\t\t%.2f%%\n", taxinformation);
  printf("tax amount:\t\t\t$%.2f\n", taxdollars);
  printf("total cost:\t\t\t$%.2f\n", totalcost);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%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    0xea5(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea6(%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    0xe86(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdff(%rip),%xmm1
divsd  %xmm1,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xe7c(%rip),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%esi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe3e(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x2c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe3c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%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    0xf90(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%r14
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf8e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf89(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf8e(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
cvtsi2ssl 0x18(%rsp),%xmm2
cvtsi2ssl 0xc(%rsp),%xmm0
mulss  0x8(%rsp),%xmm0
mulss  0x14(%rsp),%xmm2
addss  %xmm0,%xmm2
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xe04(%rip),%xmm0
cvtss2sd %xmm2,%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x20(%rsp)
addss  %xmm0,%xmm2
movss  %xmm2,0x24(%rsp)
lea    0xe0d(%rip),%rbx
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe05(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
xorps  %xmm1,%xmm1
cvtsi2ss %esi,%xmm1
movss  0x14(%rsp),%xmm0
mulss  %xmm0,%xmm1
xorps  %xmm2,%xmm2
cvtsi2ssl 0xc(%rsp),%xmm2
mulss  0x8(%rsp),%xmm2
movss  %xmm2,0x1c(%rsp)
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xdd1(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x1c(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdcc(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x24(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdce(%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 item1 ?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"what is the price of item1 ?\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [33 x i8] c"what is the quantity of item2 ?\0A\00"
@.str.5 = [30 x i8] c"what is the price of item2 ?\0A\00"
@.str.6 = [33 x i8] c"enter the tax rate (in percent):\00"
@.str.7 = [5 x i8] c"\09%s\0A\00"
@.str.8 = [11 x i8] c"my company\00"
@.str.9 = [15 x i8] c"invoice\00"
@.str.10 = [33 x i8] c"item1: %d @ %.2f per item\09$%.2f\0A\00"
@.str.11 = [33 x i8] c"item2: %d @ %.2f per item\09$%.2f\0A\00"
@.str.12 = [20 x i8] c"tax rate:\09\09\09%.2f%%\0A\00"
@.str.13 = [21 x i8] c"tax amount:\09\09\09$%.2f\0A\00"
@.str.14 = [21 x i8] c"total cost:\09\09\09$%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca i32
%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 ([33 x i8], [33 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 ([30 x i8], [30 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* %3)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 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* %4)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 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 ([33 x i8], [33 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 i32, i32* %2
%23 = sitofp i32 %22 to float
%24 = load float, float* %3
%25 = load i32, i32* %4
%26 = sitofp i32 %25 to float
%27 = load float, float* %5
%28 = fmul float %26, %27
%29 = call float @llvm.fmuladd.f32(float %23, float %24, float %28)
store float %29, float* %7
%30 = load float, float* %6
%31 = fpext float %30 to double
%32 = fdiv double %31, 1.000000e+02
%33 = load float, float* %7
%34 = fpext float %33 to double
%35 = fmul double %32, %34
%36 = fptrunc double %35 to float
store float %36, float* %8
%37 = load float, float* %7
%38 = load float, float* %8
%39 = fadd float %37, %38
store float %39, float* %9
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%42 = load i32, i32* %2
%43 = sitofp i32 %42 to float
%44 = load float, float* %3
%45 = fmul float %43, %44
store float %45, float* %10
%46 = load i32, i32* %4
%47 = sitofp i32 %46 to float
%48 = load float, float* %5
%49 = fmul float %47, %48
store float %49, float* %11
%50 = load i32, i32* %2
%51 = load float, float* %3
%52 = fpext float %51 to double
%53 = load float, float* %10
%54 = fpext float %53 to double
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %50, double %52, double %54)
%56 = load i32, i32* %4
%57 = load float, float* %5
%58 = fpext float %57 to double
%59 = load float, float* %11
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %56, double %58, double %60)
%62 = load float, float* %6
%63 = fpext float %62 to double
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), double %63)
%65 = load float, float* %8
%66 = fpext float %65 to double
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), double %66)
%68 = load float, float* %9
%69 = fpext float %68 to double
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0), double %69)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.6 = [33 x i8] c"enter the tax rate (in percent):\00"
@.str.7 = [5 x i8] c"\09%s\0A\00"
@.str.8 = [11 x i8] c"my company\00"
@.str.9 = [15 x i8] c"invoice\00"
@.str.10 = [33 x i8] c"item1: %d @ %.2f per item\09$%.2f\0A\00"
@.str.11 = [33 x i8] c"item2: %d @ %.2f per item\09$%.2f\0A\00"
@.str.12 = [20 x i8] c"tax rate:\09\09\09%.2f%%\0A\00"
@.str.13 = [21 x i8] c"tax amount:\09\09\09$%.2f\0A\00"
@.str.14 = [21 x i8] c"total cost:\09\09\09$%.2f\0A\00"
@str = [32 x i8] c"what is the quantity of item1 ?\00"
@str.15 = [29 x i8] c"what is the price of item1 ?\00"
@str.16 = [32 x i8] c"what is the quantity of item2 ?\00"
@str.17 = [29 x i8] c"what is the price of item2 ?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = bitcast i32* %1 to i8*
%7 = bitcast float* %2 to i8*
%8 = bitcast i32* %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 ([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.15, 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* %2)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.16, 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.17, 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 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* %5)
%21 = load i32, i32* %1
%22 = sitofp i32 %21 to float
%23 = load float, float* %2
%24 = load i32, i32* %3
%25 = sitofp i32 %24 to float
%26 = load float, float* %4
%27 = fmul float %26, %25
%28 = call float @llvm.fmuladd.f32(float %22, float %23, float %27)
%29 = load float, float* %5
%30 = fpext float %29 to double
%31 = fdiv double %30, 1.000000e+02
%32 = fpext float %28 to double
%33 = fmul double %31, %32
%34 = fptrunc double %33 to float
%35 = fadd float %28, %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%38 = load i32, i32* %1
%39 = sitofp i32 %38 to float
%40 = load float, float* %2
%41 = fmul float %40, %39
%42 = load i32, i32* %3
%43 = sitofp i32 %42 to float
%44 = load float, float* %4
%45 = fmul float %44, %43
%46 = fpext float %40 to double
%47 = fpext float %41 to double
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %38, double %46, double %47)
%49 = load i32, i32* %3
%50 = load float, float* %4
%51 = fpext float %50 to double
%52 = fpext float %45 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %49, double %51, double %52)
%54 = load float, float* %5
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), double %55)
%57 = fpext float %34 to double
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), double %57)
%59 = fpext float %35 to double
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0), double %59)
ret i32 0
}