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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sleep(double);
int main() {
  int fd = open("c5.dat", O_RDONLY);
  char buf[1024];
  while (1) {
    if (read(fd, buf, 1024) > 0) {
      printf("%s", buf);
    }
    sleep(0.5);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
lea    0xea6(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <read@plt>
cmp    $0x0,%rax
jle    119b <main+0x5b>
lea    -0x410(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
movsd  0xe5d(%rip),%xmm0
call   1060 <sleep@plt>
jmp    116a <main+0x2a>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
lea    0xeac(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
mov    %rsp,%r14
lea    0xea2(%rip),%r15
jmp    117d <main+0x3d>
nop
movsd  0xe88(%rip),%xmm0
call   1060 <sleep@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1040 <read@plt>
test   %rax,%rax
jle    1170 <main+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
jmp    1170 <main+0x30>

LLVM IR (-O0):
@.str = [7 x i8] c"c5.dat\00"
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
store i32 0, i32* %1
%4 = load i32, i32* @O_RDONLY
%5 = call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %2
br label %6
6: ; preds = %0, %14
%7 = load i32, i32* %2
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = call i64 @read(i32 %7, i8* %8, i32 1024)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %6
%15 = call i32 @sleep(double 5.000000e-01)
br label %6
}

LLVM IR (-O2):
@.str = [7 x i8] c"c5.dat\00"
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = load i32, i32* @O_RDONLY
%3 = tail call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
br label %5
5: ; preds = %10, %0
%6 = call i64 @read(i32 %3, i8* %4, i32 1024)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %10
10: ; preds = %8, %5
%11 = call i32 @sleep(double 5.000000e-01)
br label %5
}