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


x86 assembly (clang, -O0):
<ftf_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x10,%edi
call   1050 <buff_name@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe5a(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11e9 <ftf_decrypt+0x79>
cmpq   $0x0,-0x38(%rbp)
jne    11fa <ftf_decrypt+0x8a>
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125c <ftf_decrypt+0xec>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1090 <cpyfile@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1080 <_ftf_decrypt@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <unlink@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftf_decrypt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x10,%edi
call   1050 <buff_name@plt>
mov    %rax,%r12
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
mov    %r12,%rdx
call   1060 <fprintf@plt>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe46(%rip),%rsi
mov    %r12,%rdi
call   1070 <fopen@plt>
mov    %rax,%r13
mov    0x2e0e(%rip),%rax
test   %rbx,%rbx
je     122e <ftf_decrypt+0xbe>
test   %r13,%r13
je     122e <ftf_decrypt+0xbe>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <cpyfile@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe10(%rip),%rsi
mov    %r15,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1080 <_ftf_decrypt@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1030 <unlink@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"w+\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @ftf_decrypt(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 i32, i32* @stdout
%14 = load i8*, i8** %8
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %5
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %9
%18 = load i8*, i8** %8
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %10
%20 = load i32*, i32** %9
%21 = icmp eq i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %3
%23 = load i32*, i32** %10
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %22, %3
%26 = load i32, i32* @EXIT_FAILURE
store i32 %26, i32* %4
br label %46
27: ; preds = %22
%28 = load i32*, i32** %9
%29 = load i32*, i32** %10
%30 = call i32 @cpyfile(i32* %28, i32* %29)
%31 = load i32*, i32** %9
%32 = call i32 @fclose(i32* %31)
%33 = load i8*, i8** %6
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %34, i32** %11
%35 = load i32*, i32** %10
%36 = load i32*, i32** %11
%37 = load i8*, i8** %7
%38 = call i32 @_ftf_decrypt(i32* %35, i32* %36, i8* %37)
%39 = load i32*, i32** %10
%40 = call i32 @fclose(i32* %39)
%41 = load i32*, i32** %11
%42 = call i32 @fclose(i32* %41)
%43 = load i8*, i8** %8
%44 = call i32 @unlink(i8* %43)
%45 = load i32, i32* @EXIT_SUCCESS
store i32 %45, i32* %4
br label %46
46: ; preds = %27, %25
%47 = load i32, i32* %4
ret i32 %47
}

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