#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*/ exit(int /*<<< orphan*/);
unsigned char *malloc(int);
int /*<<< orphan*/ printLastError(char *);
int /*<<< orphan*/ printf(char *, ...);
int private_decrypt(unsigned char *, int, char *, unsigned char *);
int private_encrypt(unsigned char *, int /*<<< orphan*/, char *,
                    unsigned char *);
int public_decrypt(unsigned char *, int, char *, unsigned char *);
int public_encrypt(unsigned char *, int /*<<< orphan*/, char *,
                   unsigned char *);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  char plainText[2048] = "Hello";
  unsigned char *encrypted = malloc(64000);
  unsigned char *decrypted = malloc(64000);
  int encrypted_length =
      public_encrypt((unsigned char *)plainText, strlen(plainText),
                     "./exes/serverFiles/public.pem", encrypted);
  if (encrypted_length == -1) {
    printLastError("Public Encrypt failed ");
    exit(0);
  }
  printf("Encrypted length =%d\n", encrypted_length);
  printf("Encrypted Text=%s\n", encrypted);
  int decrypted_length =
      private_decrypt((unsigned char *)encrypted, encrypted_length,
                      "./exes/serverFiles/private.pem", decrypted);
  if (decrypted_length == -1) {
    printLastError("Private Decrypt failed ");
    exit(0);
  }
  printf("Decrypted Text =%s\n", decrypted);
  printf("Decrypted Length =%d\n", decrypted_length);
  encrypted_length =
      private_encrypt((unsigned char *)plainText, strlen(plainText),
                      "./exes/serverFiles/private.pem", encrypted);
  if (encrypted_length == -1) {
    printLastError("Private Encrypt failed");
    exit(0);
  }
  printf("Encrypted length =%d\n", encrypted_length);
  decrypted_length =
      public_decrypt((unsigned char *)encrypted, encrypted_length,
                     "./exes/serverFiles/public.pem", decrypted);
  if (decrypted_length == -1) {
    printLastError("Public Decrypt failed");
    exit(0);
  }
  printf("Decrypted Text =%s\n", decrypted);
  printf("Decrypted Length =%d\n", decrypted_length);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1070 <memset@plt>
