#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 */
char *decrypt_pri(char const *, char const *);
char *decrypt_pub(char const *, char const *);
char *encrypt_pri(char *, char const *);
char *encrypt_pub(char *, char const *);
char *generate_private_key(int);
char *generate_public_key(char const *);
int /*<<< orphan*/ printf(char *, char const *);
int main(int argc, char **argv) {
  const char *a = generate_private_key(4096);
  printf("%s", a);
  const char *b = generate_public_key(a);
  printf("%s", b);
  const char *c = encrypt_pub("Hello,world\n", b);
  printf("%s\n", c);
  const char *d = decrypt_pri(c, a);
  printf("%s", d);
  const char *e = encrypt_pri("Hello,world\n", a);
  printf("%s\n", e);
  const char *f = decrypt_pub(e, b);
  printf("%s", f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1000,%edi
call   1050 <generate_private_key@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <generate_public_key@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1070 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1080 <encrypt_pub@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <decrypt_pri@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xdff(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdf2(%rip),%rdi
call   1040 <encrypt_pri@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdeb(%rip),%rdi
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <decrypt_pub@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xdba(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1000,%edi
call   1050 <generate_private_key@plt>
mov    %rax,%r13
lea    0xe71(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %r13,%rdi
call   1030 <generate_public_key@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
lea    0xe4c(%rip),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1080 <encrypt_pub@plt>
mov    %rax,%rbx
lea    0xe44(%rip),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <decrypt_pri@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <encrypt_pri@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <decrypt_pub@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [13 x i8] c"Hello,world\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i8* @generate_private_key(i32 4096)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %6
%16 = call i8* @generate_public_key(i8* %15)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %7
%20 = call i8* @encrypt_pub(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %19)
store i8* %20, i8** %8
%21 = load i8*, i8** %8
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %8
%24 = load i8*, i8** %6
%25 = call i8* @decrypt_pri(i8* %23, i8* %24)
store i8* %25, i8** %9
%26 = load i8*, i8** %9
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %6
%29 = call i8* @encrypt_pri(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %28)
store i8* %29, i8** %10
%30 = load i8*, i8** %10
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %10
%33 = load i8*, i8** %7
%34 = call i8* @decrypt_pub(i8* %32, i8* %33)
store i8* %34, i8** %11
%35 = load i8*, i8** %11
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [13 x i8] c"Hello,world\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @generate_private_key(i32 4096)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = tail call i8* @generate_public_key(i8* %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i8* @encrypt_pub(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = tail call i8* @decrypt_pri(i8* %7, i8* %3)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i8* @encrypt_pri(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = tail call i8* @decrypt_pub(i8* %11, i8* %5)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
ret i32 0
}