#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_EXCL;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int errno;
int open(char *, int, int);
int _create(char *path) {
  int fd;
  errno = 0;
  if ((fd = open(path, O_CREAT | O_EXCL,
                 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) ==
      -1) {
    return -errno;
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e8d(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    0x2eb4(%rip),%rax
mov    (%rax),%esi
mov    0x2e7b(%rip),%rax
or     (%rax),%esi
mov    0x2e52(%rip),%rax
mov    (%rax),%edx
mov    0x2e79(%rip),%rax
or     (%rax),%edx
mov    0x2e50(%rip),%rax
or     (%rax),%edx
mov    0x2e6f(%rip),%rax
or     (%rax),%edx
mov    0x2e36(%rip),%rax
or     (%rax),%edx
mov    0x2e15(%rip),%rax
or     (%rax),%edx
call   1040 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11a9 <_create+0x89>
xor    %eax,%eax
mov    0x2e21(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <_create+0x98>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_create>:
push   %rbx
mov    0x2ed0(%rip),%rax
mov    0x2e99(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e6e(%rip),%rax
mov    0x2e97(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e6c(%rip),%rax
or     (%rax),%edx
mov    0x2e8b(%rip),%rax
or     (%rax),%edx
mov    0x2e62(%rip),%rbx
mov    0x2e4b(%rip),%rax
or     (%rax),%edx
movl   $0x0,(%rbx)
mov    0x2e24(%rip),%rax
or     (%rax),%edx
call   1040 <open@plt>
cmp    $0xffffffff,%eax
je     118b <_create+0x6b>
mov    %eax,%edi
call   1030 <close@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
sub    (%rbx),%eax
pop    %rbx
ret

LLVM IR (-O0):
@errno = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
define i32 @_create(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* @errno
%5 = load i8*, i8** %3
%6 = load i32, i32* @O_CREAT
%7 = load i32, i32* @O_EXCL
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IRUSR
%10 = load i32, i32* @S_IWUSR
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IRGRP
%13 = or i32 %11, %12
%14 = load i32, i32* @S_IWGRP
%15 = or i32 %13, %14
%16 = load i32, i32* @S_IROTH
%17 = or i32 %15, %16
%18 = load i32, i32* @S_IWOTH
%19 = or i32 %17, %18
%20 = call i32 @open(i8* %5, i32 %8, i32 %19)
store i32 %20, i32* %4
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %1
%23 = load i32, i32* @errno
%24 = sub nsw i32 0, %23
store i32 %24, i32* %2
br label %28
25: ; preds = %1
%26 = load i32, i32* %4
%27 = call i32 @close(i32 %26)
store i32 0, i32* %2
br label %28
28: ; preds = %25, %22
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@errno = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
define i32 @_create(i8* nocapture %0) {
store i32 0, i32* @errno
%2 = load i32, i32* @O_CREAT
%3 = load i32, i32* @O_EXCL
%4 = or i32 %3, %2
%5 = load i32, i32* @S_IRUSR
%6 = load i32, i32* @S_IWUSR
%7 = or i32 %6, %5
%8 = load i32, i32* @S_IRGRP
%9 = or i32 %7, %8
%10 = load i32, i32* @S_IWGRP
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IROTH
%13 = or i32 %11, %12
%14 = load i32, i32* @S_IWOTH
%15 = or i32 %13, %14
%16 = tail call i32 @open(i8* %0, i32 %4, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = load i32, i32* @errno
%20 = sub nsw i32 0, %19
br label %23
21: ; preds = %1
%22 = tail call i32 @close(i32 %16)
br label %23
23: ; preds = %21, %18
%24 = phi i32 [ %20, %18 ], [ 0, %21 ]
ret i32 %24
}