#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*/ time_t;
struct tm {
  int tm_hour;
};
struct stat {
  scalar_t__ st_size;
};
typedef int /*<<< orphan*/ str;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fseek(int /*<<< orphan*/ *, scalar_t__, int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *f;
  char fname[100] = "data/2007-08-09.dat";
  char lines[15][100];
  struct stat buf;
  char str[200];
  int i, hour;
  time_t starttime;
  struct tm *loctime;
  stat(fname, &buf);
  if ((f = fopen(fname, "r")) == NULL) {
    printf("error1\n");
    return 1;
  }
  starttime = time(NULL);
  loctime = localtime(&starttime);
  printf("time: %i\n", loctime->tm_hour);
  if (fseek(f, buf.st_size - loctime->tm_hour * 300 * 70, SEEK_SET) != 0) {
    printf("error\n");
    return 1;
  }
  fgets(str, sizeof(str), f);
  while (fgets(str, sizeof(str), f) != NULL) {
    printf("%s", str);
  }
  printf("done\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x750,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x64,%edx
call   1070 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    -0x668(%rbp),%rsi
call   1060 <stat@plt>
lea    -0x80(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11f6 <main+0x76>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e4 <main+0x164>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x73c(%rbp)
lea    -0x73c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x748(%rbp)
mov    -0x748(%rbp),%rax
mov    (%rax),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x668(%rbp),%rsi
mov    -0x748(%rbp),%rax
imul   $0x12c,(%rax),%eax
imul   $0x46,%eax,%eax
cltq
sub    %rax,%rsi
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
cmp    $0x0,%rax
je     1281 <main+0x101>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e4 <main+0x164>
lea    -0x730(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xc8,%esi
call   1050 <fgets@plt>
lea    -0x730(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xc8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     12cf <main+0x14f>
lea    -0x730(%rbp),%rsi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1296 <main+0x116>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x750,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x150,%rsp
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe85(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe69(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe4d(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe31(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <stat@plt>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     125c <main+0xdc>
mov    %rax,%r15
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
imul   $0x5208,(%rbx),%eax
cltq
sub    %rax,%rsi
mov    0x2d9c(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
call   1090 <fseek@plt>
test   %rax,%rax
je     126f <main+0xef>
lea    0xe1c(%rip),%rdi
jmp    1263 <main+0xe3>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    12e0 <main+0x160>
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12d2 <main+0x152>
lea    0xdcb(%rip),%r14
lea    0x80(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    12b0 <main+0x130>
lea    0xd98(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
%struct.tm = type { i32 }
@__const.main.fname = [100 x i8] c"data/2007-08-09.dat\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"error1\0A\00"
@.str.2 = [10 x i8] c"time: %i\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [7 x i8] c"error\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [6 x i8] c"done\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [100 x i8]
%8 = alloca [15 x [100 x i8]]
%9 = alloca %struct.stat
%10 = alloca [200 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast [100 x i8]* %7 to i8*
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%17 = call i32 @stat(i8* %16, %struct.stat* %9)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %59
23: ; preds = %2
%24 = call i32 @time(i32* null)
store i32 %24, i32* %13
%25 = call %struct.tm* @localtime(i32* %13)
store %struct.tm* %25, %struct.tm** %14
%26 = load %struct.tm*, %struct.tm** %14
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32*, i32** %6
%31 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%32 = load i64, i64* %31
%33 = load %struct.tm*, %struct.tm** %14
%34 = getelementptr inbounds %struct.tm, %struct.tm* %33, i32 0, i32 0
%35 = load i32, i32* %34
%36 = mul nsw i32 %35, 300
%37 = mul nsw i32 %36, 70
%38 = sext i32 %37 to i64
%39 = sub nsw i64 %32, %38
%40 = load i32, i32* @SEEK_SET
%41 = call i64 @fseek(i32* %30, i64 %39, i32 %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %23
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %59
45: ; preds = %23
%46 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%47 = load i32*, i32** %6
%48 = call i32* @fgets(i8* %46, i32 200, i32* %47)
br label %49
49: ; preds = %54, %45
%50 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%51 = load i32*, i32** %6
%52 = call i32* @fgets(i8* %50, i32 200, i32* %51)
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %55)
br label %49
57: ; preds = %49
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %59
59: ; preds = %57, %43, %21
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.tm = type { i32 }
@__const.main.fname = [100 x i8] c"data/2007-08-09.dat\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"time: %i\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [3 x i8] c"%s\00"
@str = [5 x i8] c"done\00"
@str.6 = [6 x i8] c"error\00"
@str.7 = [7 x i8] c"error1\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca %struct.stat
%5 = alloca [200 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.stat* %4 to i8*
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%10 = bitcast i32* %6 to i8*
%11 = call i32 @stat(i8* %7, %struct.stat* %4)
%12 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.7, i64 0, i64 0))
br label %43
16: ; preds = %2
%17 = tail call i32 @time(i32* null)
store i32 %17, i32* %6
%18 = call %struct.tm* @localtime(i32* %6)
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i64 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%23 = load i64, i64* %22
%24 = load i32, i32* %19
%25 = mul i32 %24, 21000
%26 = sext i32 %25 to i64
%27 = sub nsw i64 %23, %26
%28 = load i32, i32* @SEEK_SET
%29 = call i64 @fseek(i32* %12, i64 %27, i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %16
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0))
br label %43
33: ; preds = %16
%34 = call i32* @fgets(i8* %9, i32 200, i32* %12)
%35 = call i32* @fgets(i8* %9, i32 200, i32* %12)
%36 = icmp eq i32* %35, null
br i1 %36, label %41, label %37
37: ; preds = %33, %37
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%39 = call i32* @fgets(i8* %9, i32 200, i32* %12)
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %37
41: ; preds = %37, %33
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %43
43: ; preds = %41, %31, %14
%44 = phi i32 [ 1, %14 ], [ 1, %31 ], [ 0, %41 ]
ret i32 %44
}