#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 */
typedef int /*<<< orphan*/ temp_buf;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ serverINETAddress;
typedef int /*<<< orphan*/ clientINETAddress;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int /*<<< orphan*/ bad_input(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
scalar_t__ chdir(char *);
int /*<<< orphan*/ close(int);
int dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ file_exists(char *);
scalar_t__ fork();
int getpid();
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ instruction(int);
int /*<<< orphan*/ is_allowed_cmd(char *, char *);
scalar_t__ listen(int, int);
char *malloc(int);
int /*<<< orphan*/ parse_file(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  int sockfd, newsockfd, serverLen, clientLen;
  int port = 5000;
  char buffer[256], temp_buf[256];
  char *cmd_file_pathname = NULL;
  char *usr_file_pathname = NULL;
  struct sockaddr_in serverINETAddress;
  struct sockaddr *serverSockAddrPtr;
  struct sockaddr_in clientINETAddress;
  struct sockaddr *clientSockAddrPtr;
  signal(SIGCHLD, SIG_IGN);
  if ((argc % 2) == 0 || argc > 7)
    bad_input(argv[0]);
  int i;
  for (i = 1; i < argc; i += 2) {
    char *param = argv[i];
    if (strcmp(param, "-p") == 0)
      port = atoi(argv[i + 1]);
    else if (strcmp(param, "-c") == 0) {
      cmd_file_pathname = malloc(256);
      strcat(cmd_file_pathname, "/");
      strcat(cmd_file_pathname, argv[i + 1]);
    } else if (strcmp(param, "-u") == 0) {
      usr_file_pathname = malloc(256);
      strcat(usr_file_pathname, "/");
      strcat(usr_file_pathname, argv[i + 1]);
    } else
      bad_input(argv[0]);
  }
  if (!file_exists(cmd_file_pathname) || !file_exists(usr_file_pathname))
    return 0;
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0)
    error("ERROR opening socket");
  serverLen = sizeof(serverINETAddress);
  bzero((char *)&serverINETAddress, serverLen);
  serverINETAddress.sin_family = AF_INET;
  serverINETAddress.sin_addr.s_addr = htonl(INADDR_ANY);
  serverINETAddress.sin_port = htons(port);
  serverSockAddrPtr = (struct sockaddr *)&serverINETAddress;
  if (bind(sockfd, serverSockAddrPtr, serverLen) < 0)
    error("ERROR on binding");
  if (listen(sockfd, 5) < 0)
    error("ERROR on listening");
  clientSockAddrPtr = (struct sockaddr *)&clientINETAddress;
  clientLen = sizeof(clientINETAddress);
  instruction(port);
  while (1) {
    newsockfd = accept(sockfd, clientSockAddrPtr, &clientLen);
    if (newsockfd < 0)
      error("ERROR on accept");
    printf("Server %d: connection %d accepted\n", getpid(), newsockfd);
    int logged = 0;
    if (fork() == 0) {
      int a = dup2(newsockfd, STDOUT_FILENO);
      int b = dup2(newsockfd, STDERR_FILENO);
      if (a < 0 || b < 0)
        error("ERROR on dup2");
      while (1) {
        bzero(buffer, sizeof(buffer));
        if (recv(newsockfd, buffer, sizeof(buffer), 0) < 0)
          error("ERROR on receiving");
        if (!logged && usr_file_pathname != NULL) {
          if (!parse_file(usr_file_pathname, &buffer[sizeof("login")])) {
            printf("Access denied\n");
            close(newsockfd);
            exit(0);
          } else {
            printf("Logged in\n");
            logged = 1;
            continue;
          }
        }
        if (strcmp(buffer, "exit\n") == 0) {
          close(newsockfd);
          exit(0);
        }
        bzero(temp_buf, sizeof(temp_buf));
        strcpy(temp_buf, buffer);
        char *p = strtok(temp_buf, " ");
        if (strcmp(p, "login") == 0)
          continue;
        if (cmd_file_pathname != NULL &&
            !is_allowed_cmd(cmd_file_pathname, p)) {
          printf("Command not allowed\n");
          continue;
        }
        if (strcmp(p, "cd") == 0) {
          p = strtok(NULL, " ");
          p[strlen(p) - 1] = '\0';
          if (chdir(p) < 0)
            perror("error");
        } else
          system(buffer);
      }
    } else
      close(newsockfd);
  }
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1388,-0x24(%rbp)
movq   $0x0,-0x238(%rbp)
movq   $0x0,-0x240(%rbp)
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
mov    0x2c92(%rip),%rax
mov    (%rax),%esi
call   1100 <signal@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     135b <main+0x6b>
cmpl   $0x7,-0x8(%rbp)
jle    1367 <main+0x77>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1180 <bad_input@plt>
movl   $0x1,-0x274(%rbp)
mov    -0x274(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14cf <main+0x1df>
mov    -0x10(%rbp),%rax
movslq -0x274(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x280(%rbp)
mov    -0x280(%rbp),%rdi
lea    0xc5c(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    13d4 <main+0xe4>
mov    -0x10(%rbp),%rax
mov    -0x274(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   11d0 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    14b6 <main+0x1c6>
mov    -0x280(%rbp),%rdi
lea    0xc21(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    143a <main+0x14a>
mov    $0x100,%edi
call   1120 <malloc@plt>
mov    %rax,-0x238(%rbp)
mov    -0x238(%rbp),%rdi
lea    0xbf6(%rip),%rsi
call   11e0 <strcat@plt>
mov    -0x238(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x274(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   11e0 <strcat@plt>
jmp    14b1 <main+0x1c1>
mov    -0x280(%rbp),%rdi
lea    0xbc0(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    14a0 <main+0x1b0>
mov    $0x100,%edi
call   1120 <malloc@plt>
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rdi
lea    0xb90(%rip),%rsi
call   11e0 <strcat@plt>
mov    -0x240(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x274(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   11e0 <strcat@plt>
jmp    14ac <main+0x1bc>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1180 <bad_input@plt>
jmp    14b1 <main+0x1c1>
jmp    14b6 <main+0x1c6>
jmp    14bb <main+0x1cb>
mov    -0x274(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x274(%rbp)
jmp    1371 <main+0x81>
mov    -0x238(%rbp),%rdi
call   1050 <file_exists@plt>
cmp    $0x0,%eax
je     14f9 <main+0x209>
mov    -0x240(%rbp),%rdi
call   1050 <file_exists@plt>
cmp    $0x0,%eax
jne    1504 <main+0x214>
xor    %eax,%eax
add    $0x2a0,%rsp
pop    %rbp
ret
mov    0x2ad5(%rip),%rax
mov    (%rax),%edi
mov    0x2aa4(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1210 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1536 <main+0x246>
lea    0xada(%rip),%rdi
call   1160 <error@plt>
movl   $0xc,-0x1c(%rbp)
lea    -0x250(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   11b0 <bzero@plt>
mov    0x2a8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x248(%rbp)
mov    0x2a76(%rip),%rax
mov    (%rax),%edi
call   10d0 <htonl@plt>
mov    %eax,-0x24c(%rbp)
mov    -0x24(%rbp),%edi
call   10a0 <htons@plt>
mov    %eax,-0x250(%rbp)
lea    -0x250(%rbp),%rax
mov    %rax,-0x258(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x258(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1150 <bind@plt>
cmp    $0x0,%rax
jge    15b3 <main+0x2c3>
lea    0xa72(%rip),%rdi
call   1160 <error@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   1130 <listen@plt>
cmp    $0x0,%rax
jge    15d6 <main+0x2e6>
lea    0xa60(%rip),%rdi
call   1160 <error@plt>
lea    -0x268(%rbp),%rax
mov    %rax,-0x270(%rbp)
movl   $0xc,-0x20(%rbp)
mov    -0x24(%rbp),%edi
call   1110 <instruction@plt>
mov    -0x14(%rbp),%edi
mov    -0x270(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   11c0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    161f <main+0x32f>
lea    0xa2a(%rip),%rdi
call   1160 <error@plt>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
mov    -0x18(%rbp),%edx
lea    0xa22(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
movl   $0x0,-0x284(%rbp)
mov    $0x0,%al
call   1200 <fork@plt>
cmp    $0x0,%rax
jne    18c1 <main+0x5d1>
mov    -0x18(%rbp),%edi
mov    0x2992(%rip),%rax
mov    (%rax),%esi
call   10b0 <dup2@plt>
mov    %eax,-0x288(%rbp)
mov    -0x18(%rbp),%edi
mov    0x293b(%rip),%rax
mov    (%rax),%esi
call   10b0 <dup2@plt>
mov    %eax,-0x28c(%rbp)
cmpl   $0x0,-0x288(%rbp)
jl     169c <main+0x3ac>
cmpl   $0x0,-0x28c(%rbp)
jge    16a8 <main+0x3b8>
lea    0x9d4(%rip),%rdi
call   1160 <error@plt>
jmp    16ad <main+0x3bd>
lea    -0x130(%rbp),%rdi
mov    $0x100,%esi
call   11b0 <bzero@plt>
mov    -0x18(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jge    16ea <main+0x3fa>
lea    0x9a0(%rip),%rdi
call   1160 <error@plt>
cmpl   $0x0,-0x284(%rbp)
jne    175f <main+0x46f>
cmpq   $0x0,-0x240(%rbp)
je     175f <main+0x46f>
mov    -0x240(%rbp),%rdi
lea    -0x130(%rbp),%rsi
add    $0x6,%rsi
call   1170 <parse_file@plt>
cmp    $0x0,%eax
jne    1742 <main+0x452>
lea    0x96c(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
mov    -0x18(%rbp),%edi
call   10e0 <close@plt>
xor    %edi,%edi
call   11f0 <exit@plt>
lea    0x95e(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
movl   $0x1,-0x284(%rbp)
jmp    16ad <main+0x3bd>
lea    -0x130(%rbp),%rdi
lea    0x945(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    178b <main+0x49b>
mov    -0x18(%rbp),%edi
call   10e0 <close@plt>
xor    %edi,%edi
call   11f0 <exit@plt>
lea    -0x230(%rbp),%rdi
mov    $0x100,%esi
call   11b0 <bzero@plt>
lea    -0x230(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x230(%rbp),%rdi
lea    0x8fb(%rip),%rsi
call   11a0 <strtok@plt>
mov    %rax,-0x298(%rbp)
mov    -0x298(%rbp),%rdi
lea    0x8e3(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    17eb <main+0x4fb>
jmp    16ad <main+0x3bd>
cmpq   $0x0,-0x238(%rbp)
je     1828 <main+0x538>
mov    -0x238(%rbp),%rdi
mov    -0x298(%rbp),%rsi
call   1140 <is_allowed_cmd@plt>
cmp    $0x0,%eax
jne    1828 <main+0x538>
lea    0x8a4(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
jmp    16ad <main+0x3bd>
mov    -0x298(%rbp),%rdi
lea    0x89f(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    18b0 <main+0x5c0>
xor    %eax,%eax
mov    %eax,%edi
lea    0x868(%rip),%rsi
call   11a0 <strtok@plt>
mov    %rax,-0x298(%rbp)
mov    -0x298(%rbp),%rax
mov    %rax,-0x2a0(%rbp)
mov    -0x298(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x2a0(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x298(%rbp),%rdi
call   1080 <chdir@plt>
cmp    $0x0,%rax
jge    18ab <main+0x5bb>
lea    0x832(%rip),%rdi
call   1190 <perror@plt>
jmp    18bc <main+0x5cc>
lea    -0x130(%rbp),%rdi
call   1090 <system@plt>
jmp    16ad <main+0x3bd>
mov    -0x18(%rbp),%edi
call   10e0 <close@plt>
jmp    15f3 <main+0x303>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x248,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
mov    0x2ca1(%rip),%rax
mov    (%rax),%esi
call   1110 <signal@plt>
cmp    $0x7,%r14d
jg     144b <main+0x14b>
mov    %r14d,%eax
and    $0x1,%eax
je     144b <main+0x14b>
cmp    $0x2,%r14d
jl     145e <main+0x15e>
movl   $0x1388,0x4(%rsp)
mov    $0x1,%r13d
xor    %eax,%eax
mov    %rax,0x10(%rsp)
lea    0xc96(%rip),%r12
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    139b <main+0x9b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rbp,%r13,8),%rdi
call   11e0 <atoi@plt>
mov    %eax,0x4(%rsp)
add    $0x2,%r13
cmp    %r14d,%r13d
jge    1474 <main+0x174>
mov    0x0(%rbp,%r13,8),%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     1380 <main+0x80>
mov    %r15,%rdi
lea    0xc49(%rip),%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     13f0 <main+0xf0>
mov    %r15,%rdi
lea    0xc3a(%rip),%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     1418 <main+0x118>
mov    0x0(%rbp),%rdi
call   1190 <bad_input@plt>
jmp    138e <main+0x8e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x100,%edi
call   1130 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
lea    0xbff(%rip),%rsi
call   11f0 <strcat@plt>
mov    0x8(%rbp,%r13,8),%rsi
mov    %rbx,0x10(%rsp)
jmp    143e <main+0x13e>
mov    $0x100,%edi
call   1130 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
lea    0xbd7(%rip),%rsi
call   11f0 <strcat@plt>
mov    0x8(%rbp,%r13,8),%rsi
mov    %rbx,0x8(%rsp)
mov    %rbx,%rdi
call   11f0 <strcat@plt>
jmp    138e <main+0x8e>
mov    0x0(%rbp),%rdi
call   1190 <bad_input@plt>
cmp    $0x2,%r14d
jge    134e <main+0x4e>
movl   $0x1388,0x4(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    0x10(%rsp),%rdi
call   1050 <file_exists@plt>
test   %eax,%eax
je     1490 <main+0x190>
mov    0x8(%rsp),%rdi
call   1050 <file_exists@plt>
test   %eax,%eax
jne    14a4 <main+0x1a4>
xor    %eax,%eax
add    $0x248,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b35(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2b03(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1220 <socket@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    14d1 <main+0x1d1>
lea    0xb3f(%rip),%rdi
call   1170 <error@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   11c0 <bzero@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    0x2ae7(%rip),%rax
mov    (%rax),%edi
call   10e0 <htonl@plt>
mov    %eax,0x24(%rsp)
mov    0x4(%rsp),%edi
call   10b0 <htons@plt>
mov    %eax,0x20(%rsp)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1160 <bind@plt>
test   %rax,%rax
jns    152a <main+0x22a>
lea    0xafb(%rip),%rdi
call   1170 <error@plt>
mov    %r12d,%edi
mov    $0x5,%esi
call   1140 <listen@plt>
test   %rax,%rax
jns    1548 <main+0x248>
lea    0xaee(%rip),%rdi
call   1170 <error@plt>
movl   $0xc,0x1c(%rsp)
mov    0x4(%rsp),%edi
call   1120 <instruction@plt>
lea    0x30(%rsp),%r14
lea    0x1c(%rsp),%rbx
lea    0xada(%rip),%r13
lea    0xae3(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   11d0 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    159c <main+0x29c>
mov    %r13,%rdi
call   1170 <error@plt>
xor    %eax,%eax
call   1070 <getpid@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   10d0 <printf@plt>
xor    %eax,%eax
call   1210 <fork@plt>
test   %rax,%rax
je     15c6 <main+0x2c6>
mov    %ebp,%edi
call   10f0 <close@plt>
jmp    1580 <main+0x280>
mov    0x2a23(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   10c0 <dup2@plt>
mov    %eax,%ebx
mov    0x29d1(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   10c0 <dup2@plt>
test   %ebx,%ebx
js     15f0 <main+0x2f0>
test   %eax,%eax
jns    15fc <main+0x2fc>
lea    0xa80(%rip),%rdi
call   1170 <error@plt>
cmpq   $0x0,0x8(%rsp)
setne  %r15b
lea    0x40(%rsp),%r12
lea    0x140(%rsp),%r14
mov    0x10(%rsp),%r13
jmp    1640 <main+0x340>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0xa7c(%rip),%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     1700 <main+0x400>
mov    %r12,%rdi
call   10a0 <system@plt>
mov    %r12,%rdi
mov    $0x100,%esi
call   11c0 <bzero@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jns    166f <main+0x36f>
lea    0xa1b(%rip),%rdi
call   1170 <error@plt>
test   $0x1,%r15b
jne    1742 <main+0x442>
mov    %r12,%rdi
lea    0xa15(%rip),%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     1775 <main+0x475>
mov    %r14,%rdi
mov    $0x100,%esi
call   11c0 <bzero@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
lea    0x9eb(%rip),%rsi
call   11b0 <strtok@plt>
mov    %rax,%rbx
mov    %rax,%rdi
lea    0x9db(%rip),%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     1640 <main+0x340>
test   %r13,%r13
je     1620 <main+0x320>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1150 <is_allowed_cmd@plt>
test   %eax,%eax
jne    1620 <main+0x320>
lea    0x9b9(%rip),%rdi
call   1060 <puts@plt>
jmp    1640 <main+0x340>
xor    %edi,%edi
lea    0x995(%rip),%rsi
call   11b0 <strtok@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1090 <chdir@plt>
test   %rax,%rax
jns    1640 <main+0x340>
lea    0x971(%rip),%rdi
call   11a0 <perror@plt>
jmp    1640 <main+0x340>
mov    0x8(%rsp),%rdi
lea    0x46(%rsp),%rsi
call   1180 <parse_file@plt>
test   %eax,%eax
je     1769 <main+0x469>
lea    0x975(%rip),%rdi
call   1060 <puts@plt>
xor    %r15d,%r15d
jmp    1640 <main+0x340>
lea    0x953(%rip),%rdi
call   1060 <puts@plt>
mov    %ebp,%edi
call   10f0 <close@plt>
xor    %edi,%edi
call   1200 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@.str = [3 x i8] c"-p\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [3 x i8] c"-u\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.4 = [21 x i8] c"ERROR opening socket\00"
@INADDR_ANY = global i32 0
@.str.5 = [17 x i8] c"ERROR on binding\00"
@.str.6 = [19 x i8] c"ERROR on listening\00"
@.str.7 = [16 x i8] c"ERROR on accept\00"
@.str.8 = [35 x i8] c"Server %d: connection %d accepted\0A\00"
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str.9 = [14 x i8] c"ERROR on dup2\00"
@.str.10 = [19 x i8] c"ERROR on receiving\00"
@.str.11 = [15 x i8] c"Access denied\0A\00"
@.str.12 = [11 x i8] c"Logged in\0A\00"
@.str.13 = [6 x i8] c"exit\0A\00"
@.str.14 = [2 x i8] c" \00"
@.str.15 = [6 x i8] c"login\00"
@.str.16 = [21 x i8] c"Command not allowed\0A\00"
@.str.17 = [3 x i8] c"cd\00"
@.str.18 = [6 x i8] c"error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [256 x i8]
%12 = alloca [256 x i8]
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca %struct.sockaddr_in
%16 = alloca %struct.sockaddr*
%17 = alloca %struct.sockaddr_in
%18 = alloca %struct.sockaddr*
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 5000, i32* %10
store i8* null, i8** %13
store i8* null, i8** %14
%25 = load i32, i32* @SIGCHLD
%26 = load i32, i32* @SIG_IGN
%27 = call i32 @signal(i32 %25, i32 %26)
%28 = load i32, i32* %4
%29 = srem i32 %28, 2
%30 = icmp eq i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %2
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 7
br i1 %33, label %34, label %39
34: ; preds = %31, %2
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @bad_input(i8* %37)
br label %39
39: ; preds = %34, %31
store i32 1, i32* %19
br label %40
40: ; preds = %101, %39
%41 = load i32, i32* %19
%42 = load i32, i32* %4
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %104
44: ; preds = %40
%45 = load i8**, i8*** %5
%46 = load i32, i32* %19
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
store i8* %49, i8** %20
%50 = load i8*, i8** %20
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %44
%54 = load i8**, i8*** %5
%55 = load i32, i32* %19
%56 = add nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %54, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @atoi(i8* %59)
store i32 %60, i32* %10
br label %100
61: ; preds = %44
%62 = load i8*, i8** %20
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %77
65: ; preds = %61
%66 = call i8* @malloc(i32 256)
store i8* %66, i8** %13
%67 = load i8*, i8** %13
%68 = call i32 @strcat(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%69 = load i8*, i8** %13
%70 = load i8**, i8*** %5
%71 = load i32, i32* %19
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %70, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 @strcat(i8* %69, i8* %75)
br label %99
77: ; preds = %61
%78 = load i8*, i8** %20
%79 = call i64 @strcmp(i8* %78, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %93
81: ; preds = %77
%82 = call i8* @malloc(i32 256)
store i8* %82, i8** %14
%83 = load i8*, i8** %14
%84 = call i32 @strcat(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%85 = load i8*, i8** %14
%86 = load i8**, i8*** %5
%87 = load i32, i32* %19
%88 = add nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %86, i64 %89
%91 = load i8*, i8** %90
%92 = call i32 @strcat(i8* %85, i8* %91)
br label %98
93: ; preds = %77
%94 = load i8**, i8*** %5
%95 = getelementptr inbounds i8*, i8** %94, i64 0
%96 = load i8*, i8** %95
%97 = call i32 @bad_input(i8* %96)
br label %98
98: ; preds = %93, %81
br label %99
99: ; preds = %98, %65
br label %100
100: ; preds = %99, %53
br label %101
101: ; preds = %100
%102 = load i32, i32* %19
%103 = add nsw i32 %102, 2
store i32 %103, i32* %19
br label %40
104: ; preds = %40
%105 = load i8*, i8** %13
%106 = call i32 @file_exists(i8* %105)
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %112
108: ; preds = %104
%109 = load i8*, i8** %14
%110 = call i32 @file_exists(i8* %109)
%111 = icmp ne i32 %110, 0
br i1 %111, label %113, label %112
112: ; preds = %108, %104
ret i32 0
113: ; preds = %108
%114 = load i32, i32* @AF_INET
%115 = load i32, i32* @SOCK_STREAM
%116 = call i32 @socket(i32 %114, i32 %115, i32 0)
store i32 %116, i32* %6
%117 = load i32, i32* %6
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %121
119: ; preds = %113
%120 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %121
121: ; preds = %119, %113
store i32 12, i32* %8
%122 = bitcast %struct.sockaddr_in* %15 to i8*
%123 = load i32, i32* %8
%124 = call i32 @bzero(i8* %122, i32 %123)
%125 = load i32, i32* @AF_INET
%126 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 2
store i32 %125, i32* %126
%127 = load i32, i32* @INADDR_ANY
%128 = call i32 @htonl(i32 %127)
%129 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
%130 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %129, i32 0, i32 0
store i32 %128, i32* %130
%131 = load i32, i32* %10
%132 = call i32 @htons(i32 %131)
%133 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
store i32 %132, i32* %133
%134 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
store %struct.sockaddr* %134, %struct.sockaddr** %16
%135 = load i32, i32* %6
%136 = load %struct.sockaddr*, %struct.sockaddr** %16
%137 = load i32, i32* %8
%138 = call i64 @bind(i32 %135, %struct.sockaddr* %136, i32 %137)
%139 = icmp slt i64 %138, 0
br i1 %139, label %140, label %142
140: ; preds = %121
%141 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %142
142: ; preds = %140, %121
%143 = load i32, i32* %6
%144 = call i64 @listen(i32 %143, i32 5)
%145 = icmp slt i64 %144, 0
br i1 %145, label %146, label %148
146: ; preds = %142
%147 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %148
148: ; preds = %146, %142
%149 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
store %struct.sockaddr* %149, %struct.sockaddr** %18
store i32 12, i32* %9
%150 = load i32, i32* %10
%151 = call i32 @instruction(i32 %150)
br label %152
152: ; preds = %148, %263
%153 = load i32, i32* %6
%154 = load %struct.sockaddr*, %struct.sockaddr** %18
%155 = call i32 @accept(i32 %153, %struct.sockaddr* %154, i32* %9)
store i32 %155, i32* %7
%156 = load i32, i32* %7
%157 = icmp slt i32 %156, 0
br i1 %157, label %158, label %160
158: ; preds = %152
%159 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %160
160: ; preds = %158, %152
%161 = call i32 (...) @getpid()
%162 = load i32, i32* %7
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 %161, i32 %162)
store i32 0, i32* %21
%164 = call i64 (...) @fork()
%165 = icmp eq i64 %164, 0
br i1 %165, label %166, label %260
166: ; preds = %160
%167 = load i32, i32* %7
%168 = load i32, i32* @STDOUT_FILENO
%169 = call i32 @dup2(i32 %167, i32 %168)
store i32 %169, i32* %22
%170 = load i32, i32* %7
%171 = load i32, i32* @STDERR_FILENO
%172 = call i32 @dup2(i32 %170, i32 %171)
store i32 %172, i32* %23
%173 = load i32, i32* %22
%174 = icmp slt i32 %173, 0
br i1 %174, label %178, label %175
175: ; preds = %166
%176 = load i32, i32* %23
%177 = icmp slt i32 %176, 0
br i1 %177, label %178, label %180
178: ; preds = %175, %166
%179 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %180
180: ; preds = %178, %175
br label %181
181: ; preds = %180, %206, %227, %236, %259
%182 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%183 = call i32 @bzero(i8* %182, i32 256)
%184 = load i32, i32* %7
%185 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%186 = call i64 @recv(i32 %184, i8* %185, i32 256, i32 0)
%187 = icmp slt i64 %186, 0
br i1 %187, label %188, label %190
188: ; preds = %181
%189 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %190
190: ; preds = %188, %181
%191 = load i32, i32* %21
%192 = icmp ne i32 %191, 0
br i1 %192, label %208, label %193
193: ; preds = %190
%194 = load i8*, i8** %14
%195 = icmp ne i8* %194, null
br i1 %195, label %196, label %208
196: ; preds = %193
%197 = load i8*, i8** %14
%198 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 6
%199 = call i32 @parse_file(i8* %197, i8* %198)
%200 = icmp ne i32 %199, 0
br i1 %200, label %206, label %201
201: ; preds = %196
%202 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%203 = load i32, i32* %7
%204 = call i32 @close(i32 %203)
%205 = call i32 @exit(i32 0)
unreachable
206: ; preds = %196
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %21
br label %181
208: ; preds = %193, %190
%209 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%210 = call i64 @strcmp(i8* %209, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%211 = icmp eq i64 %210, 0
br i1 %211, label %212, label %216
212: ; preds = %208
%213 = load i32, i32* %7
%214 = call i32 @close(i32 %213)
%215 = call i32 @exit(i32 0)
unreachable
216: ; preds = %208
%217 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%218 = call i32 @bzero(i8* %217, i32 256)
%219 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%220 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%221 = call i32 @strcpy(i8* %219, i8* %220)
%222 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%223 = call i8* @strtok(i8* %222, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i8* %223, i8** %24
%224 = load i8*, i8** %24
%225 = call i64 @strcmp(i8* %224, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%226 = icmp eq i64 %225, 0
br i1 %226, label %227, label %228
227: ; preds = %216
br label %181
228: ; preds = %216
%229 = load i8*, i8** %13
%230 = icmp ne i8* %229, null
br i1 %230, label %231, label %238
231: ; preds = %228
%232 = load i8*, i8** %13
%233 = load i8*, i8** %24
%234 = call i32 @is_allowed_cmd(i8* %232, i8* %233)
%235 = icmp ne i32 %234, 0
br i1 %235, label %238, label %236
236: ; preds = %231
%237 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0))
br label %181
238: ; preds = %231, %228
%239 = load i8*, i8** %24
%240 = call i64 @strcmp(i8* %239, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%241 = icmp eq i64 %240, 0
br i1 %241, label %242, label %256
242: ; preds = %238
%243 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i8* %243, i8** %24
%244 = load i8*, i8** %24
%245 = load i8*, i8** %24
%246 = call i32 @strlen(i8* %245)
%247 = sub nsw i32 %246, 1
%248 = sext i32 %247 to i64
%249 = getelementptr inbounds i8, i8* %244, i64 %248
store i8 0, i8* %249
%250 = load i8*, i8** %24
%251 = call i64 @chdir(i8* %250)
%252 = icmp slt i64 %251, 0
br i1 %252, label %253, label %255
253: ; preds = %242
%254 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
br label %255
255: ; preds = %253, %242
br label %259
256: ; preds = %238
%257 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%258 = call i32 @system(i8* %257)
br label %259
259: ; preds = %256, %255
br label %181
260: ; preds = %160
%261 = load i32, i32* %7
%262 = call i32 @close(i32 %261)
br label %263
263: ; preds = %260
br label %152
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@.str = [3 x i8] c"-p\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [3 x i8] c"-u\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.4 = [21 x i8] c"ERROR opening socket\00"
@INADDR_ANY = global i32 0
@.str.5 = [17 x i8] c"ERROR on binding\00"
@.str.6 = [19 x i8] c"ERROR on listening\00"
@.str.7 = [16 x i8] c"ERROR on accept\00"
@.str.8 = [35 x i8] c"Server %d: connection %d accepted\0A\00"
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str.9 = [14 x i8] c"ERROR on dup2\00"
@.str.10 = [19 x i8] c"ERROR on receiving\00"
@.str.13 = [6 x i8] c"exit\0A\00"
@.str.14 = [2 x i8] c" \00"
@.str.15 = [6 x i8] c"login\00"
@.str.17 = [3 x i8] c"cd\00"
@.str.18 = [6 x i8] c"error\00"
@str = [20 x i8] c"Command not allowed\00"
@str.19 = [14 x i8] c"Access denied\00"
@str.20 = [10 x i8] c"Logged in\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = bitcast i32* %3 to i8*
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = bitcast %struct.sockaddr_in* %6 to i8*
%12 = bitcast %struct.sockaddr_in* %7 to i8*
%13 = load i32, i32* @SIGCHLD
%14 = load i32, i32* @SIG_IGN
%15 = tail call i32 @signal(i32 %13, i32 %14)
%16 = and i32 %0, 1
%17 = icmp eq i32 %16, 0
%18 = icmp sgt i32 %0, 7
%19 = or i1 %18, %17
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = load i8*, i8** %1
%22 = tail call i32 @bad_input(i8* %21)
br label %23
23: ; preds = %2, %20
%24 = icmp sgt i32 %0, 1
br i1 %24, label %25, label %69
25: ; preds = %23, %62
%26 = phi i64 [ %66, %62 ], [ 1, %23 ]
%27 = phi i32 [ %65, %62 ], [ 5000, %23 ]
%28 = phi i8* [ %64, %62 ], [ null, %23 ]
%29 = phi i8* [ %63, %62 ], [ null, %23 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 %26
%31 = load i8*, i8** %30
%32 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %25
%35 = add nuw nsw i64 %26, 1
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i32 @atoi(i8* %37)
br label %62
39: ; preds = %25
%40 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %39
%43 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%44 = tail call i32 @strcat(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = add nuw nsw i64 %26, 1
%46 = getelementptr inbounds i8*, i8** %1, i64 %45
%47 = load i8*, i8** %46
%48 = tail call i32 @strcat(i8* %43, i8* %47)
br label %62
49: ; preds = %39
%50 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%54 = tail call i32 @strcat(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%55 = add nuw nsw i64 %26, 1
%56 = getelementptr inbounds i8*, i8** %1, i64 %55
%57 = load i8*, i8** %56
%58 = tail call i32 @strcat(i8* %53, i8* %57)
br label %62
59: ; preds = %49
%60 = load i8*, i8** %1
%61 = tail call i32 @bad_input(i8* %60)
br label %62
62: ; preds = %42, %59, %52, %34
%63 = phi i8* [ %29, %34 ], [ %29, %42 ], [ %53, %52 ], [ %29, %59 ]
%64 = phi i8* [ %28, %34 ], [ %43, %42 ], [ %28, %52 ], [ %28, %59 ]
%65 = phi i32 [ %38, %34 ], [ %27, %42 ], [ %27, %52 ], [ %27, %59 ]
%66 = add nuw i64 %26, 2
%67 = trunc i64 %66 to i32
%68 = icmp slt i32 %67, %0
br i1 %68, label %25, label %69
69: ; preds = %62, %23
%70 = phi i8* [ null, %23 ], [ %63, %62 ]
%71 = phi i8* [ null, %23 ], [ %64, %62 ]
%72 = phi i32 [ 5000, %23 ], [ %65, %62 ]
%73 = tail call i32 @file_exists(i8* %71)
%74 = icmp eq i32 %73, 0
br i1 %74, label %78, label %75
75: ; preds = %69
%76 = tail call i32 @file_exists(i8* %70)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %75, %69
ret i32 0
79: ; preds = %75
%80 = load i32, i32* @AF_INET
%81 = load i32, i32* @SOCK_STREAM
%82 = tail call i32 @socket(i32 %80, i32 %81, i32 0)
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %79
%85 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %86
86: ; preds = %84, %79
%87 = call i32 @bzero(i8* %11, i32 12)
%88 = load i32, i32* @AF_INET
%89 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %88, i32* %89
%90 = load i32, i32* @INADDR_ANY
%91 = tail call i32 @htonl(i32 %90)
%92 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
store i32 %91, i32* %92
%93 = tail call i32 @htons(i32 %72)
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
store i32 %93, i32* %94
%95 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%96 = call i64 @bind(i32 %82, %struct.sockaddr* %95, i32 12)
%97 = icmp slt i64 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %86
%99 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %100
100: ; preds = %98, %86
%101 = call i64 @listen(i32 %82, i32 5)
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %105
103: ; preds = %100
%104 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %105
105: ; preds = %103, %100
%106 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
store i32 12, i32* %3
%107 = call i32 @instruction(i32 %72)
br label %108
108: ; preds = %184, %105
%109 = call i32 @accept(i32 %82, %struct.sockaddr* %106, i32* %3)
%110 = icmp slt i32 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %108
%112 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %113
113: ; preds = %111, %108
%114 = call i32 (...) @getpid()
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 %114, i32 %109)
%116 = call i64 (...) @fork()
%117 = icmp eq i64 %116, 0
br i1 %117, label %118, label %184
118: ; preds = %113
%119 = load i32, i32* @STDOUT_FILENO
%120 = call i32 @dup2(i32 %109, i32 %119)
%121 = load i32, i32* @STDERR_FILENO
%122 = call i32 @dup2(i32 %109, i32 %121)
%123 = icmp slt i32 %120, 0
%124 = icmp slt i32 %122, 0
%125 = select i1 %123, i1 true, i1 %124
br i1 %125, label %126, label %128
126: ; preds = %118
%127 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %128
128: ; preds = %118, %126
%129 = icmp ne i8* %70, null
%130 = icmp eq i8* %71, null
%131 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 6
br label %132
132: ; preds = %148, %128
%133 = phi i1 [ false, %148 ], [ %129, %128 ]
br label %134
134: ; preds = %183, %132
%135 = call i32 @bzero(i8* %9, i32 256)
%136 = call i64 @recv(i32 %109, i8* %9, i32 256, i32 0)
%137 = icmp slt i64 %136, 0
br i1 %137, label %138, label %140
138: ; preds = %134
%139 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %140
140: ; preds = %138, %134
br i1 %133, label %141, label %150
141: ; preds = %140
%142 = call i32 @parse_file(i8* %70, i8* %131)
%143 = icmp eq i32 %142, 0
br i1 %143, label %144, label %148
144: ; preds = %141
%145 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.19, i64 0, i64 0))
%146 = call i32 @close(i32 %109)
%147 = call i32 @exit(i32 0)
unreachable
148: ; preds = %141
%149 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.20, i64 0, i64 0))
br label %132
150: ; preds = %140
%151 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%152 = icmp eq i64 %151, 0
br i1 %152, label %153, label %156
153: ; preds = %150
%154 = call i32 @close(i32 %109)
%155 = call i32 @exit(i32 0)
unreachable
156: ; preds = %150
%157 = call i32 @bzero(i8* %10, i32 256)
%158 = call i32 @strcpy(i8* %10, i8* %9)
%159 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%160 = call i64 @strcmp(i8* %159, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%161 = icmp eq i64 %160, 0
br i1 %161, label %183, label %162
162: ; preds = %156
br i1 %130, label %168, label %163
163: ; preds = %162
%164 = call i32 @is_allowed_cmd(i8* %71, i8* %159)
%165 = icmp eq i32 %164, 0
br i1 %165, label %166, label %168
166: ; preds = %163
%167 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %183
168: ; preds = %163, %162
%169 = call i64 @strcmp(i8* %159, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%170 = icmp eq i64 %169, 0
br i1 %170, label %171, label %181
171: ; preds = %168
%172 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%173 = call i32 @strlen(i8* %172)
%174 = add nsw i32 %173, -1
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds i8, i8* %172, i64 %175
store i8 0, i8* %176
%177 = call i64 @chdir(i8* %172)
%178 = icmp slt i64 %177, 0
br i1 %178, label %179, label %183
179: ; preds = %171
%180 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
br label %183
181: ; preds = %168
%182 = call i32 @system(i8* %9)
br label %183
183: ; preds = %181, %179, %171, %156, %166
br label %134
184: ; preds = %113
%185 = call i32 @close(i32 %109)
br label %108
}