#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*/ report(char *);
int open_files(FILE **code_file, char *code_file_name, FILE **input_file,
               char *input_file_name) {
  (*code_file) = fopen(code_file_name, "r");
  if ((*code_file) != NULL) {
    (*input_file) = fopen(input_file_name, "r");
    if ((*input_file) == NULL) {
      fclose((*code_file));
      report("Couldn't open input file");
      return 1;
    }
  } else {
    report("Couldn't open code file");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<open_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c1 <open_files+0x91>
mov    -0x28(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11bc <open_files+0x8c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <fclose@plt>
lea    0xe57(%rip),%rdi
call   1050 <report@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e0 <open_files+0xb0>
jmp    11d9 <open_files+0xa9>
lea    0xe53(%rip),%rdi
call   1050 <report@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e0 <open_files+0xb0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_files>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xeb8(%rip),%rsi
mov    %rax,%rdi
call   1040 <fopen@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1185 <open_files+0x55>
lea    0xea1(%rip),%rsi
mov    %r15,%rdi
call   1040 <fopen@plt>
mov    %rax,%rcx
mov    %rax,(%r14)
xor    %eax,%eax
test   %rcx,%rcx
jne    1196 <open_files+0x66>
mov    (%rbx),%rdi
call   1030 <fclose@plt>
lea    0xe7f(%rip),%rdi
jmp    118c <open_files+0x5c>
lea    0xe8f(%rip),%rdi
call   1050 <report@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Couldn't open input file\00"
@.str.2 = [24 x i8] c"Couldn't open code file\00"
define i32 @open_files(i32** %0, i8* %1, i32** %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i8*
%8 = alloca i32**
%9 = alloca i8*
store i32** %0, i32*** %6
store i8* %1, i8** %7
store i32** %2, i32*** %8
store i8* %3, i8** %9
%10 = load i8*, i8** %7
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i32**, i32*** %6
store i32* %11, i32** %12
%13 = load i32**, i32*** %6
%14 = load i32*, i32** %13
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %29
16: ; preds = %4
%17 = load i8*, i8** %9
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = load i32**, i32*** %8
store i32* %18, i32** %19
%20 = load i32**, i32*** %8
%21 = load i32*, i32** %20
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load i32**, i32*** %6
%25 = load i32*, i32** %24
%26 = call i32 @fclose(i32* %25)
%27 = call i32 @report(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %5
br label %32
28: ; preds = %16
br label %31
29: ; preds = %4
%30 = call i32 @report(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %5
br label %32
31: ; preds = %28
store i32 0, i32* %5
br label %32
32: ; preds = %31, %29, %23
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Couldn't open input file\00"
@.str.2 = [24 x i8] c"Couldn't open code file\00"
define i32 @open_files(i32** nocapture %0, i8* nocapture %1, i32** nocapture writeonly %2, i8* nocapture %3) {
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %0
%6 = icmp eq i32* %5, null
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32*, i32** %0
%12 = tail call i32 @fclose(i32* %11)
br label %13
13: ; preds = %4, %10
%14 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), %4 ]
%15 = tail call i32 @report(i8* %14)
br label %16
16: ; preds = %13, %7
%17 = phi i32 [ 0, %7 ], [ 1, %13 ]
ret i32 %17
}