#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ system(char *);
void generateKey(char *path) {
  char *privateKey = malloc(64);
  char *publicKey = malloc(64);
  char command1[] = "openssl genrsa -out 2048";
  char command2[] = "openssl rsa -in -outform PEM -pubout -out ";
  char *finalCommand1 = malloc(100);
  char *finalCommand2 = malloc(100);
  strcpy(privateKey, path);
  strcat(privateKey, "private.pem");
  printf("command: %s\n", command1);
  strncpy(finalCommand1, command1, 20);
  strcat(finalCommand1, privateKey);
  strcat(finalCommand1, command1 + 19);
  printf("command: %s\n", finalCommand1);
  strcpy(publicKey, path);
  strcat(publicKey, "public.pem");
  printf("public: %s\n", publicKey);
  strncpy(finalCommand2, command2, 16);
  strcat(finalCommand2, privateKey);
  printf("command: %s\n", finalCommand2);
  strcat(finalCommand2, command2 + 15);
  strcat(finalCommand2, publicKey);
  strcat(finalCommand2, command2 + 41);
  printf("command: %s\n", finalCommand2);
  system(finalCommand1);
  system(finalCommand2);
  free(privateKey);
  free(publicKey);
  free(finalCommand2);
  free(finalCommand1);
}


x86 assembly (clang, -O0):
<generateKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0xe4e(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe4b(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe48(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe46(%rip),%al
mov    %al,-0x28(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe40(%rip),%rsi
mov    $0x2b,%edx
call   1080 <memcpy@plt>
mov    $0x64,%edi
call   1090 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    $0x64,%edi
call   1090 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0x40(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1070 <printf@plt>
mov    -0x78(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x14,%edx
call   1040 <strncpy@plt>
mov    -0x78(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x78(%rbp),%rdi
lea    -0x40(%rbp),%rsi
add    $0x13,%rsi
call   10a0 <strcat@plt>
mov    -0x78(%rbp),%rsi
lea    0xde9(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rsi
lea    0xdd4(%rip),%rdi
call   1070 <printf@plt>
mov    -0x80(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strncpy@plt>
mov    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x80(%rbp),%rsi
lea    0xd8d(%rip),%rdi
call   1070 <printf@plt>
mov    -0x80(%rbp),%rdi
lea    -0x70(%rbp),%rsi
add    $0xf,%rsi
call   10a0 <strcat@plt>
mov    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x80(%rbp),%rdi
lea    -0x70(%rbp),%rsi
add    $0x29,%rsi
call   10a0 <strcat@plt>
mov    -0x80(%rbp),%rsi
lea    0xd4e(%rip),%rdi
call   1070 <printf@plt>
mov    -0x78(%rbp),%rdi
call   1060 <system@plt>
mov    -0x80(%rbp),%rdi
call   1060 <system@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateKey>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%rbp
mov    %rdi,0x8(%rsp)
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
movups 0xe62(%rip),%xmm0
movups %xmm0,0x19(%rsp)
movaps 0xe4d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe7c(%rip),%xmm0
movups %xmm0,0x4b(%rsp)
movaps 0xe65(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe49(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
lea    0xe43(%rip),%rsi
mov    %r14,%rdi
call   1090 <strcat@plt>
lea    0xe40(%rip),%rbp
lea    0x10(%rsp),%r13
mov    %rbp,%rdi
mov    %r13,%rsi
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x14,%edx
call   1040 <strncpy@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
lea    0x23(%rsp),%rsi
mov    %r12,%rdi
call   1090 <strcat@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <printf@plt>
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
call   1050 <strcpy@plt>
lea    0xdf6(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcat@plt>
lea    0xdf2(%rip),%rdi
mov    %r15,%rsi
call   1070 <printf@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
lea    0x3f(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcat@plt>
lea    0x59(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    %r12,%rdi
call   1060 <system@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.generateKey.command1 = [25 x i8] c"openssl genrsa -out 2048\00"
@__const.generateKey.command2 = [43 x i8] c"openssl rsa -in -outform PEM -pubout -out \00"
@.str = [12 x i8] c"private.pem\00"
@.str.1 = [13 x i8] c"command: %s\0A\00"
@.str.2 = [11 x i8] c"public.pem\00"
@.str.3 = [12 x i8] c"public: %s\0A\00"
define void @generateKey(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [25 x i8]
%6 = alloca [43 x i8]
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %2
%9 = call i8* @malloc(i32 64)
store i8* %9, i8** %3
%10 = call i8* @malloc(i32 64)
store i8* %10, i8** %4
%11 = bitcast [25 x i8]* %5 to i8*
%12 = bitcast [43 x i8]* %6 to i8*
%13 = call i8* @malloc(i32 100)
store i8* %13, i8** %7
%14 = call i8* @malloc(i32 100)
store i8* %14, i8** %8
%15 = load i8*, i8** %3
%16 = load i8*, i8** %2
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = load i8*, i8** %3
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [25 x i8], [25 x i8]* %5, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %7
%23 = getelementptr inbounds [25 x i8], [25 x i8]* %5, i64 0, i64 0
%24 = call i32 @strncpy(i8* %22, i8* %23, i32 20)
%25 = load i8*, i8** %7
%26 = load i8*, i8** %3
%27 = call i32 @strcat(i8* %25, i8* %26)
%28 = load i8*, i8** %7
%29 = getelementptr inbounds [25 x i8], [25 x i8]* %5, i64 0, i64 0
%30 = getelementptr inbounds i8, i8* %29, i64 19
%31 = call i32 @strcat(i8* %28, i8* %30)
%32 = load i8*, i8** %7
%33 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %4
%35 = load i8*, i8** %2
%36 = call i32 @strcpy(i8* %34, i8* %35)
%37 = load i8*, i8** %4
%38 = call i32 @strcat(i8* %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%39 = load i8*, i8** %4
%40 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %8
%42 = getelementptr inbounds [43 x i8], [43 x i8]* %6, i64 0, i64 0
%43 = call i32 @strncpy(i8* %41, i8* %42, i32 16)
%44 = load i8*, i8** %8
%45 = load i8*, i8** %3
%46 = call i32 @strcat(i8* %44, i8* %45)
%47 = load i8*, i8** %8
%48 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %47)
%49 = load i8*, i8** %8
%50 = getelementptr inbounds [43 x i8], [43 x i8]* %6, i64 0, i64 0
%51 = getelementptr inbounds i8, i8* %50, i64 15
%52 = call i32 @strcat(i8* %49, i8* %51)
%53 = load i8*, i8** %8
%54 = load i8*, i8** %4
%55 = call i32 @strcat(i8* %53, i8* %54)
%56 = load i8*, i8** %8
%57 = getelementptr inbounds [43 x i8], [43 x i8]* %6, i64 0, i64 0
%58 = getelementptr inbounds i8, i8* %57, i64 41
%59 = call i32 @strcat(i8* %56, i8* %58)
%60 = load i8*, i8** %8
%61 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %60)
%62 = load i8*, i8** %7
%63 = call i32 @system(i8* %62)
%64 = load i8*, i8** %8
%65 = call i32 @system(i8* %64)
%66 = load i8*, i8** %3
%67 = call i32 @free(i8* %66)
%68 = load i8*, i8** %4
%69 = call i32 @free(i8* %68)
%70 = load i8*, i8** %8
%71 = call i32 @free(i8* %70)
%72 = load i8*, i8** %7
%73 = call i32 @free(i8* %72)
ret void
}

LLVM IR (-O2):
@__const.generateKey.command1 = [25 x i8] c"openssl genrsa -out 2048\00"
@__const.generateKey.command2 = [43 x i8] c"openssl rsa -in -outform PEM -pubout -out \00"
@.str = [12 x i8] c"private.pem\00"
@.str.1 = [13 x i8] c"command: %s\0A\00"
@.str.2 = [11 x i8] c"public.pem\00"
@.str.3 = [12 x i8] c"public: %s\0A\00"
define void @generateKey(i8* %0) {
%2 = alloca [25 x i8]
%3 = alloca [43 x i8]
%4 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%5 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%6 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [43 x i8], [43 x i8]* %3, i64 0, i64 0
%8 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%9 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%10 = tail call i32 @strcpy(i8* %4, i8* %0)
%11 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%13 = call i32 @strncpy(i8* %8, i8* %6, i32 20)
%14 = call i32 @strcat(i8* %8, i8* %4)
%15 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 19
%16 = call i32 @strcat(i8* %8, i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%18 = call i32 @strcpy(i8* %5, i8* %0)
%19 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%21 = call i32 @strncpy(i8* %9, i8* %7, i32 16)
%22 = call i32 @strcat(i8* %9, i8* %4)
%23 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%24 = getelementptr inbounds [43 x i8], [43 x i8]* %3, i64 0, i64 15
%25 = call i32 @strcat(i8* %9, i8* %24)
%26 = call i32 @strcat(i8* %9, i8* %5)
%27 = getelementptr inbounds [43 x i8], [43 x i8]* %3, i64 0, i64 41
%28 = call i32 @strcat(i8* %9, i8* %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%30 = call i32 @system(i8* %8)
%31 = call i32 @system(i8* %9)
%32 = call i32 @free(i8* %4)
%33 = call i32 @free(i8* %5)
%34 = call i32 @free(i8* %9)
%35 = call i32 @free(i8* %8)
ret void
}