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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, unsigned long);
int read(int, unsigned long *, int);
int main(void) {
  int fd;
  unsigned long word;
  ssize_t nr;
  fd = open("/Users/aaa/cprograms/systemProgramming/deneme.txt", O_RDONLY);
  nr = read(fd, &word, sizeof(unsigned long));
  if (nr == -1)
    return -1;
  printf("%lu", word);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
lea    0xeb1(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1040 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1181 <main+0x51>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <main+0x68>
mov    -0x10(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%esi
lea    0xebf(%rip),%rdi
call   1050 <open@plt>
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x8,%edx
call   1040 <read@plt>
cmp    $0xffffffff,%eax
je     116e <main+0x3e>
mov    (%rsp),%rsi
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"/Users/aaa/cprograms/systemProgramming/deneme.txt\00"
@O_RDONLY = global i32 0
@.str.1 = [4 x i8] c"%lu\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = call i32 @read(i32 %7, i64* %3, i32 8)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 -1, i32* %1
br label %15
12: ; preds = %0
%13 = load i64, i64* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %13)
store i32 0, i32* %1
br label %15
15: ; preds = %12, %11
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [50 x i8] c"/Users/aaa/cprograms/systemProgramming/deneme.txt\00"
@O_RDONLY = global i32 0
@.str.1 = [4 x i8] c"%lu\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @read(i32 %4, i64* %1, i32 8)
%6 = icmp eq i32 %5, -1
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i64, i64* %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %8)
br label %10
10: ; preds = %0, %7
%11 = phi i32 [ 0, %7 ], [ -1, %0 ]
ret i32 %11
}