#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_APPEND;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ getchar();
int open(char *, int);
int /*<<< orphan*/ printf(char *, int);
int file1(void) {
  int fname = open("/Users/sergey/Documents/programming/cs50git/os/file1.c",
                   O_WRONLY | O_APPEND);
  int fname2 = open("/Users/sergey/Documents/programming/cs50git/os/fork1.c",
                    O_WRONLY | O_APPEND);
  printf(" fname= %lu \n", sizeof("blablablsd"));
  printf(" fname2= %i \n", fname2);
  close(fname);
  close(fname2);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<file1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
mov    0x2e78(%rip),%rax
or     (%rax),%esi
lea    0xe9f(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
mov    0x2e57(%rip),%rax
or     (%rax),%esi
lea    0xeb5(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0xb,%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file1>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e8d(%rip),%r14
mov    0x2e7e(%rip),%rbp
mov    0x0(%rbp),%esi
or     (%r14),%esi
lea    0xea1(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%esi
or     (%r14),%esi
lea    0xec4(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
lea    0xeed(%rip),%rdi
mov    $0xb,%esi
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %ebp,%edi
call   1040 <close@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"/Users/sergey/Documents/programming/cs50git/os/file1.c\00"
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@.str.1 = [55 x i8] c"/Users/sergey/Documents/programming/cs50git/os/fork1.c\00"
@.str.2 = [14 x i8] c" fname= %lu \0A\00"
@.str.3 = [14 x i8] c" fname2= %i \0A\00"
define i32 @file1() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_APPEND
%5 = or i32 %3, %4
%6 = call i32 @open(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %1
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_APPEND
%9 = or i32 %7, %8
%10 = call i32 @open(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %9)
store i32 %10, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 11)
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = call i32 @close(i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @close(i32 %16)
%18 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [55 x i8] c"/Users/sergey/Documents/programming/cs50git/os/file1.c\00"
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@.str.1 = [55 x i8] c"/Users/sergey/Documents/programming/cs50git/os/fork1.c\00"
@.str.2 = [14 x i8] c" fname= %lu \0A\00"
@.str.3 = [14 x i8] c" fname2= %i \0A\00"
define i32 @file1() {
%1 = load i32, i32* @O_WRONLY
%2 = load i32, i32* @O_APPEND
%3 = or i32 %2, %1
%4 = tail call i32 @open(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_APPEND
%7 = or i32 %6, %5
%8 = tail call i32 @open(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 11)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%11 = tail call i32 @close(i32 %4)
%12 = tail call i32 @close(i32 %8)
%13 = tail call i32 (...) @getchar()
ret i32 0
}