#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *low_libfn(char *, int);
int /*<<< orphan*/ stderr;
FILE *low_libopen(char *file, int bFatal) {
  FILE *ff;
  char *fn;
  fn = low_libfn(file, bFatal);
  if (fn == NULL) {
    ff = NULL;
  } else {
    if (bFatal)
      fprintf(stderr, "Opening library file %s\n", fn);
    ff = fopen(fn, "r");
  }
  return ff;
}


x86 assembly (clang, -O0):
<low_libopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <low_libfn@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1167 <low_libopen+0x37>
movq   $0x0,-0x18(%rbp)
jmp    119e <low_libopen+0x6e>
cmpl   $0x0,-0xc(%rbp)
je     118a <low_libopen+0x5a>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe7b(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<low_libopen>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1040 <low_libfn@plt>
test   %rax,%rax
je     1173 <low_libopen+0x43>
mov    %rax,%rbx
test   %ebp,%ebp
je     115e <low_libopen+0x2e>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <fopen@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Opening library file %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
define i32* @low_libopen(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = call i8* @low_libfn(i8* %7, i32 %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
store i32* null, i32** %5
br label %23
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %6
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %13
%21 = load i8*, i8** %6
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %5
br label %23
23: ; preds = %20, %12
%24 = load i32*, i32** %5
ret i32* %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Opening library file %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
define noalias i32* @low_libopen(i8* %0, i32 %1) {
%3 = tail call i8* @low_libfn(i8* %0, i32 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %10
10: ; preds = %7, %5
%11 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %2, %10
%13 = phi i32* [ %11, %10 ], [ null, %2 ]
ret i32* %13
}