#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ _ftf_encrypt(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                char *);
char *buff_name(int);
int /*<<< orphan*/ cpyfile(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ unlink(char *);
int ftf_encrypt(char *_plaintext, char *_ciphertext, char *key) {
  char *_buffer = buff_name(16);
  FILE *plaintext = fopen(_plaintext, "r");
  FILE *buffer = fopen(_buffer, "w+");
  if (plaintext == NULL || buffer == NULL)
    return EXIT_FAILURE;
  cpyfile(plaintext, buffer);
  fclose(plaintext);
  FILE *ciphertext = fopen(_ciphertext, "w+");
  _ftf_encrypt(buffer, ciphertext, key);
  unlink(_buffer);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<ftf_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x10,%edi
call   1060 <buff_name@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11c0 <ftf_encrypt+0x60>
cmpq   $0x0,-0x38(%rbp)
jne    11d1 <ftf_encrypt+0x71>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1221 <ftf_encrypt+0xc1>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1080 <cpyfile@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <_ftf_encrypt@plt>
mov    -0x28(%rbp),%rdi
call   1030 <unlink@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftf_encrypt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x10,%edi
call   1060 <buff_name@plt>
mov    %rax,%r12
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe6a(%rip),%rsi
mov    %r12,%rdi
call   1070 <fopen@plt>
mov    %rax,%r13
mov    0x2e36(%rip),%rax
test   %rbx,%rbx
je     11f3 <ftf_encrypt+0x93>
test   %r13,%r13
je     11f3 <ftf_encrypt+0x93>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <cpyfile@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe34(%rip),%rsi
mov    %r15,%rdi
call   1070 <fopen@plt>
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1050 <_ftf_encrypt@plt>
mov    %r12,%rdi
call   1030 <unlink@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"w+\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @ftf_encrypt(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = call i8* @buff_name(i32 16)
store i8* %12, i8** %8
%13 = load i8*, i8** %5
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %9
%15 = load i8*, i8** %8
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %10
%17 = load i32*, i32** %9
%18 = icmp eq i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %3
%20 = load i32*, i32** %10
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19, %3
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %4
br label %39
24: ; preds = %19
%25 = load i32*, i32** %9
%26 = load i32*, i32** %10
%27 = call i32 @cpyfile(i32* %25, i32* %26)
%28 = load i32*, i32** %9
%29 = call i32 @fclose(i32* %28)
%30 = load i8*, i8** %6
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %31, i32** %11
%32 = load i32*, i32** %10
%33 = load i32*, i32** %11
%34 = load i8*, i8** %7
%35 = call i32 @_ftf_encrypt(i32* %32, i32* %33, i8* %34)
%36 = load i8*, i8** %8
%37 = call i32 @unlink(i8* %36)
%38 = load i32, i32* @EXIT_SUCCESS
store i32 %38, i32* %4
br label %39
39: ; preds = %24, %22
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"w+\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @ftf_encrypt(i8* nocapture %0, i8* nocapture %1, i8* %2) {
%4 = tail call i8* @buff_name(i32 16)
%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* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %5, null
%8 = icmp eq i32* %6, null
%9 = or i1 %7, %8
br i1 %9, label %16, label %10
10: ; preds = %3
%11 = tail call i32 @cpyfile(i32* %5, i32* %6)
%12 = tail call i32 @fclose(i32* %5)
%13 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @_ftf_encrypt(i32* %6, i32* %13, i8* %2)
%15 = tail call i32 @unlink(i8* %4)
br label %16
16: ; preds = %3, %10
%17 = phi i32* [ @EXIT_SUCCESS, %10 ], [ @EXIT_FAILURE, %3 ]
%18 = load i32, i32* %17
ret i32 %18
}