#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__ {
  scalar_t__ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ host_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ chroot(char *);
int /*<<< orphan*/ close(int);
int execv(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(TYPE_1__);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, char, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int sendfd(int, char *, scalar_t__, int);
int /*<<< orphan*/ setresuid(int, int, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ socketpair(int /*<<< orphan*/, int /*<<< orphan*/,
                      int /*<<< orphan*/, int *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
int main(int argc, char **argv) {
  int sockfd, client_sockfd;
  int host_port;
  int yes;
  char buffer[1024];
  struct sockaddr_in host_addr, client_addr;
  host_port = 80;
  if (argc > 1)
    host_port = atoi(argv[1]);
  if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              37, "creating a socket");
      exit(0);
    } while (0);
  }
  if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              41, "setting socket option SO_REUSEADDR");
      exit(0);
    } while (0);
  memset(&(host_addr), '\0', sizeof(host_addr));
  host_addr.sin_family = AF_INET;
  host_addr.sin_port = htons(host_port);
  host_addr.sin_addr.s_addr = 0;
  if (bind(sockfd, (struct sockaddr *)&host_addr, sizeof(struct sockaddr)) ==
      -1)
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              50, "binding to socket");
      exit(0);
    } while (0);
  if (listen(sockfd, 1000) == -1)
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              53, "listening on socket");
      exit(0);
    } while (0);
  signal(SIGCHLD, SIG_IGN);
  signal(SIGPIPE, SIG_IGN);
  chroot("/jail");
  chdir("/");
  int pid;
  int file_fds[2];
  if (socketpair(AF_UNIX, SOCK_STREAM, 0, file_fds))
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              74, "socketpair");
      exit(0);
    } while (0);
  if ((pid = fork()) == 0) {
    setresuid(1000, 1000, 1000);
    close(file_fds[1]);
    char pipe_fd_str[32] = {'\0'};
    char *child_name = "./filesv";
    sprintf(pipe_fd_str, "%d", file_fds[0]);
    char *child_argv[] = {child_name, pipe_fd_str, 0};
    if (1)
      printf("file fd = %s\n", pipe_fd_str);
    if (execv(child_name, child_argv) == -1)
      do {
        fprintf(stderr, "Error: %s:%d: %s\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/"
                "heads/master/lab3/server.c",
                96, "execve");
        exit(0);
      } while (0);
  }
  sleep(1);
  close(file_fds[0]);
  if (1)
    printf("the first web service launched...\n");
  int mail_fds[2];
  if (socketpair(AF_UNIX, SOCK_STREAM, 0, mail_fds))
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              106, "socketpair");
      exit(0);
    } while (0);
  if ((pid = fork()) == 0) {
    setresuid(1002, 1002, 1002);
    close(mail_fds[1]);
    char pipe_fd_str[32] = {'\0'};
    char *child_name = "./banksv";
    sprintf(pipe_fd_str, "%d", mail_fds[0]);
    char *child_argv[] = {child_name, pipe_fd_str, 0};
    if (1)
      printf("mail fd = %s\n", pipe_fd_str);
    if (execv(child_name, child_argv) == -1)
      do {
        fprintf(stderr, "Error: %s:%d: %s\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/"
                "heads/master/lab3/server.c",
                128, "execve");
        exit(0);
      } while (0);
  }
  sleep(1);
  close(mail_fds[0]);
  if (1)
    printf("the second web service launched...\n");
  int disp_fds[2];
  if (socketpair(AF_UNIX, SOCK_STREAM, 0, disp_fds))
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              138, "socketpair");
      exit(0);
    } while (0);
  if ((pid = fork()) == 0) {
    setresuid(1003, 1003, 1003);
    close(disp_fds[1]);
    char pipe_fd_str[32] = {'\0'};
    char *child_name = "./httpd";
    sprintf(pipe_fd_str, "%d", disp_fds[0]);
    char *child_argv[] = {child_name, pipe_fd_str, 0};
    if (1)
      printf("%s\n", pipe_fd_str);
    if (execv(child_name, child_argv) == -1)
      do {
        fprintf(stderr, "Error: %s:%d: %s\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/"
                "heads/master/lab3/server.c",
                159, "execve");
        exit(0);
      } while (0);
  }
  sleep(1);
  close(disp_fds[0]);
  if (1)
    printf("the http dispatcher service launched...\n");
  char temp[32] = {'\0'};
  sprintf(temp, "%d", file_fds[1]);
  if (-1 == sendfd(disp_fds[1], temp, strlen(temp) + 1, file_fds[1]))
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              170, "send fd");
      exit(0);
    } while (0);
  if (1)
    printf("sending %s...\n", temp);
  char temp2[32] = {'\0'};
  sprintf(temp2, "%d", mail_fds[1]);
  if (-1 == sendfd(disp_fds[1], temp2, strlen(temp2) + 1, mail_fds[1]))
    do {
      fprintf(stderr, "Error: %s:%d: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/"
              "lab3/server.c",
              176, "send fd");
      exit(0);
    } while (0);
  if (1)
    printf("sending %s...\n", temp2);
  close(file_fds[1]);
  close(mail_fds[1]);
  while (1) {
    int size;
    if ((client_sockfd =
             accept(sockfd, (struct sockaddr *)&client_addr, &size)) == -1)
      do {
        fprintf(stderr, "Error: %s:%d: %s\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/"
                "heads/master/lab3/server.c",
                188, "accepting client connection");
        exit(0);
      } while (0);
    printf("Parent process client_sockfd = %d\n", client_sockfd);
    if (1)
      printf("server: accepting a client from %s port %d\n",
             inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
    char *sock_fd_str = "hello, world\n";
    if (1) {
      printf("sending a socket to the client:\n");
    }
    if (-1 == sendfd(disp_fds[1], sock_fd_str, strlen(sock_fd_str) + 1,
                     client_sockfd))
      do {
        fprintf(stderr, "Error: %s:%d: %s\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/"
                "heads/master/lab3/server.c",
                203, "send sock fd");
        exit(0);
      } while (0);
    close(client_sockfd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x50,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12ca <main+0x3a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1150 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
mov    0x2cd6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11b0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1323 <main+0x93>
jmp    12f4 <main+0x64>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
lea    0xcfc(%rip),%rsi
lea    0xd07(%rip),%rdx
mov    $0x25,%ecx
lea    0xd88(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2cbb(%rip),%rax
mov    (%rax),%esi
mov    0x2c62(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    1384 <main+0xf4>
jmp    1355 <main+0xc5>
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
lea    0xc9b(%rip),%rsi
lea    0xca6(%rip),%rdx
mov    $0x29,%ecx
lea    0xd39(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
lea    -0x438(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10b0 <memset@plt>
mov    0x2c42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x428(%rbp)
mov    -0x1c(%rbp),%edi
call   1090 <htons@plt>
mov    %eax,-0x438(%rbp)
movq   $0x0,-0x430(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x438(%rbp),%rsi
mov    $0x4,%edx
call   1130 <bind@plt>
cmp    $0xffffffff,%eax
jne    1410 <main+0x180>
jmp    13e1 <main+0x151>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
lea    0xc0f(%rip),%rsi
lea    0xc1a(%rip),%rdx
mov    $0x32,%ecx
lea    0xcd0(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x3e8,%esi
call   1110 <listen@plt>
cmp    $0xffffffff,%eax
jne    145a <main+0x1ca>
jmp    142b <main+0x19b>
mov    0x2b86(%rip),%rax
mov    (%rax),%edi
lea    0xbc5(%rip),%rsi
lea    0xbd0(%rip),%rdx
mov    $0x35,%ecx
lea    0xc98(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
mov    0x2b6f(%rip),%rax
mov    (%rax),%edi
mov    0x2b5e(%rip),%rax
mov    (%rax),%esi
call   10d0 <signal@plt>
mov    0x2b30(%rip),%rax
mov    (%rax),%edi
mov    0x2b47(%rip),%rax
mov    (%rax),%esi
call   10d0 <signal@plt>
lea    0xc6b(%rip),%rdi
call   1030 <chroot@plt>
lea    0xc65(%rip),%rdi
call   1080 <chdir@plt>
mov    0x2b31(%rip),%rax
mov    (%rax),%edi
mov    0x2b00(%rip),%rax
mov    (%rax),%esi
lea    -0x45c(%rbp),%rcx
xor    %edx,%edx
call   10f0 <socketpair@plt>
cmp    $0x0,%rax
je     14fe <main+0x26e>
jmp    14cf <main+0x23f>
mov    0x2ae2(%rip),%rax
mov    (%rax),%edi
lea    0xb21(%rip),%rsi
lea    0xb2c(%rip),%rdx
mov    $0x4a,%ecx
lea    0xc10(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
mov    $0x0,%al
call   11a0 <fork@plt>
mov    %eax,-0x454(%rbp)
cmp    $0x0,%eax
jne    15f8 <main+0x368>
mov    $0x3e8,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1050 <setresuid@plt>
mov    -0x458(%rbp),%edi
call   10c0 <close@plt>
lea    -0x480(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
lea    0xbc6(%rip),%rax
mov    %rax,-0x488(%rbp)
lea    -0x480(%rbp),%rdi
mov    -0x45c(%rbp),%edx
lea    0xbb4(%rip),%rsi
call   1160 <sprintf@plt>
mov    -0x488(%rbp),%rax
mov    %rax,-0x4a0(%rbp)
lea    -0x480(%rbp),%rax
mov    %rax,-0x498(%rbp)
movq   $0x0,-0x490(%rbp)
lea    -0x480(%rbp),%rsi
lea    0xb7d(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x488(%rbp),%rdi
lea    -0x4a0(%rbp),%rsi
call   1190 <execv@plt>
cmp    $0xffffffff,%eax
jne    15f3 <main+0x363>
jmp    15c4 <main+0x334>
mov    0x29ed(%rip),%rax
mov    (%rax),%edi
lea    0xa2c(%rip),%rsi
lea    0xa37(%rip),%rdx
mov    $0x60,%ecx
lea    0xb40(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
jmp    15f8 <main+0x368>
mov    $0x1,%edi
call   1180 <sleep@plt>
mov    -0x45c(%rbp),%edi
call   10c0 <close@plt>
lea    0xb1a(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    0x29b6(%rip),%rax
mov    (%rax),%edi
mov    0x2985(%rip),%rax
mov    (%rax),%esi
lea    -0x4a8(%rbp),%rcx
xor    %edx,%edx
call   10f0 <socketpair@plt>
cmp    $0x0,%rax
je     1679 <main+0x3e9>
jmp    164a <main+0x3ba>
mov    0x2967(%rip),%rax
mov    (%rax),%edi
lea    0x9a6(%rip),%rsi
lea    0x9b1(%rip),%rdx
mov    $0x6a,%ecx
lea    0xa95(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
mov    $0x0,%al
call   11a0 <fork@plt>
mov    %eax,-0x454(%rbp)
cmp    $0x0,%eax
jne    1773 <main+0x4e3>
mov    $0x3ea,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1050 <setresuid@plt>
mov    -0x4a4(%rbp),%edi
call   10c0 <close@plt>
lea    -0x4d0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
lea    0xa8f(%rip),%rax
mov    %rax,-0x4d8(%rbp)
lea    -0x4d0(%rbp),%rdi
mov    -0x4a8(%rbp),%edx
lea    0xa39(%rip),%rsi
call   1160 <sprintf@plt>
mov    -0x4d8(%rbp),%rax
mov    %rax,-0x4f0(%rbp)
lea    -0x4d0(%rbp),%rax
mov    %rax,-0x4e8(%rbp)
movq   $0x0,-0x4e0(%rbp)
lea    -0x4d0(%rbp),%rsi
lea    0xa43(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x4d8(%rbp),%rdi
lea    -0x4f0(%rbp),%rsi
call   1190 <execv@plt>
cmp    $0xffffffff,%eax
jne    176e <main+0x4de>
jmp    173f <main+0x4af>
mov    0x2872(%rip),%rax
mov    (%rax),%edi
lea    0x8b1(%rip),%rsi
lea    0x8bc(%rip),%rdx
mov    $0x80,%ecx
lea    0x9c5(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
jmp    1773 <main+0x4e3>
mov    $0x1,%edi
call   1180 <sleep@plt>
mov    -0x4a8(%rbp),%edi
call   10c0 <close@plt>
lea    0x9d9(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    0x283b(%rip),%rax
mov    (%rax),%edi
mov    0x280a(%rip),%rax
mov    (%rax),%esi
lea    -0x4f8(%rbp),%rcx
xor    %edx,%edx
call   10f0 <socketpair@plt>
cmp    $0x0,%rax
je     17f4 <main+0x564>
jmp    17c5 <main+0x535>
mov    0x27ec(%rip),%rax
mov    (%rax),%edi
lea    0x82b(%rip),%rsi
lea    0x836(%rip),%rdx
mov    $0x8a,%ecx
lea    0x91a(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
mov    $0x0,%al
call   11a0 <fork@plt>
mov    %eax,-0x454(%rbp)
cmp    $0x0,%eax
jne    18ee <main+0x65e>
mov    $0x3eb,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1050 <setresuid@plt>
mov    -0x4f4(%rbp),%edi
call   10c0 <close@plt>
lea    -0x520(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
lea    0x94f(%rip),%rax
mov    %rax,-0x528(%rbp)
lea    -0x520(%rbp),%rdi
mov    -0x4f8(%rbp),%edx
lea    0x8be(%rip),%rsi
call   1160 <sprintf@plt>
mov    -0x528(%rbp),%rax
mov    %rax,-0x540(%rbp)
lea    -0x520(%rbp),%rax
mov    %rax,-0x538(%rbp)
movq   $0x0,-0x530(%rbp)
lea    -0x520(%rbp),%rsi
lea    0x77c(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x528(%rbp),%rdi
lea    -0x540(%rbp),%rsi
call   1190 <execv@plt>
cmp    $0xffffffff,%eax
jne    18e9 <main+0x659>
jmp    18ba <main+0x62a>
mov    0x26f7(%rip),%rax
mov    (%rax),%edi
lea    0x736(%rip),%rsi
lea    0x741(%rip),%rdx
mov    $0x9f,%ecx
lea    0x84a(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
jmp    18ee <main+0x65e>
mov    $0x1,%edi
call   1180 <sleep@plt>
mov    -0x4f8(%rbp),%edi
call   10c0 <close@plt>
lea    0x88a(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x560(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
lea    -0x560(%rbp),%rdi
mov    -0x458(%rbp),%edx
lea    0x7de(%rip),%rsi
call   1160 <sprintf@plt>
mov    -0x4f4(%rbp),%eax
mov    %eax,-0x59c(%rbp)
lea    -0x560(%rbp),%rax
mov    %rax,-0x598(%rbp)
lea    -0x560(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x59c(%rbp),%edi
mov    -0x598(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    -0x458(%rbp),%ecx
call   1100 <sendfd@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    19c5 <main+0x735>
jmp    1996 <main+0x706>
mov    0x261b(%rip),%rax
mov    (%rax),%edi
lea    0x65a(%rip),%rsi
lea    0x665(%rip),%rdx
mov    $0xaa,%ecx
lea    0x804(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
lea    -0x560(%rbp),%rsi
lea    0x7f2(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x580(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
lea    -0x580(%rbp),%rdi
mov    -0x4a4(%rbp),%edx
lea    0x715(%rip),%rsi
call   1160 <sprintf@plt>
mov    -0x4f4(%rbp),%eax
mov    %eax,-0x5ac(%rbp)
lea    -0x580(%rbp),%rax
mov    %rax,-0x5a8(%rbp)
lea    -0x580(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x5ac(%rbp),%edi
mov    -0x5a8(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    -0x4a4(%rbp),%ecx
call   1100 <sendfd@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1a8e <main+0x7fe>
jmp    1a5f <main+0x7cf>
mov    0x2552(%rip),%rax
mov    (%rax),%edi
lea    0x591(%rip),%rsi
lea    0x59c(%rip),%rdx
mov    $0xb0,%ecx
lea    0x73b(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
lea    -0x580(%rbp),%rsi
lea    0x729(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x458(%rbp),%edi
call   10c0 <close@plt>
mov    -0x4a4(%rbp),%edi
call   10c0 <close@plt>
mov    -0x14(%rbp),%edi
lea    -0x450(%rbp),%rsi
lea    -0x584(%rbp),%rdx
call   1140 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1b0f <main+0x87f>
jmp    1ae0 <main+0x850>
mov    0x24d1(%rip),%rax
mov    (%rax),%edi
lea    0x510(%rip),%rsi
lea    0x51b(%rip),%rdx
mov    $0xbc,%ecx
lea    0x6d1(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
mov    -0x18(%rbp),%esi
lea    0x6d7(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x448(%rbp),%rdi
call   1060 <inet_ntoa@plt>
mov    %rax,-0x5c8(%rbp)
mov    -0x450(%rbp),%edi
call   1120 <ntohs@plt>
mov    -0x5c8(%rbp),%rsi
mov    %eax,%edx
lea    0x6c5(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    0x6e3(%rip),%rax
mov    %rax,-0x590(%rbp)
lea    0x6e3(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x4f4(%rbp),%eax
mov    %eax,-0x5bc(%rbp)
mov    -0x590(%rbp),%rax
mov    %rax,-0x5b8(%rbp)
mov    -0x590(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x5bc(%rbp),%edi
mov    -0x5b8(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    -0x18(%rbp),%ecx
call   1100 <sendfd@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1bf6 <main+0x966>
jmp    1bc7 <main+0x937>
mov    0x23ea(%rip),%rax
mov    (%rax),%edi
lea    0x429(%rip),%rsi
lea    0x434(%rip),%rdx
mov    $0xcb,%ecx
lea    0x684(%rip),%r8
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1170 <exit@plt>
mov    -0x18(%rbp),%edi
call   10c0 <close@plt>
jmp    1ab9 <main+0x829>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    $0x50,%ebx
cmp    $0x2,%edi
jl     12c6 <main+0x26>
mov    0x8(%rsi),%rdi
call   1160 <atoi@plt>
mov    %eax,%ebx
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
mov    0x2cda(%rip),%r14
mov    (%r14),%esi
xor    %edx,%edx
call   11c0 <socket@plt>
cmp    $0xffffffff,%eax
jne    130d <main+0x6d>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
lea    0xd0b(%rip),%rsi
lea    0xd16(%rip),%rdx
lea    0xd9c(%rip),%r8
mov    $0x25,%ecx
jmp    19a3 <main+0x703>
mov    %eax,%ebp
mov    0x2cd2(%rip),%rax
mov    (%rax),%esi
mov    0x2c79(%rip),%rax
mov    (%rax),%edx
lea    0x74(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    1360 <main+0xc0>
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
lea    0xcb8(%rip),%rsi
lea    0xcc3(%rip),%rdx
lea    0xd5b(%rip),%r8
mov    $0x29,%ecx
jmp    19a3 <main+0x703>
lea    0x90(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10c0 <memset@plt>
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xa0(%rsp)
mov    %ebx,%edi
call   10a0 <htons@plt>
mov    %eax,0x90(%rsp)
movq   $0x0,0x98(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1140 <bind@plt>
cmp    $0xffffffff,%eax
jne    13dd <main+0x13d>
mov    0x2bfc(%rip),%rax
mov    (%rax),%edi
lea    0xc3b(%rip),%rsi
lea    0xc46(%rip),%rdx
lea    0xd01(%rip),%r8
mov    $0x32,%ecx
jmp    19a3 <main+0x703>
mov    %ebp,%edi
mov    $0x3e8,%esi
call   1120 <listen@plt>
cmp    $0xffffffff,%eax
jne    1416 <main+0x176>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    0xc02(%rip),%rsi
lea    0xc0d(%rip),%rdx
lea    0xcda(%rip),%r8
mov    $0x35,%ecx
jmp    19a3 <main+0x703>
mov    0x2bb3(%rip),%rax
mov    (%rax),%edi
mov    0x2ba2(%rip),%rbx
mov    (%rbx),%esi
call   10e0 <signal@plt>
mov    0x2b74(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   10e0 <signal@plt>
lea    0xcb6(%rip),%rdi
call   1030 <chroot@plt>
lea    0xcb0(%rip),%rdi
call   1090 <chdir@plt>
mov    0x2b7c(%rip),%r15
mov    (%r15),%edi
mov    (%r14),%esi
lea    0x18(%rsp),%rcx
xor    %edx,%edx
call   1100 <socketpair@plt>
test   %rax,%rax
jne    152d <main+0x28d>
xor    %eax,%eax
call   11b0 <fork@plt>
test   %eax,%eax
jne    1555 <main+0x2b5>
mov    $0x3e8,%edi
mov    $0x3e8,%esi
mov    $0x3e8,%edx
call   1060 <setresuid@plt>
mov    0x1c(%rsp),%edi
call   10d0 <close@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
mov    0x18(%rsp),%edx
lea    0xc5b(%rip),%rsi
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
call   1170 <sprintf@plt>
lea    0xc3e(%rip),%r12
mov    %r12,0x20(%rsp)
mov    %rbx,0x28(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xc30(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %r12,%rdi
call   11a0 <execv@plt>
cmp    $0xffffffff,%eax
jne    1555 <main+0x2b5>
mov    0x2aac(%rip),%rax
mov    (%rax),%edi
lea    0xaeb(%rip),%rsi
lea    0xaf6(%rip),%rdx
lea    0xc04(%rip),%r8
mov    $0x60,%ecx
jmp    19a3 <main+0x703>
mov    0x2a84(%rip),%rax
mov    (%rax),%edi
lea    0xac3(%rip),%rsi
lea    0xace(%rip),%rdx
lea    0xbb7(%rip),%r8
mov    $0x4a,%ecx
jmp    19a3 <main+0x703>
mov    $0x1,%edi
call   1190 <sleep@plt>
mov    0x18(%rsp),%edi
call   10d0 <close@plt>
lea    0xc7b(%rip),%rdi
call   1040 <puts@plt>
mov    (%r15),%edi
mov    (%r14),%esi
lea    0x10(%rsp),%rcx
xor    %edx,%edx
call   1100 <socketpair@plt>
test   %rax,%rax
jne    1645 <main+0x3a5>
xor    %eax,%eax
call   11b0 <fork@plt>
test   %eax,%eax
jne    166d <main+0x3cd>
mov    $0x3ea,%edi
mov    $0x3ea,%esi
mov    $0x3ea,%edx
call   1060 <setresuid@plt>
mov    0x14(%rsp),%edi
call   10d0 <close@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
mov    0x10(%rsp),%edx
lea    0xb43(%rip),%rsi
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
call   1170 <sprintf@plt>
lea    0xb47(%rip),%r12
mov    %r12,0x20(%rsp)
mov    %rbx,0x28(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xb36(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %r12,%rdi
call   11a0 <execv@plt>
cmp    $0xffffffff,%eax
jne    166d <main+0x3cd>
mov    0x2994(%rip),%rax
mov    (%rax),%edi
lea    0x9d3(%rip),%rsi
lea    0x9de(%rip),%rdx
lea    0xaec(%rip),%r8
mov    $0x80,%ecx
jmp    19a3 <main+0x703>
mov    0x296c(%rip),%rax
mov    (%rax),%edi
lea    0x9ab(%rip),%rsi
lea    0x9b6(%rip),%rdx
lea    0xa9f(%rip),%r8
mov    $0x6a,%ecx
jmp    19a3 <main+0x703>
mov    $0x1,%edi
call   1190 <sleep@plt>
mov    0x10(%rsp),%edi
call   10d0 <close@plt>
lea    0xb85(%rip),%rdi
call   1040 <puts@plt>
mov    (%r15),%edi
mov    (%r14),%esi
lea    0x8(%rsp),%rcx
xor    %edx,%edx
call   1100 <socketpair@plt>
test   %rax,%rax
jne    1754 <main+0x4b4>
xor    %eax,%eax
call   11b0 <fork@plt>
test   %eax,%eax
jne    177c <main+0x4dc>
mov    $0x3eb,%edi
mov    $0x3eb,%esi
mov    $0x3eb,%edx
call   1060 <setresuid@plt>
mov    0xc(%rsp),%edi
call   10d0 <close@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
mov    0x8(%rsp),%edx
lea    0xa2b(%rip),%rsi
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
call   1170 <sprintf@plt>
lea    0xa46(%rip),%r14
mov    %r14,0x20(%rsp)
mov    %rbx,0x28(%rsp)
movq   $0x0,0x30(%rsp)
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
call   11a0 <execv@plt>
cmp    $0xffffffff,%eax
jne    177c <main+0x4dc>
mov    0x2885(%rip),%rax
mov    (%rax),%edi
lea    0x8c4(%rip),%rsi
lea    0x8cf(%rip),%rdx
lea    0x9dd(%rip),%r8
mov    $0x9f,%ecx
jmp    19a3 <main+0x703>
mov    0x285d(%rip),%rax
mov    (%rax),%edi
lea    0x89c(%rip),%rsi
lea    0x8a7(%rip),%rdx
lea    0x990(%rip),%r8
mov    $0x8a,%ecx
jmp    19a3 <main+0x703>
mov    $0x1,%edi
call   1190 <sleep@plt>
mov    0x8(%rsp),%edi
call   10d0 <close@plt>
lea    0xa99(%rip),%rdi
call   1040 <puts@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
mov    0x1c(%rsp),%edx
lea    0x963(%rip),%rsi
lea    0x50(%rsp),%r14
mov    %r14,%rdi
call   1170 <sprintf@plt>
mov    0xc(%rsp),%ebx
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%rdx
mov    0x1c(%rsp),%ecx
mov    %ebx,%edi
mov    %r14,%rsi
call   1110 <sendfd@plt>
cmp    $0xffffffff,%eax
jne    180b <main+0x56b>
mov    0x27ce(%rip),%rax
mov    (%rax),%edi
lea    0x80d(%rip),%rsi
lea    0x818(%rip),%rdx
lea    0x94c(%rip),%r8
mov    $0xaa,%ecx
jmp    19a3 <main+0x703>
lea    0x943(%rip),%rdi
lea    0x50(%rsp),%rsi
xor    %eax,%eax
call   10b0 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
mov    0x14(%rsp),%edx
lea    0x8e0(%rip),%rsi
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1170 <sprintf@plt>
mov    0xc(%rsp),%ebx
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%rdx
mov    0x14(%rsp),%ecx
mov    %ebx,%edi
mov    %r14,%rsi
call   1110 <sendfd@plt>
cmp    $0xffffffff,%eax
jne    188e <main+0x5ee>
mov    0x274b(%rip),%rax
mov    (%rax),%edi
lea    0x78a(%rip),%rsi
lea    0x795(%rip),%rdx
lea    0x8c9(%rip),%r8
mov    $0xb0,%ecx
jmp    19a3 <main+0x703>
lea    0x8c0(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x1c(%rsp),%edi
call   10d0 <close@plt>
mov    0x14(%rsp),%edi
call   10d0 <close@plt>
lea    0x78(%rsp),%rsi
lea    0x4c(%rsp),%rdx
mov    %ebp,%edi
call   1150 <accept@plt>
cmp    $0xffffffff,%eax
je     195b <main+0x6bb>
mov    %eax,%ebx
lea    0x8f9(%rip),%r13
lea    0x78(%rsp),%r14
lea    0x4c(%rsp),%r15
lea    0x899(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x80(%rsp),%rdi
call   1070 <inet_ntoa@plt>
mov    %rax,%r12
mov    0x78(%rsp),%edi
call   1130 <ntohs@plt>
lea    0x893(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0x934(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edi
mov    $0xe,%edx
mov    %r13,%rsi
mov    %ebx,%ecx
call   1110 <sendfd@plt>
cmp    $0xffffffff,%eax
je     1980 <main+0x6e0>
mov    %ebx,%edi
call   10d0 <close@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1150 <accept@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    18e0 <main+0x640>
mov    0x2656(%rip),%rax
mov    (%rax),%edi
lea    0x695(%rip),%rsi
lea    0x6a0(%rip),%rdx
lea    0x7eb(%rip),%r8
mov    $0xbc,%ecx
jmp    19a3 <main+0x703>
mov    0x2631(%rip),%rax
mov    (%rax),%edi
lea    0x670(%rip),%rsi
lea    0x67b(%rip),%rdx
lea    0x83f(%rip),%r8
mov    $0xcb,%ecx
call   10f0 <fprintf@plt>
xor    %edi,%edi
call   1180 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"Error: %s:%d: %s\0A\00"
@.str.1 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/lab3/server.c\00"
@.str.2 = [18 x i8] c"creating a socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.3 = [35 x i8] c"setting socket option SO_REUSEADDR\00"
@AF_INET = global i32 0
@.str.4 = [18 x i8] c"binding to socket\00"
@.str.5 = [20 x i8] c"listening on socket\00"
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@.str.6 = [6 x i8] c"/jail\00"
@.str.7 = [2 x i8] c"/\00"
@AF_UNIX = global i32 0
@.str.8 = [11 x i8] c"socketpair\00"
@.str.9 = [9 x i8] c"./filesv\00"
@.str.10 = [3 x i8] c"%d\00"
@.str.11 = [14 x i8] c"file fd = %s\0A\00"
@.str.12 = [7 x i8] c"execve\00"
@.str.13 = [35 x i8] c"the first web service launched...\0A\00"
@.str.14 = [9 x i8] c"./banksv\00"
@.str.15 = [14 x i8] c"mail fd = %s\0A\00"
@.str.16 = [36 x i8] c"the second web service launched...\0A\00"
@.str.17 = [8 x i8] c"./httpd\00"
@.str.18 = [4 x i8] c"%s\0A\00"
@.str.19 = [41 x i8] c"the http dispatcher service launched...\0A\00"
@.str.20 = [8 x i8] c"send fd\00"
@.str.21 = [15 x i8] c"sending %s...\0A\00"
@.str.22 = [28 x i8] c"accepting client connection\00"
@.str.23 = [35 x i8] c"Parent process client_sockfd = %d\0A\00"
@.str.24 = [44 x i8] c"server: accepting a client from %s port %d\0A\00"
@.str.25 = [14 x i8] c"hello, world\0A\00"
@.str.26 = [33 x i8] c"sending a socket to the client:\0A\00"
@.str.27 = [13 x i8] c"send sock fd\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 [1024 x i8]
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = alloca [2 x i32]
%15 = alloca [32 x i8]
%16 = alloca i8*
%17 = alloca [3 x i8*]
%18 = alloca [2 x i32]
%19 = alloca [32 x i8]
%20 = alloca i8*
%21 = alloca [3 x i8*]
%22 = alloca [2 x i32]
%23 = alloca [32 x i8]
%24 = alloca i8*
%25 = alloca [3 x i8*]
%26 = alloca [32 x i8]
%27 = alloca [32 x i8]
%28 = alloca i32
%29 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 80, i32* %8
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 1
br i1 %31, label %32, label %37
32: ; preds = %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %8
br label %37
37: ; preds = %32, %2
%38 = load i32, i32* @PF_INET
%39 = load i32, i32* @SOCK_STREAM
%40 = call i32 @socket(i32 %38, i32 %39, i32 0)
store i32 %40, i32* %6
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %48
42: ; preds = %37
br label %43
43: ; preds = %42
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 37, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%46 = call i32 @exit(i32 0)
unreachable
47: ; No predecessors!
br label %48
48: ; preds = %47, %37
%49 = load i32, i32* %6
%50 = load i32, i32* @SOL_SOCKET
%51 = load i32, i32* @SO_REUSEADDR
%52 = call i32 @setsockopt(i32 %49, i32 %50, i32 %51, i32* %9, i32 4)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %60
54: ; preds = %48
br label %55
55: ; preds = %54
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 41, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%58 = call i32 @exit(i32 0)
unreachable
59: ; No predecessors!
br label %60
60: ; preds = %59, %48
%61 = call i32 @memset(%struct.sockaddr_in* %11, i8 signext 0, i32 24)
%62 = load i32, i32* @AF_INET
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %62, i32* %63
%64 = load i32, i32* %8
%65 = call i32 @htons(i32 %64)
%66 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %65, i32* %66
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%68 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %67, i32 0, i32 0
store i64 0, i64* %68
%69 = load i32, i32* %6
%70 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%71 = call i32 @bind(i32 %69, %struct.sockaddr* %70, i32 4)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %79
73: ; preds = %60
br label %74
74: ; preds = %73
%75 = load i32, i32* @stderr
%76 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%77 = call i32 @exit(i32 0)
unreachable
78: ; No predecessors!
br label %79
79: ; preds = %78, %60
%80 = load i32, i32* %6
%81 = call i32 @listen(i32 %80, i32 1000)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %89
83: ; preds = %79
br label %84
84: ; preds = %83
%85 = load i32, i32* @stderr
%86 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 53, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%87 = call i32 @exit(i32 0)
unreachable
88: ; No predecessors!
br label %89
89: ; preds = %88, %79
%90 = load i32, i32* @SIGCHLD
%91 = load i32, i32* @SIG_IGN
%92 = call i32 @signal(i32 %90, i32 %91)
%93 = load i32, i32* @SIGPIPE
%94 = load i32, i32* @SIG_IGN
%95 = call i32 @signal(i32 %93, i32 %94)
%96 = call i32 @chroot(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%97 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%98 = load i32, i32* @AF_UNIX
%99 = load i32, i32* @SOCK_STREAM
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%101 = call i64 @socketpair(i32 %98, i32 %99, i32 0, i32* %100)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %109
103: ; preds = %89
br label %104
104: ; preds = %103
%105 = load i32, i32* @stderr
%106 = call i32 @fprintf(i32 %105, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 74, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%107 = call i32 @exit(i32 0)
unreachable
108: ; No predecessors!
br label %109
109: ; preds = %108, %89
%110 = call i32 (...) @fork()
store i32 %110, i32* %13
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %140
112: ; preds = %109
%113 = call i32 @setresuid(i32 1000, i32 1000, i32 1000)
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%115 = load i32, i32* %114
%116 = call i32 @close(i32 %115)
%117 = bitcast [32 x i8]* %15 to i8*
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8** %16
%118 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%119 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%120 = load i32, i32* %119
%121 = call i32 @sprintf(i8* %118, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %120)
%122 = getelementptr inbounds [3 x i8*], [3 x i8*]* %17, i64 0, i64 0
%123 = load i8*, i8** %16
store i8* %123, i8** %122
%124 = getelementptr inbounds i8*, i8** %122, i64 1
%125 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
store i8* %125, i8** %124
%126 = getelementptr inbounds i8*, i8** %124, i64 1
store i8* null, i8** %126
%127 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %127)
%129 = load i8*, i8** %16
%130 = getelementptr inbounds [3 x i8*], [3 x i8*]* %17, i64 0, i64 0
%131 = call i32 @execv(i8* %129, i8** %130)
%132 = icmp eq i32 %131, -1
br i1 %132, label %133, label %139
133: ; preds = %112
br label %134
134: ; preds = %133
%135 = load i32, i32* @stderr
%136 = call i32 @fprintf(i32 %135, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 96, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%137 = call i32 @exit(i32 0)
unreachable
138: ; No predecessors!
br label %139
139: ; preds = %138, %112
br label %140
140: ; preds = %139, %109
%141 = call i32 @sleep(i32 1)
%142 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%143 = load i32, i32* %142
%144 = call i32 @close(i32 %143)
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
%146 = load i32, i32* @AF_UNIX
%147 = load i32, i32* @SOCK_STREAM
%148 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%149 = call i64 @socketpair(i32 %146, i32 %147, i32 0, i32* %148)
%150 = icmp ne i64 %149, 0
br i1 %150, label %151, label %157
151: ; preds = %140
br label %152
152: ; preds = %151
%153 = load i32, i32* @stderr
%154 = call i32 @fprintf(i32 %153, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 106, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%155 = call i32 @exit(i32 0)
unreachable
156: ; No predecessors!
br label %157
157: ; preds = %156, %140
%158 = call i32 (...) @fork()
store i32 %158, i32* %13
%159 = icmp eq i32 %158, 0
br i1 %159, label %160, label %188
160: ; preds = %157
%161 = call i32 @setresuid(i32 1002, i32 1002, i32 1002)
%162 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%163 = load i32, i32* %162
%164 = call i32 @close(i32 %163)
%165 = bitcast [32 x i8]* %19 to i8*
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8** %20
%166 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%167 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%168 = load i32, i32* %167
%169 = call i32 @sprintf(i8* %166, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %168)
%170 = getelementptr inbounds [3 x i8*], [3 x i8*]* %21, i64 0, i64 0
%171 = load i8*, i8** %20
store i8* %171, i8** %170
%172 = getelementptr inbounds i8*, i8** %170, i64 1
%173 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
store i8* %173, i8** %172
%174 = getelementptr inbounds i8*, i8** %172, i64 1
store i8* null, i8** %174
%175 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i8* %175)
%177 = load i8*, i8** %20
%178 = getelementptr inbounds [3 x i8*], [3 x i8*]* %21, i64 0, i64 0
%179 = call i32 @execv(i8* %177, i8** %178)
%180 = icmp eq i32 %179, -1
br i1 %180, label %181, label %187
181: ; preds = %160
br label %182
182: ; preds = %181
%183 = load i32, i32* @stderr
%184 = call i32 @fprintf(i32 %183, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%185 = call i32 @exit(i32 0)
unreachable
186: ; No predecessors!
br label %187
187: ; preds = %186, %160
br label %188
188: ; preds = %187, %157
%189 = call i32 @sleep(i32 1)
%190 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%191 = load i32, i32* %190
%192 = call i32 @close(i32 %191)
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.16, i64 0, i64 0))
%194 = load i32, i32* @AF_UNIX
%195 = load i32, i32* @SOCK_STREAM
%196 = getelementptr inbounds [2 x i32], [2 x i32]* %22, i64 0, i64 0
%197 = call i64 @socketpair(i32 %194, i32 %195, i32 0, i32* %196)
%198 = icmp ne i64 %197, 0
br i1 %198, label %199, label %205
199: ; preds = %188
br label %200
200: ; preds = %199
%201 = load i32, i32* @stderr
%202 = call i32 @fprintf(i32 %201, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 138, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%203 = call i32 @exit(i32 0)
unreachable
204: ; No predecessors!
br label %205
205: ; preds = %204, %188
%206 = call i32 (...) @fork()
store i32 %206, i32* %13
%207 = icmp eq i32 %206, 0
br i1 %207, label %208, label %236
208: ; preds = %205
%209 = call i32 @setresuid(i32 1003, i32 1003, i32 1003)
%210 = getelementptr inbounds [2 x i32], [2 x i32]* %22, i64 0, i64 1
%211 = load i32, i32* %210
%212 = call i32 @close(i32 %211)
%213 = bitcast [32 x i8]* %23 to i8*
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8** %24
%214 = getelementptr inbounds [32 x i8], [32 x i8]* %23, i64 0, i64 0
%215 = getelementptr inbounds [2 x i32], [2 x i32]* %22, i64 0, i64 0
%216 = load i32, i32* %215
%217 = call i32 @sprintf(i8* %214, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %216)
%218 = getelementptr inbounds [3 x i8*], [3 x i8*]* %25, i64 0, i64 0
%219 = load i8*, i8** %24
store i8* %219, i8** %218
%220 = getelementptr inbounds i8*, i8** %218, i64 1
%221 = getelementptr inbounds [32 x i8], [32 x i8]* %23, i64 0, i64 0
store i8* %221, i8** %220
%222 = getelementptr inbounds i8*, i8** %220, i64 1
store i8* null, i8** %222
%223 = getelementptr inbounds [32 x i8], [32 x i8]* %23, i64 0, i64 0
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i8* %223)
%225 = load i8*, i8** %24
%226 = getelementptr inbounds [3 x i8*], [3 x i8*]* %25, i64 0, i64 0
%227 = call i32 @execv(i8* %225, i8** %226)
%228 = icmp eq i32 %227, -1
br i1 %228, label %229, label %235
229: ; preds = %208
br label %230
230: ; preds = %229
%231 = load i32, i32* @stderr
%232 = call i32 @fprintf(i32 %231, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 159, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%233 = call i32 @exit(i32 0)
unreachable
234: ; No predecessors!
br label %235
235: ; preds = %234, %208
br label %236
236: ; preds = %235, %205
%237 = call i32 @sleep(i32 1)
%238 = getelementptr inbounds [2 x i32], [2 x i32]* %22, i64 0, i64 0
%239 = load i32, i32* %238
%240 = call i32 @close(i32 %239)
%241 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.19, i64 0, i64 0))
%242 = bitcast [32 x i8]* %26 to i8*
%243 = getelementptr inbounds [32 x i8], [32 x i8]* %26, i64 0, i64 0
%244 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%245 = load i32, i32* %244
%246 = call i32 @sprintf(i8* %243, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %245)
%247 = getelementptr inbounds [2 x i32], [2 x i32]* %22, i64 0, i64 1
%248 = load i32, i32* %247
%249 = getelementptr inbounds [32 x i8], [32 x i8]* %26, i64 0, i64 0
%250 = getelementptr inbounds [32 x i8], [32 x i8]* %26, i64 0, i64 0
%251 = call i64 @strlen(i8* %250)
%252 = add nsw i64 %251, 1
%253 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%254 = load i32, i32* %253
%255 = call i32 @sendfd(i32 %248, i8* %249, i64 %252, i32 %254)
%256 = icmp eq i32 -1, %255
br i1 %256, label %257, label %263
257: ; preds = %236
br label %258
258: ; preds = %257
%259 = load i32, i32* @stderr
%260 = call i32 @fprintf(i32 %259, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 170, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
%261 = call i32 @exit(i32 0)
unreachable
262: ; No predecessors!
br label %263
263: ; preds = %262, %236
%264 = getelementptr inbounds [32 x i8], [32 x i8]* %26, i64 0, i64 0
%265 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0), i8* %264)
%266 = bitcast [32 x i8]* %27 to i8*
%267 = getelementptr inbounds [32 x i8], [32 x i8]* %27, i64 0, i64 0
%268 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%269 = load i32, i32* %268
%270 = call i32 @sprintf(i8* %267, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %269)
%271 = getelementptr inbounds [2 x i32], [2 x i32]* %22, i64 0, i64 1
%272 = load i32, i32* %271
%273 = getelementptr inbounds [32 x i8], [32 x i8]* %27, i64 0, i64 0
%274 = getelementptr inbounds [32 x i8], [32 x i8]* %27, i64 0, i64 0
%275 = call i64 @strlen(i8* %274)
%276 = add nsw i64 %275, 1
%277 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%278 = load i32, i32* %277
%279 = call i32 @sendfd(i32 %272, i8* %273, i64 %276, i32 %278)
%280 = icmp eq i32 -1, %279
br i1 %280, label %281, label %287
281: ; preds = %263
br label %282
282: ; preds = %281
%283 = load i32, i32* @stderr
%284 = call i32 @fprintf(i32 %283, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 176, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
%285 = call i32 @exit(i32 0)
unreachable
286: ; No predecessors!
br label %287
287: ; preds = %286, %263
%288 = getelementptr inbounds [32 x i8], [32 x i8]* %27, i64 0, i64 0
%289 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0), i8* %288)
%290 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%291 = load i32, i32* %290
%292 = call i32 @close(i32 %291)
%293 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%294 = load i32, i32* %293
%295 = call i32 @close(i32 %294)
br label %296
296: ; preds = %287, %334
%297 = load i32, i32* %6
%298 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%299 = call i32 @accept(i32 %297, %struct.sockaddr* %298, i32* %28)
store i32 %299, i32* %7
%300 = icmp eq i32 %299, -1
br i1 %300, label %301, label %307
301: ; preds = %296
br label %302
302: ; preds = %301
%303 = load i32, i32* @stderr
%304 = call i32 @fprintf(i32 %303, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 188, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.22, i64 0, i64 0))
%305 = call i32 @exit(i32 0)
unreachable
306: ; No predecessors!
br label %307
307: ; preds = %306, %296
%308 = load i32, i32* %7
%309 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.23, i64 0, i64 0), i32 %308)
%310 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%311 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %310, i32 0, i32 0
%312 = load i64, i64* %311
%313 = call i8* @inet_ntoa(i64 %312)
%314 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%315 = load i32, i32* %314
%316 = call i32 @ntohs(i32 %315)
%317 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.24, i64 0, i64 0), i8* %313, i32 %316)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.25, i64 0, i64 0), i8** %29
%318 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.26, i64 0, i64 0))
%319 = getelementptr inbounds [2 x i32], [2 x i32]* %22, i64 0, i64 1
%320 = load i32, i32* %319
%321 = load i8*, i8** %29
%322 = load i8*, i8** %29
%323 = call i64 @strlen(i8* %322)
%324 = add nsw i64 %323, 1
%325 = load i32, i32* %7
%326 = call i32 @sendfd(i32 %320, i8* %321, i64 %324, i32 %325)
%327 = icmp eq i32 -1, %326
br i1 %327, label %328, label %334
328: ; preds = %307
br label %329
329: ; preds = %328
%330 = load i32, i32* @stderr
%331 = call i32 @fprintf(i32 %330, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 203, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.27, i64 0, i64 0))
%332 = call i32 @exit(i32 0)
unreachable
333: ; No predecessors!
br label %334
334: ; preds = %333, %307
%335 = load i32, i32* %7
%336 = call i32 @close(i32 %335)
br label %296
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"Error: %s:%d: %s\0A\00"
@.str.1 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/insertion/SEED_LAB/refs/heads/master/lab3/server.c\00"
@.str.2 = [18 x i8] c"creating a socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.3 = [35 x i8] c"setting socket option SO_REUSEADDR\00"
@AF_INET = global i32 0
@.str.4 = [18 x i8] c"binding to socket\00"
@.str.5 = [20 x i8] c"listening on socket\00"
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@.str.6 = [6 x i8] c"/jail\00"
@.str.7 = [2 x i8] c"/\00"
@AF_UNIX = global i32 0
@.str.8 = [11 x i8] c"socketpair\00"
@.str.9 = [9 x i8] c"./filesv\00"
@.str.10 = [3 x i8] c"%d\00"
@.str.11 = [14 x i8] c"file fd = %s\0A\00"
@.str.12 = [7 x i8] c"execve\00"
@.str.14 = [9 x i8] c"./banksv\00"
@.str.15 = [14 x i8] c"mail fd = %s\0A\00"
@.str.17 = [8 x i8] c"./httpd\00"
@.str.20 = [8 x i8] c"send fd\00"
@.str.21 = [15 x i8] c"sending %s...\0A\00"
@.str.22 = [28 x i8] c"accepting client connection\00"
@.str.23 = [35 x i8] c"Parent process client_sockfd = %d\0A\00"
@.str.24 = [44 x i8] c"server: accepting a client from %s port %d\0A\00"
@.str.25 = [14 x i8] c"hello, world\0A\00"
@.str.27 = [13 x i8] c"send sock fd\00"
@str = [34 x i8] c"the first web service launched...\00"
@str.28 = [35 x i8] c"the second web service launched...\00"
@str.29 = [40 x i8] c"the http dispatcher service launched...\00"
@str.30 = [32 x i8] c"sending a socket to the client:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca [2 x i32]
%7 = alloca [32 x i8]
%8 = alloca [3 x i8*]
%9 = alloca [2 x i32]
%10 = alloca [32 x i8]
%11 = alloca [3 x i8*]
%12 = alloca [2 x i32]
%13 = alloca [32 x i8]
%14 = alloca [3 x i8*]
%15 = alloca [32 x i8]
%16 = alloca [32 x i8]
%17 = alloca i32
%18 = bitcast i32* %3 to i8*
%19 = bitcast %struct.sockaddr_in* %4 to i8*
%20 = bitcast %struct.sockaddr_in* %5 to i8*
%21 = icmp sgt i32 %0, 1
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
br label %26
26: ; preds = %22, %2
%27 = phi i32 [ %25, %22 ], [ 80, %2 ]
%28 = load i32, i32* @PF_INET
%29 = load i32, i32* @SOCK_STREAM
%30 = tail call i32 @socket(i32 %28, i32 %29, i32 0)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 37, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%35 = tail call i32 @exit(i32 0)
unreachable
36: ; preds = %26
%37 = load i32, i32* @SOL_SOCKET
%38 = load i32, i32* @SO_REUSEADDR
%39 = call i32 @setsockopt(i32 %30, i32 %37, i32 %38, i32* %3, i32 4)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 41, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @exit(i32 0)
unreachable
45: ; preds = %36
%46 = call i32 @memset(%struct.sockaddr_in* %4, i8 signext 0, i32 24)
%47 = load i32, i32* @AF_INET
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %47, i32* %48
%49 = call i32 @htons(i32 %27)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %49, i32* %50
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i64 0, i64* %51
%52 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%53 = call i32 @bind(i32 %30, %struct.sockaddr* %52, i32 4)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %59
55: ; preds = %45
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%58 = call i32 @exit(i32 0)
unreachable
59: ; preds = %45
%60 = call i32 @listen(i32 %30, i32 1000)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 53, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%65 = call i32 @exit(i32 0)
unreachable
66: ; preds = %59
%67 = load i32, i32* @SIGCHLD
%68 = load i32, i32* @SIG_IGN
%69 = call i32 @signal(i32 %67, i32 %68)
%70 = load i32, i32* @SIGPIPE
%71 = load i32, i32* @SIG_IGN
%72 = call i32 @signal(i32 %70, i32 %71)
%73 = call i32 @chroot(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%74 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%75 = bitcast [2 x i32]* %6 to i8*
%76 = load i32, i32* @AF_UNIX
%77 = load i32, i32* @SOCK_STREAM
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%79 = call i64 @socketpair(i32 %76, i32 %77, i32 0, i32* %78)
%80 = icmp eq i64 %79, 0
br i1 %80, label %85, label %81
81: ; preds = %66
%82 = load i32, i32* @stderr
%83 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 74, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%84 = call i32 @exit(i32 0)
unreachable
85: ; preds = %66
%86 = call i32 (...) @fork()
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %108
88: ; preds = %85
%89 = call i32 @setresuid(i32 1000, i32 1000, i32 1000)
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%91 = load i32, i32* %90
%92 = call i32 @close(i32 %91)
%93 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%94 = load i32, i32* %78
%95 = call i32 @sprintf(i8* %93, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %94)
%96 = bitcast [3 x i8*]* %8 to i8*
%97 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8** %97
%98 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 1
store i8* %93, i8** %98
%99 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 2
store i8* null, i8** %99
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %93)
%101 = call i32 @execv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8** %97)
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %107
103: ; preds = %88
%104 = load i32, i32* @stderr
%105 = call i32 @fprintf(i32 %104, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 96, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%106 = call i32 @exit(i32 0)
unreachable
107: ; preds = %88
br label %108
108: ; preds = %107, %85
%109 = call i32 @sleep(i32 1)
%110 = load i32, i32* %78
%111 = call i32 @close(i32 %110)
%112 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%113 = bitcast [2 x i32]* %9 to i8*
%114 = load i32, i32* @AF_UNIX
%115 = load i32, i32* @SOCK_STREAM
%116 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%117 = call i64 @socketpair(i32 %114, i32 %115, i32 0, i32* %116)
%118 = icmp eq i64 %117, 0
br i1 %118, label %123, label %119
119: ; preds = %108
%120 = load i32, i32* @stderr
%121 = call i32 @fprintf(i32 %120, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 106, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%122 = call i32 @exit(i32 0)
unreachable
123: ; preds = %108
%124 = call i32 (...) @fork()
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %146
126: ; preds = %123
%127 = call i32 @setresuid(i32 1002, i32 1002, i32 1002)
%128 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%129 = load i32, i32* %128
%130 = call i32 @close(i32 %129)
%131 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%132 = load i32, i32* %116
%133 = call i32 @sprintf(i8* %131, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %132)
%134 = bitcast [3 x i8*]* %11 to i8*
%135 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8** %135
%136 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 1
store i8* %131, i8** %136
%137 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 2
store i8* null, i8** %137
%138 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i8* %131)
%139 = call i32 @execv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8** %135)
%140 = icmp eq i32 %139, -1
br i1 %140, label %141, label %145
141: ; preds = %126
%142 = load i32, i32* @stderr
%143 = call i32 @fprintf(i32 %142, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%144 = call i32 @exit(i32 0)
unreachable
145: ; preds = %126
br label %146
146: ; preds = %145, %123
%147 = call i32 @sleep(i32 1)
%148 = load i32, i32* %116
%149 = call i32 @close(i32 %148)
%150 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.28, i64 0, i64 0))
%151 = bitcast [2 x i32]* %12 to i8*
%152 = load i32, i32* @AF_UNIX
%153 = load i32, i32* @SOCK_STREAM
%154 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%155 = call i64 @socketpair(i32 %152, i32 %153, i32 0, i32* %154)
%156 = icmp eq i64 %155, 0
br i1 %156, label %161, label %157
157: ; preds = %146
%158 = load i32, i32* @stderr
%159 = call i32 @fprintf(i32 %158, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 138, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%160 = call i32 @exit(i32 0)
unreachable
161: ; preds = %146
%162 = call i32 (...) @fork()
%163 = icmp eq i32 %162, 0
br i1 %163, label %164, label %184
164: ; preds = %161
%165 = call i32 @setresuid(i32 1003, i32 1003, i32 1003)
%166 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%167 = load i32, i32* %166
%168 = call i32 @close(i32 %167)
%169 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%170 = load i32, i32* %154
%171 = call i32 @sprintf(i8* %169, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %170)
%172 = bitcast [3 x i8*]* %14 to i8*
%173 = getelementptr inbounds [3 x i8*], [3 x i8*]* %14, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8** %173
%174 = getelementptr inbounds [3 x i8*], [3 x i8*]* %14, i64 0, i64 1
store i8* %169, i8** %174
%175 = getelementptr inbounds [3 x i8*], [3 x i8*]* %14, i64 0, i64 2
store i8* null, i8** %175
%176 = call i32 @puts(i8* %169)
%177 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8** %173)
%178 = icmp eq i32 %177, -1
br i1 %178, label %179, label %183
179: ; preds = %164
%180 = load i32, i32* @stderr
%181 = call i32 @fprintf(i32 %180, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 159, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%182 = call i32 @exit(i32 0)
unreachable
183: ; preds = %164
br label %184
184: ; preds = %183, %161
%185 = call i32 @sleep(i32 1)
%186 = load i32, i32* %154
%187 = call i32 @close(i32 %186)
%188 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.29, i64 0, i64 0))
%189 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%190 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%191 = load i32, i32* %190
%192 = call i32 @sprintf(i8* %189, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %191)
%193 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%194 = load i32, i32* %193
%195 = call i64 @strlen(i8* %189)
%196 = add nsw i64 %195, 1
%197 = load i32, i32* %190
%198 = call i32 @sendfd(i32 %194, i8* %189, i64 %196, i32 %197)
%199 = icmp eq i32 %198, -1
br i1 %199, label %200, label %204
200: ; preds = %184
%201 = load i32, i32* @stderr
%202 = call i32 @fprintf(i32 %201, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 170, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
%203 = call i32 @exit(i32 0)
unreachable
204: ; preds = %184
%205 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0), i8* %189)
%206 = getelementptr inbounds [32 x i8], [32 x i8]* %16, i64 0, i64 0
%207 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%208 = load i32, i32* %207
%209 = call i32 @sprintf(i8* %206, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %208)
%210 = load i32, i32* %193
%211 = call i64 @strlen(i8* %206)
%212 = add nsw i64 %211, 1
%213 = load i32, i32* %207
%214 = call i32 @sendfd(i32 %210, i8* %206, i64 %212, i32 %213)
%215 = icmp eq i32 %214, -1
br i1 %215, label %216, label %220
216: ; preds = %204
%217 = load i32, i32* @stderr
%218 = call i32 @fprintf(i32 %217, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 176, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
%219 = call i32 @exit(i32 0)
unreachable
220: ; preds = %204
%221 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0), i8* %206)
%222 = load i32, i32* %190
%223 = call i32 @close(i32 %222)
%224 = load i32, i32* %207
%225 = call i32 @close(i32 %224)
%226 = bitcast i32* %17 to i8*
%227 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%228 = call i32 @accept(i32 %30, %struct.sockaddr* %227, i32* %17)
%229 = icmp eq i32 %228, -1
br i1 %229, label %233, label %230
230: ; preds = %220
%231 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
%232 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
br label %237
233: ; preds = %253, %220
%234 = load i32, i32* @stderr
%235 = call i32 @fprintf(i32 %234, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 188, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.22, i64 0, i64 0))
%236 = call i32 @exit(i32 0)
unreachable
237: ; preds = %230, %253
%238 = phi i32 [ %228, %230 ], [ %255, %253 ]
%239 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.23, i64 0, i64 0), i32 %238)
%240 = load i64, i64* %231
%241 = call i8* @inet_ntoa(i64 %240)
%242 = load i32, i32* %232
%243 = call i32 @ntohs(i32 %242)
%244 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.24, i64 0, i64 0), i8* %241, i32 %243)
%245 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.30, i64 0, i64 0))
%246 = load i32, i32* %193
%247 = call i32 @sendfd(i32 %246, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.25, i64 0, i64 0), i64 14, i32 %238)
%248 = icmp eq i32 %247, -1
br i1 %248, label %249, label %253
249: ; preds = %237
%250 = load i32, i32* @stderr
%251 = call i32 @fprintf(i32 %250, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 203, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.27, i64 0, i64 0))
%252 = call i32 @exit(i32 0)
unreachable
253: ; preds = %237
%254 = call i32 @close(i32 %238)
%255 = call i32 @accept(i32 %30, %struct.sockaddr* %227, i32* %17)
%256 = icmp eq i32 %255, -1
br i1 %256, label %233, label %237
}