#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv) {
  int fd = open(argv[1], O_RDONLY);
  for (;;) {
    lseek(fd, 0, SEEK_SET);
    char buf[0x10000] = {0};
    read(fd, buf, sizeof(buf) - 1);
    printf("%s\n\n", buf);
    sleep(1);
  }
  close(fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
lea    -0x10020(%rbp),%rdi
xor    %esi,%esi
mov    $0x10000,%edx
call   1050 <memset@plt>
mov    -0x14(%rbp),%edi
lea    -0x10020(%rbp),%rsi
mov    $0xffff,%edx
call   1060 <read@plt>
lea    -0x10020(%rbp),%rsi
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    1192 <main+0x32>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10008,%rsp
mov    0x8(%rsi),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,%ebx
mov    0x2e4f(%rip),%r12
mov    %rsp,%r14
lea    0xe6d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    $0x10000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xffff,%edx
call   1060 <read@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    11a0 <main+0x40>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@SEEK_SET = global i32 0
@.str = [5 x i8] c"%s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [65536 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @O_RDONLY
%12 = call i32 @open(i8* %10, i32 %11)
store i32 %12, i32* %6
br label %13
13: ; preds = %13, %2
%14 = load i32, i32* %6
%15 = load i32, i32* @SEEK_SET
%16 = call i32 @lseek(i32 %14, i32 0, i32 %15)
%17 = bitcast [65536 x i8]* %7 to i8*
%18 = load i32, i32* %6
%19 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%20 = call i32 @read(i32 %18, i8* %19, i32 65535)
%21 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @sleep(i32 1)
br label %13
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@SEEK_SET = global i32 0
@.str = [5 x i8] c"%s\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65536 x i8]
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 @open(i8* %5, i32 %6)
%8 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
br label %9
9: ; preds = %9, %2
%10 = load i32, i32* @SEEK_SET
%11 = call i32 @lseek(i32 %7, i32 0, i32 %10)
%12 = call i32 @read(i32 %7, i8* %8, i32 65535)
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8)
%14 = call i32 @sleep(i32 1)
br label %9
}