#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char **, int, int, int /*<<< orphan*/ *);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ puts(char *);
int main() {
  char fruit[14];
  FILE *myfile;
  int x;
  if (!(myfile = fopen("froot.txt", " r"))) {
    puts("\n\tError reading file!");
    return 1;
  }
  while (!0) {
    x = fread(&fruit, 14, 1, myfile);
    if (x == 0)
      break;
    printf("%3d: %s\n", ftell(myfile), fruit);
  }
  fclose(myfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11a8 <main+0x48>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1206 <main+0xa6>
jmp    11ad <main+0x4d>
lea    -0x12(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0xe,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11d6 <main+0x76>
jmp    11f6 <main+0x96>
mov    -0x20(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,%esi
lea    -0x12(%rbp),%rdx
lea    0xe37(%rip),%rdi
call   1060 <printf@plt>
jmp    11ad <main+0x4d>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11ea <main+0x8a>
mov    %rax,%rbx
lea    0x2(%rsp),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     11de <main+0x7e>
lea    0xe7d(%rip),%r14
lea    0x2(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jne    11b0 <main+0x50>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    11fb <main+0x9b>
lea    0xe1c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"froot.txt\00"
@.str.1 = [3 x i8] c" r\00"
@.str.2 = [22 x i8] c"\0A\09Error reading file!\00"
@.str.3 = [9 x i8] c"%3d: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [14 x i8]
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
%6 = icmp ne i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %25
9: ; preds = %0
br label %10
10: ; preds = %9, %17
%11 = bitcast [14 x i8]* %2 to i8**
%12 = load i32*, i32** %3
%13 = call i32 @fread(i8** %11, i32 14, i32 1, i32* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
br label %22
17: ; preds = %10
%18 = load i32*, i32** %3
%19 = call i32 @ftell(i32* %18)
%20 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %19, i8* %20)
br label %10
22: ; preds = %16
%23 = load i32*, i32** %3
%24 = call i32 @fclose(i32* %23)
store i32 0, i32* %1
br label %25
25: ; preds = %22, %7
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [10 x i8] c"froot.txt\00"
@.str.1 = [3 x i8] c" r\00"
@.str.2 = [22 x i8] c"\0A\09Error reading file!\00"
@.str.3 = [9 x i8] c"%3d: %s\0A\00"
define i32 @main() {
%1 = alloca [14 x i8]
%2 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = bitcast [14 x i8]* %1 to i8**
%7 = call i32 @fread(i8** %6, i32 14, i32 1, i32* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %16, label %11
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %18
11: ; preds = %5, %11
%12 = call i32 @ftell(i32* %3)
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %12, i8* %2)
%14 = call i32 @fread(i8** %6, i32 14, i32 1, i32* %3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %11
16: ; preds = %11, %5
%17 = call i32 @fclose(i32* %3)
br label %18
18: ; preds = %16, %9
%19 = phi i32 [ 0, %16 ], [ 1, %9 ]
ret i32 %19
}