#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_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int, int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int fd;
  fd = open("dfs_write.data", O_CREAT | O_WRONLY, 0644);
  write(fd, "01234", 5);
  write(fd, "56789", 5);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%esi
mov    0x2e7a(%rip),%rax
or     (%rax),%esi
lea    0xea1(%rip),%rdi
mov    $0x1a4,%edx
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xe99(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
lea    0xe8b(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ec0(%rip),%rax
mov    0x2e91(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xeb6(%rip),%rdi
mov    $0x1a4,%edx
call   1050 <open@plt>
mov    %eax,%ebx
lea    0xeb2(%rip),%rsi
mov    %eax,%edi
mov    $0x5,%edx
call   1030 <write@plt>
lea    0xea5(%rip),%rsi
mov    %ebx,%edi
mov    $0x5,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"dfs_write.data\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@.str.1 = [6 x i8] c"01234\00"
@.str.2 = [6 x i8] c"56789\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @O_CREAT
%8 = load i32, i32* @O_WRONLY
%9 = or i32 %7, %8
%10 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %9, i32 420)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%13 = load i32, i32* %6
%14 = call i32 @write(i32 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%15 = load i32, i32* %6
%16 = call i32 @close(i32 %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"dfs_write.data\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@.str.1 = [6 x i8] c"01234\00"
@.str.2 = [6 x i8] c"56789\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_CREAT
%4 = load i32, i32* @O_WRONLY
%5 = or i32 %4, %3
%6 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5, i32 420)
%7 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%8 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%9 = tail call i32 @close(i32 %6)
ret i32 0
}