#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*/ debug_output_org_lbp(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
void debug_output_org_tables(const char *filename) {
  FILE *stream;
  stream = fopen(filename, "w");
  if (stream == NULL) {
    fprintf(stderr, "cannot open '%s' for writing\n", filename);
    exit(1);
  }
  debug_output_org_lbp(stream);
  if (ferror(stream) || fclose(stream)) {
    fprintf(stderr, "error writing to '%s'\n", filename);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<debug_output_org_tables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ae <debug_output_org_tables+0x4e>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe63(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <debug_output_org_lbp@plt>
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
jne    11dd <debug_output_org_tables+0x7d>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
cmp    $0x0,%rax
je     1200 <debug_output_org_tables+0xa0>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe2f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_output_org_tables>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b7 <debug_output_org_tables+0x57>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <debug_output_org_lbp@plt>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    11a5 <debug_output_org_tables+0x45>
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
jne    11a5 <debug_output_org_tables+0x45>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
jmp    11c7 <debug_output_org_tables+0x67>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"cannot open '%s' for writing\0A\00"
@.str.2 = [23 x i8] c"error writing to '%s'\0A\00"
define void @debug_output_org_tables(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %2
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = load i32*, i32** %3
%15 = call i32 @debug_output_org_lbp(i32* %14)
%16 = load i32*, i32** %3
%17 = call i64 @ferror(i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %13
%20 = load i32*, i32** %3
%21 = call i64 @fclose(i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %19, %13
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %2
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"cannot open '%s' for writing\0A\00"
@.str.2 = [23 x i8] c"error writing to '%s'\0A\00"
define void @debug_output_org_tables(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %1
%9 = tail call i32 @debug_output_org_lbp(i32* %2)
%10 = tail call i64 @ferror(i32* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = tail call i64 @fclose(i32* %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12, %8
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %12
ret void
}