#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_CREAT;
int O_WRONLY;
int /*<<< orphan*/ S_IRWXU;
int open(char *, int, int /*<<< orphan*/);
int createdump(char *path) {
  int fd;
  if (!path) {
    fd = open("data", O_WRONLY | O_CREAT | O_APPEND, S_IRWXU);
  } else {
    fd = open(path, O_WRONLY | O_CREAT | O_APPEND, S_IRWXU);
  }
  return fd;
}


x86 assembly (clang, -O0):
<createdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    115f <createdump+0x4f>
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
mov    0x2ec1(%rip),%rax
or     (%rax),%esi
mov    0x2e80(%rip),%rax
or     (%rax),%esi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
lea    0xeae(%rip),%rdi
call   1030 <open@plt>
mov    %eax,-0xc(%rbp)
jmp    118f <createdump+0x7f>
mov    -0x8(%rbp),%rdi
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
mov    0x2e85(%rip),%rax
or     (%rax),%esi
mov    0x2e44(%rip),%rax
or     (%rax),%esi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
call   1030 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createdump>:
mov    0x2eb1(%rip),%rax
mov    0x2eda(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e97(%rip),%rax
or     (%rax),%esi
mov    0x2eae(%rip),%rax
mov    (%rax),%edx
test   %rdi,%rdi
je     113e <createdump+0x2e>
jmp    1030 <open@plt>
lea    0xebb(%rip),%rdi
jmp    1030 <open@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"data\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@S_IRWXU = global i32 0
define i32 @createdump(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_CREAT
%9 = or i32 %7, %8
%10 = load i32, i32* @O_APPEND
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IRWXU
%13 = call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
store i32 %13, i32* %3
br label %23
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = load i32, i32* @O_WRONLY
%17 = load i32, i32* @O_CREAT
%18 = or i32 %16, %17
%19 = load i32, i32* @O_APPEND
%20 = or i32 %18, %19
%21 = load i32, i32* @S_IRWXU
%22 = call i32 @open(i8* %15, i32 %20, i32 %21)
store i32 %22, i32* %3
br label %23
23: ; preds = %14, %6
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [5 x i8] c"data\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@S_IRWXU = global i32 0
define i32 @createdump(i8* %0) {
%2 = icmp eq i8* %0, null
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %4, %3
%6 = load i32, i32* @O_APPEND
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IRWXU
br i1 %2, label %9, label %11
9: ; preds = %1
%10 = tail call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
br label %13
11: ; preds = %1
%12 = tail call i32 @open(i8* %0, i32 %7, i32 %8)
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %12, %11 ], [ %10, %9 ]
ret i32 %14
}