#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*/ display(long *, float *, int *, int);
int /*<<< orphan*/ inputBarcode(char *, long *, int);
int /*<<< orphan*/ inputPrice(char *, float *, int);
int /*<<< orphan*/ inputQuantity(char *, int *, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  long int barcode[100], y;
  float price[100];
  int qty[100];
  int counter = 0;
  int i;
  printf("Grocery Store Inventory\n");
  printf("=======================\n");
  for (i = 0; i < 100; i++) {
    inputBarcode("Barcode   : ", barcode, i);
    if (barcode[i] == 0)
      i = 100;
    else {
      inputPrice("Price     : ", price, i);
      inputQuantity("Quantity  : ", qty, i);
      counter = i + 1;
    }
  }
  display(barcode, price, qty, counter);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x670,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x664(%rbp)
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x668(%rbp)
cmpl   $0x64,-0x668(%rbp)
jge    1233 <main+0xe3>
lea    -0x330(%rbp),%rsi
mov    -0x668(%rbp),%edx
lea    0xe83(%rip),%rdi
call   1070 <inputBarcode@plt>
movslq -0x668(%rbp),%rax
cmpq   $0x0,-0x330(%rbp,%rax,8)
jne    11d9 <main+0x89>
movl   $0x64,-0x668(%rbp)
jmp    121a <main+0xca>
lea    -0x4d0(%rbp),%rsi
mov    -0x668(%rbp),%edx
lea    0xe52(%rip),%rdi
call   1060 <inputPrice@plt>
lea    -0x660(%rbp),%rsi
mov    -0x668(%rbp),%edx
lea    0xe46(%rip),%rdi
call   1050 <inputQuantity@plt>
mov    -0x668(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x664(%rbp)
jmp    121f <main+0xcf>
mov    -0x668(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x668(%rbp)
jmp    118e <main+0x3e>
lea    -0x330(%rbp),%rdi
lea    -0x4d0(%rbp),%rsi
lea    -0x660(%rbp),%rdx
mov    -0x664(%rbp),%ecx
call   1030 <display@plt>
xor    %eax,%eax
add    $0x670,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x648,%rsp
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe80(%rip),%rdi
mov    %rsp,%rsi
xor    %r12d,%r12d
xor    %edx,%edx
call   1070 <inputBarcode@plt>
cmpq   $0x0,(%rsp)
je     11fd <main+0xad>
xor    %ebx,%ebx
lea    0xe7d(%rip),%r13
lea    0x320(%rsp),%rbp
lea    0xe54(%rip),%r14
mov    %rsp,%r15
nop
lea    0xe56(%rip),%rdi
lea    0x4b0(%rsp),%rsi
mov    %ebx,%edx
call   1060 <inputPrice@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1050 <inputQuantity@plt>
cmp    $0x63,%ebx
jae    11f7 <main+0xa7>
lea    0x1(%rbx),%r12
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1070 <inputBarcode@plt>
cmpq   $0x0,0x8(%rsp,%rbx,8)
mov    %r12,%rbx
jne    11b0 <main+0x60>
jmp    11fd <main+0xad>
mov    $0x64,%r12d
mov    %rsp,%rdi
lea    0x4b0(%rsp),%rsi
lea    0x320(%rsp),%rdx
mov    %r12d,%ecx
call   1040 <display@plt>
xor    %eax,%eax
add    $0x648,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Grocery Store Inventory\0A\00"
@.str.1 = [25 x i8] c"=======================\0A\00"
@.str.2 = [13 x i8] c"Barcode : \00"
@.str.3 = [13 x i8] c"Price : \00"
@.str.4 = [13 x i8] c"Quantity : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i64]
%3 = alloca i64
%4 = alloca [100 x float]
%5 = alloca [100 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %10
10: ; preds = %33, %0
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 100
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = getelementptr inbounds [100 x i64], [100 x i64]* %2, i64 0, i64 0
%15 = load i32, i32* %7
%16 = call i32 @inputBarcode(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64* %14, i32 %15)
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i64], [100 x i64]* %2, i64 0, i64 %18
%20 = load i64, i64* %19
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %13
store i32 100, i32* %7
br label %32
23: ; preds = %13
%24 = getelementptr inbounds [100 x float], [100 x float]* %4, i64 0, i64 0
%25 = load i32, i32* %7
%26 = call i32 @inputPrice(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), float* %24, i32 %25)
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%28 = load i32, i32* %7
%29 = call i32 @inputQuantity(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %27, i32 %28)
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %32
32: ; preds = %23, %22
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %10
36: ; preds = %10
%37 = getelementptr inbounds [100 x i64], [100 x i64]* %2, i64 0, i64 0
%38 = getelementptr inbounds [100 x float], [100 x float]* %4, i64 0, i64 0
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%40 = load i32, i32* %6
%41 = call i32 @display(i64* %37, float* %38, i32* %39, i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [13 x i8] c"Barcode : \00"
@.str.3 = [13 x i8] c"Price : \00"
@.str.4 = [13 x i8] c"Quantity : \00"
@str = [24 x i8] c"Grocery Store Inventory\00"
@str.5 = [24 x i8] c"=======================\00"
define i32 @main() {
%1 = alloca [100 x i64]
%2 = alloca [100 x float]
%3 = alloca [100 x i32]
%4 = bitcast [100 x i64]* %1 to i8*
%5 = bitcast [100 x float]* %2 to i8*
%6 = bitcast [100 x i32]* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.5, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i64], [100 x i64]* %1, i64 0, i64 0
%10 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 0
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%12 = call i32 @inputBarcode(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64* %9, i32 0)
%13 = getelementptr inbounds [100 x i64], [100 x i64]* %1, i64 0, i64 0
%14 = load i64, i64* %13
%15 = icmp eq i64 %14, 0
br i1 %15, label %30, label %22
16: ; preds = %22
%17 = call i32 @inputBarcode(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64* %9, i32 %26)
%18 = zext i32 %26 to i64
%19 = getelementptr inbounds [100 x i64], [100 x i64]* %1, i64 0, i64 %18
%20 = load i64, i64* %19
%21 = icmp eq i64 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %0, %16
%23 = phi i32 [ %26, %16 ], [ 0, %0 ]
%24 = call i32 @inputPrice(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), float* %10, i32 %23)
%25 = call i32 @inputQuantity(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %11, i32 %23)
%26 = add nuw nsw i32 %23, 1
%27 = icmp ult i32 %23, 99
br i1 %27, label %16, label %30
28: ; preds = %16
%29 = add nuw nsw i32 %23, 1
br label %30
30: ; preds = %22, %28, %0
%31 = phi i32 [ %29, %28 ], [ 0, %0 ], [ 100, %22 ]
%32 = call i32 @display(i64* %9, float* %10, i32* %11, i32 %31)
ret i32 0
}