#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ load_from_files(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdout;
void load_from_paths(char *file_x6502, char *file_out) {
  FILE *fp_x6502 = fopen(file_x6502, "r");
  FILE *fp_out;
  if (file_out == NULL) {
    fp_out = stdout;
  } else {
    fp_out = fopen(file_out, "w");
  }
  load_from_files(fp_x6502, fp_out);
  fclose(fp_x6502);
  fclose(fp_out);
}


x86 assembly (clang, -O0):
<load_from_paths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1172 <load_from_paths+0x42>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1186 <load_from_paths+0x56>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <load_from_files@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_from_paths>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xec2(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     115f <load_from_paths+0x2f>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fopen@plt>
mov    %rax,%rbx
jmp    1169 <load_from_paths+0x39>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <load_from_files@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>

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

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