#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char const *);
char *strdup(char const *);
int /*<<< orphan*/ system(char *);
int main(int argc, char const *argv[]) {
  FILE *message, *session_key, *ciphertext, *init_vector;
  char *message_filename = (char *)malloc(sizeof(char) * 64);
  char *sesskey_filename = (char *)malloc(sizeof(char) * 64);
  char *pubkey_filename = (char *)malloc(sizeof(char) * 64);
  char *privkey_filename = (char *)malloc(sizeof(char) * 64);
  int message_set = 0;
  int sesskey_set = 0;
  int pubkey_set = 0;
  int privkey_set = 0;
  int i;
  for (i = 0; i < argc; i++) {
    char *test = strdup(argv[i]);
    char const *v1 = "-m";
    char const *v2 = "--message";
    char const *v3 = "-s";
    char const *v4 = "--session";
    char const *v5 = "-p";
    char const *v6 = "--pubkey";
    char const *v7 = "-r";
    char const *v8 = "--privkey";
    if (strcmp(test, v1) == 0 || strcmp(test, v2) == 0) {
      memcpy(message_filename, argv[++i], sizeof(char) * 64);
      message_set = 1;
    }
    if (strcmp(test, v3) == 0 || strcmp(test, v4) == 0) {
      memcpy(sesskey_filename, argv[++i], sizeof(char) * 64);
      sesskey_set = 1;
    }
    if (strcmp(test, v5) == 0 || strcmp(test, v6) == 0) {
      memcpy(pubkey_filename, argv[++i], sizeof(char) * 64);
      pubkey_set = 1;
    }
    if (strcmp(test, v7) == 0 || strcmp(test, v8) == 0) {
      memcpy(privkey_filename, argv[++i], sizeof(char) * 64);
      privkey_set = 1;
    }
  }
  if (message_set == 0) {
    fprintf(stderr, "Error: Message filename not set\n");
    exit(EXIT_FAILURE);
  }
  if (sesskey_set == 0) {
    fprintf(stderr, "Error: Session Key filename not set\n");
    exit(EXIT_FAILURE);
  }
  if (pubkey_set == 0) {
    fprintf(stderr, "Error: Public Key filename not set\n");
    exit(EXIT_FAILURE);
  }
  if (privkey_set == 0) {
    fprintf(stderr, "Error: Private Key filename not set\n");
    exit(EXIT_FAILURE);
  }
  char cmd[500];
  sprintf(cmd, "openssl rsautl -raw -inkey %s -pubin -in %s -out sesskey.txt",
          pubkey_filename, sesskey_filename);
  system(cmd);
  char key[9];
  session_key = fopen("sesskey.txt", "r");
  if (!session_key) {
    fprintf(stderr,
            "Unable to open session key file. This should not happen\n");
    exit(EXIT_FAILURE);
  }
  fgets(key, 9, session_key);
  sprintf(cmd, "openssl des -in %s -out %s.enc -pass file:./sesskey.txt",
          message_filename, message_filename);
  system(cmd);
  sprintf(cmd, "openssl dgst -sha256 -binary %s > hash", message_filename);
  system(cmd);
  sprintf(cmd,
          "openssl rsautl -sign -inkey %s -keyform PEM -in hash > signature",
          privkey_filename);
  system(cmd);
  sprintf(cmd, "rm hash");
  system(cmd);
  free(message_filename);
  free(sesskey_filename);
  free(pubkey_filename);
  free(privkey_filename);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1430 <main+0x280>
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x70(%rbp)
lea    0xdb4(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    0xdac(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    0xdab(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    0xda0(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    0xd9c(%rip),%rax
mov    %rax,-0x98(%rbp)
lea    0xd91(%rip),%rax
mov    %rax,-0xa0(%rbp)
lea    0xd8c(%rip),%rax
mov    %rax,-0xa8(%rbp)
lea    0xd81(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12dd <main+0x12d>
mov    -0x70(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1306 <main+0x156>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x40,%edx
call   1080 <memcpy@plt>
movl   $0x1,-0x54(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     133a <main+0x18a>
mov    -0x70(%rbp),%rdi
mov    -0x90(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1363 <main+0x1b3>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x40,%edx
call   1080 <memcpy@plt>
movl   $0x1,-0x58(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1397 <main+0x1e7>
mov    -0x70(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    13c0 <main+0x210>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x40,%edx
call   1080 <memcpy@plt>
movl   $0x1,-0x5c(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     13f4 <main+0x244>
mov    -0x70(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    141d <main+0x26d>
mov    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x40,%edx
call   1080 <memcpy@plt>
movl   $0x1,-0x60(%rbp)
jmp    1422 <main+0x272>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1224 <main+0x74>
cmpl   $0x0,-0x54(%rbp)
jne    145d <main+0x2ad>
mov    0x2b9f(%rip),%rax
mov    (%rax),%edi
lea    0xbe9(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x58(%rbp)
jne    148a <main+0x2da>
mov    0x2b72(%rip),%rax
mov    (%rax),%edi
lea    0xbdd(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b55(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x5c(%rbp)
jne    14b7 <main+0x307>
mov    0x2b45(%rip),%rax
mov    (%rax),%edi
lea    0xbd5(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b28(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x60(%rbp)
jne    14e4 <main+0x334>
mov    0x2b18(%rip),%rax
mov    (%rax),%edi
lea    0xbcc(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2afb(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    -0x2b0(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xbc8(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x2b0(%rbp),%rdi
call   1040 <system@plt>
lea    0xbdf(%rip),%rdi
lea    0xb0c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1552 <main+0x3a2>
mov    0x2aaa(%rip),%rax
mov    (%rax),%edi
lea    0xbc0(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2a8d(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    -0x2b9(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x9,%esi
call   1050 <fgets@plt>
lea    -0x2b0(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x38(%rbp),%rcx
lea    0xbbb(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x2b0(%rbp),%rdi
call   1040 <system@plt>
lea    -0x2b0(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xbce(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x2b0(%rbp),%rdi
call   1040 <system@plt>
lea    -0x2b0(%rbp),%rdi
mov    -0x50(%rbp),%rdx
lea    0xbd0(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x2b0(%rbp),%rdi
call   1040 <system@plt>
lea    -0x2b0(%rbp),%rdi
lea    0xbf0(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x2b0(%rbp),%rdi
call   1040 <system@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x2c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    $0x40,%edi
call   1090 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %ebp,%ebp
jle    14b7 <main+0x307>
movl   $0x0,0xc(%rsp)
xor    %r15d,%r15d
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
xor    %r12d,%r12d
jmp    1260 <main+0xb0>
nopw   0x0(%rax,%rax,1)
movslq %r12d,%rax
add    $0x1,%r12d
mov    0x8(%rbx,%rax,8),%rsi
mov    0x10(%rsp),%rdi
mov    $0x40,%edx
call   1080 <memcpy@plt>
movl   $0x1,0x8(%rsp)
add    $0x1,%r12d
cmp    %ebp,%r12d
jge    1380 <main+0x1d0>
movslq %r12d,%r13
mov    (%rbx,%r13,8),%rdi
call   10d0 <strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
lea    0xd87(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1297 <main+0xe7>
mov    %r14,%rdi
lea    0xd76(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12b7 <main+0x107>
lea    0x1(%r13),%r12d
mov    0x8(%rbx,%r13,8),%rsi
mov    0x18(%rsp),%rdi
mov    $0x40,%edx
call   1080 <memcpy@plt>
movl   $0x1,0xc(%rsp)
mov    %r14,%rdi
lea    0xd4c(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12df <main+0x12f>
mov    %r14,%rdi
lea    0xd3b(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1300 <main+0x150>
movslq %r12d,%rax
add    $0x1,%r12d
mov    0x8(%rbx,%rax,8),%rsi
mov    0x28(%rsp),%rdi
mov    $0x40,%edx
call   1080 <memcpy@plt>
mov    $0x1,%r15d
mov    %r14,%rdi
lea    0xd10(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1328 <main+0x178>
mov    %r14,%rdi
lea    0xcff(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    134b <main+0x19b>
movslq %r12d,%rax
add    $0x1,%r12d
mov    0x8(%rbx,%rax,8),%rsi
mov    0x20(%rsp),%rdi
mov    $0x40,%edx
call   1080 <memcpy@plt>
movl   $0x1,0x4(%rsp)
mov    %r14,%rdi
lea    0xcd1(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1230 <main+0x80>
mov    %r14,%rdi
lea    0xcbc(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1253 <main+0xa3>
jmp    1230 <main+0x80>
cmpl   $0x0,0xc(%rsp)
je     14b7 <main+0x307>
test   %r15d,%r15d
je     14c9 <main+0x319>
cmpl   $0x0,0x4(%rsp)
je     14db <main+0x32b>
cmpl   $0x0,0x8(%rsp)
mov    0x28(%rsp),%r14
mov    0x20(%rsp),%r15
je     14ed <main+0x33d>
lea    0xd07(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xd14(%rip),%rdi
lea    0xc41(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     14ff <main+0x34f>
lea    0x37(%rsp),%rdi
mov    $0x9,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
lea    0xd2b(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    0x18(%rsp),%rbp
mov    %rbp,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xd3a(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xd45(%rip),%rsi
mov    %rbx,%rdi
mov    0x10(%rsp),%r12
mov    %r12,%rdx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
movabs $0x68736168206d72,%rax
mov    %rax,0x40(%rsp)
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
lea    0xb6c(%rip),%rsi
jmp    150f <main+0x35f>
mov    0x2b10(%rip),%rax
mov    (%rax),%edi
lea    0xb7b(%rip),%rsi
jmp    150f <main+0x35f>
mov    0x2afe(%rip),%rax
mov    (%rax),%edi
lea    0xb8e(%rip),%rsi
jmp    150f <main+0x35f>
mov    0x2aec(%rip),%rax
mov    (%rax),%edi
lea    0xba0(%rip),%rsi
jmp    150f <main+0x35f>
mov    0x2ada(%rip),%rax
mov    (%rax),%edi
lea    0xbf0(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2abd(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-m\00"
@.str.1 = [10 x i8] c"--message\00"
@.str.2 = [3 x i8] c"-s\00"
@.str.3 = [10 x i8] c"--session\00"
@.str.4 = [3 x i8] c"-p\00"
@.str.5 = [9 x i8] c"--pubkey\00"
@.str.6 = [3 x i8] c"-r\00"
@.str.7 = [10 x i8] c"--privkey\00"
@stderr = global i32 0
@.str.8 = [33 x i8] c"Error: Message filename not set\0A\00"
@EXIT_FAILURE = global i32 0
@.str.9 = [37 x i8] c"Error: Session Key filename not set\0A\00"
@.str.10 = [36 x i8] c"Error: Public Key filename not set\0A\00"
@.str.11 = [37 x i8] c"Error: Private Key filename not set\0A\00"
@.str.12 = [61 x i8] c"openssl rsautl -raw -inkey %s -pubin -in %s -out sesskey.txt\00"
@.str.13 = [12 x i8] c"sesskey.txt\00"
@.str.14 = [2 x i8] c"r\00"
@.str.15 = [57 x i8] c"Unable to open session key file. This should not happen\0A\00"
@.str.16 = [56 x i8] c"openssl des -in %s -out %s.enc -pass file:./sesskey.txt\00"
@.str.17 = [39 x i8] c"openssl dgst -sha256 -binary %s > hash\00"
@.str.18 = [65 x i8] c"openssl rsautl -sign -inkey %s -keyform PEM -in hash > signature\00"
@.str.19 = [8 x i8] c"rm hash\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i8*
%28 = alloca [500 x i8]
%29 = alloca [9 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%30 = call i64 @malloc(i32 64)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %10
%32 = call i64 @malloc(i32 64)
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %11
%34 = call i64 @malloc(i32 64)
%35 = inttoptr i64 %34 to i8*
store i8* %35, i8** %12
%36 = call i64 @malloc(i32 64)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %13
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
br label %38
38: ; preds = %125, %2
%39 = load i32, i32* %18
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %128
42: ; preds = %38
%43 = load i8**, i8*** %5
%44 = load i32, i32* %18
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i8* @strdup(i8* %47)
store i8* %48, i8** %19
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %20
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %21
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %22
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %23
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %24
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %25
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %26
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8** %27
%49 = load i8*, i8** %19
%50 = load i8*, i8** %20
%51 = call i64 @strcmp(i8* %49, i8* %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %58, label %53
53: ; preds = %42
%54 = load i8*, i8** %19
%55 = load i8*, i8** %21
%56 = call i64 @strcmp(i8* %54, i8* %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %67
58: ; preds = %53, %42
%59 = load i8*, i8** %10
%60 = load i8**, i8*** %5
%61 = load i32, i32* %18
%62 = add nsw i32 %61, 1
store i32 %62, i32* %18
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %60, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 @memcpy(i8* %59, i8* %65, i32 64)
store i32 1, i32* %14
br label %67
67: ; preds = %58, %53
%68 = load i8*, i8** %19
%69 = load i8*, i8** %22
%70 = call i64 @strcmp(i8* %68, i8* %69)
%71 = icmp eq i64 %70, 0
br i1 %71, label %77, label %72
72: ; preds = %67
%73 = load i8*, i8** %19
%74 = load i8*, i8** %23
%75 = call i64 @strcmp(i8* %73, i8* %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %86
77: ; preds = %72, %67
%78 = load i8*, i8** %11
%79 = load i8**, i8*** %5
%80 = load i32, i32* %18
%81 = add nsw i32 %80, 1
store i32 %81, i32* %18
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %79, i64 %82
%84 = load i8*, i8** %83
%85 = call i32 @memcpy(i8* %78, i8* %84, i32 64)
store i32 1, i32* %15
br label %86
86: ; preds = %77, %72
%87 = load i8*, i8** %19
%88 = load i8*, i8** %24
%89 = call i64 @strcmp(i8* %87, i8* %88)
%90 = icmp eq i64 %89, 0
br i1 %90, label %96, label %91
91: ; preds = %86
%92 = load i8*, i8** %19
%93 = load i8*, i8** %25
%94 = call i64 @strcmp(i8* %92, i8* %93)
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %105
96: ; preds = %91, %86
%97 = load i8*, i8** %12
%98 = load i8**, i8*** %5
%99 = load i32, i32* %18
%100 = add nsw i32 %99, 1
store i32 %100, i32* %18
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %98, i64 %101
%103 = load i8*, i8** %102
%104 = call i32 @memcpy(i8* %97, i8* %103, i32 64)
store i32 1, i32* %16
br label %105
105: ; preds = %96, %91
%106 = load i8*, i8** %19
%107 = load i8*, i8** %26
%108 = call i64 @strcmp(i8* %106, i8* %107)
%109 = icmp eq i64 %108, 0
br i1 %109, label %115, label %110
110: ; preds = %105
%111 = load i8*, i8** %19
%112 = load i8*, i8** %27
%113 = call i64 @strcmp(i8* %111, i8* %112)
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %124
115: ; preds = %110, %105
%116 = load i8*, i8** %13
%117 = load i8**, i8*** %5
%118 = load i32, i32* %18
%119 = add nsw i32 %118, 1
store i32 %119, i32* %18
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8*, i8** %117, i64 %120
%122 = load i8*, i8** %121
%123 = call i32 @memcpy(i8* %116, i8* %122, i32 64)
store i32 1, i32* %17
br label %124
124: ; preds = %115, %110
br label %125
125: ; preds = %124
%126 = load i32, i32* %18
%127 = add nsw i32 %126, 1
store i32 %127, i32* %18
br label %38
128: ; preds = %38
%129 = load i32, i32* %14
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %136
131: ; preds = %128
%132 = load i32, i32* @stderr
%133 = call i32 @fprintf(i32 %132, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%134 = load i32, i32* @EXIT_FAILURE
%135 = call i32 @exit(i32 %134)
unreachable
136: ; preds = %128
%137 = load i32, i32* %15
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %144
139: ; preds = %136
%140 = load i32, i32* @stderr
%141 = call i32 @fprintf(i32 %140, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
%142 = load i32, i32* @EXIT_FAILURE
%143 = call i32 @exit(i32 %142)
unreachable
144: ; preds = %136
%145 = load i32, i32* %16
%146 = icmp eq i32 %145, 0
br i1 %146, label %147, label %152
147: ; preds = %144
%148 = load i32, i32* @stderr
%149 = call i32 @fprintf(i32 %148, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%150 = load i32, i32* @EXIT_FAILURE
%151 = call i32 @exit(i32 %150)
unreachable
152: ; preds = %144
%153 = load i32, i32* %17
%154 = icmp eq i32 %153, 0
br i1 %154, label %155, label %160
155: ; preds = %152
%156 = load i32, i32* @stderr
%157 = call i32 @fprintf(i32 %156, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%158 = load i32, i32* @EXIT_FAILURE
%159 = call i32 @exit(i32 %158)
unreachable
160: ; preds = %152
%161 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%162 = load i8*, i8** %12
%163 = load i8*, i8** %11
%164 = call i32 (i8*, i8*, ...) @sprintf(i8* %161, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.12, i64 0, i64 0), i8* %162, i8* %163)
%165 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%166 = call i32 @system(i8* %165)
%167 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32* %167, i32** %7
%168 = load i32*, i32** %7
%169 = icmp ne i32* %168, null
br i1 %169, label %175, label %170
170: ; preds = %160
%171 = load i32, i32* @stderr
%172 = call i32 @fprintf(i32 %171, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.15, i64 0, i64 0))
%173 = load i32, i32* @EXIT_FAILURE
%174 = call i32 @exit(i32 %173)
unreachable
175: ; preds = %160
%176 = getelementptr inbounds [9 x i8], [9 x i8]* %29, i64 0, i64 0
%177 = load i32*, i32** %7
%178 = call i32 @fgets(i8* %176, i32 9, i32* %177)
%179 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%180 = load i8*, i8** %10
%181 = load i8*, i8** %10
%182 = call i32 (i8*, i8*, ...) @sprintf(i8* %179, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.16, i64 0, i64 0), i8* %180, i8* %181)
%183 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%184 = call i32 @system(i8* %183)
%185 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%186 = load i8*, i8** %10
%187 = call i32 (i8*, i8*, ...) @sprintf(i8* %185, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.17, i64 0, i64 0), i8* %186)
%188 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%189 = call i32 @system(i8* %188)
%190 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%191 = load i8*, i8** %13
%192 = call i32 (i8*, i8*, ...) @sprintf(i8* %190, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.18, i64 0, i64 0), i8* %191)
%193 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%194 = call i32 @system(i8* %193)
%195 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%196 = call i32 (i8*, i8*, ...) @sprintf(i8* %195, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0))
%197 = getelementptr inbounds [500 x i8], [500 x i8]* %28, i64 0, i64 0
%198 = call i32 @system(i8* %197)
%199 = load i8*, i8** %10
%200 = call i32 @free(i8* %199)
%201 = load i8*, i8** %11
%202 = call i32 @free(i8* %201)
%203 = load i8*, i8** %12
%204 = call i32 @free(i8* %203)
%205 = load i8*, i8** %13
%206 = call i32 @free(i8* %205)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-m\00"
@.str.1 = [10 x i8] c"--message\00"
@.str.2 = [3 x i8] c"-s\00"
@.str.3 = [10 x i8] c"--session\00"
@.str.4 = [3 x i8] c"-p\00"
@.str.5 = [9 x i8] c"--pubkey\00"
@.str.6 = [3 x i8] c"-r\00"
@.str.7 = [10 x i8] c"--privkey\00"
@stderr = global i32 0
@.str.8 = [33 x i8] c"Error: Message filename not set\0A\00"
@EXIT_FAILURE = global i32 0
@.str.9 = [37 x i8] c"Error: Session Key filename not set\0A\00"
@.str.10 = [36 x i8] c"Error: Public Key filename not set\0A\00"
@.str.11 = [37 x i8] c"Error: Private Key filename not set\0A\00"
@.str.12 = [61 x i8] c"openssl rsautl -raw -inkey %s -pubin -in %s -out sesskey.txt\00"
@.str.13 = [12 x i8] c"sesskey.txt\00"
@.str.14 = [2 x i8] c"r\00"
@.str.15 = [57 x i8] c"Unable to open session key file. This should not happen\0A\00"
@.str.16 = [56 x i8] c"openssl des -in %s -out %s.enc -pass file:./sesskey.txt\00"
@.str.17 = [39 x i8] c"openssl dgst -sha256 -binary %s > hash\00"
@.str.18 = [65 x i8] c"openssl rsautl -sign -inkey %s -keyform PEM -in hash > signature\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [500 x i8]
%4 = alloca [9 x i8]
%5 = tail call i64 @malloc(i32 64)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i64 @malloc(i32 64)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i64 @malloc(i32 64)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i64 @malloc(i32 64)
%12 = inttoptr i64 %11 to i8*
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %84
14: ; preds = %2, %77
%15 = phi i32 [ %37, %77 ], [ 0, %2 ]
%16 = phi i32 [ %51, %77 ], [ 0, %2 ]
%17 = phi i32 [ %65, %77 ], [ 0, %2 ]
%18 = phi i32 [ %79, %77 ], [ 0, %2 ]
%19 = phi i32 [ %80, %77 ], [ 0, %2 ]
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i8* @strdup(i8* %22)
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %14
%27 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26, %14
%30 = add nsw i32 %19, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %1, i64 %31
%33 = load i8*, i8** %32
%34 = tail call i32 @memcpy(i8* %6, i8* %33, i32 64)
br label %35
35: ; preds = %29, %26
%36 = phi i32 [ %30, %29 ], [ %19, %26 ]
%37 = phi i32 [ 1, %29 ], [ %15, %26 ]
%38 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %35
%41 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %49
43: ; preds = %40, %35
%44 = add nsw i32 %36, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %1, i64 %45
%47 = load i8*, i8** %46
%48 = tail call i32 @memcpy(i8* %8, i8* %47, i32 64)
br label %49
49: ; preds = %43, %40
%50 = phi i32 [ %44, %43 ], [ %36, %40 ]
%51 = phi i32 [ 1, %43 ], [ %16, %40 ]
%52 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %49
%55 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %63
57: ; preds = %54, %49
%58 = add nsw i32 %50, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %1, i64 %59
%61 = load i8*, i8** %60
%62 = tail call i32 @memcpy(i8* %10, i8* %61, i32 64)
br label %63
63: ; preds = %57, %54
%64 = phi i32 [ %58, %57 ], [ %50, %54 ]
%65 = phi i32 [ 1, %57 ], [ %17, %54 ]
%66 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %71, label %68
68: ; preds = %63
%69 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %68, %63
%72 = add nsw i32 %64, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %1, i64 %73
%75 = load i8*, i8** %74
%76 = tail call i32 @memcpy(i8* %12, i8* %75, i32 64)
br label %77
77: ; preds = %71, %68
%78 = phi i32 [ %72, %71 ], [ %64, %68 ]
%79 = phi i32 [ 1, %71 ], [ %18, %68 ]
%80 = add nsw i32 %78, 1
%81 = icmp slt i32 %80, %0
br i1 %81, label %14, label %82
82: ; preds = %77
%83 = icmp eq i32 %37, 0
br i1 %83, label %84, label %89
84: ; preds = %2, %82
%85 = load i32, i32* @stderr
%86 = tail call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%87 = load i32, i32* @EXIT_FAILURE
%88 = tail call i32 @exit(i32 %87)
unreachable
89: ; preds = %82
%90 = icmp eq i32 %51, 0
br i1 %90, label %91, label %96
91: ; preds = %89
%92 = load i32, i32* @stderr
%93 = tail call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
%94 = load i32, i32* @EXIT_FAILURE
%95 = tail call i32 @exit(i32 %94)
unreachable
96: ; preds = %89
%97 = icmp eq i32 %65, 0
br i1 %97, label %98, label %103
98: ; preds = %96
%99 = load i32, i32* @stderr
%100 = tail call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%101 = load i32, i32* @EXIT_FAILURE
%102 = tail call i32 @exit(i32 %101)
unreachable
103: ; preds = %96
%104 = icmp eq i32 %79, 0
br i1 %104, label %105, label %110
105: ; preds = %103
%106 = load i32, i32* @stderr
%107 = tail call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%108 = load i32, i32* @EXIT_FAILURE
%109 = tail call i32 @exit(i32 %108)
unreachable
110: ; preds = %103
%111 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%112 = call i32 (i8*, i8*, ...) @sprintf(i8* %111, i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.12, i64 0, i64 0), i8* %10, i8* %8)
%113 = call i32 @system(i8* %111)
%114 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%115 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%116 = icmp eq i32* %115, null
br i1 %116, label %117, label %122
117: ; preds = %110
%118 = load i32, i32* @stderr
%119 = tail call i32 @fprintf(i32 %118, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.15, i64 0, i64 0))
%120 = load i32, i32* @EXIT_FAILURE
%121 = tail call i32 @exit(i32 %120)
unreachable
122: ; preds = %110
%123 = call i32 @fgets(i8* %114, i32 9, i32* %115)
%124 = call i32 (i8*, i8*, ...) @sprintf(i8* %111, i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.16, i64 0, i64 0), i8* %6, i8* %6)
%125 = call i32 @system(i8* %111)
%126 = call i32 (i8*, i8*, ...) @sprintf(i8* %111, i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.17, i64 0, i64 0), i8* %6)
%127 = call i32 @system(i8* %111)
%128 = call i32 (i8*, i8*, ...) @sprintf(i8* %111, i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.18, i64 0, i64 0), i8* %12)
%129 = call i32 @system(i8* %111)
%130 = bitcast [500 x i8]* %3 to i64*
store i64 29400259773885810, i64* %130
%131 = call i32 @system(i8* %111)
%132 = call i32 @free(i8* %6)
%133 = call i32 @free(i8* %8)
%134 = call i32 @free(i8* %10)
%135 = call i32 @free(i8* %12)
ret i32 0
}