#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_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ puts(char *);
int main() {
  FILE *f;
  char froot[14];
  int record, offset;
  if (!(f = fopen("froot.txt", "r"))) {
    puts("Error reading file\n");
    return 1;
  }
  record = 12;
  offset = record * 14;
  fseek(f, offset, SEEK_SET);
  fread(froot, 14, 1, f);
  printf("%d : %s\n", (ftell(f)) / 14, froot);
  fclose(f);
  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    1225 <main+0xb5>
movl   $0xc,-0x24(%rbp)
imul   $0xe,-0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    0x2e0c(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
lea    -0x1e(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0xe,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    $0xe,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    -0x1e(%rbp),%rdx
lea    0xe10(%rip),%rdi
call   1060 <printf@plt>
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   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe82(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11ff <main+0x8f>
mov    %rax,%rbx
mov    0x2e47(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xa8,%esi
call   1080 <fseek@plt>
lea    0xa(%rsp),%r14
mov    %r14,%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@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
lea    0xe35(%rip),%rdi
mov    %r14,%rdx
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1210 <main+0xa0>
lea    0xe06(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"froot.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Error reading file\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [9 x i8] c"%d : %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 ([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 ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %15
7: ; preds = %0
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %3, i32 168, i32 %8)
%10 = call i32 @fread(i8* %2, i32 14, i32 1, i32* %3)
%11 = tail call i32 @ftell(i32* %3)
%12 = sdiv i32 %11, 14
%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 @fclose(i32* %3)
br label %15
15: ; preds = %7, %5
%16 = phi i32 [ 0, %7 ], [ 1, %5 ]
ret i32 %16
}