#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_RDWR;
int O_TRUNC;
int /*<<< orphan*/ Platform_Halt(int);
int errno;
int open(char *, int, int);
int Platform_New(unsigned char *n, long long n__len, long long *h) {
  int _o_result;
  int fd;
  fd = open((char *)n, O_CREAT | O_TRUNC | O_RDWR, 0664);
  if (fd < 0) {
    _o_result = errno;
    return _o_result;
  } else {
    *h = fd;
    _o_result = 0;
    return _o_result;
  }
__retchk:
  Platform_Halt(-3);
  return 0;
  ;
}


x86 assembly (clang, -O0):
<Platform_New>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2ec9(%rip),%rax
mov    (%rax),%esi
mov    0x2eb8(%rip),%rax
or     (%rax),%esi
mov    0x2e97(%rip),%rax
or     (%rax),%esi
mov    $0x1b4,%edx
call   1030 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1171 <Platform_New+0x61>
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <Platform_New+0x79>
movslq -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Platform_New>:
push   %rbx
mov    0x2ee0(%rip),%rax
mov    0x2ed1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rdx,%rbx
mov    0x2eab(%rip),%rax
or     (%rax),%esi
mov    $0x1b4,%edx
call   1030 <open@plt>
test   %eax,%eax
js     1146 <Platform_New+0x36>
mov    %eax,%eax
mov    %rax,(%rbx)
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@errno = global i32 0
define i32 @Platform_New(i8* %0, i64 %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64* %2, i64** %7
%10 = load i8*, i8** %5
%11 = load i32, i32* @O_CREAT
%12 = load i32, i32* @O_TRUNC
%13 = or i32 %11, %12
%14 = load i32, i32* @O_RDWR
%15 = or i32 %13, %14
%16 = call i32 @open(i8* %10, i32 %15, i32 436)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load i32, i32* @errno
store i32 %20, i32* %8
%21 = load i32, i32* %8
store i32 %21, i32* %4
br label %29
22: ; preds = %3
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = load i64*, i64** %7
store i64 %24, i64* %25
store i32 0, i32* %8
%26 = load i32, i32* %8
store i32 %26, i32* %4
br label %29
27: ; No predecessors!
%28 = call i32 @Platform_Halt(i32 -3)
store i32 0, i32* %4
br label %29
29: ; preds = %27, %22, %19
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@errno = global i32 0
define i32 @Platform_New(i8* nocapture %0, i64 %1, i64* nocapture writeonly %2) {
%4 = load i32, i32* @O_CREAT
%5 = load i32, i32* @O_TRUNC
%6 = or i32 %5, %4
%7 = load i32, i32* @O_RDWR
%8 = or i32 %6, %7
%9 = tail call i32 @open(i8* %0, i32 %8, i32 436)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = load i32, i32* @errno
br label %15
13: ; preds = %3
%14 = zext i32 %9 to i64
store i64 %14, i64* %2
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ %12, %11 ], [ 0, %13 ]
ret i32 %16
}