#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 *, ...);
void display(long int barcode[], float price[], int qty[], int num) {
  int i;
  float total = 0;
  printf("\n\n\t\tGoods in Stock\n");
  printf("\t\t==============\n");
  printf("Barcode\t\tPrice\tQuantity\tValue\n");
  printf("--------------------------------------------------------\n");
  for (i = 0; i < num; i++) {
    printf("%10ld %10.2f %10d     %10.2f\n", barcode[i], price[i], qty[i],
           price[i] * qty[i]);
    total += price[i] * qty[i];
  }
  printf("\t\t\t\t\t--------\n");
  printf("Total value goods in stocks          %10.2f\n\n", total);
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120c <display+0xfc>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm2
mulss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xeb4(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116e <display+0x5e>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe82(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xf0f(%rip),%rdi
call   1030 <puts@plt>
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jle    11e2 <display+0xc2>
mov    %ebp,%r13d
xorps  %xmm0,%xmm0
xor    %ebp,%ebp
lea    0xe87(%rip),%r12
nopl   0x0(%rax)
movss  %xmm0,(%rsp)
mov    (%r15,%rbp,8),%rsi
mov    (%r14,%rbp,4),%edx
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
movss  (%rbx,%rbp,4),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mulss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r12,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl (%r14,%rbp,4),%xmm0
mulss  (%rbx,%rbp,4),%xmm0
movss  (%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%rsp)
movss  (%rsp),%xmm0
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1180 <display+0x60>
cvtss2sd %xmm0,%xmm0
jmp    11e5 <display+0xc5>
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe21(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"\0A\0A\09\09Goods in Stock\0A\00"
@.str.1 = [18 x i8] c"\09\09==============\0A\00"
@.str.2 = [31 x i8] c"Barcode\09\09Price\09Quantity\09Value\0A\00"
@.str.3 = [58 x i8] c"--------------------------------------------------------\0A\00"
@.str.4 = [30 x i8] c"%10ld %10.2f %10d %10.2f\0A\00"
@.str.5 = [15 x i8] c"\09\09\09\09\09--------\0A\00"
@.str.6 = [46 x i8] c"Total value goods in stocks %10.2f\0A\0A\00"
define void @display(i64* %0, float* %1, i32* %2, i32 %3) {
%5 = alloca i64*
%6 = alloca float*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
store i64* %0, i64** %5
store float* %1, float** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store float 0.000000e+00, float* %10
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %9
br label %15
15: ; preds = %63, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %66
19: ; preds = %15
%20 = load i64*, i64** %5
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i64, i64* %20, i64 %22
%24 = load i64, i64* %23
%25 = load float*, float** %6
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %25, i64 %27
%29 = load float, float* %28
%30 = fpext float %29 to double
%31 = load i32*, i32** %7
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load float*, float** %6
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds float, float* %36, i64 %38
%40 = load float, float* %39
%41 = load i32*, i32** %7
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = sitofp i32 %45 to float
%47 = fmul float %40, %46
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %24, double %30, i32 %35, double %48)
%50 = load float*, float** %6
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %50, i64 %52
%54 = load float, float* %53
%55 = load i32*, i32** %7
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
%59 = load i32, i32* %58
%60 = sitofp i32 %59 to float
%61 = load float, float* %10
%62 = call float @llvm.fmuladd.f32(float %54, float %60, float %61)
store float %62, float* %10
br label %63
63: ; preds = %19
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %15
66: ; preds = %15
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%68 = load float, float* %10
%69 = fpext float %68 to double
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), double %69)
ret void
}

LLVM IR (-O2):
@.str.4 = [30 x i8] c"%10ld %10.2f %10d %10.2f\0A\00"
@.str.6 = [46 x i8] c"Total value goods in stocks %10.2f\0A\0A\00"
@str = [19 x i8] c"\0A\0A\09\09Goods in Stock\00"
@str.7 = [17 x i8] c"\09\09==============\00"
@str.8 = [30 x i8] c"Barcode\09\09Price\09Quantity\09Value\00"
@str.9 = [57 x i8] c"--------------------------------------------------------\00"
@str.10 = [14 x i8] c"\09\09\09\09\09--------\00"
define void @display(i64* nocapture %0, float* nocapture %1, i32* nocapture %2, i32 %3) {
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.9, i64 0, i64 0))
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %34
10: ; preds = %4
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %30, %12 ]
%14 = phi float [ 0.000000e+00, %10 ], [ %29, %12 ]
%15 = getelementptr inbounds i64, i64* %0, i64 %13
%16 = load i64, i64* %15
%17 = getelementptr inbounds float, float* %1, i64 %13
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = getelementptr inbounds i32, i32* %2, i64 %13
%21 = load i32, i32* %20
%22 = sitofp i32 %21 to float
%23 = fmul float %18, %22
%24 = fpext float %23 to double
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %16, double %19, i32 %21, double %24)
%26 = load float, float* %17
%27 = load i32, i32* %20
%28 = sitofp i32 %27 to float
%29 = tail call float @llvm.fmuladd.f32(float %26, float %28, float %14)
%30 = add nuw nsw i64 %13, 1
%31 = icmp eq i64 %30, %11
br i1 %31, label %32, label %12
32: ; preds = %12
%33 = fpext float %29 to double
br label %34
34: ; preds = %32, %4
%35 = phi double [ 0.000000e+00, %4 ], [ %33, %32 ]
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.10, i64 0, i64 0))
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), double %35)
ret void
}