#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef size_t ssize_t;
typedef int /*<<< orphan*/ servaddr;
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EOF;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fputs(char *, int /*<<< orphan*/);
int getpid();
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
size_t read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int listenfd, connfd;
  struct sockaddr_in servaddr;
  pid_t childpid;
  char recvline[4096 + 1];
  ssize_t n;
  if (argc != 2) {
    fprintf(stderr, "Uso: %s <Porta>\n", argv[0]);
    fprintf(stderr, "Vai rodar um servidor de echo na porta <Porta> TCP\n");
    exit(1);
  }
  if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    perror("socket :(\n");
    exit(2);
  }
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr.sin_port = htons(atoi(argv[1]));
  if (bind(listenfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == -1) {
    perror("bind :(\n");
    exit(3);
  }
  if (listen(listenfd, 1) == -1) {
    perror("listen :(\n");
    exit(4);
  }
  printf("[Servidor no ar. Aguardando conexoes na porta %s]\n", argv[1]);
  printf("[Para finalizar, pressione CTRL+c ou rode um kill ou killall]\n");
  for (;;) {
    if ((connfd = accept(listenfd, (struct sockaddr *)NULL, NULL)) == -1) {
      perror("accept :(\n");
      exit(5);
    }
    if ((childpid = fork()) == 0) {
      printf("[Uma conexao aberta]\n");
      close(listenfd);
      while ((n = read(connfd, recvline, 4096)) > 0) {
        recvline[n] = 0;
        printf("[Cliente conectado no processo filho %d enviou:] ", getpid());
        if ((fputs(recvline, stdout)) == EOF) {
          perror("fputs :( \n");
          exit(6);
        }
        write(connfd, recvline, strlen(recvline));
      }
      printf("[Uma conexao fechada]\n");
      exit(0);
    }
    close(connfd);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1292 <main+0x62>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
mov    0x2d1e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12cd <main+0x9d>
lea    0xd87(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x2d06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    133f <main+0x10f>
lea    0xd20(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   10d0 <listen@plt>
cmp    $0xffffffff,%eax
jne    136b <main+0x13b>
lea    0xcfd(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x4,%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1110 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    13c0 <main+0x190>
lea    0xd25(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x5,%edi
call   1130 <exit@plt>
mov    $0x0,%al
call   1140 <fork@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jne    14c0 <main+0x290>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    -0x18(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    $0x1000,%edx
call   10b0 <read@plt>
mov    %rax,-0x1038(%rbp)
cmp    $0x0,%rax
jbe    14ab <main+0x27b>
mov    -0x1038(%rbp),%rax
movb   $0x0,-0x1030(%rbp,%rax,1)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x1030(%rbp),%rdi
mov    0x2b76(%rip),%rax
mov    (%rax),%esi
call   1080 <fputs@plt>
mov    0x2b88(%rip),%rcx
cmp    (%rcx),%rax
jne    146f <main+0x23f>
lea    0xcc9(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x6,%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1044(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x1040(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x1044(%rbp),%edi
mov    -0x1040(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    13e9 <main+0x1b9>
lea    0xc82(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%edi
call   10a0 <close@plt>
jmp    138f <main+0x15f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1020,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    128c <main+0x4c>
mov    0x2d8a(%rip),%r15
mov    (%r15),%edi
mov    0x2d58(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
cmp    $0xffffffff,%eax
jne    12c1 <main+0x81>
lea    0xdc8(%rip),%rdi
call   1100 <perror@plt>
mov    $0x2,%edi
call   1140 <exit@plt>
mov    0x2d35(%rip),%rbx
mov    (%rbx),%edi
mov    0x0(%rbp),%rdx
lea    0xd60(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd61(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rsp)
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
call   10a0 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    0x8(%rbp),%rdi
call   1130 <atoi@plt>
mov    %eax,%edi
call   1070 <htons@plt>
mov    %eax,(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1329 <main+0xe9>
lea    0xd36(%rip),%rdi
call   1100 <perror@plt>
mov    $0x3,%edi
call   1140 <exit@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   10e0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1350 <main+0x110>
lea    0xd18(%rip),%rdi
call   1100 <perror@plt>
mov    $0x4,%edi
call   1140 <exit@plt>
mov    0x8(%rbp),%rsi
lea    0xd09(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd76(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1120 <accept@plt>
cmp    $0xffffffff,%eax
je     13a4 <main+0x164>
mov    %eax,%ebp
xor    %eax,%eax
call   1150 <fork@plt>
test   %eax,%eax
je     13ba <main+0x17a>
mov    %ebp,%edi
call   10b0 <close@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1120 <accept@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1380 <main+0x140>
lea    0xcec(%rip),%rdi
call   1100 <perror@plt>
mov    $0x5,%edi
call   1140 <exit@plt>
lea    0xd5c(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1000,%edx
call   10c0 <read@plt>
test   %rax,%rax
je     1451 <main+0x211>
lea    0xcb8(%rip),%r14
mov    0x2bc7(%rip),%r15
lea    0x10(%rsp),%rbx
mov    0x2bdb(%rip),%r12
nopl   (%rax)
movb   $0x0,0x10(%rsp,%rax,1)
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1090 <fputs@plt>
cmp    (%r12),%rax
je     1464 <main+0x224>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   10c0 <read@plt>
test   %rax,%rax
jne    1400 <main+0x1c0>
lea    0xcda(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1140 <exit@plt>
lea    0xc69(%rip),%rdi
call   1100 <perror@plt>
mov    $0x6,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [17 x i8] c"Uso: %s <Porta>\0A\00"
@.str.1 = [52 x i8] c"Vai rodar um servidor de echo na porta <Porta> TCP\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [11 x i8] c"socket :(\0A\00"
@INADDR_ANY = global i32 0
@.str.3 = [9 x i8] c"bind :(\0A\00"
@.str.4 = [11 x i8] c"listen :(\0A\00"
@.str.5 = [51 x i8] c"[Servidor no ar. Aguardando conexoes na porta %s]\0A\00"
@.str.6 = [63 x i8] c"[Para finalizar, pressione CTRL+c ou rode um kill ou killall]\0A\00"
@.str.7 = [11 x i8] c"accept :(\0A\00"
@.str.8 = [22 x i8] c"[Uma conexao aberta]\0A\00"
@.str.9 = [50 x i8] c"[Cliente conectado no processo filho %d enviou:] \00"
@stdout = global i32 0
@EOF = global i64 0
@.str.10 = [11 x i8] c"fputs :( \0A\00"
@.str.11 = [23 x i8] c"[Uma conexao fechada]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca [4097 x i8]
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %23
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i32, i32* @AF_INET
%25 = load i32, i32* @SOCK_STREAM
%26 = call i32 @socket(i32 %24, i32 %25, i32 0)
store i32 %26, i32* %6
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %23
%32 = call i32 @bzero(%struct.sockaddr_in* %8, i32 12)
%33 = load i32, i32* @AF_INET
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %33, i32* %34
%35 = load i32, i32* @INADDR_ANY
%36 = call i32 @htonl(i32 %35)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%38 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %37, i32 0, i32 0
store i32 %36, i32* %38
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @atoi(i8* %41)
%43 = call i32 @htons(i32 %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %43, i32* %44
%45 = load i32, i32* %6
%46 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%47 = call i32 @bind(i32 %45, %struct.sockaddr* %46, i32 12)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %52
49: ; preds = %31
%50 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%51 = call i32 @exit(i32 3)
unreachable
52: ; preds = %31
%53 = load i32, i32* %6
%54 = call i32 @listen(i32 %53, i32 1)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %52
%57 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%58 = call i32 @exit(i32 4)
unreachable
59: ; preds = %52
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 1
%62 = load i8*, i8** %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i8* %62)
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0))
br label %65
65: ; preds = %106, %59
%66 = load i32, i32* %6
%67 = call i32 @accept(i32 %66, %struct.sockaddr* null, i32* null)
store i32 %67, i32* %7
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%71 = call i32 @exit(i32 5)
unreachable
72: ; preds = %65
%73 = call i32 (...) @fork()
store i32 %73, i32* %9
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %106
75: ; preds = %72
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%77 = load i32, i32* %6
%78 = call i32 @close(i32 %77)
br label %79
79: ; preds = %97, %75
%80 = load i32, i32* %7
%81 = getelementptr inbounds [4097 x i8], [4097 x i8]* %10, i64 0, i64 0
%82 = call i64 @read(i32 %80, i8* %81, i32 4096)
store i64 %82, i64* %11
%83 = icmp ugt i64 %82, 0
br i1 %83, label %84, label %103
84: ; preds = %79
%85 = load i64, i64* %11
%86 = getelementptr inbounds [4097 x i8], [4097 x i8]* %10, i64 0, i64 %85
store i8 0, i8* %86
%87 = call i32 (...) @getpid()
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i32 %87)
%89 = getelementptr inbounds [4097 x i8], [4097 x i8]* %10, i64 0, i64 0
%90 = load i32, i32* @stdout
%91 = call i64 @fputs(i8* %89, i32 %90)
%92 = load i64, i64* @EOF
%93 = icmp eq i64 %91, %92
br i1 %93, label %94, label %97
94: ; preds = %84
%95 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%96 = call i32 @exit(i32 6)
unreachable
97: ; preds = %84
%98 = load i32, i32* %7
%99 = getelementptr inbounds [4097 x i8], [4097 x i8]* %10, i64 0, i64 0
%100 = getelementptr inbounds [4097 x i8], [4097 x i8]* %10, i64 0, i64 0
%101 = call i32 @strlen(i8* %100)
%102 = call i32 @write(i32 %98, i8* %99, i32 %101)
br label %79
103: ; preds = %79
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
%105 = call i32 @exit(i32 0)
unreachable
106: ; preds = %72
%107 = load i32, i32* %7
%108 = call i32 @close(i32 %107)
br label %65
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [17 x i8] c"Uso: %s <Porta>\0A\00"
@.str.1 = [52 x i8] c"Vai rodar um servidor de echo na porta <Porta> TCP\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [11 x i8] c"socket :(\0A\00"
@INADDR_ANY = global i32 0
@.str.3 = [9 x i8] c"bind :(\0A\00"
@.str.4 = [11 x i8] c"listen :(\0A\00"
@.str.5 = [51 x i8] c"[Servidor no ar. Aguardando conexoes na porta %s]\0A\00"
@.str.7 = [11 x i8] c"accept :(\0A\00"
@.str.9 = [50 x i8] c"[Cliente conectado no processo filho %d enviou:] \00"
@stdout = global i32 0
@EOF = global i64 0
@.str.10 = [11 x i8] c"fputs :( \0A\00"
@str = [62 x i8] c"[Para finalizar, pressione CTRL+c ou rode um kill ou killall]\00"
@str.12 = [21 x i8] c"[Uma conexao aberta]\00"
@str.13 = [22 x i8] c"[Uma conexao fechada]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [4097 x i8]
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = tail call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @exit(i32 2)
unreachable
23: ; preds = %15
%24 = call i32 @bzero(%struct.sockaddr_in* %3, i32 12)
%25 = load i32, i32* @AF_INET
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %25, i32* %26
%27 = load i32, i32* @INADDR_ANY
%28 = tail call i32 @htonl(i32 %27)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %28, i32* %29
%30 = getelementptr inbounds i8*, i8** %1, i64 1
%31 = load i8*, i8** %30
%32 = tail call i32 @atoi(i8* %31)
%33 = tail call i32 @htons(i32 %32)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %33, i32* %34
%35 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%36 = call i32 @bind(i32 %18, %struct.sockaddr* %35, i32 12)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %23
%39 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 @exit(i32 3)
unreachable
41: ; preds = %23
%42 = call i32 @listen(i32 %18, i32 1)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @exit(i32 4)
unreachable
47: ; preds = %41
%48 = load i8*, i8** %30
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i8* %48)
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
%51 = call i32 @accept(i32 %18, %struct.sockaddr* null, i32* null)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %85, %47
%54 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%55 = call i32 @exit(i32 5)
unreachable
56: ; preds = %47, %85
%57 = phi i32 [ %87, %85 ], [ %51, %47 ]
%58 = call i32 (...) @fork()
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %85
60: ; preds = %56
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0))
%62 = call i32 @close(i32 %18)
%63 = call i64 @read(i32 %57, i8* %6, i32 4096)
%64 = icmp eq i64 %63, 0
br i1 %64, label %82, label %65
65: ; preds = %60, %77
%66 = phi i64 [ %80, %77 ], [ %63, %60 ]
%67 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 %66
store i8 0, i8* %67
%68 = call i32 (...) @getpid()
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i32 %68)
%70 = load i32, i32* @stdout
%71 = call i64 @fputs(i8* %6, i32 %70)
%72 = load i64, i64* @EOF
%73 = icmp eq i64 %71, %72
br i1 %73, label %74, label %77
74: ; preds = %65
%75 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%76 = call i32 @exit(i32 6)
unreachable
77: ; preds = %65
%78 = call i32 @strlen(i8* %6)
%79 = call i32 @write(i32 %57, i8* %6, i32 %78)
%80 = call i64 @read(i32 %57, i8* %6, i32 4096)
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %65
82: ; preds = %77, %60
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.13, i64 0, i64 0))
%84 = call i32 @exit(i32 0)
unreachable
85: ; preds = %56
%86 = call i32 @close(i32 %57)
%87 = call i32 @accept(i32 %18, %struct.sockaddr* null, i32* null)
%88 = icmp eq i32 %87, -1
br i1 %88, label %53, label %56
}