#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*/ crypt(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                         unsigned char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
void get_filepointers(char *read_f, char *write_f, unsigned char *passphrase,
                      int encswitch) {
  FILE *fp_r = NULL, *fp_w = NULL;
  fp_r = fopen(read_f, "r");
  fp_w = fopen(write_f, "w");
  crypt(fp_r, fp_w, passphrase, encswitch);
  if (fp_r != NULL) {
    fclose(fp_r);
  }
  if (fp_w != NULL) {
    fclose(fp_w);
  }
}


x86 assembly (clang, -O0):
<get_filepointers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <crypt@plt>
cmpq   $0x0,-0x28(%rbp)
je     11a7 <get_filepointers+0x77>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x30(%rbp)
je     11bb <get_filepointers+0x8b>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_filepointers>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %rsi,%rbp
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rsi
mov    %rbp,%rdi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r12,%rdx
mov    %r15d,%ecx
call   1030 <crypt@plt>
test   %rbx,%rbx
je     1180 <get_filepointers+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %r14,%r14
je     1195 <get_filepointers+0x65>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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