#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*/ SEEK_CUR;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ puts(char *);
int main(void) {
  FILE *myfile;
  char froot[14 + 1];
  int record;
  if (!(myfile = fopen("froot.txt", "r"))) {
    puts("Error reading file");
    return 1;
  }
  for (record = 0; record < 25; record++) {
    fread(froot, 14, 1, myfile);
    fseek(myfile, 0, SEEK_CUR);
    printf("%d - %s\n", (ftell(myfile)) / 14, froot);
  }
  fclose(myfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11b8 <main+0x48>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1235 <main+0xc5>
movl   $0x0,-0x24(%rbp)
cmpl   $0x19,-0x24(%rbp)
jge    1225 <main+0xb5>
lea    -0x1f(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0xe,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x10(%rbp),%rdi
mov    0x2dfd(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    $0xe,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    -0x1f(%rbp),%rdx
lea    0xe0d(%rip),%rdi
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11bf <main+0x4f>
mov    -0x10(%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   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe7d(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1211 <main+0xa1>
mov    %rax,%rbx
mov    $0x19,%ebp
lea    0x1(%rsp),%r14
mov    0x2e40(%rip),%r12
lea    0xe70(%rip),%r15
nop
mov    %r14,%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
movslq %eax,%rsi
imul   $0xffffffff92492493,%rsi,%rax
shr    $0x20,%rax
add    %eax,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x3,%esi
add    %eax,%esi
mov    %r15,%rdi
mov    %r14,%rdx
call   1060 <printf@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x40>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1222 <main+0xb2>
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"froot.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Error reading file\00"
@SEEK_CUR = global i32 0
@.str.3 = [9 x i8] c"%d - %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [15 x i8]
%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 ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %31
9: ; preds = %0
store i32 0, i32* %4
br label %10
10: ; preds = %25, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 25
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%15 = load i32*, i32** %2
%16 = call i32 @fread(i8* %14, i32 14, i32 1, i32* %15)
%17 = load i32*, i32** %2
%18 = load i32, i32* @SEEK_CUR
%19 = call i32 @fseek(i32* %17, i32 0, i32 %18)
%20 = load i32*, i32** %2
%21 = call i32 @ftell(i32* %20)
%22 = sdiv i32 %21, 14
%23 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %22, i8* %23)
br label %25
25: ; preds = %13
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %10
28: ; preds = %10
%29 = load i32*, i32** %2
%30 = call i32 @fclose(i32* %29)
store i32 0, i32* %1
br label %31
31: ; preds = %28, %7
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [10 x i8] c"froot.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Error reading file\00"
@SEEK_CUR = global i32 0
@.str.3 = [9 x i8] c"%d - %s\0A\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 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 ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %19
7: ; preds = %0, %7
%8 = phi i32 [ %15, %7 ], [ 0, %0 ]
%9 = call i32 @fread(i8* %2, i32 14, i32 1, i32* %3)
%10 = load i32, i32* @SEEK_CUR
%11 = call i32 @fseek(i32* %3, i32 0, i32 %10)
%12 = call i32 @ftell(i32* %3)
%13 = sdiv i32 %12, 14
%14 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %13, i8* %2)
%15 = add nuw nsw i32 %8, 1
%16 = icmp eq i32 %15, 25
br i1 %16, label %17, label %7
17: ; preds = %7
%18 = call i32 @fclose(i32* %3)
br label %19
19: ; preds = %17, %5
%20 = phi i32 [ 0, %17 ], [ 1, %5 ]
ret i32 %20
}