#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*/ DBG__dump(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ *stderr;
void DBGdump(const char *filename) {
  if (!filename) {
    DBG__dump(stderr);
  } else {
    FILE *out = fopen(filename, "w");
    if (!out) {
      perror(filename);
      return;
    }
    DBG__dump(out);
    fclose(out);
  }
}


x86 assembly (clang, -O0):
<DBGdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116b <DBGdump+0x2b>
mov    0x2e82(%rip),%rax
mov    (%rax),%rdi
call   1040 <DBG__dump@plt>
jmp    11aa <DBGdump+0x6a>
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1198 <DBGdump+0x58>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
jmp    11aa <DBGdump+0x6a>
mov    -0x10(%rbp),%rdi
call   1040 <DBG__dump@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DBGdump>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1177 <DBGdump+0x37>
mov    %rdi,%r14
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     118d <DBGdump+0x4d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <DBG__dump@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <DBG__dump@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <perror@plt>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [2 x i8] c"w\00"
define void @DBGdump(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32*, i32** @stderr
%8 = call i32 @DBG__dump(i32* %7)
br label %22
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = icmp ne i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = call i32 @perror(i8* %15)
br label %22
17: ; preds = %9
%18 = load i32*, i32** %3
%19 = call i32 @DBG__dump(i32* %18)
%20 = load i32*, i32** %3
%21 = call i32 @fclose(i32* %20)
br label %22
22: ; preds = %14, %17, %6
ret void
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [2 x i8] c"w\00"
define void @DBGdump(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32*, i32** @stderr
%5 = tail call i32 @DBG__dump(i32* %4)
br label %14
6: ; preds = %1
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @perror(i8* %0)
br label %14
11: ; preds = %6
%12 = tail call i32 @DBG__dump(i32* %7)
%13 = tail call i32 @fclose(i32* %7)
br label %14
14: ; preds = %9, %11, %3
ret void
}