#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*/ shm_error(char *);
int shm_open(char *, int, int);
int /*<<< orphan*/ trace_flow(char *);
int open_and_confirm(char *name, int o_flags, int flags) {
  if (1) {
    trace_flow("ENTERING: open_and_confirm");
  }
  int fd = shm_open(name, o_flags, flags);
  if (1 && fd == -1) {
    shm_error("fd");
  }
  if (1) {
    trace_flow("LEAVING: open_and_confirm");
  }
  return fd;
}


x86 assembly (clang, -O0):
<open_and_confirm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xeb7(%rip),%rdi
call   1050 <trace_flow@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <shm_open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1176 <open_and_confirm+0x46>
lea    0xeaa(%rip),%rdi
call   1030 <shm_error@plt>
lea    0xea1(%rip),%rdi
call   1050 <trace_flow@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_and_confirm>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xebd(%rip),%rdi
call   1050 <trace_flow@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <shm_open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1168 <open_and_confirm+0x38>
lea    0xeb8(%rip),%rdi
call   1030 <shm_error@plt>
lea    0xeaf(%rip),%rdi
call   1050 <trace_flow@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"ENTERING: open_and_confirm\00"
@.str.1 = [3 x i8] c"fd\00"
@.str.2 = [26 x i8] c"LEAVING: open_and_confirm\00"
define i32 @open_and_confirm(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = call i32 @trace_flow(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %4
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i32 @shm_open(i8* %9, i32 %10, i32 %11)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @shm_error(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = call i32 @trace_flow(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* %7
ret i32 %19
}

LLVM IR (-O2):
@.str = [27 x i8] c"ENTERING: open_and_confirm\00"
@.str.1 = [3 x i8] c"fd\00"
@.str.2 = [26 x i8] c"LEAVING: open_and_confirm\00"
define i32 @open_and_confirm(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 @trace_flow(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @shm_open(i8* %0, i32 %1, i32 %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @shm_error(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %3
%10 = tail call i32 @trace_flow(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
ret i32 %5
}