#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 */
struct parse {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ assert(struct parse *);
int errno;
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ parse_init(struct parse *, int);
int parse_init_open(struct parse *parse, const char *path) {
  int file;
  assert(parse);
  file = open(path, O_RDONLY);
  if (file < 0)
    return -errno;
  parse_init(parse, file);
  return 0;
}


x86 assembly (clang, -O0):
<parse_init_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e94(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    117b <parse_init_open+0x4b>
xor    %eax,%eax
mov    0x2e67(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <parse_init_open+0x5e>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <parse_init@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_init_open>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1040 <open@plt>
test   %eax,%eax
js     1162 <parse_init_open+0x32>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <parse_init@plt>
xor    %eax,%eax
jmp    116d <parse_init_open+0x3d>
mov    0x2e6f(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.parse = type { i32 }
@O_RDONLY = global i32 0
@errno = global i32 0
define i32 @parse_init_open(%struct.parse* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.parse*
%5 = alloca i8*
%6 = alloca i32
store %struct.parse* %0, %struct.parse** %4
store i8* %1, i8** %5
%7 = load %struct.parse*, %struct.parse** %4
%8 = call i32 @assert(%struct.parse* %7)
%9 = load i8*, i8** %5
%10 = load i32, i32* @O_RDONLY
%11 = call i32 @open(i8* %9, i32 %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @errno
%16 = sub nsw i32 0, %15
store i32 %16, i32* %3
br label %21
17: ; preds = %2
%18 = load %struct.parse*, %struct.parse** %4
%19 = load i32, i32* %6
%20 = call i32 @parse_init(%struct.parse* %18, i32 %19)
store i32 0, i32* %3
br label %21
21: ; preds = %17, %14
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%struct.parse = type { i32 }
@O_RDONLY = global i32 0
@errno = global i32 0
define i32 @parse_init_open(%struct.parse* %0, i8* nocapture %1) {
%3 = tail call i32 @assert(%struct.parse* %0)
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i8* %1, i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* @errno
%9 = sub nsw i32 0, %8
br label %12
10: ; preds = %2
%11 = tail call i32 @parse_init(%struct.parse* %0, i32 %5)
br label %12
12: ; preds = %10, %7
%13 = phi i32 [ %9, %7 ], [ 0, %10 ]
ret i32 %13
}