#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*/ word;
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
int open(char *, int /*<<< orphan*/);
int write(int, unsigned long *, size_t);
int main(void) {
  int fd;
  unsigned long word = 1720;
  size_t count;
  ssize_t nr;
  fd = open("/Users/aaa/cprograms/systemProgramming/deneme.txt", O_WRONLY);
  count = sizeof(word);
  nr = write(fd, &word, count);
  if (nr == -1)
    return -1;
  else if (nr != count)
    return nr - count;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x6b8,-0x10(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
lea    0xeb9(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
movq   $0x8,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rdx
lea    -0x10(%rbp),%rsi
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1180 <main+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <main+0x8a>
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     119e <main+0x7e>
movslq -0x1c(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    11aa <main+0x8a>
jmp    11a3 <main+0x83>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x6b8,(%rsp)
mov    0x2ea8(%rip),%rax
mov    (%rax),%esi
lea    0xec7(%rip),%rdi
call   1040 <open@plt>
mov    %rsp,%rsi
mov    $0x8,%edx
mov    %eax,%edi
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     1159 <main+0x39>
cmp    $0x8,%eax
jne    115b <main+0x3b>
xor    %eax,%eax
pop    %rcx
ret
add    $0xfffffff8,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"/Users/aaa/cprograms/systemProgramming/deneme.txt\00"
@O_WRONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
store i64 1720, i64* %3
%6 = load i32, i32* @O_WRONLY
%7 = call i32 @open(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %2
store i64 8, i64* %4
%8 = load i32, i32* %2
%9 = load i64, i64* %4
%10 = call i32 @write(i32 %8, i64* %3, i64 %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 -1, i32* %1
br label %27
14: ; preds = %0
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = load i64, i64* %4
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = load i64, i64* %4
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %1
br label %27
25: ; preds = %14
br label %26
26: ; preds = %25
store i32 0, i32* %1
br label %27
27: ; preds = %26, %19, %13
%28 = load i32, i32* %1
ret i32 %28
}

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