#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*/ PF_INET;
int /*<<< orphan*/ SIGCHLD;
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*/ close(int);
int execve(char *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ htons(int);
scalar_t__ inet_ntoa(TYPE_1__);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, char, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
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 = 8989;
  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/"
              "lab1/server.c",
              32, "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/"
              "lab1/server.c",
              36, "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/"
              "lab1/server.c",
              44, "binding to socket");
      exit(0);
    } while (0);
  if (listen(sockfd, 100) == -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/"
              "lab1/server.c",
              47, "listening on socket");
      exit(0);
    } while (0);
  signal(SIGCHLD, SIG_IGN);
  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/lab1/server.c",
                52, "accepting client connection");
        exit(0);
      } while (0);
    if (1)
      printf("server: accepting a client from %s port %d\n",
             (char *)inet_ntoa(client_addr.sin_addr),
             ntohs(client_addr.sin_port));
    int pid;
    if ((pid = fork()) == 0) {
      char client_fd_str[32] = {'\0'};
      char *child_name = "./httpd";
      char *child_argv[] = {child_name, client_fd_str, 0};
      sprintf(client_fd_str, "%d", client_sockfd);
      printf("%s\n", client_fd_str);
      if (execve(child_name, child_argv, 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/lab1/server.c",
                  68, "execve");
          exit(0);
        } while (0);
    } else
      close(client_sockfd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x231d,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    125a <main+0x3a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12b3 <main+0x93>
jmp    1284 <main+0x64>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xd6c(%rip),%rsi
lea    0xd77(%rip),%rdx
mov    $0x20,%ecx
lea    0xdf8(%rip),%r8
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
mov    0x2ce2(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    1314 <main+0xf4>
jmp    12e5 <main+0xc5>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
lea    0xd0b(%rip),%rsi
lea    0xd16(%rip),%rdx
mov    $0x24,%ecx
lea    0xda9(%rip),%r8
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
lea    -0x438(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x428(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x438(%rbp)
movq   $0x0,-0x430(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x438(%rbp),%rsi
mov    $0x4,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    13a0 <main+0x180>
jmp    1371 <main+0x151>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
lea    0xc7f(%rip),%rsi
lea    0xc8a(%rip),%rdx
mov    $0x2c,%ecx
lea    0xd40(%rip),%r8
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x64,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    13ea <main+0x1ca>
jmp    13bb <main+0x19b>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
lea    0xc35(%rip),%rsi
lea    0xc40(%rip),%rdx
mov    $0x2f,%ecx
lea    0xd08(%rip),%r8
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    0x2be7(%rip),%rax
mov    (%rax),%edi
mov    0x2bd6(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
mov    -0x14(%rbp),%edi
lea    -0x450(%rbp),%rsi
lea    -0x454(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1457 <main+0x237>
jmp    1428 <main+0x208>
mov    0x2b91(%rip),%rax
mov    (%rax),%edi
lea    0xbc8(%rip),%rsi
lea    0xbd3(%rip),%rdx
mov    $0x34,%ecx
lea    0xcaf(%rip),%r8
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    -0x448(%rbp),%rdi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x4a8(%rbp)
mov    -0x450(%rbp),%edi
call   10d0 <ntohs@plt>
mov    -0x4a8(%rbp),%rsi
mov    %eax,%edx
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %eax,-0x458(%rbp)
cmp    $0x0,%eax
jne    156c <main+0x34c>
lea    -0x480(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
lea    0xc86(%rip),%rax
mov    %rax,-0x488(%rbp)
mov    -0x488(%rbp),%rax
mov    %rax,-0x4a0(%rbp)
lea    -0x480(%rbp),%rax
mov    %rax,-0x498(%rbp)
movq   $0x0,-0x490(%rbp)
lea    -0x480(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xc4f(%rip),%rsi
call   1110 <sprintf@plt>
lea    -0x480(%rbp),%rsi
lea    0xb00(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x488(%rbp),%rdi
lea    -0x4a0(%rbp),%rsi
xor    %edx,%edx
call   1090 <execve@plt>
cmp    $0xffffffff,%eax
jne    1567 <main+0x347>
jmp    1538 <main+0x318>
mov    0x2a81(%rip),%rax
mov    (%rax),%edi
lea    0xab8(%rip),%rsi
lea    0xac3(%rip),%rdx
mov    $0x44,%ecx
lea    0xbf2(%rip),%r8
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
jmp    1574 <main+0x354>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
jmp    1401 <main+0x1e1>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    $0x231d,%ebx
cmp    $0x2,%edi
jl     1246 <main+0x26>
mov    0x8(%rsi),%rdi
call   1100 <atoi@plt>
mov    %eax,%ebx
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
mov    0x2d62(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
cmp    $0xffffffff,%eax
jne    128c <main+0x6c>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    0xd8c(%rip),%rsi
lea    0xd97(%rip),%rdx
lea    0xe1d(%rip),%r8
mov    $0x20,%ecx
jmp    13db <main+0x1bb>
mov    %eax,%r13d
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
mov    0x2d09(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %r13d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    12e1 <main+0xc1>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
lea    0xd37(%rip),%rsi
lea    0xd42(%rip),%rdx
lea    0xdda(%rip),%r8
mov    $0x24,%ecx
jmp    13db <main+0x1bb>
lea    0x48(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x58(%rsp)
mov    %ebx,%edi
call   1050 <htons@plt>
mov    %eax,0x48(%rsp)
movq   $0x0,0x50(%rsp)
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1353 <main+0x133>
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
lea    0xcc5(%rip),%rsi
lea    0xcd0(%rip),%rdx
lea    0xd8b(%rip),%r8
mov    $0x2c,%ecx
jmp    13db <main+0x1bb>
mov    %r13d,%edi
mov    $0x64,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    138a <main+0x16a>
mov    0x2c54(%rip),%rax
mov    (%rax),%edi
lea    0xc8b(%rip),%rsi
lea    0xc96(%rip),%rdx
lea    0xd63(%rip),%r8
mov    $0x2f,%ecx
jmp    13db <main+0x1bb>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
mov    0x2c36(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
lea    0x30(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r13d,%edi
call   10f0 <accept@plt>
cmp    $0xffffffff,%eax
jne    13e7 <main+0x1c7>
mov    0x2c01(%rip),%rax
mov    (%rax),%edi
lea    0xc38(%rip),%rsi
lea    0xc43(%rip),%rdx
lea    0xd24(%rip),%r8
mov    $0x34,%ecx
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    %eax,%r15d
lea    0x60(%rsp),%r12
lea    0x30(%rsp),%rbp
lea    0x8(%rsp),%rbx
jmp    141e <main+0x1fe>
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1080 <close@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   10f0 <accept@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
je     13b8 <main+0x198>
mov    0x38(%rsp),%rdi
call   1040 <inet_ntoa@plt>
mov    %rax,%r14
mov    0x30(%rsp),%edi
call   10d0 <ntohs@plt>
lea    0xcdb(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
jne    1400 <main+0x1e0>
mov    %rbx,%r14
mov    %rbp,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
lea    0xcd6(%rip),%rbp
mov    %rbp,0x10(%rsp)
mov    %r12,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mov    %r12,%rdi
lea    0xcc1(%rip),%rsi
mov    %r15d,%edx
call   1110 <sprintf@plt>
lea    0xb76(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1090 <execve@plt>
cmp    $0xffffffff,%eax
je     14c1 <main+0x2a1>
mov    %rbx,%rbp
mov    %r14,%rbx
jmp    1408 <main+0x1e8>
mov    0x2af8(%rip),%rax
mov    (%rax),%edi
lea    0xb2f(%rip),%rsi
lea    0xb3a(%rip),%rdx
lea    0xc6e(%rip),%r8
mov    $0x44,%ecx
jmp    13db <main+0x1bb>

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/lab1/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
@.str.6 = [28 x i8] c"accepting client connection\00"
@.str.7 = [44 x i8] c"server: accepting a client from %s port %d\0A\00"
@.str.8 = [8 x i8] c"./httpd\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [4 x i8] c"%s\0A\00"
@.str.11 = [7 x i8] c"execve\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 i32
%15 = alloca [32 x i8]
%16 = alloca i8*
%17 = alloca [3 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 8989, i32* %8
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %8
br label %25
25: ; preds = %20, %2
%26 = load i32, i32* @PF_INET
%27 = load i32, i32* @SOCK_STREAM
%28 = call i32 @socket(i32 %26, i32 %27, i32 0)
store i32 %28, i32* %6
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %36
30: ; preds = %25
br label %31
31: ; preds = %30
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, 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 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @exit(i32 0)
unreachable
35: ; No predecessors!
br label %36
36: ; preds = %35, %25
%37 = load i32, i32* %6
%38 = load i32, i32* @SOL_SOCKET
%39 = load i32, i32* @SO_REUSEADDR
%40 = call i32 @setsockopt(i32 %37, i32 %38, i32 %39, i32* %9, i32 4)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %48
42: ; preds = %36
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 36, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @exit(i32 0)
unreachable
47: ; No predecessors!
br label %48
48: ; preds = %47, %36
%49 = call i32 @memset(%struct.sockaddr_in* %11, i8 signext 0, i32 24)
%50 = load i32, i32* @AF_INET
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %50, i32* %51
%52 = load i32, i32* %8
%53 = call i32 @htons(i32 %52)
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %53, i32* %54
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
store i64 0, i64* %56
%57 = load i32, i32* %6
%58 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%59 = call i32 @bind(i32 %57, %struct.sockaddr* %58, i32 4)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %67
61: ; preds = %48
br label %62
62: ; preds = %61
%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 44, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%65 = call i32 @exit(i32 0)
unreachable
66: ; No predecessors!
br label %67
67: ; preds = %66, %48
%68 = load i32, i32* %6
%69 = call i32 @listen(i32 %68, i32 100)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %77
71: ; preds = %67
br label %72
72: ; preds = %71
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, 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 47, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%75 = call i32 @exit(i32 0)
unreachable
76: ; No predecessors!
br label %77
77: ; preds = %76, %67
%78 = load i32, i32* @SIGCHLD
%79 = load i32, i32* @SIG_IGN
%80 = call i32 @signal(i32 %78, i32 %79)
br label %81
81: ; preds = %77, %130
%82 = load i32, i32* %6
%83 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%84 = call i32 @accept(i32 %82, %struct.sockaddr* %83, i32* %13)
store i32 %84, i32* %7
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %92
86: ; preds = %81
br label %87
87: ; preds = %86
%88 = load i32, i32* @stderr
%89 = call i32 @fprintf(i32 %88, 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 52, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%90 = call i32 @exit(i32 0)
unreachable
91: ; No predecessors!
br label %92
92: ; preds = %91, %81
%93 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%94 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %93, i32 0, i32 0
%95 = load i64, i64* %94
%96 = call i64 @inet_ntoa(i64 %95)
%97 = inttoptr i64 %96 to i8*
%98 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%99 = load i32, i32* %98
%100 = call i32 @ntohs(i32 %99)
%101 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i8* %97, i32 %100)
%102 = call i32 (...) @fork()
store i32 %102, i32* %14
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %127
104: ; preds = %92
%105 = bitcast [32 x i8]* %15 to i8*
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %16
%106 = getelementptr inbounds [3 x i8*], [3 x i8*]* %17, i64 0, i64 0
%107 = load i8*, i8** %16
store i8* %107, i8** %106
%108 = getelementptr inbounds i8*, i8** %106, i64 1
%109 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
store i8* %109, i8** %108
%110 = getelementptr inbounds i8*, i8** %108, i64 1
store i8* null, i8** %110
%111 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%112 = load i32, i32* %7
%113 = call i32 @sprintf(i8* %111, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %112)
%114 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%115 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %114)
%116 = load i8*, i8** %16
%117 = getelementptr inbounds [3 x i8*], [3 x i8*]* %17, i64 0, i64 0
%118 = call i32 @execve(i8* %116, i8** %117, i32 0)
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %126
120: ; preds = %104
br label %121
121: ; preds = %120
%122 = load i32, i32* @stderr
%123 = call i32 @fprintf(i32 %122, 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 68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%124 = call i32 @exit(i32 0)
unreachable
125: ; No predecessors!
br label %126
126: ; preds = %125, %104
br label %130
127: ; preds = %92
%128 = load i32, i32* %7
%129 = call i32 @close(i32 %128)
br label %130
130: ; preds = %127, %126
br label %81
}

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/lab1/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
@.str.6 = [28 x i8] c"accepting client connection\00"
@.str.7 = [44 x i8] c"server: accepting a client from %s port %d\0A\00"
@.str.8 = [8 x i8] c"./httpd\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [4 x i8] c"%s\0A\00"
@.str.11 = [7 x i8] c"execve\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca [3 x i8*]
%9 = bitcast i32* %3 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = bitcast %struct.sockaddr_in* %5 to i8*
%12 = icmp sgt i32 %0, 1
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
br label %17
17: ; preds = %13, %2
%18 = phi i32 [ %16, %13 ], [ 8989, %2 ]
%19 = load i32, i32* @PF_INET
%20 = load i32, i32* @SOCK_STREAM
%21 = tail call i32 @socket(i32 %19, i32 %20, i32 0)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, 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 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%26 = tail call i32 @exit(i32 0)
unreachable
27: ; preds = %17
%28 = load i32, i32* @SOL_SOCKET
%29 = load i32, i32* @SO_REUSEADDR
%30 = call i32 @setsockopt(i32 %21, i32 %28, i32 %29, i32* %3, i32 4)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i32, i32* @stderr
%34 = 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 36, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %27
%37 = call i32 @memset(%struct.sockaddr_in* %4, i8 signext 0, i32 24)
%38 = load i32, i32* @AF_INET
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %38, i32* %39
%40 = call i32 @htons(i32 %18)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %40, i32* %41
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i64 0, i64* %42
%43 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%44 = call i32 @bind(i32 %21, %struct.sockaddr* %43, i32 4)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %50
46: ; preds = %36
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, 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 44, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%49 = call i32 @exit(i32 0)
unreachable
50: ; preds = %36
%51 = call i32 @listen(i32 %21, i32 100)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, 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 47, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 @exit(i32 0)
unreachable
57: ; preds = %50
%58 = load i32, i32* @SIGCHLD
%59 = load i32, i32* @SIG_IGN
%60 = call i32 @signal(i32 %58, i32 %59)
%61 = bitcast i32* %6 to i8*
%62 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%63 = call i32 @accept(i32 %21, %struct.sockaddr* %62, i32* %6)
%64 = icmp eq i32 %63, -1
br i1 %64, label %73, label %65
65: ; preds = %57
%66 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
%68 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%69 = bitcast [3 x i8*]* %8 to i8*
%70 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
%71 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 1
%72 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 2
br label %77
73: ; preds = %99, %57
%74 = load i32, i32* @stderr
%75 = call i32 @fprintf(i32 %74, 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 52, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%76 = call i32 @exit(i32 0)
unreachable
77: ; preds = %65, %99
%78 = phi i32 [ %63, %65 ], [ %100, %99 ]
%79 = load i64, i64* %66
%80 = call i64 @inet_ntoa(i64 %79)
%81 = inttoptr i64 %80 to i8*
%82 = load i32, i32* %67
%83 = call i32 @ntohs(i32 %82)
%84 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i8* %81, i32 %83)
%85 = call i32 (...) @fork()
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %97
87: ; preds = %77
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %70
store i8* %68, i8** %71
store i8* null, i8** %72
%88 = call i32 @sprintf(i8* %68, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %78)
%89 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %68)
%90 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %70, i32 0)
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %96
92: ; preds = %87
%93 = load i32, i32* @stderr
%94 = call i32 @fprintf(i32 %93, 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 68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%95 = call i32 @exit(i32 0)
unreachable
96: ; preds = %87
br label %99
97: ; preds = %77
%98 = call i32 @close(i32 %78)
br label %99
99: ; preds = %97, %96
%100 = call i32 @accept(i32 %21, %struct.sockaddr* %62, i32* %6)
%101 = icmp eq i32 %100, -1
br i1 %101, label %73, label %77
}