#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 scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, scalar_t__);
int open(char *, int /*<<< orphan*/);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int fd;
  char buf[1024];
  ssize_t n;
  fd = open("0153881891000013000000130111", O_RDONLY);
  for (;;) {
    n = read(fd, buf, 1024);
    if (n == 0) {
      break;
    }
    fprintf(stderr, "read %ld\n", n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    0xea7(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1030 <read@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
jne    118f <main+0x5f>
jmp    11b0 <main+0x80>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x428(%rbp),%rdx
lea    0xe77(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1161 <main+0x31>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    0x2ea3(%rip),%rax
mov    (%rax),%esi
lea    0xeb2(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x400,%edx
call   1030 <read@plt>
test   %rax,%rax
je     11a3 <main+0x73>
mov    0x2e68(%rip),%r12
lea    0xea6(%rip),%r14
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1030 <read@plt>
test   %rax,%rax
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"0153881891000013000000130111\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [10 x i8] c"read %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 %10, i32* %6
br label %11
11: ; preds = %18, %2
%12 = load i32, i32* %6
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%14 = call i64 @read(i32 %12, i8* %13, i32 1024)
store i64 %14, i64* %8
%15 = load i64, i64* %8
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %11
br label %22
18: ; preds = %11
%19 = load i32, i32* @stderr
%20 = load i64, i64* %8
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %20)
br label %11
22: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"0153881891000013000000130111\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [10 x i8] c"read %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i64 @read(i32 %6, i8* %4, i32 1024)
%8 = icmp eq i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %2, %9
%10 = phi i64 [ %13, %9 ], [ %7, %2 ]
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%13 = call i64 @read(i32 %6, i8* %4, i32 1024)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %9
15: ; preds = %9, %2
ret i32 0
}