#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 {
  TYPE_1__ sin_addr;
  void *sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ sh_buff;
typedef int /*<<< orphan*/ recv_buff;
typedef int /*<<< orphan*/ opt;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ address;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void *htons(int);
int /*<<< orphan*/ inet_addr(char *);
scalar_t__ listen(int, int);
char *malloc(int);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              char *, int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int server(int argv, char *args) {
  printf("Argument dump:%d %s\n", argv, args);
  int es_socket, new_socket, port = 2718, max_clients = 10,
                             client_socket[max_clients], addrlen, opt = 1,
                             activity;
  fd_set rfds;
  char *PASSWORD = "123";
  struct sockaddr_in address;
  int i = 0;
  while (i < max_clients) {
    i++;
    client_socket[i] = 0;
  }
  printf("Establishing Socket\n");
  es_socket = socket(AF_INET, SOCK_STREAM, 0);
  setsockopt(es_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt));
  printf("Binding Port: %d\n", port);
  if (argv < 3) {
    address.sin_family = AF_INET;
    address.sin_port = htons(port);
    address.sin_addr.s_addr = INADDR_ANY;
  } else {
    address.sin_family = AF_INET;
    address.sin_port = htons(port);
    address.sin_addr.s_addr = inet_addr(args);
  }
  if ((bind(es_socket, (struct sockaddr *)&address, sizeof(address))) != 0) {
    perror("Failed to bind port");
    exit(EXIT_FAILURE);
  }
  printf("Listining on port: %d\n", port);
  if ((listen(es_socket, max_clients)) < 0) {
    perror("Failed to listen");
    exit(EXIT_FAILURE);
  }
  while (1) {
    FD_ZERO(&rfds);
    FD_SET(es_socket, &rfds);
    i = 0;
    while (i < max_clients) {
      i++;
      if (client_socket[i] > 0) {
        send(client_socket[i], ">", strlen(">"), 0);
        char *dir = malloc(1024);
        recv(client_socket[i], dir, 1024, 0);
        if (strncmp(dir, "write", 5) == 0) {
          send(client_socket[i], "Password:", strlen("Password:"), 0);
          char *passwd = malloc(80);
          recv(client_socket[i], passwd, 80, 0);
          send(client_socket[i],
               "Writing Disabled by Deafult Uncomment code to enable\n",
               strlen("Writing Disabled by Deafult Uncomment code to enable\n"),
               0);
        } else if (strncmp(dir, "sh", 2) == 0) {
          while (1) {
            send(client_socket[i], "&", 2, 0);
            char *sh_buff = malloc(1024);
            recv(client_socket[i], sh_buff, sizeof(sh_buff), 0);
            if (strncmp(sh_buff, "echo", 4) == 0) {
              memmove(sh_buff, sh_buff + strlen("echo "),
                      1 + strlen(sh_buff + strlen("echo ")));
              send(client_socket[i], sh_buff, strlen(sh_buff), 0);
            } else if (strncmp(sh_buff, "exit", 4) == 0) {
              break;
            } else if (strncmp(sh_buff, "write", 5) == 0) {
              char *path = "/home/znet/";
              send(client_socket[i], "*", 2, 0);
              char *recv_buff = malloc(1024);
              recv(client_socket[i], recv_buff, sizeof(recv_buff), 0);
              strcpy(path, recv_buff);
              FILE *fw;
              if ((fw = fopen(path, "a")) < 0) {
                send(client_socket[i], "Error Opening File\n",
                     strlen("Error Opening File\n"), 0);
              } else {
                while (1) {
                  send(client_socket[i], ">", strlen(">"), 0);
                  char *w_buff = malloc(255);
                  if (strncmp(w_buff, "!EOF", 4) == 0) {
                    break;
                  }
                  fprintf(fw, "%s", w_buff);
                }
              }
            } else {
              char *msg = "Unknown command\n";
              send(client_socket[i], msg, strlen(msg), 0);
            }
          }
        } else {
          dir[strlen(dir) - 1] = '\0';
          DIR *d;
          struct dirent *ent;
          if ((d = opendir(dir)) != NULL) {
            while ((ent = readdir(d)) != NULL) {
              send(client_socket[i], ent->d_name, strlen(ent->d_name), 0);
              send(client_socket[i], "\n", strlen("\n"), 0);
            }
          } else {
            FILE *f;
            if ((f = fopen(dir, "r")) != NULL) {
              char *fbuff = malloc(80);
              char *masterstr = malloc(10240);
              while ((fgets(fbuff, 1024, f))) {
                send(client_socket[i], fbuff, strlen(fbuff), 0);
              }
            } else {
              send(client_socket[i], "Error Openining directory\n",
                   strlen("Error Opening directory\n"), 0);
            }
          }
        }
      }
    }
    i = 0;
    while (i < max_clients) {
      i++;
      if (client_socket[i] > 0) {
        FD_SET(client_socket[i], &rfds);
      }
    }
    activity = select(max_clients + 3, &rfds, NULL, NULL, NULL);
    if (FD_ISSET(es_socket, &rfds)) {
      addrlen = sizeof(address);
      printf("Establishing new socket\n");
      new_socket = accept(es_socket, (struct sockaddr *)&address, &addrlen);
      i = 0;
      while (i < max_clients) {
        i++;
        if (client_socket[i] == 0) {
          client_socket[i] = new_socket;
          i = max_clients;
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xd40(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
movl   $0xa9e,-0x1c(%rbp)
movl   $0xa,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xd8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x38(%rbp)
lea    0xd08(%rip),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1344 <server+0xa4>
mov    -0xd8(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq -0x64(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    1318 <server+0x78>
lea    0xcce(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%rdi
mov    0x2c65(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11c0 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2c6f(%rip),%rax
mov    (%rax),%esi
mov    0x2c36(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%rcx
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
mov    -0x1c(%rbp),%esi
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
cmpl   $0x3,-0x4(%rbp)
jge    13d9 <server+0x139>
mov    0x2c2b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <htons@plt>
mov    %rax,-0x58(%rbp)
mov    0x2c09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
jmp    13ff <server+0x15f>
mov    0x2c00(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <htons@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   10e0 <inet_addr@plt>
mov    %eax,-0x60(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x18,%edx
call   1150 <bind@plt>
cmp    $0x0,%rax
je     1434 <server+0x194>
lea    0xc1f(%rip),%rdi
call   1180 <perror@plt>
mov    0x2b93(%rip),%rax
mov    (%rax),%edi
call   11a0 <exit@plt>
mov    -0x1c(%rbp),%esi
lea    0xc16(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1140 <listen@plt>
cmp    $0x0,%rax
jge    1474 <server+0x1d4>
lea    0xc0a(%rip),%rdi
call   1180 <perror@plt>
mov    0x2b53(%rip),%rax
mov    (%rax),%edi
call   11a0 <exit@plt>
jmp    1479 <server+0x1d9>
jmp    147e <server+0x1de>
lea    -0x40(%rbp),%rdi
call   1100 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   11b0 <FD_SET@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1b4a <server+0x8aa>
mov    -0xd8(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq -0x64(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    1b45 <server+0x8a5>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xdc(%rbp)
lea    0xb9d(%rip),%rdi
call   1090 <strlen@plt>
mov    -0xdc(%rbp),%edi
mov    %eax,%edx
lea    0xb89(%rip),%rsi
xor    %ecx,%ecx
call   10b0 <send@plt>
mov    $0x400,%edi
call   1130 <malloc@plt>
mov    %rax,%rcx
mov    -0xd8(%rbp),%rax
mov    %rcx,-0x70(%rbp)
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x70(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x70(%rbp),%rdi
lea    0xb4a(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    15e8 <server+0x348>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xe4(%rbp)
lea    0xb21(%rip),%rdi
call   1090 <strlen@plt>
mov    -0xe4(%rbp),%edi
mov    %eax,%edx
lea    0xb0d(%rip),%rsi
xor    %ecx,%ecx
call   10b0 <send@plt>
mov    $0x50,%edi
call   1130 <malloc@plt>
mov    %rax,%rcx
mov    -0xd8(%rbp),%rax
mov    %rcx,-0x78(%rbp)
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x78(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xe0(%rbp)
lea    0xac6(%rip),%rdi
call   1090 <strlen@plt>
mov    -0xe0(%rbp),%edi
mov    %eax,%edx
lea    0xab2(%rip),%rsi
xor    %ecx,%ecx
call   10b0 <send@plt>
jmp    1b40 <server+0x8a0>
mov    -0x70(%rbp),%rdi
lea    0xad1(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    195b <server+0x6bb>
jmp    160c <server+0x36c>
jmp    1611 <server+0x371>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
lea    0xaa1(%rip),%rsi
mov    $0x2,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
mov    $0x400,%edi
call   1130 <malloc@plt>
mov    %rax,%rcx
mov    -0xd8(%rbp),%rax
mov    %rcx,-0x80(%rbp)
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x80(%rbp),%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x80(%rbp),%rdi
lea    0xa5d(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    173b <server+0x49b>
mov    -0x80(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    0xa31(%rip),%rdi
call   1090 <strlen@plt>
mov    %eax,%ecx
mov    -0x118(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x100(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x110(%rbp)
lea    0xa04(%rip),%rdi
call   1090 <strlen@plt>
mov    -0x110(%rbp),%rdi
cltq
add    %rax,%rdi
call   1090 <strlen@plt>
mov    -0x108(%rbp),%rdi
mov    -0x100(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1160 <memmove@plt>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xf4(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x80(%rbp),%rdi
call   1090 <strlen@plt>
mov    -0xf4(%rbp),%edi
mov    -0xf0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
jmp    1951 <server+0x6b1>
mov    -0x80(%rbp),%rdi
lea    0x98e(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    175f <server+0x4bf>
jmp    1956 <server+0x6b6>
mov    -0x80(%rbp),%rdi
lea    0x914(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    18f5 <server+0x655>
mov    -0xd8(%rbp),%rax
lea    0x94d(%rip),%rcx
mov    %rcx,-0x88(%rbp)
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
lea    0x944(%rip),%rsi
mov    $0x2,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
mov    $0x400,%edi
call   1130 <malloc@plt>
mov    %rax,%rcx
mov    -0xd8(%rbp),%rax
mov    %rcx,-0x90(%rbp)
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x90(%rbp),%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x88(%rbp),%rdi
mov    -0x90(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x88(%rbp),%rdi
lea    0x8e4(%rip),%rsi
call   1170 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmp    $0x0,%rax
jae    1854 <server+0x5b4>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x11c(%rbp)
lea    0x8b5(%rip),%rdi
call   1090 <strlen@plt>
mov    -0x11c(%rbp),%edi
mov    %eax,%edx
lea    0x8a1(%rip),%rsi
xor    %ecx,%ecx
call   10b0 <send@plt>
jmp    18f0 <server+0x650>
jmp    1859 <server+0x5b9>
jmp    185e <server+0x5be>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x120(%rbp)
lea    0x803(%rip),%rdi
call   1090 <strlen@plt>
mov    -0x120(%rbp),%edi
mov    %eax,%edx
lea    0x7ef(%rip),%rsi
xor    %ecx,%ecx
call   10b0 <send@plt>
mov    $0xff,%edi
call   1130 <malloc@plt>
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rdi
lea    0x84a(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    18cc <server+0x62c>
jmp    18eb <server+0x64b>
mov    -0x98(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
lea    0x821(%rip),%rsi
call   10f0 <fprintf@plt>
jmp    1859 <server+0x5b9>
jmp    18f0 <server+0x650>
jmp    1947 <server+0x6a7>
mov    -0xd8(%rbp),%rax
lea    0x802(%rip),%rcx
mov    %rcx,-0xa8(%rbp)
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x12c(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0xa8(%rbp),%rdi
call   1090 <strlen@plt>
mov    -0x12c(%rbp),%edi
mov    -0x128(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
jmp    194c <server+0x6ac>
jmp    1951 <server+0x6b1>
jmp    160c <server+0x36c>
jmp    1b3b <server+0x89b>
mov    -0x70(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x70(%rbp),%rdi
call   1090 <strlen@plt>
mov    %eax,%ecx
mov    -0x138(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rdi
call   1080 <opendir@plt>
mov    %rax,-0xb0(%rbp)
cmp    $0x0,%rax
je     1a48 <server+0x7a8>
jmp    19a1 <server+0x701>
mov    -0xb0(%rbp),%rdi
call   1120 <readdir@plt>
mov    %rax,-0xb8(%rbp)
cmp    $0x0,%rax
je     1a43 <server+0x7a3>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14c(%rbp)
mov    -0xb8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x148(%rbp)
mov    -0xb8(%rbp),%rax
mov    (%rax),%rdi
call   1090 <strlen@plt>
mov    -0x14c(%rbp),%edi
mov    -0x148(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x13c(%rbp)
lea    0x61b(%rip),%rdi
call   1090 <strlen@plt>
mov    -0x13c(%rbp),%edi
mov    %eax,%edx
lea    0x607(%rip),%rsi
xor    %ecx,%ecx
call   10b0 <send@plt>
jmp    19a1 <server+0x701>
jmp    1b36 <server+0x896>
mov    -0x70(%rbp),%rdi
lea    0x6c3(%rip),%rsi
call   1170 <fopen@plt>
mov    %rax,-0xc0(%rbp)
cmp    $0x0,%rax
je     1afb <server+0x85b>
mov    $0x50,%edi
call   1130 <malloc@plt>
mov    %rax,-0xc8(%rbp)
mov    $0x2800,%edi
call   1130 <malloc@plt>
mov    %rax,-0xd0(%rbp)
mov    -0xc8(%rbp),%rdi
mov    -0xc0(%rbp),%rdx
mov    $0x400,%esi
call   10d0 <fgets@plt>
cmp    $0x0,%rax
je     1af6 <server+0x856>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x15c(%rbp)
mov    -0xc8(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0xc8(%rbp),%rdi
call   1090 <strlen@plt>
mov    -0x15c(%rbp),%edi
mov    -0x158(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
jmp    1a8b <server+0x7eb>
jmp    1b31 <server+0x891>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x160(%rbp)
lea    0x61d(%rip),%rdi
call   1090 <strlen@plt>
mov    -0x160(%rbp),%edi
mov    %eax,%edx
lea    0x5ee(%rip),%rsi
xor    %ecx,%ecx
call   10b0 <send@plt>
jmp    1b36 <server+0x896>
jmp    1b3b <server+0x89b>
jmp    1b40 <server+0x8a0>
jmp    1b45 <server+0x8a5>
jmp    149a <server+0x1fa>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1b97 <server+0x8f7>
mov    -0xd8(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq -0x64(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    1b92 <server+0x8f2>
mov    -0xd8(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
lea    -0x40(%rbp),%rsi
call   11b0 <FD_SET@plt>
jmp    1b51 <server+0x8b1>
mov    -0x20(%rbp),%edi
add    $0x3,%edi
lea    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   1110 <select@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1070 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1c44 <server+0x9a4>
movl   $0x18,-0x34(%rbp)
lea    0x574(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1190 <accept@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1c3f <server+0x99f>
mov    -0xd8(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq -0x64(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1c3a <server+0x99a>
mov    -0xd8(%rbp),%rax
mov    -0x18(%rbp),%edx
movslq -0x64(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
mov    %eax,-0x64(%rbp)
jmp    1bf9 <server+0x959>
jmp    1c44 <server+0x9a4>
jmp    1479 <server+0x1d9>

x86 assembly (clang, -O2):
<server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xd36(%rip),%rdi
mov    %ebp,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   10d0 <printf@plt>
movl   $0x1,0x8(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x14(%rsp)
movups %xmm0,0x24(%rsp)
movq   $0x0,0x34(%rsp)
lea    0xe21(%rip),%rdi
call   1060 <puts@plt>
mov    0x2cd9(%rip),%r14
mov    (%r14),%rdi
mov    0x2cb7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
mov    %eax,%r13d
mov    0x2cc4(%rip),%rax
mov    (%rax),%esi
mov    0x2c8b(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %r13d,%edi
mov    $0x4,%r8d
call   1070 <setsockopt@plt>
lea    0xccc(%rip),%rdi
mov    $0xa9e,%esi
xor    %eax,%eax
call   10d0 <printf@plt>
mov    (%r14),%rax
mov    %rax,0x50(%rsp)
mov    $0xa9e,%edi
call   10b0 <htons@plt>
mov    %rax,0x48(%rsp)
cmp    $0x2,%ebp
jg     137c <server+0xcc>
mov    0x2c60(%rip),%rax
mov    (%rax),%eax
jmp    1384 <server+0xd4>
mov    %r15,%rdi
call   1100 <inet_addr@plt>
mov    %eax,0x40(%rsp)
lea    0x40(%rsp),%rsi
mov    %r13d,%edi
mov    $0x18,%edx
call   1160 <bind@plt>
test   %rax,%rax
jne    189d <server+0x5ed>
lea    0xc91(%rip),%rdi
mov    $0xa9e,%esi
xor    %eax,%eax
call   10d0 <printf@plt>
mov    %r13d,%edi
mov    $0xa,%esi
call   1150 <listen@plt>
test   %rax,%rax
js     18a6 <server+0x5f6>
lea    0x4(%rsp),%rbx
lea    0xc8b(%rip),%r15
lea    0xcf1(%rip),%r12
mov    %r13d,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1110 <FD_ZERO@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
xor    %eax,%eax
jmp    147b <server+0x1cb>
nopw   0x0(%rax,%rax,1)
lea    0xc54(%rip),%rbx
mov    %rbx,%rdi
call   10a0 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
mov    $0x50,%edi
call   1140 <malloc@plt>
mov    %r13d,%edi
mov    %rax,%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xc24(%rip),%rbx
mov    %rbx,%rdi
call   10a0 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
mov    0x38(%rsp),%rax
add    $0x1,%rax
cmp    $0xa,%rax
je     1780 <server+0x4d0>
mov    %rax,0x38(%rsp)
mov    0x14(%rsp,%rax,4),%r13d
test   %r13d,%r13d
jle    1468 <server+0x1b8>
mov    %r15,%rdi
call   10a0 <strlen@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
mov    $0x400,%edi
call   1140 <malloc@plt>
mov    %rax,%r14
mov    %r13d,%edi
mov    %rax,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %r14,%rdi
lea    0xb9b(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1410 <server+0x160>
mov    %r14,%rdi
lea    0xbc4(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     15bd <server+0x30d>
mov    %r14,%rdi
call   10a0 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %r14,%rdi
call   1090 <opendir@plt>
test   %rax,%rax
je     16fa <server+0x44a>
mov    %rax,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1130 <readdir@plt>
test   %rax,%rax
je     1468 <server+0x1b8>
mov    (%rax),%rbp
mov    %rbp,%rdi
call   10a0 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
lea    0xad3(%rip),%rbp
mov    %rbp,%rdi
call   10a0 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
jmp    1520 <server+0x270>
nopl   0x0(%rax,%rax,1)
lea    0xb3e(%rip),%r14
mov    %r14,%rdi
call   10a0 <strlen@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    %r14,%rdi
call   10a0 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
call   10a0 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1170 <memmove@plt>
mov    %rbx,%rdi
call   10a0 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
mov    %r13d,%edi
lea    0xae7(%rip),%rsi
mov    $0x2,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
mov    $0x400,%edi
call   1140 <malloc@plt>
mov    %rax,%rbx
mov    %r13d,%edi
mov    %rax,%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rbx,%rdi
lea    0xab4(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1570 <server+0x2c0>
mov    %rbx,%rdi
lea    0xaa2(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1468 <server+0x1b8>
mov    %rbx,%rdi
lea    0xa2f(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
lea    0xa8e(%rip),%rbx
test   %rax,%rax
jne    15a6 <server+0x2f6>
mov    %r13d,%edi
lea    0xa72(%rip),%rsi
mov    $0x2,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
mov    $0x400,%edi
call   1140 <malloc@plt>
mov    %rax,%rbx
mov    %r13d,%edi
mov    %rax,%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xa34(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
mov    %rbp,%rdi
lea    0xa2d(%rip),%rsi
call   1180 <fopen@plt>
mov    %rax,%rbx
nopl   0x0(%rax)
mov    %r15,%rdi
call   10a0 <strlen@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
mov    $0xff,%edi
call   1140 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     15bd <server+0x30d>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10e0 <fputs@plt>
jmp    16b0 <server+0x400>
mov    %r14,%rdi
lea    0x9e2(%rip),%rsi
call   1180 <fopen@plt>
lea    0x9f3(%rip),%rdi
lea    0x9d1(%rip),%rbx
test   %rax,%rax
je     1454 <server+0x1a4>
mov    %rax,%r14
mov    $0x50,%edi
call   1140 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x400,%esi
mov    %r14,%rdx
call   10f0 <fgets@plt>
test   %rax,%rax
je     1468 <server+0x1b8>
mov    %rbx,%rdi
call   10a0 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
mov    %rbx,%rdi
jmp    1740 <server+0x490>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x14(%rsp),%edi
test   %edi,%edi
lea    0x4(%rsp),%rbx
jle    1795 <server+0x4e5>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x18(%rsp),%edi
test   %edi,%edi
mov    $0xa,%ebp
jle    17aa <server+0x4fa>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x1c(%rsp),%edi
test   %edi,%edi
jle    17ba <server+0x50a>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x20(%rsp),%edi
test   %edi,%edi
mov    (%rsp),%r13d
jle    17ce <server+0x51e>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x24(%rsp),%edi
test   %edi,%edi
jle    17de <server+0x52e>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x28(%rsp),%edi
test   %edi,%edi
jle    17ee <server+0x53e>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x2c(%rsp),%edi
test   %edi,%edi
jle    17fe <server+0x54e>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x30(%rsp),%edi
test   %edi,%edi
jle    180e <server+0x55e>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x34(%rsp),%edi
test   %edi,%edi
jle    181e <server+0x56e>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    0x38(%rsp),%edi
test   %edi,%edi
jle    182e <server+0x57e>
mov    %rbx,%rsi
call   11c0 <FD_SET@plt>
mov    $0xd,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1120 <select@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
call   1080 <FD_ISSET@plt>
test   %rax,%rax
je     13f0 <server+0x140>
movl   $0x18,0xc(%rsp)
lea    0x8cb(%rip),%rdi
call   1060 <puts@plt>
mov    %r13d,%edi
lea    0x40(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   11a0 <accept@plt>
xor    %ecx,%ecx
xchg   %ax,%ax
add    $0x1,%ecx
mov    0x10(%rsp,%rcx,4),%edx
test   %edx,%edx
cmove  %eax,%edx
mov    %edx,0x10(%rsp,%rcx,4)
cmove  %ebp,%ecx
cmp    $0xa,%ecx
jl     1880 <server+0x5d0>
jmp    13f0 <server+0x140>
lea    0x783(%rip),%rdi
jmp    18ad <server+0x5fd>
lea    0x7a5(%rip),%rdi
call   1190 <perror@plt>
mov    0x2707(%rip),%rax
mov    (%rax),%edi
call   11b0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.dirent = type { i8* }
%struct.sockaddr = type { i32 }
@.str = [21 x i8] c"Argument dump:%d %s\0A\00"
@.str.1 = [4 x i8] c"123\00"
@.str.2 = [21 x i8] c"Establishing Socket\0A\00"
@AF_INET = global i8* null
@SOCK_STREAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.3 = [18 x i8] c"Binding Port: %d\0A\00"
@INADDR_ANY = global i32 0
@.str.4 = [20 x i8] c"Failed to bind port\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [23 x i8] c"Listining on port: %d\0A\00"
@.str.6 = [17 x i8] c"Failed to listen\00"
@.str.7 = [2 x i8] c">\00"
@.str.8 = [6 x i8] c"write\00"
@.str.9 = [10 x i8] c"Password:\00"
@.str.10 = [54 x i8] c"Writing Disabled by Deafult Uncomment code to enable\0A\00"
@.str.11 = [3 x i8] c"sh\00"
@.str.12 = [2 x i8] c"&\00"
@.str.13 = [5 x i8] c"echo\00"
@.str.14 = [6 x i8] c"echo \00"
@.str.15 = [5 x i8] c"exit\00"
@.str.16 = [12 x i8] c"/home/znet/\00"
@.str.17 = [2 x i8] c"*\00"
@.str.18 = [2 x i8] c"a\00"
@.str.19 = [20 x i8] c"Error Opening File\0A\00"
@.str.20 = [5 x i8] c"!EOF\00"
@.str.21 = [3 x i8] c"%s\00"
@.str.22 = [17 x i8] c"Unknown command\0A\00"
@.str.23 = [2 x i8] c"\0A\00"
@.str.24 = [2 x i8] c"r\00"
@.str.25 = [27 x i8] c"Error Openining directory\0A\00"
@.str.26 = [25 x i8] c"Error Opening directory\0A\00"
@.str.27 = [25 x i8] c"Establishing new socket\0A\00"
define i32 @server(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca %struct.sockaddr_in
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i32*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i32*
%27 = alloca %struct.dirent*
%28 = alloca i32*
%29 = alloca i8*
%30 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%31 = load i32, i32* %3
%32 = load i8*, i8** %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %31, i8* %32)
store i32 2718, i32* %7
store i32 10, i32* %8
%34 = load i32, i32* %8
%35 = zext i32 %34 to i64
%36 = call i8* @llvm.stacksave()
store i8* %36, i8** %9
%37 = alloca i32, i64 %35
store i64 %35, i64* %10
store i32 1, i32* %12
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %15
store i32 0, i32* %17
br label %38
38: ; preds = %42, %2
%39 = load i32, i32* %17
%40 = load i32, i32* %8
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = load i32, i32* %17
%44 = add nsw i32 %43, 1
store i32 %44, i32* %17
%45 = load i32, i32* %17
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %37, i64 %46
store i32 0, i32* %47
br label %38
48: ; preds = %38
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%50 = load i8*, i8** @AF_INET
%51 = load i32, i32* @SOCK_STREAM
%52 = call i32 @socket(i8* %50, i32 %51, i32 0)
store i32 %52, i32* %5
%53 = load i32, i32* %5
%54 = load i32, i32* @SOL_SOCKET
%55 = load i32, i32* @SO_REUSEADDR
%56 = bitcast i32* %12 to i8*
%57 = call i32 @setsockopt(i32 %53, i32 %54, i32 %55, i8* %56, i32 4)
%58 = load i32, i32* %7
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %3
%61 = icmp slt i32 %60, 3
br i1 %61, label %62, label %71
62: ; preds = %48
%63 = load i8*, i8** @AF_INET
%64 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 2
store i8* %63, i8** %64
%65 = load i32, i32* %7
%66 = call i8* @htons(i32 %65)
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 1
store i8* %66, i8** %67
%68 = load i32, i32* @INADDR_ANY
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 0
%70 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %69, i32 0, i32 0
store i32 %68, i32* %70
br label %81
71: ; preds = %48
%72 = load i8*, i8** @AF_INET
%73 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 2
store i8* %72, i8** %73
%74 = load i32, i32* %7
%75 = call i8* @htons(i32 %74)
%76 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 1
store i8* %75, i8** %76
%77 = load i8*, i8** %4
%78 = call i32 @inet_addr(i8* %77)
%79 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 0
%80 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %79, i32 0, i32 0
store i32 %78, i32* %80
br label %81
81: ; preds = %71, %62
%82 = load i32, i32* %5
%83 = bitcast %struct.sockaddr_in* %16 to %struct.sockaddr*
%84 = call i64 @bind(i32 %82, %struct.sockaddr* %83, i32 24)
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %90
86: ; preds = %81
%87 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%88 = load i32, i32* @EXIT_FAILURE
%89 = call i32 @exit(i32 %88)
unreachable
90: ; preds = %81
%91 = load i32, i32* %7
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %5
%94 = load i32, i32* %8
%95 = call i64 @listen(i32 %93, i32 %94)
%96 = icmp slt i64 %95, 0
br i1 %96, label %97, label %101
97: ; preds = %90
%98 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%99 = load i32, i32* @EXIT_FAILURE
%100 = call i32 @exit(i32 %99)
unreachable
101: ; preds = %90
br label %102
102: ; preds = %388, %101
br label %103
103: ; preds = %102
%104 = call i32 @FD_ZERO(i32* %14)
%105 = load i32, i32* %5
%106 = call i32 @FD_SET(i32 %105, i32* %14)
store i32 0, i32* %17
br label %107
107: ; preds = %335, %103
%108 = load i32, i32* %17
%109 = load i32, i32* %8
%110 = icmp slt i32 %108, %109
br i1 %110, label %111, label %336
111: ; preds = %107
%112 = load i32, i32* %17
%113 = add nsw i32 %112, 1
store i32 %113, i32* %17
%114 = load i32, i32* %17
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i32, i32* %37, i64 %115
%117 = load i32, i32* %116
%118 = icmp sgt i32 %117, 0
br i1 %118, label %119, label %335
119: ; preds = %111
%120 = load i32, i32* %17
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i32, i32* %37, i64 %121
%123 = load i32, i32* %122
%124 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%125 = call i32 @send(i32 %123, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %124, i32 0)
%126 = call i8* @malloc(i32 1024)
store i8* %126, i8** %18
%127 = load i32, i32* %17
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i32, i32* %37, i64 %128
%130 = load i32, i32* %129
%131 = load i8*, i8** %18
%132 = call i32 @recv(i32 %130, i8* %131, i32 1024, i32 0)
%133 = load i8*, i8** %18
%134 = call i64 @strncmp(i8* %133, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 5)
%135 = icmp eq i64 %134, 0
br i1 %135, label %136, label %156
136: ; preds = %119
%137 = load i32, i32* %17
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds i32, i32* %37, i64 %138
%140 = load i32, i32* %139
%141 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%142 = call i32 @send(i32 %140, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %141, i32 0)
%143 = call i8* @malloc(i32 80)
store i8* %143, i8** %19
%144 = load i32, i32* %17
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i32, i32* %37, i64 %145
%147 = load i32, i32* %146
%148 = load i8*, i8** %19
%149 = call i32 @recv(i32 %147, i8* %148, i32 80, i32 0)
%150 = load i32, i32* %17
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i32, i32* %37, i64 %151
%153 = load i32, i32* %152
%154 = call i32 @strlen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0))
%155 = call i32 @send(i32 %153, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), i32 %154, i32 0)
br label %334
156: ; preds = %119
%157 = load i8*, i8** %18
%158 = call i64 @strncmp(i8* %157, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%159 = icmp eq i64 %158, 0
br i1 %159, label %160, label %267
160: ; preds = %156
br label %161
161: ; preds = %265, %160
br label %162
162: ; preds = %161
%163 = load i32, i32* %17
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i32, i32* %37, i64 %164
%166 = load i32, i32* %165
%167 = call i32 @send(i32 %166, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i32 2, i32 0)
%168 = call i8* @malloc(i32 1024)
store i8* %168, i8** %20
%169 = load i32, i32* %17
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i32, i32* %37, i64 %170
%172 = load i32, i32* %171
%173 = load i8*, i8** %20
%174 = call i32 @recv(i32 %172, i8* %173, i32 8, i32 0)
%175 = load i8*, i8** %20
%176 = call i64 @strncmp(i8* %175, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 4)
%177 = icmp eq i64 %176, 0
br i1 %177, label %178, label %199
178: ; preds = %162
%179 = load i8*, i8** %20
%180 = load i8*, i8** %20
%181 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i8, i8* %180, i64 %182
%184 = load i8*, i8** %20
%185 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds i8, i8* %184, i64 %186
%188 = call i32 @strlen(i8* %187)
%189 = add nsw i32 1, %188
%190 = call i32 @memmove(i8* %179, i8* %183, i32 %189)
%191 = load i32, i32* %17
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds i32, i32* %37, i64 %192
%194 = load i32, i32* %193
%195 = load i8*, i8** %20
%196 = load i8*, i8** %20
%197 = call i32 @strlen(i8* %196)
%198 = call i32 @send(i32 %194, i8* %195, i32 %197, i32 0)
br label %265
199: ; preds = %162
%200 = load i8*, i8** %20
%201 = call i64 @strncmp(i8* %200, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 4)
%202 = icmp eq i64 %201, 0
br i1 %202, label %203, label %204
203: ; preds = %199
br label %266
204: ; preds = %199
%205 = load i8*, i8** %20
%206 = call i64 @strncmp(i8* %205, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 5)
%207 = icmp eq i64 %206, 0
br i1 %207, label %208, label %254
208: ; preds = %204
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8** %21
%209 = load i32, i32* %17
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i32, i32* %37, i64 %210
%212 = load i32, i32* %211
%213 = call i32 @send(i32 %212, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0), i32 2, i32 0)
%214 = call i8* @malloc(i32 1024)
store i8* %214, i8** %22
%215 = load i32, i32* %17
%216 = sext i32 %215 to i64
%217 = getelementptr inbounds i32, i32* %37, i64 %216
%218 = load i32, i32* %217
%219 = load i8*, i8** %22
%220 = call i32 @recv(i32 %218, i8* %219, i32 8, i32 0)
%221 = load i8*, i8** %21
%222 = load i8*, i8** %22
%223 = call i32 @strcpy(i8* %221, i8* %222)
%224 = load i8*, i8** %21
%225 = call i32* @fopen(i8* %224, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i32* %225, i32** %23
%226 = icmp ult i32* %225, null
br i1 %226, label %227, label %234
227: ; preds = %208
%228 = load i32, i32* %17
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds i32, i32* %37, i64 %229
%231 = load i32, i32* %230
%232 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.19, i64 0, i64 0))
%233 = call i32 @send(i32 %231, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.19, i64 0, i64 0), i32 %232, i32 0)
br label %253
234: ; preds = %208
br label %235
235: ; preds = %248, %234
br label %236
236: ; preds = %235
%237 = load i32, i32* %17
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds i32, i32* %37, i64 %238
%240 = load i32, i32* %239
%241 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%242 = call i32 @send(i32 %240, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %241, i32 0)
%243 = call i8* @malloc(i32 255)
store i8* %243, i8** %24
%244 = load i8*, i8** %24
%245 = call i64 @strncmp(i8* %244, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i32 4)
%246 = icmp eq i64 %245, 0
br i1 %246, label %247, label %248
247: ; preds = %236
br label %252
248: ; preds = %236
%249 = load i32*, i32** %23
%250 = load i8*, i8** %24
%251 = call i32 @fprintf(i32* %249, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i8* %250)
br label %235
252: ; preds = %247
br label %253
253: ; preds = %252, %227
br label %263
254: ; preds = %204
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.22, i64 0, i64 0), i8** %25
%255 = load i32, i32* %17
%256 = sext i32 %255 to i64
%257 = getelementptr inbounds i32, i32* %37, i64 %256
%258 = load i32, i32* %257
%259 = load i8*, i8** %25
%260 = load i8*, i8** %25
%261 = call i32 @strlen(i8* %260)
%262 = call i32 @send(i32 %258, i8* %259, i32 %261, i32 0)
br label %263
263: ; preds = %254, %253
br label %264
264: ; preds = %263
br label %265
265: ; preds = %264, %178
br label %161
266: ; preds = %203
br label %333
267: ; preds = %156
%268 = load i8*, i8** %18
%269 = load i8*, i8** %18
%270 = call i32 @strlen(i8* %269)
%271 = sub nsw i32 %270, 1
%272 = sext i32 %271 to i64
%273 = getelementptr inbounds i8, i8* %268, i64 %272
store i8 0, i8* %273
%274 = load i8*, i8** %18
%275 = call i32* @opendir(i8* %274)
store i32* %275, i32** %26
%276 = icmp ne i32* %275, null
br i1 %276, label %277, label %302
277: ; preds = %267
br label %278
278: ; preds = %282, %277
%279 = load i32*, i32** %26
%280 = call %struct.dirent* @readdir(i32* %279)
store %struct.dirent* %280, %struct.dirent** %27
%281 = icmp ne %struct.dirent* %280, null
br i1 %281, label %282, label %301
282: ; preds = %278
%283 = load i32, i32* %17
%284 = sext i32 %283 to i64
%285 = getelementptr inbounds i32, i32* %37, i64 %284
%286 = load i32, i32* %285
%287 = load %struct.dirent*, %struct.dirent** %27
%288 = getelementptr inbounds %struct.dirent, %struct.dirent* %287, i32 0, i32 0
%289 = load i8*, i8** %288
%290 = load %struct.dirent*, %struct.dirent** %27
%291 = getelementptr inbounds %struct.dirent, %struct.dirent* %290, i32 0, i32 0
%292 = load i8*, i8** %291
%293 = call i32 @strlen(i8* %292)
%294 = call i32 @send(i32 %286, i8* %289, i32 %293, i32 0)
%295 = load i32, i32* %17
%296 = sext i32 %295 to i64
%297 = getelementptr inbounds i32, i32* %37, i64 %296
%298 = load i32, i32* %297
%299 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0))
%300 = call i32 @send(i32 %298, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0), i32 %299, i32 0)
br label %278
301: ; preds = %278
br label %332
302: ; preds = %267
%303 = load i8*, i8** %18
%304 = call i32* @fopen(i8* %303, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i64 0, i64 0))
store i32* %304, i32** %28
%305 = icmp ne i32* %304, null
br i1 %305, label %306, label %324
306: ; preds = %302
%307 = call i8* @malloc(i32 80)
store i8* %307, i8** %29
%308 = call i8* @malloc(i32 10240)
store i8* %308, i8** %30
br label %309
309: ; preds = %314, %306
%310 = load i8*, i8** %29
%311 = load i32*, i32** %28
%312 = call i64 @fgets(i8* %310, i32 1024, i32* %311)
%313 = icmp ne i64 %312, 0
br i1 %313, label %314, label %323
314: ; preds = %309
%315 = load i32, i32* %17
%316 = sext i32 %315 to i64
%317 = getelementptr inbounds i32, i32* %37, i64 %316
%318 = load i32, i32* %317
%319 = load i8*, i8** %29
%320 = load i8*, i8** %29
%321 = call i32 @strlen(i8* %320)
%322 = call i32 @send(i32 %318, i8* %319, i32 %321, i32 0)
br label %309
323: ; preds = %309
br label %331
324: ; preds = %302
%325 = load i32, i32* %17
%326 = sext i32 %325 to i64
%327 = getelementptr inbounds i32, i32* %37, i64 %326
%328 = load i32, i32* %327
%329 = call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.26, i64 0, i64 0))
%330 = call i32 @send(i32 %328, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.25, i64 0, i64 0), i32 %329, i32 0)
br label %331
331: ; preds = %324, %323
br label %332
332: ; preds = %331, %301
br label %333
333: ; preds = %332, %266
br label %334
334: ; preds = %333, %136
br label %335
335: ; preds = %334, %111
br label %107
336: ; preds = %107
store i32 0, i32* %17
br label %337
337: ; preds = %355, %336
%338 = load i32, i32* %17
%339 = load i32, i32* %8
%340 = icmp slt i32 %338, %339
br i1 %340, label %341, label %356
341: ; preds = %337
%342 = load i32, i32* %17
%343 = add nsw i32 %342, 1
store i32 %343, i32* %17
%344 = load i32, i32* %17
%345 = sext i32 %344 to i64
%346 = getelementptr inbounds i32, i32* %37, i64 %345
%347 = load i32, i32* %346
%348 = icmp sgt i32 %347, 0
br i1 %348, label %349, label %355
349: ; preds = %341
%350 = load i32, i32* %17
%351 = sext i32 %350 to i64
%352 = getelementptr inbounds i32, i32* %37, i64 %351
%353 = load i32, i32* %352
%354 = call i32 @FD_SET(i32 %353, i32* %14)
br label %355
355: ; preds = %349, %341
br label %337
356: ; preds = %337
%357 = load i32, i32* %8
%358 = add nsw i32 %357, 3
%359 = call i32 @select(i32 %358, i32* %14, i32* null, i32* null, i32* null)
store i32 %359, i32* %13
%360 = load i32, i32* %5
%361 = call i64 @FD_ISSET(i32 %360, i32* %14)
%362 = icmp ne i64 %361, 0
br i1 %362, label %363, label %388
363: ; preds = %356
store i32 24, i32* %11
%364 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.27, i64 0, i64 0))
%365 = load i32, i32* %5
%366 = bitcast %struct.sockaddr_in* %16 to %struct.sockaddr*
%367 = call i32 @accept(i32 %365, %struct.sockaddr* %366, i32* %11)
store i32 %367, i32* %6
store i32 0, i32* %17
br label %368
368: ; preds = %386, %363
%369 = load i32, i32* %17
%370 = load i32, i32* %8
%371 = icmp slt i32 %369, %370
br i1 %371, label %372, label %387
372: ; preds = %368
%373 = load i32, i32* %17
%374 = add nsw i32 %373, 1
store i32 %374, i32* %17
%375 = load i32, i32* %17
%376 = sext i32 %375 to i64
%377 = getelementptr inbounds i32, i32* %37, i64 %376
%378 = load i32, i32* %377
%379 = icmp eq i32 %378, 0
br i1 %379, label %380, label %386
380: ; preds = %372
%381 = load i32, i32* %6
%382 = load i32, i32* %17
%383 = sext i32 %382 to i64
%384 = getelementptr inbounds i32, i32* %37, i64 %383
store i32 %381, i32* %384
%385 = load i32, i32* %8
store i32 %385, i32* %17
br label %386
386: ; preds = %380, %372
br label %368
387: ; preds = %368
br label %388
388: ; preds = %387, %356
br label %102
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
%struct.dirent = type { i8* }
@.str = [21 x i8] c"Argument dump:%d %s\0A\00"
@AF_INET = global i8* null
@SOCK_STREAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.3 = [18 x i8] c"Binding Port: %d\0A\00"
@INADDR_ANY = global i32 0
@.str.4 = [20 x i8] c"Failed to bind port\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [23 x i8] c"Listining on port: %d\0A\00"
@.str.6 = [17 x i8] c"Failed to listen\00"
@.str.7 = [2 x i8] c">\00"
@.str.8 = [6 x i8] c"write\00"
@.str.9 = [10 x i8] c"Password:\00"
@.str.10 = [54 x i8] c"Writing Disabled by Deafult Uncomment code to enable\0A\00"
@.str.11 = [3 x i8] c"sh\00"
@.str.12 = [2 x i8] c"&\00"
@.str.13 = [5 x i8] c"echo\00"
@.str.14 = [6 x i8] c"echo \00"
@.str.15 = [5 x i8] c"exit\00"
@.str.16 = [12 x i8] c"/home/znet/\00"
@.str.17 = [2 x i8] c"*\00"
@.str.18 = [2 x i8] c"a\00"
@.str.20 = [5 x i8] c"!EOF\00"
@.str.22 = [17 x i8] c"Unknown command\0A\00"
@.str.23 = [2 x i8] c"\0A\00"
@.str.24 = [2 x i8] c"r\00"
@.str.25 = [27 x i8] c"Error Openining directory\0A\00"
@.str.26 = [25 x i8] c"Error Opening directory\0A\00"
@str = [20 x i8] c"Establishing Socket\00"
@str.28 = [24 x i8] c"Establishing new socket\00"
define i32 @server(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %1)
%8 = alloca [10 x i32]
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%11 = bitcast i32* %5 to i8*
%12 = bitcast %struct.sockaddr_in* %6 to i8*
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 1
%14 = bitcast i32* %13 to i8*
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%16 = load i8*, i8** @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = tail call i32 @socket(i8* %16, i32 %17, i32 0)
%19 = load i32, i32* @SOL_SOCKET
%20 = load i32, i32* @SO_REUSEADDR
%21 = call i32 @setsockopt(i32 %18, i32 %19, i32 %20, i8* %10, i32 4)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 2718)
%23 = icmp slt i32 %0, 3
%24 = load i8*, i8** @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i8* %24, i8** %25
%26 = call i8* @htons(i32 2718)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
store i8* %26, i8** %27
br i1 %23, label %28, label %30
28: ; preds = %2
%29 = load i32, i32* @INADDR_ANY
br label %32
30: ; preds = %2
%31 = call i32 @inet_addr(i8* %1)
br label %32
32: ; preds = %30, %28
%33 = phi i32 [ %29, %28 ], [ %31, %30 ]
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0, i32 0
store i32 %33, i32* %34
%35 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%36 = call i64 @bind(i32 %18, %struct.sockaddr* %35, i32 24)
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %32
%39 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 2718)
%44 = call i64 @listen(i32 %18, i32 10)
%45 = icmp slt i64 %44, 0
br i1 %45, label %56, label %46
46: ; preds = %42
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 2
%48 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 3
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 4
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 5
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 6
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 7
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 8
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 9
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 10
br label %60
56: ; preds = %42
%57 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %223, %46
%61 = call i32 @FD_ZERO(i32* %5)
%62 = call i32 @FD_SET(i32 %18, i32* %5)
br label %63
63: ; preds = %60, %167
%64 = phi i64 [ 0, %60 ], [ %65, %167 ]
%65 = add nuw nsw i64 %64, 1
%66 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = icmp sgt i32 %67, 0
br i1 %68, label %69, label %167
69: ; preds = %63
%70 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%71 = call i32 @send(i32 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %70, i32 0)
%72 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%73 = call i32 @recv(i32 %67, i8* %72, i32 1024, i32 0)
%74 = call i64 @strncmp(i8* %72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 5)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %81
76: ; preds = %69
%77 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%78 = call i32 @send(i32 %67, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %77, i32 0)
%79 = call dereferenceable_or_null(80) i8* @malloc(i32 80)
%80 = call i32 @recv(i32 %67, i8* %79, i32 80, i32 0)
br label %162
81: ; preds = %69
%82 = call i64 @strncmp(i8* %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %130
84: ; preds = %81, %129
%85 = call i32 @send(i32 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i32 2, i32 0)
%86 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%87 = call i32 @recv(i32 %67, i8* %86, i32 8, i32 0)
%88 = call i64 @strncmp(i8* %86, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 4)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %100
90: ; preds = %84
%91 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %86, i64 %92
%94 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %86, i64 %95
%97 = call i32 @strlen(i8* %96)
%98 = add nsw i32 %97, 1
%99 = call i32 @memmove(i8* %86, i8* %93, i32 %98)
br label %125
100: ; preds = %84
%101 = call i64 @strncmp(i8* %86, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 4)
%102 = icmp eq i64 %101, 0
br i1 %102, label %167, label %103
103: ; preds = %100
%104 = call i64 @strncmp(i8* %86, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 5)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %125
106: ; preds = %103
%107 = call i32 @send(i32 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0), i32 2, i32 0)
%108 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%109 = call i32 @recv(i32 %67, i8* %108, i32 8, i32 0)
%110 = call i32 @strcpy(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8* %108)
%111 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%112 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%113 = call i32 @send(i32 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %112, i32 0)
%114 = call dereferenceable_or_null(255) i8* @malloc(i32 255)
%115 = call i64 @strncmp(i8* %114, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i32 4)
%116 = icmp eq i64 %115, 0
br i1 %116, label %129, label %117
117: ; preds = %106, %117
%118 = phi i8* [ %122, %117 ], [ %114, %106 ]
%119 = call i32 @fputs(i8* %118, i32* %111)
%120 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%121 = call i32 @send(i32 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %120, i32 0)
%122 = call dereferenceable_or_null(255) i8* @malloc(i32 255)
%123 = call i64 @strncmp(i8* %122, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i32 4)
%124 = icmp eq i64 %123, 0
br i1 %124, label %129, label %117
125: ; preds = %103, %90
%126 = phi i8* [ %86, %90 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.22, i64 0, i64 0), %103 ]
%127 = call i32 @strlen(i8* %126)
%128 = call i32 @send(i32 %67, i8* %126, i32 %127, i32 0)
br label %129
129: ; preds = %117, %125, %106
br label %84
130: ; preds = %81
%131 = call i32 @strlen(i8* %72)
%132 = add nsw i32 %131, -1
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i8, i8* %72, i64 %133
store i8 0, i8* %134
%135 = call i32* @opendir(i8* %72)
%136 = icmp eq i32* %135, null
br i1 %136, label %150, label %137
137: ; preds = %130
%138 = call %struct.dirent* @readdir(i32* %135)
%139 = icmp eq %struct.dirent* %138, null
br i1 %139, label %167, label %140
140: ; preds = %137, %140
%141 = phi %struct.dirent* [ %148, %140 ], [ %138, %137 ]
%142 = getelementptr inbounds %struct.dirent, %struct.dirent* %141, i64 0, i32 0
%143 = load i8*, i8** %142
%144 = call i32 @strlen(i8* %143)
%145 = call i32 @send(i32 %67, i8* %143, i32 %144, i32 0)
%146 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0))
%147 = call i32 @send(i32 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0), i32 %146, i32 0)
%148 = call %struct.dirent* @readdir(i32* %135)
%149 = icmp eq %struct.dirent* %148, null
br i1 %149, label %167, label %140
150: ; preds = %130
%151 = call i32* @fopen(i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i64 0, i64 0))
%152 = icmp eq i32* %151, null
br i1 %152, label %162, label %153
153: ; preds = %150
%154 = call dereferenceable_or_null(80) i8* @malloc(i32 80)
%155 = call i64 @fgets(i8* %154, i32 1024, i32* %151)
%156 = icmp eq i64 %155, 0
br i1 %156, label %167, label %157
157: ; preds = %153, %157
%158 = call i32 @strlen(i8* %154)
%159 = call i32 @send(i32 %67, i8* %154, i32 %158, i32 0)
%160 = call i64 @fgets(i8* %154, i32 1024, i32* %151)
%161 = icmp eq i64 %160, 0
br i1 %161, label %167, label %157
162: ; preds = %150, %76
%163 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), %76 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.26, i64 0, i64 0), %150 ]
%164 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), %76 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.25, i64 0, i64 0), %150 ]
%165 = call i32 @strlen(i8* %163)
%166 = call i32 @send(i32 %67, i8* %164, i32 %165, i32 0)
br label %167
167: ; preds = %140, %157, %100, %162, %137, %153, %63
%168 = icmp eq i64 %65, 10
br i1 %168, label %169, label %63
169: ; preds = %167
%170 = load i32, i32* %13
%171 = icmp sgt i32 %170, 0
br i1 %171, label %172, label %174
172: ; preds = %169
%173 = call i32 @FD_SET(i32 %170, i32* %5)
br label %174
174: ; preds = %172, %169
%175 = load i32, i32* %47
%176 = icmp sgt i32 %175, 0
br i1 %176, label %177, label %179
177: ; preds = %174
%178 = call i32 @FD_SET(i32 %175, i32* %5)
br label %179
179: ; preds = %177, %174
%180 = load i32, i32* %48
%181 = icmp sgt i32 %180, 0
br i1 %181, label %182, label %184
182: ; preds = %179
%183 = call i32 @FD_SET(i32 %180, i32* %5)
br label %184
184: ; preds = %182, %179
%185 = load i32, i32* %49
%186 = icmp sgt i32 %185, 0
br i1 %186, label %187, label %189
187: ; preds = %184
%188 = call i32 @FD_SET(i32 %185, i32* %5)
br label %189
189: ; preds = %187, %184
%190 = load i32, i32* %50
%191 = icmp sgt i32 %190, 0
br i1 %191, label %192, label %194
192: ; preds = %189
%193 = call i32 @FD_SET(i32 %190, i32* %5)
br label %194
194: ; preds = %192, %189
%195 = load i32, i32* %51
%196 = icmp sgt i32 %195, 0
br i1 %196, label %197, label %199
197: ; preds = %194
%198 = call i32 @FD_SET(i32 %195, i32* %5)
br label %199
199: ; preds = %197, %194
%200 = load i32, i32* %52
%201 = icmp sgt i32 %200, 0
br i1 %201, label %202, label %204
202: ; preds = %199
%203 = call i32 @FD_SET(i32 %200, i32* %5)
br label %204
204: ; preds = %202, %199
%205 = load i32, i32* %53
%206 = icmp sgt i32 %205, 0
br i1 %206, label %207, label %209
207: ; preds = %204
%208 = call i32 @FD_SET(i32 %205, i32* %5)
br label %209
209: ; preds = %207, %204
%210 = load i32, i32* %54
%211 = icmp sgt i32 %210, 0
br i1 %211, label %212, label %214
212: ; preds = %209
%213 = call i32 @FD_SET(i32 %210, i32* %5)
br label %214
214: ; preds = %212, %209
%215 = load i32, i32* %55
%216 = icmp sgt i32 %215, 0
br i1 %216, label %217, label %219
217: ; preds = %214
%218 = call i32 @FD_SET(i32 %215, i32* %5)
br label %219
219: ; preds = %217, %214
%220 = call i32 @select(i32 13, i32* %5, i32* null, i32* null, i32* null)
%221 = call i64 @FD_ISSET(i32 %18, i32* %5)
%222 = icmp eq i64 %221, 0
br i1 %222, label %223, label %224
223: ; preds = %227, %219
br label %60
224: ; preds = %219
store i32 24, i32* %3
%225 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.28, i64 0, i64 0))
%226 = call i32 @accept(i32 %18, %struct.sockaddr* %35, i32* %3)
br label %227
227: ; preds = %227, %224
%228 = phi i32 [ 0, %224 ], [ %235, %227 ]
%229 = add nsw i32 %228, 1
%230 = zext i32 %229 to i64
%231 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %230
%232 = load i32, i32* %231
%233 = icmp eq i32 %232, 0
%234 = select i1 %233, i32 %226, i32 %232
store i32 %234, i32* %231
%235 = select i1 %233, i32 10, i32 %229
%236 = icmp slt i32 %235, 10
br i1 %236, label %227, label %223
}