movb   $0x48,-0x810(%rbp)
movb   $0x65,-0x80f(%rbp)
movb   $0x6c,-0x80e(%rbp)
movb   $0x6c,-0x80d(%rbp)
movb   $0x6f,-0x80c(%rbp)
mov    $0xfa00,%edi
call   1080 <malloc@plt>
mov    %rax,-0x818(%rbp)
mov    $0xfa00,%edi
call   1080 <malloc@plt>
mov    %rax,-0x820(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x830(%rbp)
lea    -0x810(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x830(%rbp),%rdi
mov    %eax,%esi
mov    -0x818(%rbp),%rcx
lea    0xdbe(%rip),%rdx
call   10c0 <public_encrypt@plt>
mov    %eax,-0x824(%rbp)
cmpl   $0xffffffff,-0x824(%rbp)
jne    126d <main+0xcd>
lea    0xdbd(%rip),%rdi
call   1090 <printLastError@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x824(%rbp),%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x818(%rbp),%rsi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x818(%rbp),%rdi
mov    -0x824(%rbp),%esi
mov    -0x820(%rbp),%rcx
lea    0xdad(%rip),%rdx
call   1060 <private_decrypt@plt>
mov    %eax,-0x828(%rbp)
cmpl   $0xffffffff,-0x828(%rbp)
jne    12dc <main+0x13c>
lea    0xdad(%rip),%rdi
call   1090 <printLastError@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x820(%rbp),%rsi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x828(%rbp),%esi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x810(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x810(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x838(%rbp),%rdi
mov    %eax,%esi
mov    -0x818(%rbp),%rcx
lea    0xd28(%rip),%rdx
call   10b0 <private_encrypt@plt>
mov    %eax,-0x824(%rbp)
cmpl   $0xffffffff,-0x824(%rbp)
jne    1361 <main+0x1c1>
lea    0xd6a(%rip),%rdi
call   1090 <printLastError@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x824(%rbp),%esi
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x818(%rbp),%rdi
mov    -0x824(%rbp),%esi
mov    -0x820(%rbp),%rcx
lea    0xc70(%rip),%rdx
call   1030 <public_decrypt@plt>
mov    %eax,-0x828(%rbp)
cmpl   $0xffffffff,-0x828(%rbp)
jne    13bb <main+0x21b>
lea    0xd27(%rip),%rdi
call   1090 <printLastError@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x820(%rbp),%rsi
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x828(%rbp),%esi
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rsp,%rbp
mov    $0x800,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
movl   $0x6c6c6548,(%rsp)
movb   $0x6f,0x4(%rsp)
mov    $0xfa00,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0xfa00,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0xe0e(%rip),%rdx
mov    %rbp,%rdi
mov    %eax,%esi
mov    %rbx,%rcx
call   10c0 <public_encrypt@plt>
cmp    $0xffffffff,%eax
je     12eb <main+0x14b>
mov    %eax,%ebp
lea    0xe24(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2c(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rcx
call   1060 <private_decrypt@plt>
cmp    $0xffffffff,%eax
je     12f4 <main+0x154>
mov    %eax,%ebp
lea    0xe44(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe47(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0xde1(%rip),%rdx
mov    %rbp,%rdi
mov    %eax,%esi
mov    %rbx,%rcx
call   10b0 <private_encrypt@plt>
cmp    $0xffffffff,%eax
je     12fd <main+0x15d>
mov    %eax,%ebp
lea    0xd9d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd58(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rcx
call   1030 <public_decrypt@plt>
cmp    $0xffffffff,%eax
je     1306 <main+0x166>
mov    %eax,%ebx
lea    0xdd2(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdd5(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd2c(%rip),%rdi
jmp    130d <main+0x16d>
lea    0xd82(%rip),%rdi
jmp    130d <main+0x16d>
lea    0xdbb(%rip),%rdi
jmp    130d <main+0x16d>
lea    0xdc9(%rip),%rdi
call   1090 <printLastError@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"./exes/serverFiles/public.pem\00"
@.str.1 = [23 x i8] c"Public Encrypt failed \00"
@.str.2 = [22 x i8] c"Encrypted length =%d\0A\00"
@.str.3 = [19 x i8] c"Encrypted Text=%s\0A\00"
@.str.4 = [31 x i8] c"./exes/serverFiles/private.pem\00"
@.str.5 = [24 x i8] c"Private Decrypt failed \00"
@.str.6 = [20 x i8] c"Decrypted Text =%s\0A\00"
@.str.7 = [22 x i8] c"Decrypted Length =%d\0A\00"
@.str.8 = [23 x i8] c"Private Encrypt failed\00"
@.str.9 = [22 x i8] c"Public Decrypt failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2048 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [2048 x i8]* %6 to i8*
%12 = bitcast i8* %11 to [2048 x i8]*
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i32 0, i32 0
store i8 72, i8* %13
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i32 0, i32 1
store i8 101, i8* %14
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i32 0, i32 2
store i8 108, i8* %15
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i32 0, i32 3
store i8 108, i8* %16
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i32 0, i32 4
store i8 111, i8* %17
%18 = call i8* @malloc(i32 64000)
store i8* %18, i8** %7
%19 = call i8* @malloc(i32 64000)
store i8* %19, i8** %8
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = load i8*, i8** %7
%24 = call i32 @public_encrypt(i8* %20, i32 %22, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %2
%28 = call i32 @printLastError(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %2
%31 = load i32, i32* %9
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i8*, i8** %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %7
%36 = load i32, i32* %9
%37 = load i8*, i8** %8
%38 = call i32 @private_decrypt(i8* %35, i32 %36, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %37)
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %30
%42 = call i32 @printLastError(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %30
%45 = load i8*, i8** %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %45)
%47 = load i32, i32* %10
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%50 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%51 = call i32 @strlen(i8* %50)
%52 = load i8*, i8** %7
%53 = call i32 @private_encrypt(i8* %49, i32 %51, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %52)
store i32 %53, i32* %9
%54 = load i32, i32* %9
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %44
%57 = call i32 @printLastError(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%58 = call i32 @exit(i32 0)
unreachable
59: ; preds = %44
%60 = load i32, i32* %9
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %60)
%62 = load i8*, i8** %7
%63 = load i32, i32* %9
%64 = load i8*, i8** %8
%65 = call i32 @public_decrypt(i8* %62, i32 %63, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %64)
store i32 %65, i32* %10
%66 = load i32, i32* %10
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %71
68: ; preds = %59
%69 = call i32 @printLastError(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%70 = call i32 @exit(i32 0)
unreachable
71: ; preds = %59
%72 = load i8*, i8** %8
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %72)
%74 = load i32, i32* %10
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %74)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"./exes/serverFiles/public.pem\00"
@.str.1 = [23 x i8] c"Public Encrypt failed \00"
@.str.2 = [22 x i8] c"Encrypted length =%d\0A\00"
@.str.3 = [19 x i8] c"Encrypted Text=%s\0A\00"
@.str.4 = [31 x i8] c"./exes/serverFiles/private.pem\00"
@.str.5 = [24 x i8] c"Private Decrypt failed \00"
@.str.6 = [20 x i8] c"Decrypted Text =%s\0A\00"
@.str.7 = [22 x i8] c"Decrypted Length =%d\0A\00"
@.str.8 = [23 x i8] c"Private Encrypt failed\00"
@.str.9 = [22 x i8] c"Public Decrypt failed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
store i8 72, i8* %4
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 1
store i8 101, i8* %5
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 2
store i8 108, i8* %6
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 3
store i8 108, i8* %7
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 4
store i8 111, i8* %8
%9 = tail call dereferenceable_or_null(64000) i8* @malloc(i32 64000)
%10 = tail call dereferenceable_or_null(64000) i8* @malloc(i32 64000)
%11 = call i32 @strlen(i8* %4)
%12 = call i32 @public_encrypt(i8* %4, i32 %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %9)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @printLastError(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%20 = call i32 @private_decrypt(i8* %9, i32 %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = call i32 @printLastError(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %17
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %10)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %20)
%28 = call i32 @strlen(i8* %4)
%29 = call i32 @private_encrypt(i8* %4, i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = call i32 @printLastError(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %25
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%36 = call i32 @public_decrypt(i8* %9, i32 %29, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %10)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = call i32 @printLastError(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%40 = call i32 @exit(i32 0)
unreachable
41: ; preds = %34
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %10)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %36)
ret i32 0
}