#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 /*<<< orphan*/ printf(char *);
int rsa_verify_file(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void task1(char *cipher_file_name_template, char *pubkey_file_name,
           char *signature_file_name, char *right_cipher_file_name) {
  printf("\nAufgabe 1:\n");
  int i;
  for (i = 1; i < 4; i++) {
    char cipher_file_name[16384];
    sprintf(cipher_file_name, cipher_file_name_template, i);
    int result = rsa_verify_file(cipher_file_name, pubkey_file_name,
                                 signature_file_name);
    char output[16384];
    if (result > 0) {
      strcpy(output, "\tSignature did match for file ");
      strcat(output, cipher_file_name);
      strcpy(right_cipher_file_name, cipher_file_name);
    } else if (result == 0) {
      strcpy(output, "\tSignature did not match for file ");
      strcat(output, cipher_file_name);
    } else {
      strcpy(output, "\tSignature check failed for file ");
      strcat(output, cipher_file_name);
    }
    strcat(output, "\n");
    printf(output);
  }
}


x86 assembly (clang, -O0):
<task1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    128d <task1+0x13d>
lea    -0x4030(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1070 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <rsa_verify_file@plt>
mov    %eax,-0x4034(%rbp)
cmpl   $0x0,-0x4034(%rbp)
jle    11fd <task1+0xad>
lea    -0x8040(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1260 <task1+0x110>
cmpl   $0x0,-0x4034(%rbp)
jne    1235 <task1+0xe5>
lea    -0x8040(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
call   1060 <strcat@plt>
jmp    125b <task1+0x10b>
lea    -0x8040(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x8040(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
call   1060 <strcat@plt>
jmp    1260 <task1+0x110>
lea    -0x8040(%rbp),%rdi
lea    0xd9d(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x8040(%rbp),%rdi
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117e <task1+0x2e>
add    $0x8040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<task1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8008,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
lea    0xee2(%rip),%rdi
call   1040 <puts@plt>
lea    0x4000(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <rsa_verify_file@plt>
test   %eax,%eax
jle    11e5 <task1+0x85>
lea    0xe46(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x4000(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
jmp    1212 <task1+0xb2>
je     11f0 <task1+0x90>
lea    0xe54(%rip),%rsi
jmp    11f7 <task1+0x97>
lea    0xe28(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x4000(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xe4b(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1060 <printf@plt>
lea    0x4000(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x2,%edx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <rsa_verify_file@plt>
test   %eax,%eax
jle    1288 <task1+0x128>
lea    0xda3(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x4000(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
jmp    12b5 <task1+0x155>
je     1293 <task1+0x133>
lea    0xdb1(%rip),%rsi
jmp    129a <task1+0x13a>
lea    0xd85(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x4000(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xda8(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1060 <printf@plt>
lea    0x4000(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x3,%edx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <rsa_verify_file@plt>
test   %eax,%eax
jle    132b <task1+0x1cb>
lea    0xd00(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x4000(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
jmp    1358 <task1+0x1f8>
je     1336 <task1+0x1d6>
lea    0xd0e(%rip),%rsi
jmp    133d <task1+0x1dd>
lea    0xce2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x4000(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xd05(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1060 <printf@plt>
add    $0x8008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"\0AAufgabe 1:\0A\00"
@.str.1 = [31 x i8] c"\09Signature did match for file \00"
@.str.2 = [35 x i8] c"\09Signature did not match for file \00"
@.str.3 = [34 x i8] c"\09Signature check failed for file \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @task1(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [16384 x i8]
%11 = alloca i32
%12 = alloca [16384 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %9
br label %14
14: ; preds = %58, %4
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %61
17: ; preds = %14
%18 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%19 = load i8*, i8** %5
%20 = load i32, i32* %9
%21 = call i32 @sprintf(i8* %18, i8* %19, i32 %20)
%22 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = call i32 @rsa_verify_file(i8* %22, i8* %23, i8* %24)
store i32 %25, i32* %11
%26 = load i32, i32* %11
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %17
%29 = getelementptr inbounds [16384 x i8], [16384 x i8]* %12, i64 0, i64 0
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%31 = getelementptr inbounds [16384 x i8], [16384 x i8]* %12, i64 0, i64 0
%32 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%33 = call i32 @strcat(i8* %31, i8* %32)
%34 = load i8*, i8** %8
%35 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%36 = call i32 @strcpy(i8* %34, i8* %35)
br label %53
37: ; preds = %17
%38 = load i32, i32* %11
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = getelementptr inbounds [16384 x i8], [16384 x i8]* %12, i64 0, i64 0
%42 = call i32 @strcpy(i8* %41, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%43 = getelementptr inbounds [16384 x i8], [16384 x i8]* %12, i64 0, i64 0
%44 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%45 = call i32 @strcat(i8* %43, i8* %44)
br label %52
46: ; preds = %37
%47 = getelementptr inbounds [16384 x i8], [16384 x i8]* %12, i64 0, i64 0
%48 = call i32 @strcpy(i8* %47, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%49 = getelementptr inbounds [16384 x i8], [16384 x i8]* %12, i64 0, i64 0
%50 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%51 = call i32 @strcat(i8* %49, i8* %50)
br label %52
52: ; preds = %46, %40
br label %53
53: ; preds = %52, %28
%54 = getelementptr inbounds [16384 x i8], [16384 x i8]* %12, i64 0, i64 0
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%56 = getelementptr inbounds [16384 x i8], [16384 x i8]* %12, i64 0, i64 0
%57 = call i32 @printf(i8* %56)
br label %58
58: ; preds = %53
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %9
br label %14
61: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"\09Signature did match for file \00"
@.str.2 = [35 x i8] c"\09Signature did not match for file \00"
@.str.3 = [34 x i8] c"\09Signature check failed for file \00"
@.str.4 = [2 x i8] c"\0A\00"
@str = [12 x i8] c"\0AAufgabe 1:\00"
define void @task1(i8* nocapture %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [16384 x i8]
%6 = alloca [16384 x i8]
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [16384 x i8], [16384 x i8]* %6, i64 0, i64 0
%10 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) %0, i32 1)
%11 = call i32 @rsa_verify_file(i8* %8, i8* %1, i8* %2)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @strcat(i8* %9, i8* %8)
%16 = call i32 @strcpy(i8* %3, i8* %8)
br label %25
17: ; preds = %4
%18 = icmp eq i32 %11, 0
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @strcat(i8* %9, i8* %8)
br label %25
22: ; preds = %17
%23 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @strcat(i8* %9, i8* %8)
br label %25
25: ; preds = %19, %22, %13
%26 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @printf(i8* %9)
%28 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) %0, i32 2)
%29 = call i32 @rsa_verify_file(i8* %8, i8* %1, i8* %2)
%30 = icmp sgt i32 %29, 0
br i1 %30, label %39, label %31
31: ; preds = %25
%32 = icmp eq i32 %29, 0
br i1 %32, label %36, label %33
33: ; preds = %31
%34 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @strcat(i8* %9, i8* %8)
br label %43
36: ; preds = %31
%37 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @strcat(i8* %9, i8* %8)
br label %43
39: ; preds = %25
%40 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @strcat(i8* %9, i8* %8)
%42 = call i32 @strcpy(i8* %3, i8* %8)
br label %43
43: ; preds = %39, %36, %33
%44 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 @printf(i8* %9)
%46 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) %0, i32 3)
%47 = call i32 @rsa_verify_file(i8* %8, i8* %1, i8* %2)
%48 = icmp sgt i32 %47, 0
br i1 %48, label %57, label %49
49: ; preds = %43
%50 = icmp eq i32 %47, 0
br i1 %50, label %54, label %51
51: ; preds = %49
%52 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @strcat(i8* %9, i8* %8)
br label %61
54: ; preds = %49
%55 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%56 = call i32 @strcat(i8* %9, i8* %8)
br label %61
57: ; preds = %43
%58 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%59 = call i32 @strcat(i8* %9, i8* %8)
%60 = call i32 @strcpy(i8* %3, i8* %8)
br label %61
61: ; preds = %57, %54, %51
%62 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%63 = call i32 @printf(i8* %9)
ret void
}