#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 O_CREAT;
int O_TRUNC;
int O_WRONLY;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWUSR;
int open(char *, int, int);
int main(void) {
  int fd;
  fd = open("/Users/aaa/cprograms/systemProgramming/deneme.txt",
            O_WRONLY | O_CREAT | O_TRUNC,
            S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IROTH);
  if (fd == -1)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    0x2ec9(%rip),%rax
or     (%rax),%esi
mov    0x2eb8(%rip),%rax
or     (%rax),%esi
mov    0x2e8f(%rip),%rax
mov    (%rax),%edx
mov    0x2e66(%rip),%rax
or     (%rax),%edx
mov    0x2e85(%rip),%rax
or     (%rax),%edx
mov    0x2e64(%rip),%rax
or     (%rax),%edx
mov    0x2e53(%rip),%rax
or     (%rax),%edx
lea    0xe92(%rip),%rdi
call   1030 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    118c <main+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <main+0x83>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e88(%rip),%rax
mov    0x2ed9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2ec6(%rip),%rax
or     (%rax),%esi
mov    0x2e9d(%rip),%rax
mov    0x2e76(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e93(%rip),%rax
or     (%rax),%edx
mov    0x2e72(%rip),%rax
or     (%rax),%edx
mov    0x2e61(%rip),%rax
or     (%rax),%edx
lea    0xea0(%rip),%rdi
call   1030 <open@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
neg    %ecx
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"/Users/aaa/cprograms/systemProgramming/deneme.txt\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IWUSR = global i32 0
@S_IRUSR = global i32 0
@S_IWGRP = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %3, %4
%6 = load i32, i32* @O_TRUNC
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IWUSR
%9 = load i32, i32* @S_IRUSR
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IWGRP
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IRGRP
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IROTH
%16 = or i32 %14, %15
%17 = call i32 @open(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %0
store i32 -1, i32* %1
br label %22
21: ; preds = %0
store i32 0, i32* %1
br label %22
22: ; preds = %21, %20
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [50 x i8] c"/Users/aaa/cprograms/systemProgramming/deneme.txt\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IWUSR = global i32 0
@S_IRUSR = global i32 0
@S_IWGRP = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = load i32, i32* @O_CREAT
%3 = or i32 %2, %1
%4 = load i32, i32* @O_TRUNC
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IWUSR
%7 = load i32, i32* @S_IRUSR
%8 = or i32 %7, %6
%9 = load i32, i32* @S_IWGRP
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IRGRP
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IROTH
%14 = or i32 %12, %13
%15 = tail call i32 @open(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %14)
%16 = icmp eq i32 %15, -1
%17 = sext i1 %16 to i32
ret i32 %17
}