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

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int, ...);
int /*<<< orphan*/ pread(int, char *, int, int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  int fd;
  loff_t res;
  char buf[64], buf1[32], buf2[32], buf3[32];
  fd = open("foobar1", O_WRONLY | O_CREAT, 0666);
  write(fd, "Hello world abcdefghijklmnopqrstuvwxyz 01234567890123456789", 59);
  close(fd);
  fd = open("foobar1", O_RDONLY);
  pread(fd, buf, 11, 10);
  pread(-1, buf, 11, 10);
  pread(fd, (void *)-1, 11, 10);
  pread(-1, NULL, -1, 10);
  pread(fd, buf, 11, -1);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
mov    0x2e96(%rip),%rax
or     (%rax),%esi
lea    0xe95(%rip),%rdi
mov    $0x1b6,%edx
mov    $0x0,%al
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    0xe84(%rip),%rsi
mov    $0x3b,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0xb,%edx
mov    $0xa,%ecx
call   1060 <pread@plt>
lea    -0x50(%rbp),%rsi
mov    $0xffffffff,%edi
mov    $0xb,%edx
mov    $0xa,%ecx
call   1060 <pread@plt>
mov    -0x8(%rbp),%edi
mov    $0xffffffffffffffff,%rsi
mov    $0xb,%edx
mov    $0xa,%ecx
call   1060 <pread@plt>
mov    $0xffffffff,%edx
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%ecx
mov    %edx,%edi
call   1060 <pread@plt>
mov    -0x8(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0xb,%edx
mov    $0xffffffff,%ecx
call   1060 <pread@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    0x2e79(%rip),%rax
mov    0x2ea2(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe9f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   1050 <open@plt>
mov    %eax,%ebp
lea    0xe8f(%rip),%rsi
mov    %eax,%edi
mov    $0x3b,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <open@plt>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0xb,%edx
mov    $0xa,%ecx
call   1060 <pread@plt>
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    $0xb,%edx
mov    $0xa,%ecx
call   1060 <pread@plt>
mov    %ebx,%edi
mov    $0xffffffffffffffff,%rsi
mov    $0xb,%edx
mov    $0xa,%ecx
call   1060 <pread@plt>
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    $0xffffffff,%edx
mov    $0xa,%ecx
call   1060 <pread@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xb,%edx
mov    $0xffffffff,%ecx
call   1060 <pread@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"foobar1\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.1 = [60 x i8] c"Hello world abcdefghijklmnopqrstuvwxyz 01234567890123456789\00"
@O_RDONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [64 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
store i32 0, i32* %1
%8 = load i32, i32* @O_WRONLY
%9 = load i32, i32* @O_CREAT
%10 = or i32 %8, %9
%11 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10, i32 438)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = call i32 @write(i32 %12, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i32 59)
%14 = load i32, i32* %2
%15 = call i32 @close(i32 %14)
%16 = load i32, i32* @O_RDONLY
%17 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%20 = call i32 @pread(i32 %18, i8* %19, i32 11, i32 10)
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%22 = call i32 @pread(i32 -1, i8* %21, i32 11, i32 10)
%23 = load i32, i32* %2
%24 = call i32 @pread(i32 %23, i8* inttoptr (i64 -1 to i8*), i32 11, i32 10)
%25 = call i32 @pread(i32 -1, i8* null, i32 -1, i32 10)
%26 = load i32, i32* %2
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%28 = call i32 @pread(i32 %26, i8* %27, i32 11, i32 -1)
%29 = load i32, i32* %2
%30 = call i32 @close(i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"foobar1\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.1 = [60 x i8] c"Hello world abcdefghijklmnopqrstuvwxyz 01234567890123456789\00"
@O_RDONLY = global i32 0
define i32 @main() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %4, %3
%6 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5, i32 438)
%7 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i32 59)
%8 = tail call i32 @close(i32 %6)
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @pread(i32 %10, i8* %2, i32 11, i32 10)
%12 = call i32 @pread(i32 -1, i8* %2, i32 11, i32 10)
%13 = tail call i32 @pread(i32 %10, i8* inttoptr (i64 -1 to i8*), i32 11, i32 10)
%14 = tail call i32 @pread(i32 -1, i8* null, i32 -1, i32 10)
%15 = call i32 @pread(i32 %10, i8* %2, i32 11, i32 -1)
%16 = tail call i32 @close(i32 %10)
ret i32 0
}