#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 */
struct sockaddr_in {
  int /*<<< orphan*/ sin_family;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ *h_addr_list;
};
typedef int /*<<< orphan*/ server_address;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
unsigned long atoi(char *);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int get_mapped_num_from_char(char);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(unsigned long);
char *malloc(int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int write(int, char *, int);
int main(int argc, char **argv) {
  int comms_sfd;
  unsigned long int comms_port_number;
  struct hostent *server;
  struct sockaddr_in server_address;
  FILE *input_file;
  FILE *key_file;
  if (argc < 4) {
    fprintf(stderr, "Not enough arguments provided. Exiting...\n");
    fprintf(stderr,
            "Correct usage: "
            "%s input_file key_file port\n",
            argv[0]);
    exit(1);
  } else if (argc > 4) {
    fprintf(stderr, "Extra arguments entered. Ignoring all but the first "
                    "three.\n");
  }
  comms_port_number = atoi(argv[3]);
  if ((comms_port_number > 65535) || (comms_port_number < 0)) {
    fprintf(stderr, "Port out of range! Please choose a different port! "
                    "Exiting...\n");
    exit(1);
  }
  input_file = fopen(argv[1], "r");
  key_file = fopen(argv[2], "r");
  if (input_file == NULL) {
    fprintf(stderr, "Input file does not exist or cannot be read! "
                    "Exiting...\n");
    exit(1);
  } else if (key_file == NULL) {
    fprintf(stderr, "Key file does not exist or cannot be read! "
                    "Exiting...\n");
    exit(1);
  }
  char *temp_buffer = malloc(sizeof(char) * 1000000);
  memset(temp_buffer, '\0', sizeof(char) * 1000000);
  fgets(temp_buffer, 1000000, input_file);
  char *input_text = malloc(sizeof(char) * (strlen(temp_buffer) + 1));
  memset(input_text, '\0', sizeof(char) * (strlen(temp_buffer) + 1));
  strcpy(input_text, temp_buffer);
  int input_str_len = strlen(input_text);
  if (input_text[input_str_len - 1] == '\n') {
    input_text[input_str_len - 1] = '\0';
  }
  memset(temp_buffer, '\0', sizeof(char) * 1000000);
  fgets(temp_buffer, 1000000, key_file);
  char *key_text = malloc(sizeof(char) * (strlen(temp_buffer) + 1));
  memset(key_text, '\0', sizeof(char) * (strlen(temp_buffer) + 1));
  strcpy(key_text, temp_buffer);
  input_str_len = strlen(key_text);
  if (key_text[input_str_len - 1] == '\n') {
    key_text[input_str_len - 1] = '\0';
  }
  free(temp_buffer);
  if (strlen(input_text) > strlen(key_text)) {
    fprintf(stderr, "Key file too small. Please try again with larger "
                    "file. Exiting...\n");
    exit(1);
  }
  for (unsigned long i = 0; i < strlen(input_text); i++) {
    if (get_mapped_num_from_char(input_text[i]) == -1) {
      fprintf(stderr, "Bad characters in input text. Exiting...\n");
      exit(1);
    }
  }
  for (unsigned long i = 0; i < strlen(key_text); i++) {
    if (get_mapped_num_from_char(key_text[i]) == -1) {
      fprintf(stderr, "Bad characters in key text. Exiting...\n");
      exit(1);
    }
  }
  comms_sfd = socket(AF_INET, SOCK_STREAM, 0);
  if (comms_sfd < 0) {
    fprintf(stderr, "Could not create comms socket! Exiting...\n");
    exit(1);
  }
  server = gethostbyname("localhost");
  if (server == NULL) {
    fprintf(stderr, "localhost is not a valid host! Exiting...\n");
    exit(1);
  }
  memset((char *)&server_address, '\0', sizeof(server_address));
  server_address.sin_port = htons(comms_port_number);
  memcpy(&server_address.sin_addr, server->h_addr_list[0], server->h_length);
  server_address.sin_family = AF_INET;
  int connect_result = connect(comms_sfd, (struct sockaddr *)&server_address,
                               sizeof(server_address));
  if (connect_result < 0) {
    fprintf(stderr, "Connection failed! Is the port correct? Exiting...\n");
    exit(2);
  }
  int read_return;
  int write_return;
  unsigned int concat_index = 0;
  char read_buffer[10];
  char *concat_buffer = malloc(sizeof(char) * 1000000);
  memset(read_buffer, '\0', 1);
  memset(concat_buffer, '\0', sizeof(char) * 1000000);
  write_return = write(comms_sfd,
                       "$"
                       "@@",
                       3);
  if (write_return < 0) {
    fprintf(stderr, "Failed to write data. Exiting...\n");
    exit(1);
  }
  while (strstr(concat_buffer, "@@") == NULL) {
    read_return = read(comms_sfd, read_buffer, 1);
    if (read_return != -1) {
      concat_buffer[concat_index] = read_buffer[0];
      concat_index++;
    }
  }
  if (strstr(concat_buffer, "&"
                            "@@") != NULL) {
    write_return = write(comms_sfd, input_text, strlen(input_text));
    if (write_return < 0) {
      fprintf(stderr, "Failed to write data. Exiting...\n");
      exit(1);
    }
    write_return = write(comms_sfd, "@@", 2);
    if (write_return < 0) {
      fprintf(stderr, "Failed to write data. Exiting...\n");
      exit(1);
    }
    write_return = write(comms_sfd, key_text, strlen(key_text));
    if (write_return < 0) {
      fprintf(stderr, "Failed to write data. Exiting...\n");
      exit(1);
    }
    write_return = write(comms_sfd, "@@", 2);
    if (write_return < 0) {
      fprintf(stderr, "Failed to write data. Exiting...\n");
      exit(1);
    }
    concat_index = 0;
    memset(read_buffer, '\0', 10);
    memset(concat_buffer, '\0', sizeof(char) * 1000000);
    while (strstr(concat_buffer, "@@") == NULL) {
      read_return = read(comms_sfd, read_buffer, 1);
      if (read_return != -1) {
        concat_buffer[concat_index] = read_buffer[0];
        concat_index++;
      }
    }
    int input_string_length = strlen(concat_buffer);
    concat_buffer[input_string_length - 1] = '\0';
    concat_buffer[input_string_length - 2] = '\0';
    for (int i = 0; i < strlen(concat_buffer); i++) {
      printf("%c", concat_buffer[i]);
    }
    printf("\n");
  } else if (strstr(concat_buffer, "%"
                                   "@@") != NULL) {
    fprintf(stderr, "OTP_DEC may NOT connect to OTP_ENC_D. Exiting...\n");
    exit(1);
  } else {
    fprintf(stderr, "Got bad data. Exiting...\n");
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    12a2 <main+0x62>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jle    12c3 <main+0x83>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
jmp    12c8 <main+0x88>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1120 <atoi@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xffff,-0x20(%rbp)
ja     12f2 <main+0xb2>
cmpq   $0x0,-0x20(%rbp)
jae    1313 <main+0xd3>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb0(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd98(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    136f <main+0x12f>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
cmpq   $0x0,-0x48(%rbp)
jne    139b <main+0x15b>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    13a0 <main+0x160>
mov    $0xf4240,%edi
call   1100 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1090 <memset@plt>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    $0xf4240,%esi
call   10b0 <fgets@plt>
mov    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1100 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xb0(%rbp),%rdi
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%rax
mov    -0x5c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    145e <main+0x21e>
mov    -0x58(%rbp),%rax
mov    -0x5c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1090 <memset@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    $0xf4240,%esi
call   10b0 <fgets@plt>
mov    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1100 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xb8(%rbp),%rdi
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x68(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x68(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x68(%rbp),%rax
mov    -0x5c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    150e <main+0x2ce>
mov    -0x68(%rbp),%rax
mov    -0x5c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xbc(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xbc(%rbp),%eax
cmp    %ecx,%eax
jle    1560 <main+0x320>
mov    0x2a92(%rip),%rax
mov    (%rax),%edi
lea    0xbf5(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
movq   $0x0,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xc8(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    15e2 <main+0x3a2>
mov    -0x58(%rbp),%rax
mov    -0x70(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10d0 <get_mapped_num_from_char@plt>
cmp    $0xffffffff,%eax
jne    15cc <main+0x38c>
mov    0x2a26(%rip),%rax
mov    (%rax),%edi
lea    0xbcc(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    15d1 <main+0x391>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    1568 <main+0x328>
movq   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xd0(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    1664 <main+0x424>
mov    -0x68(%rbp),%rax
mov    -0x78(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10d0 <get_mapped_num_from_char@plt>
cmp    $0xffffffff,%eax
jne    164e <main+0x40e>
mov    0x29a4(%rip),%rax
mov    (%rax),%edi
lea    0xb74(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    1653 <main+0x413>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    15ea <main+0x3aa>
mov    0x297d(%rip),%rax
mov    (%rax),%edi
mov    0x295c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    16ab <main+0x46b>
mov    0x2947(%rip),%rax
mov    (%rax),%edi
lea    0xb3f(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xb52(%rip),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    16e7 <main+0x4a7>
mov    0x290b(%rip),%rax
mov    (%rax),%edi
lea    0xb38(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    -0x20(%rbp),%rdi
call   1070 <htons@plt>
mov    %eax,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
add    $0x4,%rdi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
call   10f0 <memcpy@plt>
mov    0x28c1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   1140 <connect@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    176b <main+0x52b>
mov    0x2887(%rip),%rax
mov    (%rax),%edi
lea    0xadf(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
movl   $0x0,-0x88(%rbp)
mov    $0xf4240,%edi
call   1100 <malloc@plt>
mov    %rax,-0xa0(%rbp)
lea    -0x92(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1090 <memset@plt>
mov    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1090 <memset@plt>
mov    -0x14(%rbp),%edi
lea    0xab7(%rip),%rsi
mov    $0x3,%edx
call   1050 <write@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    17f4 <main+0x5b4>
mov    0x27fe(%rip),%rax
mov    (%rax),%edi
lea    0xa8e(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    17f9 <main+0x5b9>
mov    -0xa0(%rbp),%rdi
lea    0xa67(%rip),%rsi
call   1150 <strstr@plt>
cmp    $0x0,%rax
jne    1861 <main+0x621>
mov    -0x14(%rbp),%edi
lea    -0x92(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0xffffffff,-0x80(%rbp)
je     185c <main+0x61c>
mov    -0x92(%rbp),%dl
mov    -0xa0(%rbp),%rax
mov    -0x88(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    17f9 <main+0x5b9>
mov    -0xa0(%rbp),%rdi
lea    0xa24(%rip),%rsi
call   1150 <strstr@plt>
cmp    $0x0,%rax
je     1b29 <main+0x8e9>
mov    -0x14(%rbp),%eax
mov    %eax,-0xdc(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xdc(%rbp),%edi
mov    -0xd8(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    18e3 <main+0x6a3>
mov    0x270f(%rip),%rax
mov    (%rax),%edi
lea    0x99f(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%edi
lea    0x981(%rip),%rsi
mov    $0x2,%edx
call   1050 <write@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    192b <main+0x6eb>
mov    0x26c7(%rip),%rax
mov    (%rax),%edi
lea    0x957(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xec(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xec(%rbp),%edi
mov    -0xe8(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    1990 <main+0x750>
mov    0x2662(%rip),%rax
mov    (%rax),%edi
lea    0x8f2(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%edi
lea    0x8d4(%rip),%rsi
mov    $0x2,%edx
call   1050 <write@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    19d8 <main+0x798>
mov    0x261a(%rip),%rax
mov    (%rax),%edi
lea    0x8aa(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
movl   $0x0,-0x88(%rbp)
lea    -0x92(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <memset@plt>
mov    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1090 <memset@plt>
mov    -0xa0(%rbp),%rdi
lea    0x858(%rip),%rsi
call   1150 <strstr@plt>
cmp    $0x0,%rax
jne    1a70 <main+0x830>
mov    -0x14(%rbp),%edi
lea    -0x92(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0xffffffff,-0x80(%rbp)
je     1a6b <main+0x82b>
mov    -0x92(%rbp),%dl
mov    -0xa0(%rbp),%rax
mov    -0x88(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1a08 <main+0x7c8>
mov    -0xa0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xa4(%rbp)
mov    -0xa0(%rbp),%rax
mov    -0xa4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xa0(%rbp),%rax
mov    -0xa4(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
mov    %eax,-0xf0(%rbp)
mov    -0xa0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xf0(%rbp),%eax
cmp    %ecx,%eax
jge    1b16 <main+0x8d6>
mov    -0xa0(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0x79c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    1aba <main+0x87a>
lea    0x5ee(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1b88 <main+0x948>
mov    -0xa0(%rbp),%rdi
lea    0x763(%rip),%rsi
call   1150 <strstr@plt>
cmp    $0x0,%rax
je     1b67 <main+0x927>
mov    0x248b(%rip),%rax
mov    (%rax),%edi
lea    0x748(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x246a(%rip),%rax
mov    (%rax),%edi
lea    0x759(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
xor    %edi,%edi
call   1130 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jg     128c <main+0x4c>
mov    0x2d7b(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xd99(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xdb0(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
cmp    $0x4,%edi
je     12a8 <main+0x68>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x18(%rbx),%rdi
call   1120 <atoi@plt>
cmp    $0x10000,%rax
jb     12ce <main+0x8e>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    %rax,%r15
mov    0x8(%rbx),%rdi
lea    0xdf6(%rip),%rbp
mov    %rbp,%rsi
call   1110 <fopen@plt>
mov    %rax,%r13
mov    0x10(%rbx),%rdi
mov    %rbp,%rsi
call   1110 <fopen@plt>
test   %r13,%r13
jne    130d <main+0xcd>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    %rax,%r14
test   %rax,%rax
jne    132a <main+0xea>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    $0xf4240,%edi
call   1100 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1090 <memset@plt>
mov    %r12,%rdi
mov    $0xf4240,%esi
mov    %r13,%rdx
call   10b0 <fgets@plt>
mov    %r12,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edi
call   1100 <malloc@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <memset@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    139f <main+0x15f>
movb   $0x0,-0x1(%rbx,%rax,1)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1090 <memset@plt>
mov    %r12,%rdi
mov    $0xf4240,%esi
mov    %r14,%rdx
call   10b0 <fgets@plt>
mov    %r12,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edi
call   1100 <malloc@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <memset@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r14,1)
jne    1409 <main+0x1c9>
movb   $0x0,-0x1(%r14,%rax,1)
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1070 <strlen@plt>
cmp    %eax,%ebp
jle    143c <main+0x1fc>
mov    0x2baa(%rip),%rax
mov    (%rax),%edi
lea    0xd0d(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    %rbx,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
je     1475 <main+0x235>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%edi
call   10d0 <get_mapped_num_from_char@plt>
cmp    $0xffffffff,%eax
je     1513 <main+0x2d3>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbp
jb     1450 <main+0x210>
mov    %r14,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
je     14b6 <main+0x276>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r14,%rbp,1),%edi
call   10d0 <get_mapped_num_from_char@plt>
cmp    $0xffffffff,%eax
je     1528 <main+0x2e8>
add    $0x1,%rbp
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbp
jb     1490 <main+0x250>
mov    0x2b2b(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2b08(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
test   %eax,%eax
jns    14ea <main+0x2aa>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    %eax,%r12d
lea    0xd10(%rip),%rdi
call   10c0 <gethostbyname@plt>
test   %rax,%rax
jne    153d <main+0x2fd>
mov    0x2ad3(%rip),%rax
mov    (%rax),%edi
lea    0xd00(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    0x2abe(%rip),%rax
mov    (%rax),%edi
lea    0xc64(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    0x2aa9(%rip),%rax
mov    (%rax),%edi
lea    0xc79(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    %rax,%rbp
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    %r15,%rdi
call   1080 <htons@plt>
mov    %eax,0x20(%rsp)
lea    0x1c(%rsp),%rdi
mov    0x8(%rbp),%rax
mov    (%rax),%esi
mov    0x0(%rbp),%edx
call   10f0 <memcpy@plt>
mov    0x0(%r13),%eax
mov    %eax,0x18(%rsp)
mov    %r12d,%edi
lea    0x18(%rsp),%rsi
mov    $0xc,%edx
call   1140 <connect@plt>
test   %eax,%eax
jns    15af <main+0x36f>
mov    0x2a43(%rip),%rax
mov    (%rax),%edi
lea    0xc9b(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
mov    $0xf4240,%edi
call   1100 <malloc@plt>
mov    %rax,%r15
lea    0xe(%rsp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1090 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1090 <memset@plt>
lea    0xc8a(%rip),%rsi
mov    %r12d,%edi
mov    $0x3,%edx
call   1060 <write@plt>
test   %eax,%eax
jns    1615 <main+0x3d5>
mov    0x29dd(%rip),%rax
mov    (%rax),%edi
lea    0xc6d(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    %r12d,0x8(%rsp)
lea    0xc4d(%rip),%rsi
mov    %r15,%rdi
call   1150 <strstr@plt>
test   %rax,%rax
jne    1678 <main+0x438>
xor    %r12d,%r12d
lea    0xe(%rsp),%r13
lea    0xc31(%rip),%rbp
jmp    1650 <main+0x410>
nop
mov    %r15,%rdi
mov    %rbp,%rsi
call   1150 <strstr@plt>
test   %rax,%rax
jne    1678 <main+0x438>
mov    0x8(%rsp),%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
cmp    $0xffffffff,%eax
je     1640 <main+0x400>
movzbl 0xe(%rsp),%eax
mov    %r12d,%ecx
mov    %al,(%r15,%rcx,1)
add    $0x1,%r12d
jmp    1640 <main+0x400>
lea    0xc14(%rip),%rsi
mov    %r15,%rdi
call   1150 <strstr@plt>
test   %rax,%rax
jne    16b9 <main+0x479>
lea    0xc04(%rip),%rsi
mov    %r15,%rdi
call   1150 <strstr@plt>
mov    0x2936(%rip),%rcx
mov    (%rcx),%edi
test   %rax,%rax
jne    17b4 <main+0x574>
lea    0xc19(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <write@plt>
test   %eax,%eax
js     15f4 <main+0x3b4>
lea    0xb8e(%rip),%rsi
mov    %ebp,%edi
mov    $0x2,%edx
call   1060 <write@plt>
test   %eax,%eax
js     15f4 <main+0x3b4>
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <write@plt>
test   %eax,%eax
js     15f4 <main+0x3b4>
lea    0xb57(%rip),%rsi
mov    %ebp,%edi
mov    $0x2,%edx
call   1060 <write@plt>
test   %eax,%eax
js     15f4 <main+0x3b4>
lea    0xe(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1090 <memset@plt>
lea    0xb1a(%rip),%rsi
mov    %r15,%rdi
call   1150 <strstr@plt>
test   %rax,%rax
mov    0x8(%rsp),%ebp
jne    17c0 <main+0x580>
lea    0xe(%rsp),%r14
lea    0xafd(%rip),%r12
jmp    1790 <main+0x550>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
call   1150 <strstr@plt>
test   %rax,%rax
jne    17c0 <main+0x580>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
cmp    $0xffffffff,%eax
je     1780 <main+0x540>
movzbl 0xe(%rsp),%eax
mov    %ebx,%ecx
mov    %al,(%r15,%rcx,1)
add    $0x1,%ebx
jmp    1780 <main+0x540>
lea    0xae0(%rip),%rsi
jmp    1604 <main+0x3c4>
mov    %r15,%rdi
call   1070 <strlen@plt>
cltq
movw   $0x0,-0x2(%rax,%r15,1)
mov    %r15,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    17fd <main+0x5bd>
xor    %ebx,%ebx
movsbl (%r15,%rbx,1),%edi
call   1040 <putchar@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     17e0 <main+0x5a0>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %edi,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i32, i32* }
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [43 x i8] c"Not enough arguments provided. Exiting...\0A\00"
@.str.1 = [44 x i8] c"Correct usage: %s input_file key_file port\0A\00"
@.str.2 = [60 x i8] c"Extra arguments entered. Ignoring all but the first three.\0A\00"
@.str.3 = [63 x i8] c"Port out of range! Please choose a different port! Exiting...\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [57 x i8] c"Input file does not exist or cannot be read! Exiting...\0A\00"
@.str.6 = [55 x i8] c"Key file does not exist or cannot be read! Exiting...\0A\00"
@.str.7 = [67 x i8] c"Key file too small. Please try again with larger file. Exiting...\0A\00"
@.str.8 = [42 x i8] c"Bad characters in input text. Exiting...\0A\00"
@.str.9 = [40 x i8] c"Bad characters in key text. Exiting...\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.10 = [43 x i8] c"Could not create comms socket! Exiting...\0A\00"
@.str.11 = [10 x i8] c"localhost\00"
@.str.12 = [43 x i8] c"localhost is not a valid host! Exiting...\0A\00"
@.str.13 = [52 x i8] c"Connection failed! Is the port correct? Exiting...\0A\00"
@.str.14 = [4 x i8] c"$@@\00"
@.str.15 = [34 x i8] c"Failed to write data. Exiting...\0A\00"
@.str.16 = [3 x i8] c"@@\00"
@.str.17 = [4 x i8] c"&@@\00"
@.str.18 = [3 x i8] c"%c\00"
@.str.19 = [2 x i8] c"\0A\00"
@.str.20 = [4 x i8] c"%@@\00"
@.str.21 = [50 x i8] c"OTP_DEC may NOT connect to OTP_ENC_D. Exiting...\0A\00"
@.str.22 = [26 x i8] c"Got bad data. Exiting...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca %struct.hostent*
%9 = alloca %struct.sockaddr_in
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca [10 x i8]
%23 = alloca i8*
%24 = alloca i32
%25 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %37
28: ; preds = %2
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %2
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 4
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %40, %37
br label %44
44: ; preds = %43
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 3
%47 = load i8*, i8** %46
%48 = call i64 @atoi(i8* %47)
store i64 %48, i64* %7
%49 = load i64, i64* %7
%50 = icmp ugt i64 %49, 65535
br i1 %50, label %54, label %51
51: ; preds = %44
%52 = load i64, i64* %7
%53 = icmp ult i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51, %44
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %51
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %62, i32** %10
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = call i32* @fopen(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %66, i32** %11
%67 = load i32*, i32** %10
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %73
69: ; preds = %58
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %58
%74 = load i32*, i32** %11
%75 = icmp eq i32* %74, null
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = load i32, i32* @stderr
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %73
br label %81
81: ; preds = %80
%82 = call i8* @malloc(i32 1000000)
store i8* %82, i8** %12
%83 = load i8*, i8** %12
%84 = call i32 @memset(i8* %83, i8 signext 0, i32 1000000)
%85 = load i8*, i8** %12
%86 = load i32*, i32** %10
%87 = call i32 @fgets(i8* %85, i32 1000000, i32* %86)
%88 = load i8*, i8** %12
%89 = call i32 @strlen(i8* %88)
%90 = add nsw i32 %89, 1
%91 = sext i32 %90 to i64
%92 = mul i64 1, %91
%93 = trunc i64 %92 to i32
%94 = call i8* @malloc(i32 %93)
store i8* %94, i8** %13
%95 = load i8*, i8** %13
%96 = load i8*, i8** %12
%97 = call i32 @strlen(i8* %96)
%98 = add nsw i32 %97, 1
%99 = sext i32 %98 to i64
%100 = mul i64 1, %99
%101 = trunc i64 %100 to i32
%102 = call i32 @memset(i8* %95, i8 signext 0, i32 %101)
%103 = load i8*, i8** %13
%104 = load i8*, i8** %12
%105 = call i32 @strcpy(i8* %103, i8* %104)
%106 = load i8*, i8** %13
%107 = call i32 @strlen(i8* %106)
store i32 %107, i32* %14
%108 = load i8*, i8** %13
%109 = load i32, i32* %14
%110 = sub nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %108, i64 %111
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = icmp eq i32 %114, 10
br i1 %115, label %116, label %122
116: ; preds = %81
%117 = load i8*, i8** %13
%118 = load i32, i32* %14
%119 = sub nsw i32 %118, 1
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %117, i64 %120
store i8 0, i8* %121
br label %122
122: ; preds = %116, %81
%123 = load i8*, i8** %12
%124 = call i32 @memset(i8* %123, i8 signext 0, i32 1000000)
%125 = load i8*, i8** %12
%126 = load i32*, i32** %11
%127 = call i32 @fgets(i8* %125, i32 1000000, i32* %126)
%128 = load i8*, i8** %12
%129 = call i32 @strlen(i8* %128)
%130 = add nsw i32 %129, 1
%131 = sext i32 %130 to i64
%132 = mul i64 1, %131
%133 = trunc i64 %132 to i32
%134 = call i8* @malloc(i32 %133)
store i8* %134, i8** %15
%135 = load i8*, i8** %15
%136 = load i8*, i8** %12
%137 = call i32 @strlen(i8* %136)
%138 = add nsw i32 %137, 1
%139 = sext i32 %138 to i64
%140 = mul i64 1, %139
%141 = trunc i64 %140 to i32
%142 = call i32 @memset(i8* %135, i8 signext 0, i32 %141)
%143 = load i8*, i8** %15
%144 = load i8*, i8** %12
%145 = call i32 @strcpy(i8* %143, i8* %144)
%146 = load i8*, i8** %15
%147 = call i32 @strlen(i8* %146)
store i32 %147, i32* %14
%148 = load i8*, i8** %15
%149 = load i32, i32* %14
%150 = sub nsw i32 %149, 1
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i8, i8* %148, i64 %151
%153 = load i8, i8* %152
%154 = sext i8 %153 to i32
%155 = icmp eq i32 %154, 10
br i1 %155, label %156, label %162
156: ; preds = %122
%157 = load i8*, i8** %15
%158 = load i32, i32* %14
%159 = sub nsw i32 %158, 1
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds i8, i8* %157, i64 %160
store i8 0, i8* %161
br label %162
162: ; preds = %156, %122
%163 = load i8*, i8** %12
%164 = call i32 @free(i8* %163)
%165 = load i8*, i8** %13
%166 = call i32 @strlen(i8* %165)
%167 = load i8*, i8** %15
%168 = call i32 @strlen(i8* %167)
%169 = icmp sgt i32 %166, %168
br i1 %169, label %170, label %174
170: ; preds = %162
%171 = load i32, i32* @stderr
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %171, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.7, i64 0, i64 0))
%173 = call i32 @exit(i32 1)
unreachable
174: ; preds = %162
store i64 0, i64* %16
br label %175
175: ; preds = %193, %174
%176 = load i64, i64* %16
%177 = load i8*, i8** %13
%178 = call i32 @strlen(i8* %177)
%179 = sext i32 %178 to i64
%180 = icmp ult i64 %176, %179
br i1 %180, label %181, label %196
181: ; preds = %175
%182 = load i8*, i8** %13
%183 = load i64, i64* %16
%184 = getelementptr inbounds i8, i8* %182, i64 %183
%185 = load i8, i8* %184
%186 = call i32 @get_mapped_num_from_char(i8 signext %185)
%187 = icmp eq i32 %186, -1
br i1 %187, label %188, label %192
188: ; preds = %181
%189 = load i32, i32* @stderr
%190 = call i32 (i32, i8*, ...) @fprintf(i32 %189, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
%191 = call i32 @exit(i32 1)
unreachable
192: ; preds = %181
br label %193
193: ; preds = %192
%194 = load i64, i64* %16
%195 = add i64 %194, 1
store i64 %195, i64* %16
br label %175
196: ; preds = %175
store i64 0, i64* %17
br label %197
197: ; preds = %215, %196
%198 = load i64, i64* %17
%199 = load i8*, i8** %15
%200 = call i32 @strlen(i8* %199)
%201 = sext i32 %200 to i64
%202 = icmp ult i64 %198, %201
br i1 %202, label %203, label %218
203: ; preds = %197
%204 = load i8*, i8** %15
%205 = load i64, i64* %17
%206 = getelementptr inbounds i8, i8* %204, i64 %205
%207 = load i8, i8* %206
%208 = call i32 @get_mapped_num_from_char(i8 signext %207)
%209 = icmp eq i32 %208, -1
br i1 %209, label %210, label %214
210: ; preds = %203
%211 = load i32, i32* @stderr
%212 = call i32 (i32, i8*, ...) @fprintf(i32 %211, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0))
%213 = call i32 @exit(i32 1)
unreachable
214: ; preds = %203
br label %215
215: ; preds = %214
%216 = load i64, i64* %17
%217 = add i64 %216, 1
store i64 %217, i64* %17
br label %197
218: ; preds = %197
%219 = load i32, i32* @AF_INET
%220 = load i32, i32* @SOCK_STREAM
%221 = call i32 @socket(i32 %219, i32 %220, i32 0)
store i32 %221, i32* %6
%222 = load i32, i32* %6
%223 = icmp slt i32 %222, 0
br i1 %223, label %224, label %228
224: ; preds = %218
%225 = load i32, i32* @stderr
%226 = call i32 (i32, i8*, ...) @fprintf(i32 %225, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0))
%227 = call i32 @exit(i32 1)
unreachable
228: ; preds = %218
%229 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
store %struct.hostent* %229, %struct.hostent** %8
%230 = load %struct.hostent*, %struct.hostent** %8
%231 = icmp eq %struct.hostent* %230, null
br i1 %231, label %232, label %236
232: ; preds = %228
%233 = load i32, i32* @stderr
%234 = call i32 (i32, i8*, ...) @fprintf(i32 %233, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0))
%235 = call i32 @exit(i32 1)
unreachable
236: ; preds = %228
%237 = bitcast %struct.sockaddr_in* %9 to i8*
%238 = call i32 @memset(i8* %237, i8 signext 0, i32 12)
%239 = load i64, i64* %7
%240 = call i32 @htons(i64 %239)
%241 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %240, i32* %241
%242 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%243 = load %struct.hostent*, %struct.hostent** %8
%244 = getelementptr inbounds %struct.hostent, %struct.hostent* %243, i32 0, i32 1
%245 = load i32*, i32** %244
%246 = getelementptr inbounds i32, i32* %245, i64 0
%247 = load i32, i32* %246
%248 = load %struct.hostent*, %struct.hostent** %8
%249 = getelementptr inbounds %struct.hostent, %struct.hostent* %248, i32 0, i32 0
%250 = load i32, i32* %249
%251 = call i32 @memcpy(i32* %242, i32 %247, i32 %250)
%252 = load i32, i32* @AF_INET
%253 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %252, i32* %253
%254 = load i32, i32* %6
%255 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%256 = call i32 @connect(i32 %254, %struct.sockaddr* %255, i32 12)
store i32 %256, i32* %18
%257 = load i32, i32* %18
%258 = icmp slt i32 %257, 0
br i1 %258, label %259, label %263
259: ; preds = %236
%260 = load i32, i32* @stderr
%261 = call i32 (i32, i8*, ...) @fprintf(i32 %260, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.13, i64 0, i64 0))
%262 = call i32 @exit(i32 2)
unreachable
263: ; preds = %236
store i32 0, i32* %21
%264 = call i8* @malloc(i32 1000000)
store i8* %264, i8** %23
%265 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 0
%266 = call i32 @memset(i8* %265, i8 signext 0, i32 1)
%267 = load i8*, i8** %23
%268 = call i32 @memset(i8* %267, i8 signext 0, i32 1000000)
%269 = load i32, i32* %6
%270 = call i32 @write(i32 %269, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 3)
store i32 %270, i32* %20
%271 = load i32, i32* %20
%272 = icmp slt i32 %271, 0
br i1 %272, label %273, label %277
273: ; preds = %263
%274 = load i32, i32* @stderr
%275 = call i32 (i32, i8*, ...) @fprintf(i32 %274, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%276 = call i32 @exit(i32 1)
unreachable
277: ; preds = %263
br label %278
278: ; preds = %297, %277
%279 = load i8*, i8** %23
%280 = call i32* @strstr(i8* %279, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%281 = icmp eq i32* %280, null
br i1 %281, label %282, label %298
282: ; preds = %278
%283 = load i32, i32* %6
%284 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 0
%285 = call i32 @read(i32 %283, i8* %284, i32 1)
store i32 %285, i32* %19
%286 = load i32, i32* %19
%287 = icmp ne i32 %286, -1
br i1 %287, label %288, label %297
288: ; preds = %282
%289 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 0
%290 = load i8, i8* %289
%291 = load i8*, i8** %23
%292 = load i32, i32* %21
%293 = zext i32 %292 to i64
%294 = getelementptr inbounds i8, i8* %291, i64 %293
store i8 %290, i8* %294
%295 = load i32, i32* %21
%296 = add i32 %295, 1
store i32 %296, i32* %21
br label %297
297: ; preds = %288, %282
br label %278
298: ; preds = %278
%299 = load i8*, i8** %23
%300 = call i32* @strstr(i8* %299, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%301 = icmp ne i32* %300, null
br i1 %301, label %302, label %400
302: ; preds = %298
%303 = load i32, i32* %6
%304 = load i8*, i8** %13
%305 = load i8*, i8** %13
%306 = call i32 @strlen(i8* %305)
%307 = call i32 @write(i32 %303, i8* %304, i32 %306)
store i32 %307, i32* %20
%308 = load i32, i32* %20
%309 = icmp slt i32 %308, 0
br i1 %309, label %310, label %314
310: ; preds = %302
%311 = load i32, i32* @stderr
%312 = call i32 (i32, i8*, ...) @fprintf(i32 %311, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%313 = call i32 @exit(i32 1)
unreachable
314: ; preds = %302
%315 = load i32, i32* %6
%316 = call i32 @write(i32 %315, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 2)
store i32 %316, i32* %20
%317 = load i32, i32* %20
%318 = icmp slt i32 %317, 0
br i1 %318, label %319, label %323
319: ; preds = %314
%320 = load i32, i32* @stderr
%321 = call i32 (i32, i8*, ...) @fprintf(i32 %320, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%322 = call i32 @exit(i32 1)
unreachable
323: ; preds = %314
%324 = load i32, i32* %6
%325 = load i8*, i8** %15
%326 = load i8*, i8** %15
%327 = call i32 @strlen(i8* %326)
%328 = call i32 @write(i32 %324, i8* %325, i32 %327)
store i32 %328, i32* %20
%329 = load i32, i32* %20
%330 = icmp slt i32 %329, 0
br i1 %330, label %331, label %335
331: ; preds = %323
%332 = load i32, i32* @stderr
%333 = call i32 (i32, i8*, ...) @fprintf(i32 %332, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%334 = call i32 @exit(i32 1)
unreachable
335: ; preds = %323
%336 = load i32, i32* %6
%337 = call i32 @write(i32 %336, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 2)
store i32 %337, i32* %20
%338 = load i32, i32* %20
%339 = icmp slt i32 %338, 0
br i1 %339, label %340, label %344
340: ; preds = %335
%341 = load i32, i32* @stderr
%342 = call i32 (i32, i8*, ...) @fprintf(i32 %341, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%343 = call i32 @exit(i32 1)
unreachable
344: ; preds = %335
store i32 0, i32* %21
%345 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 0
%346 = call i32 @memset(i8* %345, i8 signext 0, i32 10)
%347 = load i8*, i8** %23
%348 = call i32 @memset(i8* %347, i8 signext 0, i32 1000000)
br label %349
349: ; preds = %368, %344
%350 = load i8*, i8** %23
%351 = call i32* @strstr(i8* %350, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%352 = icmp eq i32* %351, null
br i1 %352, label %353, label %369
353: ; preds = %349
%354 = load i32, i32* %6
%355 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 0
%356 = call i32 @read(i32 %354, i8* %355, i32 1)
store i32 %356, i32* %19
%357 = load i32, i32* %19
%358 = icmp ne i32 %357, -1
br i1 %358, label %359, label %368
359: ; preds = %353
%360 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 0
%361 = load i8, i8* %360
%362 = load i8*, i8** %23
%363 = load i32, i32* %21
%364 = zext i32 %363 to i64
%365 = getelementptr inbounds i8, i8* %362, i64 %364
store i8 %361, i8* %365
%366 = load i32, i32* %21
%367 = add i32 %366, 1
store i32 %367, i32* %21
br label %368
368: ; preds = %359, %353
br label %349
369: ; preds = %349
%370 = load i8*, i8** %23
%371 = call i32 @strlen(i8* %370)
store i32 %371, i32* %24
%372 = load i8*, i8** %23
%373 = load i32, i32* %24
%374 = sub nsw i32 %373, 1
%375 = sext i32 %374 to i64
%376 = getelementptr inbounds i8, i8* %372, i64 %375
store i8 0, i8* %376
%377 = load i8*, i8** %23
%378 = load i32, i32* %24
%379 = sub nsw i32 %378, 2
%380 = sext i32 %379 to i64
%381 = getelementptr inbounds i8, i8* %377, i64 %380
store i8 0, i8* %381
store i32 0, i32* %25
br label %382
382: ; preds = %395, %369
%383 = load i32, i32* %25
%384 = load i8*, i8** %23
%385 = call i32 @strlen(i8* %384)
%386 = icmp slt i32 %383, %385
br i1 %386, label %387, label %398
387: ; preds = %382
%388 = load i8*, i8** %23
%389 = load i32, i32* %25
%390 = sext i32 %389 to i64
%391 = getelementptr inbounds i8, i8* %388, i64 %390
%392 = load i8, i8* %391
%393 = sext i8 %392 to i32
%394 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i32 %393)
br label %395
395: ; preds = %387
%396 = load i32, i32* %25
%397 = add nsw i32 %396, 1
store i32 %397, i32* %25
br label %382
398: ; preds = %382
%399 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i64 0, i64 0))
br label %412
400: ; preds = %298
%401 = load i8*, i8** %23
%402 = call i32* @strstr(i8* %401, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.20, i64 0, i64 0))
%403 = icmp ne i32* %402, null
br i1 %403, label %404, label %408
404: ; preds = %400
%405 = load i32, i32* @stderr
%406 = call i32 (i32, i8*, ...) @fprintf(i32 %405, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.21, i64 0, i64 0))
%407 = call i32 @exit(i32 1)
unreachable
408: ; preds = %400
%409 = load i32, i32* @stderr
%410 = call i32 (i32, i8*, ...) @fprintf(i32 %409, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.22, i64 0, i64 0))
%411 = call i32 @exit(i32 1)
unreachable
412: ; preds = %398
%413 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.hostent = type { i32, i32* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [43 x i8] c"Not enough arguments provided. Exiting...\0A\00"
@.str.1 = [44 x i8] c"Correct usage: %s input_file key_file port\0A\00"
@.str.2 = [60 x i8] c"Extra arguments entered. Ignoring all but the first three.\0A\00"
@.str.3 = [63 x i8] c"Port out of range! Please choose a different port! Exiting...\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [57 x i8] c"Input file does not exist or cannot be read! Exiting...\0A\00"
@.str.6 = [55 x i8] c"Key file does not exist or cannot be read! Exiting...\0A\00"
@.str.7 = [67 x i8] c"Key file too small. Please try again with larger file. Exiting...\0A\00"
@.str.8 = [42 x i8] c"Bad characters in input text. Exiting...\0A\00"
@.str.9 = [40 x i8] c"Bad characters in key text. Exiting...\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.10 = [43 x i8] c"Could not create comms socket! Exiting...\0A\00"
@.str.11 = [10 x i8] c"localhost\00"
@.str.12 = [43 x i8] c"localhost is not a valid host! Exiting...\0A\00"
@.str.13 = [52 x i8] c"Connection failed! Is the port correct? Exiting...\0A\00"
@.str.14 = [4 x i8] c"$@@\00"
@.str.15 = [34 x i8] c"Failed to write data. Exiting...\0A\00"
@.str.16 = [3 x i8] c"@@\00"
@.str.17 = [4 x i8] c"&@@\00"
@.str.20 = [4 x i8] c"%@@\00"
@.str.21 = [50 x i8] c"OTP_DEC may NOT connect to OTP_ENC_D. Exiting...\0A\00"
@.str.22 = [26 x i8] c"Got bad data. Exiting...\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [10 x i8]
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = icmp slt i32 %0, 4
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = icmp eq i32 %0, 4
br i1 %15, label %19, label %16
16: ; preds = %14
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %14, %16
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = tail call i64 @atoi(i8* %21)
%23 = icmp ugt i64 %22, 65535
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %19
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = tail call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i32* %31, null
br i1 %35, label %36, label %40
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0))
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %28
%41 = icmp eq i32* %34, null
br i1 %41, label %42, label %46
42: ; preds = %40
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0))
%45 = tail call i32 @exit(i32 1)
unreachable
46: ; preds = %40
%47 = tail call dereferenceable_or_null(1000000) i8* @malloc(i32 1000000)
%48 = tail call i32 @memset(i8* %47, i8 signext 0, i32 1000000)
%49 = tail call i32 @fgets(i8* %47, i32 1000000, i32* %31)
%50 = tail call i32 @strlen(i8* %47)
%51 = add nsw i32 %50, 1
%52 = tail call i8* @malloc(i32 %51)
%53 = tail call i32 @strlen(i8* %47)
%54 = add nsw i32 %53, 1
%55 = tail call i32 @memset(i8* %52, i8 signext 0, i32 %54)
%56 = tail call i32 @strcpy(i8* %52, i8* %47)
%57 = tail call i32 @strlen(i8* %52)
%58 = add nsw i32 %57, -1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %52, i64 %59
%61 = load i8, i8* %60
%62 = icmp eq i8 %61, 10
br i1 %62, label %63, label %64
63: ; preds = %46
store i8 0, i8* %60
br label %64
64: ; preds = %63, %46
%65 = tail call i32 @memset(i8* %47, i8 signext 0, i32 1000000)
%66 = tail call i32 @fgets(i8* %47, i32 1000000, i32* %34)
%67 = tail call i32 @strlen(i8* %47)
%68 = add nsw i32 %67, 1
%69 = tail call i8* @malloc(i32 %68)
%70 = tail call i32 @strlen(i8* %47)
%71 = add nsw i32 %70, 1
%72 = tail call i32 @memset(i8* %69, i8 signext 0, i32 %71)
%73 = tail call i32 @strcpy(i8* %69, i8* %47)
%74 = tail call i32 @strlen(i8* %69)
%75 = add nsw i32 %74, -1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %69, i64 %76
%78 = load i8, i8* %77
%79 = icmp eq i8 %78, 10
br i1 %79, label %80, label %81
80: ; preds = %64
store i8 0, i8* %77
br label %81
81: ; preds = %80, %64
%82 = tail call i32 @free(i8* %47)
%83 = tail call i32 @strlen(i8* %52)
%84 = tail call i32 @strlen(i8* %69)
%85 = icmp sgt i32 %83, %84
br i1 %85, label %89, label %86
86: ; preds = %81
%87 = tail call i32 @strlen(i8* %52)
%88 = icmp eq i32 %87, 0
br i1 %88, label %97, label %100
89: ; preds = %81
%90 = load i32, i32* @stderr
%91 = tail call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.7, i64 0, i64 0))
%92 = tail call i32 @exit(i32 1)
unreachable
93: ; preds = %100
%94 = tail call i32 @strlen(i8* %52)
%95 = sext i32 %94 to i64
%96 = icmp ult i64 %106, %95
br i1 %96, label %100, label %97
97: ; preds = %93, %86
%98 = tail call i32 @strlen(i8* %69)
%99 = icmp eq i32 %98, 0
br i1 %99, label %115, label %120
100: ; preds = %86, %93
%101 = phi i64 [ %106, %93 ], [ 0, %86 ]
%102 = getelementptr inbounds i8, i8* %52, i64 %101
%103 = load i8, i8* %102
%104 = tail call i32 @get_mapped_num_from_char(i8 signext %103)
%105 = icmp eq i32 %104, -1
%106 = add nuw i64 %101, 1
br i1 %105, label %107, label %93
107: ; preds = %100
%108 = load i32, i32* @stderr
%109 = tail call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
%110 = tail call i32 @exit(i32 1)
unreachable
111: ; preds = %120
%112 = tail call i32 @strlen(i8* %69)
%113 = sext i32 %112 to i64
%114 = icmp ult i64 %126, %113
br i1 %114, label %120, label %115
115: ; preds = %111, %97
%116 = load i32, i32* @AF_INET
%117 = load i32, i32* @SOCK_STREAM
%118 = tail call i32 @socket(i32 %116, i32 %117, i32 0)
%119 = icmp slt i32 %118, 0
br i1 %119, label %131, label %135
120: ; preds = %97, %111
%121 = phi i64 [ %126, %111 ], [ 0, %97 ]
%122 = getelementptr inbounds i8, i8* %69, i64 %121
%123 = load i8, i8* %122
%124 = tail call i32 @get_mapped_num_from_char(i8 signext %123)
%125 = icmp eq i32 %124, -1
%126 = add nuw i64 %121, 1
br i1 %125, label %127, label %111
127: ; preds = %120
%128 = load i32, i32* @stderr
%129 = tail call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0))
%130 = tail call i32 @exit(i32 1)
unreachable
131: ; preds = %115
%132 = load i32, i32* @stderr
%133 = tail call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0))
%134 = tail call i32 @exit(i32 1)
unreachable
135: ; preds = %115
%136 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%137 = icmp eq %struct.hostent* %136, null
br i1 %137, label %138, label %142
138: ; preds = %135
%139 = load i32, i32* @stderr
%140 = tail call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0))
%141 = tail call i32 @exit(i32 1)
unreachable
142: ; preds = %135
%143 = call i32 @memset(i8* %5, i8 signext 0, i32 12)
%144 = call i32 @htons(i64 %22)
%145 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %144, i32* %145
%146 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%147 = getelementptr inbounds %struct.hostent, %struct.hostent* %136, i64 0, i32 1
%148 = load i32*, i32** %147
%149 = load i32, i32* %148
%150 = getelementptr inbounds %struct.hostent, %struct.hostent* %136, i64 0, i32 0
%151 = load i32, i32* %150
%152 = call i32 @memcpy(i32* %146, i32 %149, i32 %151)
%153 = load i32, i32* @AF_INET
%154 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %153, i32* %154
%155 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%156 = call i32 @connect(i32 %118, %struct.sockaddr* %155, i32 12)
%157 = icmp slt i32 %156, 0
br i1 %157, label %158, label %162
158: ; preds = %142
%159 = load i32, i32* @stderr
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.13, i64 0, i64 0))
%161 = call i32 @exit(i32 2)
unreachable
162: ; preds = %142
%163 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%164 = call dereferenceable_or_null(1000000) i8* @malloc(i32 1000000)
%165 = call i32 @memset(i8* %163, i8 signext 0, i32 1)
%166 = call i32 @memset(i8* %164, i8 signext 0, i32 1000000)
%167 = call i32 @write(i32 %118, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 3)
%168 = icmp slt i32 %167, 0
br i1 %168, label %172, label %169
169: ; preds = %162
%170 = call i32* @strstr(i8* dereferenceable(1) %164, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%171 = icmp eq i32* %170, null
br i1 %171, label %176, label %189
172: ; preds = %162
%173 = load i32, i32* @stderr
%174 = call i32 (i32, i8*, ...) @fprintf(i32 %173, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%175 = call i32 @exit(i32 1)
unreachable
176: ; preds = %169, %185
%177 = phi i32 [ %186, %185 ], [ 0, %169 ]
%178 = call i32 @read(i32 %118, i8* %163, i32 1)
%179 = icmp eq i32 %178, -1
br i1 %179, label %185, label %180
180: ; preds = %176
%181 = load i8, i8* %163
%182 = zext i32 %177 to i64
%183 = getelementptr inbounds i8, i8* %164, i64 %182
store i8 %181, i8* %183
%184 = add i32 %177, 1
br label %185
185: ; preds = %180, %176
%186 = phi i32 [ %184, %180 ], [ %177, %176 ]
%187 = call i32* @strstr(i8* dereferenceable(1) %164, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%188 = icmp eq i32* %187, null
br i1 %188, label %176, label %189
189: ; preds = %185, %169
%190 = call i32* @strstr(i8* dereferenceable(1) %164, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%191 = icmp eq i32* %190, null
br i1 %191, label %263, label %192
192: ; preds = %189
%193 = call i32 @strlen(i8* %52)
%194 = call i32 @write(i32 %118, i8* %52, i32 %193)
%195 = icmp slt i32 %194, 0
br i1 %195, label %196, label %200
196: ; preds = %192
%197 = load i32, i32* @stderr
%198 = call i32 (i32, i8*, ...) @fprintf(i32 %197, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%199 = call i32 @exit(i32 1)
unreachable
200: ; preds = %192
%201 = call i32 @write(i32 %118, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 2)
%202 = icmp slt i32 %201, 0
br i1 %202, label %203, label %207
203: ; preds = %200
%204 = load i32, i32* @stderr
%205 = call i32 (i32, i8*, ...) @fprintf(i32 %204, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%206 = call i32 @exit(i32 1)
unreachable
207: ; preds = %200
%208 = call i32 @strlen(i8* %69)
%209 = call i32 @write(i32 %118, i8* %69, i32 %208)
%210 = icmp slt i32 %209, 0
br i1 %210, label %211, label %215
211: ; preds = %207
%212 = load i32, i32* @stderr
%213 = call i32 (i32, i8*, ...) @fprintf(i32 %212, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%214 = call i32 @exit(i32 1)
unreachable
215: ; preds = %207
%216 = call i32 @write(i32 %118, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 2)
%217 = icmp slt i32 %216, 0
br i1 %217, label %218, label %222
218: ; preds = %215
%219 = load i32, i32* @stderr
%220 = call i32 (i32, i8*, ...) @fprintf(i32 %219, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%221 = call i32 @exit(i32 1)
unreachable
222: ; preds = %215
%223 = call i32 @memset(i8* %163, i8 signext 0, i32 10)
%224 = call i32 @memset(i8* %164, i8 signext 0, i32 1000000)
%225 = call i32* @strstr(i8* dereferenceable(1) %164, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%226 = icmp eq i32* %225, null
br i1 %226, label %227, label %240
227: ; preds = %222, %236
%228 = phi i32 [ %237, %236 ], [ 0, %222 ]
%229 = call i32 @read(i32 %118, i8* %163, i32 1)
%230 = icmp eq i32 %229, -1
br i1 %230, label %236, label %231
231: ; preds = %227
%232 = load i8, i8* %163
%233 = zext i32 %228 to i64
%234 = getelementptr inbounds i8, i8* %164, i64 %233
store i8 %232, i8* %234
%235 = add i32 %228, 1
br label %236
236: ; preds = %231, %227
%237 = phi i32 [ %235, %231 ], [ %228, %227 ]
%238 = call i32* @strstr(i8* dereferenceable(1) %164, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%239 = icmp eq i32* %238, null
br i1 %239, label %227, label %240
240: ; preds = %236, %222
%241 = call i32 @strlen(i8* %164)
%242 = add nsw i32 %241, -1
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds i8, i8* %164, i64 %243
store i8 0, i8* %244
%245 = add nsw i32 %241, -2
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds i8, i8* %164, i64 %246
store i8 0, i8* %247
%248 = call i32 @strlen(i8* %164)
%249 = icmp sgt i32 %248, 0
br i1 %249, label %253, label %250
250: ; preds = %253, %240
%251 = call i32 @putchar(i32 10)
%252 = call i32 @exit(i32 0)
unreachable
253: ; preds = %240, %253
%254 = phi i64 [ %259, %253 ], [ 0, %240 ]
%255 = getelementptr inbounds i8, i8* %164, i64 %254
%256 = load i8, i8* %255
%257 = sext i8 %256 to i32
%258 = call i32 @putchar(i32 %257)
%259 = add nuw nsw i64 %254, 1
%260 = call i32 @strlen(i8* %164)
%261 = sext i32 %260 to i64
%262 = icmp slt i64 %259, %261
br i1 %262, label %253, label %250
263: ; preds = %189
%264 = call i32* @strstr(i8* dereferenceable(1) %164, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.20, i64 0, i64 0))
%265 = icmp eq i32* %264, null
%266 = load i32, i32* @stderr
br i1 %265, label %270, label %267
267: ; preds = %263
%268 = call i32 (i32, i8*, ...) @fprintf(i32 %266, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.21, i64 0, i64 0))
%269 = call i32 @exit(i32 1)
unreachable
270: ; preds = %263
%271 = call i32 (i32, i8*, ...) @fprintf(i32 %266, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.22, i64 0, i64 0))
%272 = call i32 @exit(i32 1)
unreachable
}