#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ puts(char *);
void OpenFiles(FILE **in, char *inpath, FILE **out, char *outpath) {
  *in = fopen(inpath, "rb");
  *out = fopen(outpath, "wb");
  if (in == NULL) {
    puts("can't open input file.");
    exit(-1);
  }
  if (out == NULL) {
    puts("can't open output file.");
    exit(-2);
  }
}


x86 assembly (clang, -O0):
<OpenFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    119d <OpenFiles+0x6d>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11be <OpenFiles+0x8e>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffffe,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OpenFiles>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xed8(%rip),%rsi
mov    %rax,%rdi
call   1030 <fopen@plt>
mov    %rax,(%rbx)
lea    0xec9(%rip),%rsi
mov    %r15,%rdi
call   1030 <fopen@plt>
mov    %rax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [23 x i8] c"can't open input file.\00"
@.str.3 = [24 x i8] c"can't open output file.\00"
define void @OpenFiles(i32** %0, i8* %1, i32** %2, i8* %3) {
%5 = alloca i32**
%6 = alloca i8*
%7 = alloca i32**
%8 = alloca i8*
store i32** %0, i32*** %5
store i8* %1, i8** %6
store i32** %2, i32*** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %6
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = load i32**, i32*** %5
store i32* %10, i32** %11
%12 = load i8*, i8** %8
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32**, i32*** %7
store i32* %13, i32** %14
%15 = load i32**, i32*** %5
%16 = icmp eq i32** %15, null
br i1 %16, label %17, label %20
17: ; preds = %4
%18 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %4
%21 = load i32**, i32*** %7
%22 = icmp eq i32** %21, null
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @exit(i32 -2)
unreachable
26: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
define void @OpenFiles(i32** nocapture writeonly %0, i8* nocapture %1, i32** nocapture writeonly %2, i8* nocapture %3) {
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %0
%6 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
ret void
}