#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 */

/* Variables and functions */
int decrypt_aes_128_ecb_file(char *, char *, unsigned char *, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void task2(char *right_cipher_file_name, char *key_file_name,
           unsigned char *buf_plain, int *bytes_out) {
  printf("\nAufgabe 2:\n");
  *bytes_out = 0;
  int result = decrypt_aes_128_ecb_file(right_cipher_file_name, key_file_name,
                                        buf_plain, bytes_out);
  char output[16384];
  if (result == 1) {
    strcpy(output, "\tSuccessfully decrypted cipher file ");
    strcat(output, right_cipher_file_name);
    strcat(output, "\n");
  } else {
    strcpy(output, "\tError when decrypting cipher file ");
    strcat(output, right_cipher_file_name);
    strcat(output, "\n");
  }
  printf(output);
}


x86 assembly (clang, -O0):
<task2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <decrypt_aes_128_ecb_file@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    11ce <task2+0x8e>
lea    -0x4030(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x4030(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1060 <strcat@plt>
jmp    1204 <task2+0xc4>
lea    -0x4030(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x4030(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x4030(%rbp),%rdi
call   1040 <printf@plt>
add    $0x4030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<task2>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4008,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xeda(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,(%rbx)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1060 <decrypt_aes_128_ecb_file@plt>
cmp    $0x1,%eax
lea    0xe69(%rip),%rax
lea    0xe89(%rip),%rsi
cmove  %rax,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
add    $0x4008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"\0AAufgabe 2:\0A\00"
@.str.1 = [37 x i8] c"\09Successfully decrypted cipher file \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [36 x i8] c"\09Error when decrypting cipher file \00"
define void @task2(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 [16384 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %8
store i32 0, i32* %12
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = load i8*, i8** %7
%16 = load i32*, i32** %8
%17 = call i32 @decrypt_aes_128_ecb_file(i8* %13, i8* %14, i8* %15, i32* %16)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %28
20: ; preds = %4
%21 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%23 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%24 = load i8*, i8** %5
%25 = call i32 @strcat(i8* %23, i8* %24)
%26 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%27 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
28: ; preds = %4
%29 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%31 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%32 = load i8*, i8** %5
%33 = call i32 @strcat(i8* %31, i8* %32)
%34 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %28, %20
%37 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%38 = call i32 @printf(i8* %37)
ret void
}

LLVM IR (-O2):
@.str.1 = [37 x i8] c"\09Successfully decrypted cipher file \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [36 x i8] c"\09Error when decrypting cipher file \00"
@str = [12 x i8] c"\0AAufgabe 2:\00"
define void @task2(i8* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca [16384 x i8]
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
store i32 0, i32* %3
%7 = tail call i32 @decrypt_aes_128_ecb_file(i8* %0, i8* %1, i8* %2, i32* %3)
%8 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %7, 1
%10 = select i1 %9, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0)
%11 = call i32 @strcpy(i8* %8, i8* %10)
%12 = call i32 @strcat(i8* %8, i8* %0)
%13 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* %8)
ret void
}