#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*/ *stderr;
FILE *get_logfile() {
  static FILE *logfile = NULL;
  if (NULL != logfile) {
    return logfile;
  }
  logfile = fopen(("/tmp/addr_shim.log"), "w");
  if (NULL == logfile) {
    logfile = stderr;
  }
  return logfile;
}


x86 assembly (clang, -O0):
<get_logfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
cmp    0x2f0f(%rip),%rax
je     1137 <get_logfile+0x27>
mov    0x2f02(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117c <get_logfile+0x6c>
lea    0xec2(%rip),%rdi
lea    0xece(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,0x2edf(%rip)
xor    %eax,%eax
cmp    0x2ed6(%rip),%rax
jne    1171 <get_logfile+0x61>
mov    0x2e79(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2ebf(%rip)
mov    0x2eb8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_logfile>:
push   %rax
mov    0x2f18(%rip),%rax
test   %rax,%rax
je     111f <get_logfile+0xf>
pop    %rcx
ret
lea    0xeda(%rip),%rdi
lea    0xee6(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,0x2ef7(%rip)
test   %rax,%rax
jne    111d <get_logfile+0xd>
mov    0x2e9b(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2ee1(%rip)
pop    %rcx
ret

LLVM IR (-O0):
@get_logfile.logfile = internal global i32* null
@.str = [19 x i8] c"/tmp/addr_shim.log\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32* null
define i32* @get_logfile() {
%1 = alloca i32*
%2 = load i32*, i32** @get_logfile.logfile
%3 = icmp ne i32* null, %2
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = load i32*, i32** @get_logfile.logfile
store i32* %5, i32** %1
br label %14
6: ; preds = %0
%7 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** @get_logfile.logfile
%8 = load i32*, i32** @get_logfile.logfile
%9 = icmp eq i32* null, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = load i32*, i32** @stderr
store i32* %11, i32** @get_logfile.logfile
br label %12
12: ; preds = %10, %6
%13 = load i32*, i32** @get_logfile.logfile
store i32* %13, i32** %1
br label %14
14: ; preds = %12, %4
%15 = load i32*, i32** %1
ret i32* %15
}

LLVM IR (-O2):
@get_logfile.logfile = internal unnamed_addr global i32* null
@.str = [19 x i8] c"/tmp/addr_shim.log\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32* null
define i32* @get_logfile() {
%1 = load i32*, i32** @get_logfile.logfile
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** @get_logfile.logfile
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = load i32*, i32** @stderr
store i32* %7, i32** @get_logfile.logfile
br label %8
8: ; preds = %3, %6, %0
%9 = phi i32* [ %1, %0 ], [ %7, %6 ], [ %4, %3 ]
ret i32* %9
}