#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 /*<<< orphan*/ LOG_MESSAGE(char *);
int O_CREAT;
int O_EXCL;
int S_IRWXG;
int S_IRWXU;
int S_IXGRP;
int S_IXUSR;
int /*<<< orphan*/ close(int);
int open(char *, int, int);
void syncfile_ensure_exists() {
  int fd;
  fd = open("plazapool", O_CREAT | O_EXCL,
            (S_IRWXU & ~S_IXUSR) | (S_IRWXG & ~S_IXGRP));
  if (fd != -1) {
    LOG_MESSAGE("New empty syncfile created");
    close(fd);
  }
}


x86 assembly (clang, -O0):
<syncfile_ensure_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%esi
mov    0x2e70(%rip),%rax
or     (%rax),%esi
mov    0x2e8f(%rip),%rax
mov    (%rax),%edx
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%edx
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    0x2e57(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
or     %eax,%edx
lea    0xe7f(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     11a7 <syncfile_ensure_exists+0x77>
lea    0xe70(%rip),%rdi
call   1050 <LOG_MESSAGE@plt>
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syncfile_ensure_exists>:
push   %rbx
mov    0x2ec0(%rip),%rax
mov    0x2e79(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e96(%rip),%rax
mov    0x2e7f(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    (%rax),%ecx
mov    0x2e7a(%rip),%rax
mov    0x2e63(%rip),%rdx
mov    (%rdx),%edx
not    %edx
and    (%rax),%edx
or     %ecx,%edx
lea    0xe8c(%rip),%rdi
call   1040 <open@plt>
cmp    $0xffffffff,%eax
je     1194 <syncfile_ensure_exists+0x64>
mov    %eax,%ebx
lea    0xe83(%rip),%rdi
call   1050 <LOG_MESSAGE@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1030 <close@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"plazapool\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@S_IRWXU = global i32 0
@S_IXUSR = global i32 0
@S_IRWXG = global i32 0
@S_IXGRP = global i32 0
@.str.1 = [27 x i8] c"New empty syncfile created\00"
define void @syncfile_ensure_exists() {
%1 = alloca i32
%2 = load i32, i32* @O_CREAT
%3 = load i32, i32* @O_EXCL
%4 = or i32 %2, %3
%5 = load i32, i32* @S_IRWXU
%6 = load i32, i32* @S_IXUSR
%7 = xor i32 %6, -1
%8 = and i32 %5, %7
%9 = load i32, i32* @S_IRWXG
%10 = load i32, i32* @S_IXGRP
%11 = xor i32 %10, -1
%12 = and i32 %9, %11
%13 = or i32 %8, %12
%14 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %13)
store i32 %14, i32* %1
%15 = load i32, i32* %1
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %0
%18 = call i32 @LOG_MESSAGE(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* %1
%20 = call i32 @close(i32 %19)
br label %21
21: ; preds = %17, %0
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"plazapool\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@S_IRWXU = global i32 0
@S_IXUSR = global i32 0
@S_IRWXG = global i32 0
@S_IXGRP = global i32 0
@.str.1 = [27 x i8] c"New empty syncfile created\00"
define void @syncfile_ensure_exists() {
%1 = load i32, i32* @O_CREAT
%2 = load i32, i32* @O_EXCL
%3 = or i32 %2, %1
%4 = load i32, i32* @S_IRWXU
%5 = load i32, i32* @S_IXUSR
%6 = xor i32 %5, -1
%7 = and i32 %4, %6
%8 = load i32, i32* @S_IRWXG
%9 = load i32, i32* @S_IXGRP
%10 = xor i32 %9, -1
%11 = and i32 %8, %10
%12 = or i32 %11, %7
%13 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = tail call i32 @LOG_MESSAGE(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @close(i32 %13)
br label %18
18: ; preds = %15, %0
ret void
}