#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_family;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ server_address;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ client_address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ WNOHANG;
int accept(int, struct sockaddr *, int *);
unsigned long atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
char decode_character(char, char);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ htons(unsigned long);
int /*<<< orphan*/ listen(int, int);
char *malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
unsigned long strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char **argv) {
  int listen_sfd;
  int comms_sfd;
  unsigned long int listen_port_number;
  socklen_t client_length;
  struct sockaddr_in server_address;
  struct sockaddr_in client_address;
  if (argc < 2) {
    fprintf(stderr, "No port provided! Exiting...\n");
    exit(1);
  }
  listen_sfd = socket(AF_INET, SOCK_STREAM, 0);
  if (listen_sfd < 0) {
    fprintf(stderr, "Could not create listening socket! Exiting...\n");
    exit(1);
  }
  listen_port_number = atoi(argv[1]);
  if ((listen_port_number > 65535) || (listen_port_number < 0)) {
    fprintf(stderr, "Port out of range! Please choose a different port! "
                    "Exiting...\n");
    exit(1);
  }
  memset((char *)&server_address, '\0', sizeof(server_address));
  server_address.sin_port = htons(listen_port_number);
  server_address.sin_addr.s_addr = INADDR_ANY;
  server_address.sin_family = AF_INET;
  int bind_result = bind(listen_sfd, (struct sockaddr *)&server_address,
                         sizeof(server_address));
  if (bind_result < 0) {
    fprintf(stderr, "Failed to bind listening port! "
                    "Please choose a different port! Exiting...\n");
    exit(1);
  }
  while (1) {
    static int process_status;
    waitpid(-1, &process_status, WNOHANG);
    listen(listen_sfd, 5);
    socklen_t client_length = sizeof(client_address);
    comms_sfd =
        accept(listen_sfd, (struct sockaddr *)&client_address, &client_length);
    if (comms_sfd < 0) {
      fprintf(stderr, "Client accept failed. Trying next "
                      "connection...\n");
    } else {
      pid_t spawned_pid;
      spawned_pid = fork();
      if (spawned_pid == 0) {
        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', 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++;
          }
        }
        if (strstr(concat_buffer, "$"
                                  "@@") != NULL) {
          write_return = write(comms_sfd,
                               "&"
                               "@@",
                               3);
          if (write_return < 0) {
            fprintf(stderr, "Failed to alert sender. 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';
          char *input_text = malloc(sizeof(char) * (strlen(concat_buffer) + 1));
          memset(input_text, '\0', sizeof(char) * (strlen(concat_buffer) + 1));
          strcpy(input_text, concat_buffer);
          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++;
            }
          }
          input_string_length = strlen(concat_buffer);
          concat_buffer[input_string_length - 1] = '\0';
          concat_buffer[input_string_length - 2] = '\0';
          char *key_text = malloc(sizeof(char) * (strlen(concat_buffer) + 1));
          memset(key_text, '\0', sizeof(char) * (strlen(concat_buffer) + 1));
          strcpy(key_text, concat_buffer);
          free(concat_buffer);
          for (unsigned long int i = 0; i < strlen(input_text); i++) {
            char new_char = decode_character(input_text[i], key_text[i]);
            write_return = write(comms_sfd, &new_char, 1);
          }
          write_return = write(comms_sfd, "@@", 2);
          if (write_return < 0) {
            fprintf(stderr, "Failed to alert sender. Exiting...\n");
            exit(1);
          }
        } else if (strstr(concat_buffer, "#"
                                         "@@") != NULL) {
          write_return = write(comms_sfd,
                               "%"
                               "@@",
                               3);
          if (write_return < 0) {
            fprintf(stderr, "Failed to alert sender. Exiting...\n");
          }
          exit(1);
        } else {
          fprintf(stderr, "Got bad data. Alerting sender and "
                          "exiting...\n");
          write_return = write(comms_sfd,
                               "%"
                               "@@",
                               3);
          if (write_return < 0) {
            fprintf(stderr, "Failed to alert sender. Exiting...\n");
          }
          exit(1);
        }
        exit(0);
      }
    }
  }
  close(listen_sfd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1272 <main+0x42>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xd9d(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12b7 <main+0x87>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <atoi@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xffff,-0x20(%rbp)
ja     12e1 <main+0xb1>
cmpq   $0x0,-0x20(%rbp)
jae    1300 <main+0xd0>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
lea    0xd5c(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    -0x20(%rbp),%rdi
call   1070 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    0x2cb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1371 <main+0x141>
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
lea    0xd2a(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1376 <main+0x146>
mov    0x2c63(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
lea    0x2d41(%rip),%rsi
call   10e0 <waitpid@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
movl   $0xc,-0x48(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    13db <main+0x1ab>
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    1870 <main+0x640>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    186b <main+0x63b>
movl   $0x0,-0x5c(%rbp)
mov    $0xf4240,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x70(%rbp)
lea    -0x66(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <memset@plt>
mov    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1080 <memset@plt>
mov    -0x70(%rbp),%rdi
lea    0xd04(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
jne    1479 <main+0x249>
mov    -0x18(%rbp),%edi
lea    -0x66(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
je     1474 <main+0x244>
mov    -0x66(%rbp),%dl
mov    -0x70(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1426 <main+0x1f6>
mov    -0x70(%rbp),%rdi
lea    0xc84(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
je     17b5 <main+0x585>
mov    -0x18(%rbp),%edi
lea    0xc6f(%rip),%rsi
mov    $0x3,%edx
call   1050 <write@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    14d3 <main+0x2a3>
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
lea    0xc4c(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movl   $0x0,-0x5c(%rbp)
lea    -0x66(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <memset@plt>
mov    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1080 <memset@plt>
mov    -0x70(%rbp),%rdi
lea    0xc30(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
jne    154d <main+0x31d>
mov    -0x18(%rbp),%edi
lea    -0x66(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
je     1548 <main+0x318>
mov    -0x66(%rbp),%dl
mov    -0x70(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    14fa <main+0x2ca>
mov    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x74(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xa0(%rbp),%rdi
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x80(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x5c(%rbp)
lea    -0x66(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <memset@plt>
mov    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1080 <memset@plt>
mov    -0x70(%rbp),%rdi
lea    0xb33(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
jne    164a <main+0x41a>
mov    -0x18(%rbp),%edi
lea    -0x66(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
je     1645 <main+0x415>
mov    -0x66(%rbp),%dl
mov    -0x70(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    15f7 <main+0x3c7>
mov    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x74(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xa8(%rbp),%rdi
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x88(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x80(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
cmp    %rcx,%rax
jae    1770 <main+0x540>
mov    -0x80(%rbp),%rax
mov    -0x90(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x88(%rbp),%rax
mov    -0x90(%rbp),%rcx
movsbl %dl,%edi
movsbl (%rax,%rcx,1),%esi
call   1140 <decode_character@plt>
mov    %al,-0x91(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x91(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    %eax,-0x58(%rbp)
mov    -0x90(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x90(%rbp)
jmp    16ea <main+0x4ba>
mov    -0x18(%rbp),%edi
lea    0x9bb(%rip),%rsi
mov    $0x2,%edx
call   1050 <write@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    17b0 <main+0x580>
mov    0x2830(%rip),%rax
mov    (%rax),%edi
lea    0x96f(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1864 <main+0x634>
mov    -0x70(%rbp),%rdi
lea    0x974(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
je     180f <main+0x5df>
mov    -0x18(%rbp),%edi
lea    0x95f(%rip),%rsi
mov    $0x3,%edx
call   1050 <write@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1805 <main+0x5d5>
mov    0x27d1(%rip),%rax
mov    (%rax),%edi
lea    0x910(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x27b2(%rip),%rax
mov    (%rax),%edi
lea    0x91d(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%edi
lea    0x90a(%rip),%rsi
mov    $0x3,%edx
call   1050 <write@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    185a <main+0x62a>
mov    0x277c(%rip),%rax
mov    (%rax),%edi
lea    0x8bb(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
xor    %edi,%edi
call   1110 <exit@plt>
jmp    1870 <main+0x640>
jmp    1376 <main+0x146>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x1,%edi
jg     1258 <main+0x28>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
jmp    171c <main+0x4ec>
mov    %rsi,%rbx
mov    0x2d86(%rip),%r15
mov    (%r15),%edi
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
test   %eax,%eax
jns    128e <main+0x5e>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
lea    0xd95(%rip),%rsi
jmp    171c <main+0x4ec>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
call   1100 <atoi@plt>
cmp    $0x10000,%rax
jb     12b6 <main+0x86>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
jmp    171c <main+0x4ec>
mov    %rax,%rbx
lea    0x18(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    %rbx,%rdi
call   1070 <htons@plt>
mov    %eax,0x20(%rsp)
mov    0x2cf8(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    (%r15),%eax
mov    %eax,0x18(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %eax,%eax
jns    1315 <main+0xe5>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
jmp    171c <main+0x4ec>
mov    0x2cc4(%rip),%r13
lea    0x2da9(%rip),%r14
lea    0x28(%rsp),%r15
lea    0x14(%rsp),%rbx
jmp    1345 <main+0x115>
nop
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x0(%r13),%edx
mov    $0xffffffff,%edi
mov    %r14,%rsi
call   10e0 <waitpid@plt>
mov    %ebp,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
movl   $0xc,0x14(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   10f0 <accept@plt>
test   %eax,%eax
js     1330 <main+0x100>
mov    %eax,%r12d
xor    %eax,%eax
call   1120 <fork@plt>
test   %rax,%rax
jne    1345 <main+0x115>
mov    $0xf4240,%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
lea    0xa(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1080 <memset@plt>
lea    0xd75(%rip),%rsi
mov    %r14,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
jne    1415 <main+0x1e5>
lea    0xa(%rsp),%r15
lea    0xd5c(%rip),%rbp
jmp    13f0 <main+0x1c0>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1130 <strstr@plt>
test   %rax,%rax
jne    1415 <main+0x1e5>
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0xffffffff,%eax
je     13e0 <main+0x1b0>
movzbl 0xa(%rsp),%eax
mov    %ebx,%ecx
mov    %al,(%r14,%rcx,1)
add    $0x1,%ebx
jmp    13e0 <main+0x1b0>
lea    0xcec(%rip),%rsi
mov    %r14,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
jne    1482 <main+0x252>
lea    0xd04(%rip),%rsi
mov    %r14,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
mov    0x2b86(%rip),%rbx
jne    1452 <main+0x222>
mov    (%rbx),%edi
lea    0xcef(%rip),%rsi
call   10a0 <fprintf@plt>
lea    0xcdf(%rip),%rsi
mov    %r12d,%edi
mov    $0x3,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    1478 <main+0x248>
mov    (%rbx),%edi
lea    0xc9d(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xc83(%rip),%rsi
mov    %r12d,%edi
mov    $0x3,%edx
call   1050 <write@plt>
test   %eax,%eax
js     170c <main+0x4dc>
lea    0xa(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1080 <memset@plt>
lea    0xc6e(%rip),%rsi
mov    %r14,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
jne    1525 <main+0x2f5>
lea    0xa(%rsp),%r15
lea    0xc55(%rip),%rbp
jmp    1500 <main+0x2d0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1130 <strstr@plt>
test   %rax,%rax
jne    1525 <main+0x2f5>
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0xffffffff,%eax
je     14f0 <main+0x2c0>
movzbl 0xa(%rsp),%eax
mov    %ebx,%ecx
mov    %al,(%r14,%rcx,1)
add    $0x1,%ebx
jmp    14f0 <main+0x2c0>
movabs $0xffffffff00000000,%rbp
ff ff ff
movabs $0xfffffffe00000000,%rbx
ff ff ff
mov    %r14,%rdi
call   1060 <strlen@plt>
shl    $0x20,%rax
lea    (%rax,%rbp,1),%rcx
sar    $0x20,%rcx
movb   $0x0,(%r14,%rcx,1)
add    %rbx,%rax
sar    $0x20,%rax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%ebx
mov    %ebx,%edi
call   10b0 <malloc@plt>
mov    %rax,%r15
xor    %r13d,%r13d
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1080 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xa(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   1080 <memset@plt>
lea    0xb81(%rip),%rsi
mov    %r14,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
jne    1607 <main+0x3d7>
lea    0xa(%rsp),%rbx
lea    0xb68(%rip),%rbp
jmp    15e0 <main+0x3b0>
nop
mov    %r14,%rdi
mov    %rbp,%rsi
call   1130 <strstr@plt>
test   %rax,%rax
jne    1607 <main+0x3d7>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0xffffffff,%eax
je     15d0 <main+0x3a0>
movzbl 0xa(%rsp),%eax
mov    %r13d,%ecx
mov    %al,(%r14,%rcx,1)
add    $0x1,%r13d
jmp    15d0 <main+0x3a0>
mov    %r14,%rdi
call   1060 <strlen@plt>
shl    $0x20,%rax
movabs $0xffffffff00000000,%rcx
ff ff ff
add    %rax,%rcx
sar    $0x20,%rcx
movb   $0x0,(%r14,%rcx,1)
movabs $0xfffffffe00000000,%rcx
ff ff ff
add    %rcx,%rax
sar    $0x20,%rax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%ebx
mov    %ebx,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1080 <memset@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    (%r15),%al
test   %al,%al
je     16f4 <main+0x4c4>
movsbl 0x0(%rbp),%esi
movsbl %al,%edi
call   1140 <decode_character@plt>
mov    %al,0x9(%rsp)
lea    0x9(%rsp),%rsi
mov    %r12d,%edi
mov    $0x1,%edx
call   1050 <write@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
cmp    $0x2,%rax
jb     16f4 <main+0x4c4>
mov    $0x1,%ebx
lea    0x9(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r15,%rbx,1),%edi
movsbl 0x0(%rbp,%rbx,1),%esi
call   1140 <decode_character@plt>
mov    %al,0x9(%rsp)
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1060 <strlen@plt>
cmp    %rax,%rbx
jb     16c0 <main+0x490>
lea    0xa3a(%rip),%rsi
mov    %r12d,%edi
mov    $0x2,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    172b <main+0x4fb>
mov    0x28b5(%rip),%rax
mov    (%rax),%edi
lea    0x9f4(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
xor    %edi,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"No port provided! Exiting...\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [47 x i8] c"Could not create listening socket! Exiting...\0A\00"
@.str.2 = [63 x i8] c"Port out of range! Please choose a different port! Exiting...\0A\00"
@INADDR_ANY = global i32 0
@.str.3 = [75 x i8] c"Failed to bind listening port! Please choose a different port! Exiting...\0A\00"
@main.process_status = internal global i32 0
@WNOHANG = global i32 0
@.str.4 = [49 x i8] c"Client accept failed. Trying next connection...\0A\00"
@.str.5 = [3 x i8] c"@@\00"
@.str.6 = [4 x i8] c"$@@\00"
@.str.7 = [4 x i8] c"&@@\00"
@.str.8 = [36 x i8] c"Failed to alert sender. Exiting...\0A\00"
@.str.9 = [4 x i8] c"#@@\00"
@.str.10 = [4 x i8] c"%@@\00"
@.str.11 = [46 x i8] c"Got bad data. Alerting sender and exiting...\0A\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 i64
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.sockaddr_in
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [10 x i8]
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 2
br i1 %26, label %27, label %31
27: ; preds = %2
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %2
%32 = load i32, i32* @AF_INET
%33 = load i32, i32* @SOCK_STREAM
%34 = call i32 @socket(i32 %32, i32 %33, i32 0)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %31
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i64 @atoi(i8* %44)
store i64 %45, i64* %8
%46 = load i64, i64* %8
%47 = icmp ugt i64 %46, 65535
br i1 %47, label %51, label %48
48: ; preds = %41
%49 = load i64, i64* %8
%50 = icmp ult i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %48, %41
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %48
%56 = bitcast %struct.sockaddr_in* %10 to i8*
%57 = call i32 @memset(i8* %56, i8 signext 0, i32 12)
%58 = load i64, i64* %8
%59 = call i32 @htons(i64 %58)
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %59, i32* %60
%61 = load i32, i32* @INADDR_ANY
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%63 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %62, i32 0, i32 0
store i32 %61, i32* %63
%64 = load i32, i32* @AF_INET
%65 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
store i32 %64, i32* %65
%66 = load i32, i32* %6
%67 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%68 = call i32 @bind(i32 %66, %struct.sockaddr* %67, i32 12)
store i32 %68, i32* %12
%69 = load i32, i32* %12
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %55
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %55
br label %76
76: ; preds = %75, %302
%77 = load i32, i32* @WNOHANG
%78 = call i32 @waitpid(i32 -1, i32* @main.process_status, i32 %77)
%79 = load i32, i32* %6
%80 = call i32 @listen(i32 %79, i32 5)
store i32 12, i32* %13
%81 = load i32, i32* %6
%82 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%83 = call i32 @accept(i32 %81, %struct.sockaddr* %82, i32* %13)
store i32 %83, i32* %7
%84 = load i32, i32* %7
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %76
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
br label %302
89: ; preds = %76
%90 = call i64 (...) @fork()
store i64 %90, i64* %14
%91 = load i64, i64* %14
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %301
93: ; preds = %89
store i32 0, i32* %17
%94 = call i8* @malloc(i32 1000000)
store i8* %94, i8** %19
%95 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%96 = call i32 @memset(i8* %95, i8 signext 0, i32 10)
%97 = load i8*, i8** %19
%98 = call i32 @memset(i8* %97, i8 signext 0, i32 1000000)
br label %99
99: ; preds = %118, %93
%100 = load i8*, i8** %19
%101 = call i32* @strstr(i8* %100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%102 = icmp eq i32* %101, null
br i1 %102, label %103, label %119
103: ; preds = %99
%104 = load i32, i32* %7
%105 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%106 = call i32 @read(i32 %104, i8* %105, i32 1)
store i32 %106, i32* %15
%107 = load i32, i32* %15
%108 = icmp ne i32 %107, -1
br i1 %108, label %109, label %118
109: ; preds = %103
%110 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%111 = load i8, i8* %110
%112 = load i8*, i8** %19
%113 = load i32, i32* %17
%114 = zext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %112, i64 %114
store i8 %111, i8* %115
%116 = load i32, i32* %17
%117 = add i32 %116, 1
store i32 %117, i32* %17
br label %118
118: ; preds = %109, %103
br label %99
119: ; preds = %99
%120 = load i8*, i8** %19
%121 = call i32* @strstr(i8* %120, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%122 = icmp ne i32* %121, null
br i1 %122, label %123, label %273
123: ; preds = %119
%124 = load i32, i32* %7
%125 = call i32 @write(i32 %124, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
store i32 %125, i32* %16
%126 = load i32, i32* %16
%127 = icmp slt i32 %126, 0
br i1 %127, label %128, label %132
128: ; preds = %123
%129 = load i32, i32* @stderr
%130 = call i32 @fprintf(i32 %129, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
%131 = call i32 @exit(i32 1)
unreachable
132: ; preds = %123
store i32 0, i32* %17
%133 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%134 = call i32 @memset(i8* %133, i8 signext 0, i32 10)
%135 = load i8*, i8** %19
%136 = call i32 @memset(i8* %135, i8 signext 0, i32 1000000)
br label %137
137: ; preds = %156, %132
%138 = load i8*, i8** %19
%139 = call i32* @strstr(i8* %138, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%140 = icmp eq i32* %139, null
br i1 %140, label %141, label %157
141: ; preds = %137
%142 = load i32, i32* %7
%143 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%144 = call i32 @read(i32 %142, i8* %143, i32 1)
store i32 %144, i32* %15
%145 = load i32, i32* %15
%146 = icmp ne i32 %145, -1
br i1 %146, label %147, label %156
147: ; preds = %141
%148 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%149 = load i8, i8* %148
%150 = load i8*, i8** %19
%151 = load i32, i32* %17
%152 = zext i32 %151 to i64
%153 = getelementptr inbounds i8, i8* %150, i64 %152
store i8 %149, i8* %153
%154 = load i32, i32* %17
%155 = add i32 %154, 1
store i32 %155, i32* %17
br label %156
156: ; preds = %147, %141
br label %137
157: ; preds = %137
%158 = load i8*, i8** %19
%159 = call i64 @strlen(i8* %158)
%160 = trunc i64 %159 to i32
store i32 %160, i32* %20
%161 = load i8*, i8** %19
%162 = load i32, i32* %20
%163 = sub nsw i32 %162, 1
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i8, i8* %161, i64 %164
store i8 0, i8* %165
%166 = load i8*, i8** %19
%167 = load i32, i32* %20
%168 = sub nsw i32 %167, 2
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i8, i8* %166, i64 %169
store i8 0, i8* %170
%171 = load i8*, i8** %19
%172 = call i64 @strlen(i8* %171)
%173 = add i64 %172, 1
%174 = mul i64 1, %173
%175 = trunc i64 %174 to i32
%176 = call i8* @malloc(i32 %175)
store i8* %176, i8** %21
%177 = load i8*, i8** %21
%178 = load i8*, i8** %19
%179 = call i64 @strlen(i8* %178)
%180 = add i64 %179, 1
%181 = mul i64 1, %180
%182 = trunc i64 %181 to i32
%183 = call i32 @memset(i8* %177, i8 signext 0, i32 %182)
%184 = load i8*, i8** %21
%185 = load i8*, i8** %19
%186 = call i32 @strcpy(i8* %184, i8* %185)
store i32 0, i32* %17
%187 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%188 = call i32 @memset(i8* %187, i8 signext 0, i32 10)
%189 = load i8*, i8** %19
%190 = call i32 @memset(i8* %189, i8 signext 0, i32 1000000)
br label %191
191: ; preds = %210, %157
%192 = load i8*, i8** %19
%193 = call i32* @strstr(i8* %192, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%194 = icmp eq i32* %193, null
br i1 %194, label %195, label %211
195: ; preds = %191
%196 = load i32, i32* %7
%197 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%198 = call i32 @read(i32 %196, i8* %197, i32 1)
store i32 %198, i32* %15
%199 = load i32, i32* %15
%200 = icmp ne i32 %199, -1
br i1 %200, label %201, label %210
201: ; preds = %195
%202 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%203 = load i8, i8* %202
%204 = load i8*, i8** %19
%205 = load i32, i32* %17
%206 = zext i32 %205 to i64
%207 = getelementptr inbounds i8, i8* %204, i64 %206
store i8 %203, i8* %207
%208 = load i32, i32* %17
%209 = add i32 %208, 1
store i32 %209, i32* %17
br label %210
210: ; preds = %201, %195
br label %191
211: ; preds = %191
%212 = load i8*, i8** %19
%213 = call i64 @strlen(i8* %212)
%214 = trunc i64 %213 to i32
store i32 %214, i32* %20
%215 = load i8*, i8** %19
%216 = load i32, i32* %20
%217 = sub nsw i32 %216, 1
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds i8, i8* %215, i64 %218
store i8 0, i8* %219
%220 = load i8*, i8** %19
%221 = load i32, i32* %20
%222 = sub nsw i32 %221, 2
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds i8, i8* %220, i64 %223
store i8 0, i8* %224
%225 = load i8*, i8** %19
%226 = call i64 @strlen(i8* %225)
%227 = add i64 %226, 1
%228 = mul i64 1, %227
%229 = trunc i64 %228 to i32
%230 = call i8* @malloc(i32 %229)
store i8* %230, i8** %22
%231 = load i8*, i8** %22
%232 = load i8*, i8** %19
%233 = call i64 @strlen(i8* %232)
%234 = add i64 %233, 1
%235 = mul i64 1, %234
%236 = trunc i64 %235 to i32
%237 = call i32 @memset(i8* %231, i8 signext 0, i32 %236)
%238 = load i8*, i8** %22
%239 = load i8*, i8** %19
%240 = call i32 @strcpy(i8* %238, i8* %239)
%241 = load i8*, i8** %19
%242 = call i32 @free(i8* %241)
store i64 0, i64* %23
br label %243
243: ; preds = %260, %211
%244 = load i64, i64* %23
%245 = load i8*, i8** %21
%246 = call i64 @strlen(i8* %245)
%247 = icmp ult i64 %244, %246
br i1 %247, label %248, label %263
248: ; preds = %243
%249 = load i8*, i8** %21
%250 = load i64, i64* %23
%251 = getelementptr inbounds i8, i8* %249, i64 %250
%252 = load i8, i8* %251
%253 = load i8*, i8** %22
%254 = load i64, i64* %23
%255 = getelementptr inbounds i8, i8* %253, i64 %254
%256 = load i8, i8* %255
%257 = call signext i8 @decode_character(i8 signext %252, i8 signext %256)
store i8 %257, i8* %24
%258 = load i32, i32* %7
%259 = call i32 @write(i32 %258, i8* %24, i32 1)
store i32 %259, i32* %16
br label %260
260: ; preds = %248
%261 = load i64, i64* %23
%262 = add i64 %261, 1
store i64 %262, i64* %23
br label %243
263: ; preds = %243
%264 = load i32, i32* %7
%265 = call i32 @write(i32 %264, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %265, i32* %16
%266 = load i32, i32* %16
%267 = icmp slt i32 %266, 0
br i1 %267, label %268, label %272
268: ; preds = %263
%269 = load i32, i32* @stderr
%270 = call i32 @fprintf(i32 %269, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
%271 = call i32 @exit(i32 1)
unreachable
272: ; preds = %263
br label %299
273: ; preds = %119
%274 = load i8*, i8** %19
%275 = call i32* @strstr(i8* %274, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%276 = icmp ne i32* %275, null
br i1 %276, label %277, label %287
277: ; preds = %273
%278 = load i32, i32* %7
%279 = call i32 @write(i32 %278, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
store i32 %279, i32* %16
%280 = load i32, i32* %16
%281 = icmp slt i32 %280, 0
br i1 %281, label %282, label %285
282: ; preds = %277
%283 = load i32, i32* @stderr
%284 = call i32 @fprintf(i32 %283, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %285
285: ; preds = %282, %277
%286 = call i32 @exit(i32 1)
unreachable
287: ; preds = %273
%288 = load i32, i32* @stderr
%289 = call i32 @fprintf(i32 %288, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0))
%290 = load i32, i32* %7
%291 = call i32 @write(i32 %290, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
store i32 %291, i32* %16
%292 = load i32, i32* %16
%293 = icmp slt i32 %292, 0
br i1 %293, label %294, label %297
294: ; preds = %287
%295 = load i32, i32* @stderr
%296 = call i32 @fprintf(i32 %295, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %297
297: ; preds = %294, %287
%298 = call i32 @exit(i32 1)
unreachable
299: ; preds = %272
%300 = call i32 @exit(i32 0)
unreachable
301: ; preds = %89
br label %302
302: ; preds = %301, %86
br label %76
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"No port provided! Exiting...\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [47 x i8] c"Could not create listening socket! Exiting...\0A\00"
@.str.2 = [63 x i8] c"Port out of range! Please choose a different port! Exiting...\0A\00"
@INADDR_ANY = global i32 0
@.str.3 = [75 x i8] c"Failed to bind listening port! Please choose a different port! Exiting...\0A\00"
@main.process_status = internal global i32 0
@WNOHANG = global i32 0
@.str.4 = [49 x i8] c"Client accept failed. Trying next connection...\0A\00"
@.str.5 = [3 x i8] c"@@\00"
@.str.6 = [4 x i8] c"$@@\00"
@.str.7 = [4 x i8] c"&@@\00"
@.str.8 = [36 x i8] c"Failed to alert sender. Exiting...\0A\00"
@.str.9 = [4 x i8] c"#@@\00"
@.str.10 = [4 x i8] c"%@@\00"
@.str.11 = [46 x i8] c"Got bad data. Alerting sender and exiting...\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [10 x i8]
%7 = alloca i8
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = icmp slt i32 %0, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = tail call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %15
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = tail call i64 @atoi(i8* %26)
%28 = icmp ugt i64 %27, 65535
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %24
%34 = call i32 @memset(i8* %8, i8 signext 0, i32 12)
%35 = call i32 @htons(i64 %27)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %35, i32* %36
%37 = load i32, i32* @INADDR_ANY
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %37, i32* %38
%39 = load i32, i32* @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %39, i32* %40
%41 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%42 = call i32 @bind(i32 %18, %struct.sockaddr* %41, i32 12)
%43 = icmp slt i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %33
%45 = bitcast i32* %5 to i8*
%46 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %51
47: ; preds = %33
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %44, %208
%52 = load i32, i32* @WNOHANG
%53 = call i32 @waitpid(i32 -1, i32* @main.process_status, i32 %52)
%54 = call i32 @listen(i32 %18, i32 5)
store i32 12, i32* %5
%55 = call i32 @accept(i32 %18, %struct.sockaddr* %46, i32* %5)
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
br label %208
60: ; preds = %51
%61 = call i64 (...) @fork()
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %208
63: ; preds = %60
%64 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%65 = call dereferenceable_or_null(1000000) i8* @malloc(i32 1000000)
%66 = call i32 @memset(i8* %64, i8 signext 0, i32 10)
%67 = call i32 @memset(i8* %65, i8 signext 0, i32 1000000)
%68 = call i32* @strstr(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %83
70: ; preds = %63, %79
%71 = phi i32 [ %80, %79 ], [ 0, %63 ]
%72 = call i32 @read(i32 %55, i8* %64, i32 1)
%73 = icmp eq i32 %72, -1
br i1 %73, label %79, label %74
74: ; preds = %70
%75 = load i8, i8* %64
%76 = zext i32 %71 to i64
%77 = getelementptr inbounds i8, i8* %65, i64 %76
store i8 %75, i8* %77
%78 = add i32 %71, 1
br label %79
79: ; preds = %74, %70
%80 = phi i32 [ %78, %74 ], [ %71, %70 ]
%81 = call i32* @strstr(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%82 = icmp eq i32* %81, null
br i1 %82, label %70, label %83
83: ; preds = %79, %63
%84 = call i32* @strstr(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%85 = icmp eq i32* %84, null
br i1 %85, label %187, label %86
86: ; preds = %83
%87 = call i32 @write(i32 %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %86
%94 = call i32 @memset(i8* %64, i8 signext 0, i32 10)
%95 = call i32 @memset(i8* %65, i8 signext 0, i32 1000000)
%96 = call i32* @strstr(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%97 = icmp eq i32* %96, null
br i1 %97, label %98, label %111
98: ; preds = %93, %107
%99 = phi i32 [ %108, %107 ], [ 0, %93 ]
%100 = call i32 @read(i32 %55, i8* %64, i32 1)
%101 = icmp eq i32 %100, -1
br i1 %101, label %107, label %102
102: ; preds = %98
%103 = load i8, i8* %64
%104 = zext i32 %99 to i64
%105 = getelementptr inbounds i8, i8* %65, i64 %104
store i8 %103, i8* %105
%106 = add i32 %99, 1
br label %107
107: ; preds = %102, %98
%108 = phi i32 [ %106, %102 ], [ %99, %98 ]
%109 = call i32* @strstr(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%110 = icmp eq i32* %109, null
br i1 %110, label %98, label %111
111: ; preds = %107, %93
%112 = call i64 @strlen(i8* dereferenceable(1) %65)
%113 = shl i64 %112, 32
%114 = add i64 %113, -4294967296
%115 = ashr exact i64 %114, 32
%116 = getelementptr inbounds i8, i8* %65, i64 %115
store i8 0, i8* %116
%117 = add i64 %113, -8589934592
%118 = ashr exact i64 %117, 32
%119 = getelementptr inbounds i8, i8* %65, i64 %118
store i8 0, i8* %119
%120 = call i64 @strlen(i8* dereferenceable(1) %65)
%121 = trunc i64 %120 to i32
%122 = add i32 %121, 1
%123 = call i8* @malloc(i32 %122)
%124 = call i32 @memset(i8* %123, i8 signext 0, i32 %122)
%125 = call i32 @strcpy(i8* %123, i8* %65)
%126 = call i32 @memset(i8* %64, i8 signext 0, i32 10)
%127 = call i32 @memset(i8* %65, i8 signext 0, i32 1000000)
%128 = call i32* @strstr(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%129 = icmp eq i32* %128, null
br i1 %129, label %130, label %143
130: ; preds = %111, %139
%131 = phi i32 [ %140, %139 ], [ 0, %111 ]
%132 = call i32 @read(i32 %55, i8* %64, i32 1)
%133 = icmp eq i32 %132, -1
br i1 %133, label %139, label %134
134: ; preds = %130
%135 = load i8, i8* %64
%136 = zext i32 %131 to i64
%137 = getelementptr inbounds i8, i8* %65, i64 %136
store i8 %135, i8* %137
%138 = add i32 %131, 1
br label %139
139: ; preds = %134, %130
%140 = phi i32 [ %138, %134 ], [ %131, %130 ]
%141 = call i32* @strstr(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%142 = icmp eq i32* %141, null
br i1 %142, label %130, label %143
143: ; preds = %139, %111
%144 = call i64 @strlen(i8* dereferenceable(1) %65)
%145 = shl i64 %144, 32
%146 = add i64 %145, -4294967296
%147 = ashr exact i64 %146, 32
%148 = getelementptr inbounds i8, i8* %65, i64 %147
store i8 0, i8* %148
%149 = add i64 %145, -8589934592
%150 = ashr exact i64 %149, 32
%151 = getelementptr inbounds i8, i8* %65, i64 %150
store i8 0, i8* %151
%152 = call i64 @strlen(i8* dereferenceable(1) %65)
%153 = trunc i64 %152 to i32
%154 = add i32 %153, 1
%155 = call i8* @malloc(i32 %154)
%156 = call i32 @memset(i8* %155, i8 signext 0, i32 %154)
%157 = call i32 @strcpy(i8* %155, i8* %65)
%158 = call i32 @free(i8* %65)
%159 = load i8, i8* %123
%160 = icmp eq i8 %159, 0
br i1 %160, label %167, label %161
161: ; preds = %143
%162 = load i8, i8* %155
%163 = call signext i8 @decode_character(i8 signext %159, i8 signext %162)
store i8 %163, i8* %7
%164 = call i32 @write(i32 %55, i8* %7, i32 1)
%165 = call i64 @strlen(i8* dereferenceable(1) %123)
%166 = icmp ugt i64 %165, 1
br i1 %166, label %170, label %167
167: ; preds = %170, %161, %143
%168 = call i32 @write(i32 %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%169 = icmp slt i32 %168, 0
br i1 %169, label %181, label %185
170: ; preds = %161, %170
%171 = phi i64 [ %178, %170 ], [ 1, %161 ]
%172 = getelementptr inbounds i8, i8* %123, i64 %171
%173 = load i8, i8* %172
%174 = getelementptr inbounds i8, i8* %155, i64 %171
%175 = load i8, i8* %174
%176 = call signext i8 @decode_character(i8 signext %173, i8 signext %175)
store i8 %176, i8* %7
%177 = call i32 @write(i32 %55, i8* %7, i32 1)
%178 = add nuw i64 %171, 1
%179 = call i64 @strlen(i8* dereferenceable(1) %123)
%180 = icmp ult i64 %178, %179
br i1 %180, label %170, label %167
181: ; preds = %167
%182 = load i32, i32* @stderr
%183 = call i32 @fprintf(i32 %182, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
%184 = call i32 @exit(i32 1)
unreachable
185: ; preds = %167
%186 = call i32 @exit(i32 0)
unreachable
187: ; preds = %83
%188 = call i32* @strstr(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%189 = icmp eq i32* %188, null
br i1 %189, label %198, label %190
190: ; preds = %187
%191 = call i32 @write(i32 %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
%192 = icmp slt i32 %191, 0
br i1 %192, label %193, label %196
193: ; preds = %190
%194 = load i32, i32* @stderr
%195 = call i32 @fprintf(i32 %194, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %196
196: ; preds = %193, %190
%197 = call i32 @exit(i32 1)
unreachable
198: ; preds = %187
%199 = load i32, i32* @stderr
%200 = call i32 @fprintf(i32 %199, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0))
%201 = call i32 @write(i32 %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
%202 = icmp slt i32 %201, 0
br i1 %202, label %203, label %206
203: ; preds = %198
%204 = load i32, i32* @stderr
%205 = call i32 @fprintf(i32 %204, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %206
206: ; preds = %203, %198
%207 = call i32 @exit(i32 1)
unreachable
208: ; preds = %60, %57
br label %51
}