#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_SYNC;
int O_WRONLY;
int S_IRUSR;
int S_IWUSR;
int open(char const *, int, int);
int internal_log_file_open(const char *fname) {
  int ret = -1;
  if (fname != 0) {
    ret =
        open(fname, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, S_IRUSR | S_IWUSR);
  }
  return ret;
}


x86 assembly (clang, -O0):
<internal_log_file_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1170 <internal_log_file_open+0x60>
mov    -0x8(%rbp),%rdi
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
mov    0x2eb6(%rip),%rax
or     (%rax),%esi
mov    0x2e65(%rip),%rax
or     (%rax),%esi
mov    0x2e8c(%rip),%rax
or     (%rax),%esi
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
mov    0x2e72(%rip),%rax
or     (%rax),%edx
call   1030 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<internal_log_file_open>:
test   %rdi,%rdi
je     1150 <internal_log_file_open+0x40>
mov    0x2e9c(%rip),%rax
mov    0x2ed5(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e82(%rip),%rax
or     (%rax),%esi
mov    0x2ea9(%rip),%rax
or     (%rax),%esi
mov    0x2e88(%rip),%rax
mov    0x2e91(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
jmp    1030 <open@plt>
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@O_SYNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
define i32 @internal_log_file_open(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 -1, i32* %3
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = load i32, i32* @O_WRONLY
%9 = load i32, i32* @O_CREAT
%10 = or i32 %8, %9
%11 = load i32, i32* @O_APPEND
%12 = or i32 %10, %11
%13 = load i32, i32* @O_SYNC
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IRUSR
%16 = load i32, i32* @S_IWUSR
%17 = or i32 %15, %16
%18 = call i32 @open(i8* %7, i32 %14, i32 %17)
store i32 %18, i32* %3
br label %19
19: ; preds = %6, %1
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@O_SYNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
define i32 @internal_log_file_open(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = load i32, i32* @O_WRONLY
%5 = load i32, i32* @O_CREAT
%6 = or i32 %5, %4
%7 = load i32, i32* @O_APPEND
%8 = or i32 %6, %7
%9 = load i32, i32* @O_SYNC
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IRUSR
%12 = load i32, i32* @S_IWUSR
%13 = or i32 %12, %11
%14 = tail call i32 @open(i8* %0, i32 %10, i32 %13)
br label %15
15: ; preds = %3, %1
%16 = phi i32 [ %14, %3 ], [ -1, %1 ]
ret i32 %16
}