#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*/ buf_key;
typedef int /*<<< orphan*/ buf_cipher;

/* Variables and functions */
int decrypt_aes_128_ecb(unsigned char *, int, unsigned char *, unsigned char *,
                        int *);
int read_file(char *, unsigned char *, int);
int decrypt_aes_128_ecb_file(char *cipher_file_name, char *key_file_name,
                             unsigned char *buf_plain, int *bytes_out) {
  unsigned char buf_cipher[16384];
  int bytes = read_file(cipher_file_name, buf_cipher, sizeof(buf_cipher));
  if (bytes == 0) {
    return 0;
  }
  unsigned char buf_key[16];
  int bytes_key = read_file(key_file_name, buf_key, sizeof(buf_key));
  if (bytes_key == 0) {
    return 0;
  }
  return decrypt_aes_128_ecb(buf_cipher, bytes, buf_key, buf_plain, bytes_out);
}


x86 assembly (clang, -O0):
<decrypt_aes_128_ecb_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4060,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
mov    $0x4000,%edx
call   1040 <read_file@plt>
mov    %eax,-0x4034(%rbp)
cmpl   $0x0,-0x4034(%rbp)
jne    116f <decrypt_aes_128_ecb_file+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <decrypt_aes_128_ecb_file+0xa7>
mov    -0x18(%rbp),%rdi
lea    -0x4050(%rbp),%rsi
mov    $0x10,%edx
call   1040 <read_file@plt>
mov    %eax,-0x4054(%rbp)
cmpl   $0x0,-0x4054(%rbp)
jne    11a3 <decrypt_aes_128_ecb_file+0x83>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <decrypt_aes_128_ecb_file+0xa7>
lea    -0x4030(%rbp),%rdi
mov    -0x4034(%rbp),%esi
lea    -0x4050(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <decrypt_aes_128_ecb@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt_aes_128_ecb_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x4018,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
lea    0x10(%rsp),%rsi
mov    $0x4000,%edx
call   1040 <read_file@plt>
test   %eax,%eax
je     1176 <decrypt_aes_128_ecb_file+0x56>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1040 <read_file@plt>
test   %eax,%eax
je     1176 <decrypt_aes_128_ecb_file+0x56>
lea    0x10(%rsp),%rdi
mov    %rsp,%rdx
mov    %ebp,%esi
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <decrypt_aes_128_ecb@plt>
jmp    1178 <decrypt_aes_128_ecb_file+0x58>
xor    %eax,%eax
add    $0x4018,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @decrypt_aes_128_ecb_file(i8* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca [16384 x i8]
%11 = alloca i32
%12 = alloca [16 x i8]
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32* %3, i32** %9
%14 = load i8*, i8** %6
%15 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%16 = call i32 @read_file(i8* %14, i8* %15, i32 16384)
store i32 %16, i32* %11
%17 = load i32, i32* %11
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %4
store i32 0, i32* %5
br label %34
20: ; preds = %4
%21 = load i8*, i8** %7
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%23 = call i32 @read_file(i8* %21, i8* %22, i32 16)
store i32 %23, i32* %13
%24 = load i32, i32* %13
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 0, i32* %5
br label %34
27: ; preds = %20
%28 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%29 = load i32, i32* %11
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%31 = load i8*, i8** %8
%32 = load i32*, i32** %9
%33 = call i32 @decrypt_aes_128_ecb(i8* %28, i32 %29, i8* %30, i8* %31, i32* %32)
store i32 %33, i32* %5
br label %34
34: ; preds = %27, %26, %19
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
define i32 @decrypt_aes_128_ecb_file(i8* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca [16384 x i8]
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 0
%8 = call i32 @read_file(i8* %0, i8* %7, i32 16384)
%9 = icmp eq i32 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %4
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%12 = call i32 @read_file(i8* %1, i8* %11, i32 16)
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 @decrypt_aes_128_ecb(i8* %7, i32 %8, i8* %11, i8* %2, i32* %3)
br label %16
16: ; preds = %10, %14
%17 = phi i32 [ %15, %14 ], [ 0, %10 ]
br label %18
18: ; preds = %4, %16
%19 = phi i32 [ %17, %16 ], [ 0, %4 ]
ret i32 %19
}