#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*/ O_RDONLY;
int /*<<< orphan*/ Platform_Halt(int);
int errno;
int open(char *, int /*<<< orphan*/);
int Platform_OldRO(unsigned char *n, long long n__len, long long *h) {
  int _o_result;
  int fd;
  fd = open((char *)n, O_RDONLY);
  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_OldRO>:
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    0x2eb9(%rip),%rax
mov    (%rax),%esi
call   1030 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    115a <Platform_OldRO+0x4a>
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1172 <Platform_OldRO+0x62>
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_OldRO>:
push   %rbx
mov    %rdx,%rbx
mov    0x2ecd(%rip),%rax
mov    (%rax),%esi
call   1030 <open@plt>
test   %eax,%eax
js     112f <Platform_OldRO+0x1f>
mov    %eax,%eax
mov    %rax,(%rbx)
xor    %eax,%eax
pop    %rbx
ret
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@errno = global i32 0
define i32 @Platform_OldRO(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_RDONLY
%12 = call i32 @open(i8* %10, i32 %11)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i32, i32* @errno
store i32 %16, i32* %8
%17 = load i32, i32* %8
store i32 %17, i32* %4
br label %25
18: ; preds = %3
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = load i64*, i64** %7
store i64 %20, i64* %21
store i32 0, i32* %8
%22 = load i32, i32* %8
store i32 %22, i32* %4
br label %25
23: ; No predecessors!
%24 = call i32 @Platform_Halt(i32 -3)
store i32 0, i32* %4
br label %25
25: ; preds = %23, %18, %15
%26 = load i32, i32* %4
ret i32 %26
}

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