#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 */
struct customer {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int add(struct customer *, int, char *, char *, int, double);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, int *, char *,
                  double *);
int /*<<< orphan*/ printf(char *);
int readFile(FILE *inputfile, struct customer *param, int size) {
  char customer_name[30];
  int number_of;
  char item_name[30];
  double price_of;
  int i = 2;
  printf("Reading File");
  while (fscanf(inputfile, "%s %d %s $%lf", customer_name, &number_of,
                item_name, &price_of) > 0) {
    if (!i) {
      printf(" . ");
      i = 2;
    }
    size = add(param, size, customer_name, item_name, number_of, price_of);
    i--;
    if (feof(inputfile)) {
      printf("End of File\n");
      break;
    }
  }
  return size;
}


x86 assembly (clang, -O0):
<readFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x2,-0x7c(%rbp)
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x70(%rbp),%r8
lea    0xe91(%rip),%rsi
lea    -0x44(%rbp),%rcx
lea    -0x78(%rbp),%r9
call   1050 <fscanf@plt>
cmp    $0x0,%rax
jle    1202 <readFile+0xc2>
cmpl   $0x0,-0x7c(%rbp)
jne    11b0 <readFile+0x70>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2,-0x7c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    -0x70(%rbp),%rcx
mov    -0x44(%rbp),%r8d
movsd  -0x78(%rbp),%xmm0
call   1030 <add@plt>
mov    %eax,-0x14(%rbp)
mov    -0x7c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11fd <readFile+0xbd>
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
jmp    1202 <readFile+0xc2>
jmp    1169 <readFile+0x29>
mov    -0x14(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe93(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%ebp
lea    0x30(%rsp),%r13
lea    0x10(%rsp),%r12
jmp    11bd <readFile+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x4(%rsp),%r8d
movsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %r12,%rcx
call   1030 <add@plt>
mov    %eax,%ebx
add    $0xffffffff,%ebp
mov    %r15,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    11f8 <readFile+0xa8>
mov    %r15,%rdi
lea    0xe46(%rip),%rsi
mov    %r13,%rdx
lea    0x4(%rsp),%rcx
mov    %r12,%r8
lea    0x8(%rsp),%r9
call   1060 <fscanf@plt>
test   %rax,%rax
jle    1204 <readFile+0xb4>
test   %ebp,%ebp
jne    1190 <readFile+0x40>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%ebp
jmp    1190 <readFile+0x40>
lea    0xe20(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.customer = type { i32 }
@.str = [13 x i8] c"Reading File\00"
@.str.1 = [14 x i8] c"%s %d %s $%lf\00"
@.str.2 = [4 x i8] c" . \00"
@.str.3 = [13 x i8] c"End of File\0A\00"
define i32 @readFile(i32* %0, %struct.customer* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca %struct.customer*
%6 = alloca i32
%7 = alloca [30 x i8]
%8 = alloca i32
%9 = alloca [30 x i8]
%10 = alloca double
%11 = alloca i32
store i32* %0, i32** %4
store %struct.customer* %1, %struct.customer** %5
store i32 %2, i32* %6
store i32 2, i32* %11
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %39, %3
%14 = load i32*, i32** %4
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [30 x i8], [30 x i8]* %9, i64 0, i64 0
%17 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32* %8, i8* %16, double* %10)
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %40
19: ; preds = %13
%20 = load i32, i32* %11
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %11
br label %24
24: ; preds = %22, %19
%25 = load %struct.customer*, %struct.customer** %5
%26 = load i32, i32* %6
%27 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%28 = getelementptr inbounds [30 x i8], [30 x i8]* %9, i64 0, i64 0
%29 = load i32, i32* %8
%30 = load double, double* %10
%31 = call i32 @add(%struct.customer* %25, i32 %26, i8* %27, i8* %28, i32 %29, double %30)
store i32 %31, i32* %6
%32 = load i32, i32* %11
%33 = add nsw i32 %32, -1
store i32 %33, i32* %11
%34 = load i32*, i32** %4
%35 = call i64 @feof(i32* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %24
%38 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %40
39: ; preds = %24
br label %13
40: ; preds = %37, %13
%41 = load i32, i32* %6
ret i32 %41
}

LLVM IR (-O2):
%struct.customer = type { i32 }
@.str = [13 x i8] c"Reading File\00"
@.str.1 = [14 x i8] c"%s %d %s $%lf\00"
@.str.2 = [4 x i8] c" . \00"
@str = [12 x i8] c"End of File\00"
define i32 @readFile(i32* nocapture %0, %struct.customer* %1, i32 %2) {
%4 = alloca [30 x i8]
%5 = alloca i32
%6 = alloca [30 x i8]
%7 = alloca double
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%11 = bitcast double* %7 to i8*
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %22, %3
%14 = phi i32 [ %2, %3 ], [ %26, %22 ]
%15 = phi i32 [ 2, %3 ], [ %27, %22 ]
%16 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32* %5, i8* %10, double* %7)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %32
18: ; preds = %13
%19 = icmp eq i32 %15, 0
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = phi i32 [ %15, %18 ], [ 2, %20 ]
%24 = load i32, i32* %5
%25 = load double, double* %7
%26 = call i32 @add(%struct.customer* %1, i32 %14, i8* %8, i8* %10, i32 %24, double %25)
%27 = add nsw i32 %23, -1
%28 = call i64 @feof(i32* %0)
%29 = icmp eq i64 %28, 0
br i1 %29, label %13, label %30
30: ; preds = %22
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %13, %30
%33 = phi i32 [ %26, %30 ], [ %14, %13 ]
ret i32 %33
}