#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 int socklen_t;
typedef int /*<<< orphan*/ sAdd;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ cAdd;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EINTR;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
char *decoder(char *, char *);
scalar_t__ errno;
int /*<<< orphan*/ error(char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int parse(char *);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char **argv) {
  int sockfd, newsockfd, portno;
  socklen_t clilen;
  struct sockaddr_in sAdd, cAdd;
  int w, size;
  if (argc < 2) {
    error("Error.  Need port.\n", 1);
  }
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0) {
    error("Error opening socket.\n", 1);
  }
  memset((char *)&sAdd, 0, sizeof(sAdd));
  portno = atoi(argv[1]);
  sAdd.sin_family = AF_INET;
  sAdd.sin_addr.s_addr = INADDR_ANY;
  sAdd.sin_port = htons(portno);
  if (bind(sockfd, (struct sockaddr *)&sAdd, sizeof(sAdd)) < 0) {
    error("Error in binding\n", 1);
  }
  listen(sockfd, 5);
  clilen = sizeof(cAdd);
  while (1) {
    int status;
    newsockfd = accept(sockfd, (struct sockaddr *)&cAdd, &clilen);
    if (newsockfd < 0) {
      error("Error on accepting\n", 1);
    }
    pid_t childPID = fork();
    if (childPID < 0) {
      error("PID ERROR!\n", 1);
    }
    if (childPID == 0) {
      close(sockfd);
      char buffer[10];
      int b2r = 9;
      int br = 0;
      while (br != b2r) {
        int firC;
        do {
          firC = read(newsockfd, buffer, 9);
        } while ((firC == -1) && (errno == EINTR));
        if (firC == -1) {
          error("Error in somteh.\n", 1);
        }
        br += firC;
      }
      size = parse(buffer);
      if (size == -1) {
        printf("Cannot connect.\n");
      } else {
        char oneString[size];
        char twoString[size];
        int b2read = size;
        int bRed = 0;
        int b2r2 = b2read;
        int bRed2 = 0;
        while (bRed != b2read) {
          int current;
          do {
            current = read(newsockfd, oneString, size);
          } while ((current == -1) && (errno == EINTR));
          if (current == -1) {
            error("Error in reading, 2\n", 1);
          }
          bRed += current;
        }
        while (bRed2 != b2r2) {
          int cur2;
          do {
            cur2 = read(newsockfd, twoString, size);
          } while ((cur2 == -1) && (errno == EINTR));
          if (cur2 == -1) {
            error("Error in reading, 3\n", 1);
          }
          bRed2 += cur2;
        }
        char *finalString = decoder(oneString, twoString);
        char deuxFinal[size];
        strcpy(deuxFinal, finalString);
        int b2write = size;
        int bWritten = 0;
        while (bWritten != b2write) {
          int cLoop;
          do {
            cLoop = write(newsockfd, deuxFinal, b2write);
          } while ((cLoop == -1) && (errno == EINTR));
          if (cLoop == -1) {
            error("In writting server.\n", 1);
          }
          bWritten += cLoop;
        }
      }
      exit(0);
    } else {
      pid_t endedPID = waitpid(childPID, &status, 0);
      if (endedPID == -1) {
        error("Error with endPID", 1);
      }
      close(newsockfd);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1254 <main+0x34>
lea    0xdb6(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    0x2d6c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    128b <main+0x6b>
lea    0xd93(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10b0 <bind@plt>
cmp    $0x0,%rax
jge    12fa <main+0xda>
lea    0xd3b(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10a0 <listen@plt>
movl   $0xc,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   10e0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    133c <main+0x11c>
lea    0xd0b(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jge    1363 <main+0x143>
lea    0xcf8(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
cmpq   $0x0,-0x58(%rbp)
jne    170d <main+0x4ed>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x9,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x68(%rbp),%eax
je     140f <main+0x1ef>
jmp    1395 <main+0x175>
mov    -0x18(%rbp),%edi
lea    -0x62(%rbp),%rsi
mov    $0x9,%edx
call   1090 <read@plt>
mov    %eax,-0x70(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x70(%rbp)
mov    %al,-0xc9(%rbp)
jne    13d8 <main+0x1b8>
mov    0x2c06(%rip),%rax
mov    (%rax),%rax
mov    0x2bf4(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0xc9(%rbp)
mov    -0xc9(%rbp),%al
test   $0x1,%al
jne    1395 <main+0x175>
cmpl   $0xffffffff,-0x70(%rbp)
jne    1401 <main+0x1e1>
lea    0xc66(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    -0x70(%rbp),%eax
add    -0x6c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
jmp    1384 <main+0x164>
lea    -0x62(%rbp),%rdi
call   1100 <parse@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0xffffffff,-0x48(%rbp)
jne    1436 <main+0x216>
lea    0xc43(%rip),%rdi
call   1060 <printf@plt>
jmp    1706 <main+0x4e6>
mov    -0x48(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xe0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x80(%rbp)
mov    -0x48(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xd8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x88(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x8c(%rbp)
movl   $0x0,-0x90(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
mov    -0x90(%rbp),%eax
cmp    -0x8c(%rbp),%eax
je     1551 <main+0x331>
jmp    14c4 <main+0x2a4>
mov    -0xe0(%rbp),%rsi
mov    -0x18(%rbp),%edi
mov    -0x48(%rbp),%edx
call   1090 <read@plt>
mov    %eax,-0x9c(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x9c(%rbp)
mov    %al,-0xe1(%rbp)
jne    150e <main+0x2ee>
mov    0x2ad0(%rip),%rax
mov    (%rax),%rax
mov    0x2abe(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0xe1(%rbp)
mov    -0xe1(%rbp),%al
test   $0x1,%al
jne    14c4 <main+0x2a4>
cmpl   $0xffffffff,-0x9c(%rbp)
jne    153a <main+0x31a>
lea    0xb50(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    -0x9c(%rbp),%eax
add    -0x90(%rbp),%eax
mov    %eax,-0x90(%rbp)
jmp    14ad <main+0x28d>
jmp    1556 <main+0x336>
mov    -0x98(%rbp),%eax
cmp    -0x94(%rbp),%eax
je     15fa <main+0x3da>
jmp    156d <main+0x34d>
mov    -0xd8(%rbp),%rsi
mov    -0x18(%rbp),%edi
mov    -0x48(%rbp),%edx
call   1090 <read@plt>
mov    %eax,-0xa0(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0xa0(%rbp)
mov    %al,-0xe2(%rbp)
jne    15b7 <main+0x397>
mov    0x2a27(%rip),%rax
mov    (%rax),%rax
mov    0x2a15(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0xe2(%rbp)
mov    -0xe2(%rbp),%al
test   $0x1,%al
jne    156d <main+0x34d>
cmpl   $0xffffffff,-0xa0(%rbp)
jne    15e3 <main+0x3c3>
lea    0xabc(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    -0xa0(%rbp),%eax
add    -0x98(%rbp),%eax
mov    %eax,-0x98(%rbp)
jmp    1556 <main+0x336>
mov    -0xd8(%rbp),%rsi
mov    -0xe0(%rbp),%rdi
call   1120 <decoder@plt>
mov    %rax,-0xa8(%rbp)
mov    -0x48(%rbp),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0xf0(%rbp)
mov    %rdi,%rsp
mov    %rax,-0xb0(%rbp)
mov    -0xa8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%eax
mov    %eax,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
cmp    -0xb4(%rbp),%eax
je     16ff <main+0x4df>
jmp    166f <main+0x44f>
mov    -0xf0(%rbp),%rsi
mov    -0x18(%rbp),%edi
mov    -0xb4(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0xbc(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0xbc(%rbp)
mov    %al,-0xf1(%rbp)
jne    16bc <main+0x49c>
mov    0x2922(%rip),%rax
mov    (%rax),%rax
mov    0x2910(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0xf1(%rbp)
mov    -0xf1(%rbp),%al
test   $0x1,%al
jne    166f <main+0x44f>
cmpl   $0xffffffff,-0xbc(%rbp)
jne    16e8 <main+0x4c8>
lea    0x9cc(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    -0xbc(%rbp),%eax
add    -0xb8(%rbp),%eax
mov    %eax,-0xb8(%rbp)
jmp    1658 <main+0x438>
mov    -0x78(%rbp),%rax
mov    %rax,%rsp
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x58(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
xor    %edx,%edx
call   10d0 <waitpid@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0xffffffffffffffff,-0xc8(%rbp)
ff
jne    1742 <main+0x522>
lea    0x987(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
jmp    130e <main+0xee>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r15
cmp    $0x1,%edi
jg     124a <main+0x2a>
lea    0xdc0(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    0x2d97(%rip),%r12
mov    (%r12),%edi
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    127d <main+0x5d>
lea    0xda1(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
lea    -0x48(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x8(%r15),%rdi
call   10f0 <atoi@plt>
mov    (%r12),%ecx
mov    %ecx,-0x40(%rbp)
mov    0x2d39(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,-0x44(%rbp)
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,-0x48(%rbp)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10b0 <bind@plt>
test   %rax,%rax
jns    12dc <main+0xbc>
lea    0xd59(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    %r14d,%edi
mov    $0x5,%esi
call   10a0 <listen@plt>
movl   $0xc,-0x3c(%rbp)
lea    -0x3c(%rbp),%r12
lea    -0x54(%rbp),%rbx
jmp    1308 <main+0xe8>
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
call   1080 <close@plt>
mov    %r14d,%edi
lea    -0x78(%rbp),%rsi
mov    %r12,%rdx
call   10e0 <accept@plt>
mov    %eax,%r13d
test   %eax,%eax
jns    132f <main+0x10f>
lea    0xd18(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
xor    %eax,%eax
call   1130 <fork@plt>
mov    %rax,%r15
test   %rax,%rax
js     1350 <main+0x130>
jne    1361 <main+0x141>
jmp    138a <main+0x16a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xcfa(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   10d0 <waitpid@plt>
cmp    $0xffffffffffffffff,%rax
jne    1300 <main+0xe0>
lea    0xd33(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
jmp    1300 <main+0xe0>
mov    %r14d,%edi
call   1080 <close@plt>
xor    %r14d,%r14d
lea    -0x54(%rbp),%r15
mov    0x2c20(%rip),%r12
jmp    13b0 <main+0x190>
cmp    $0xffffffff,%ebx
je     13d9 <main+0x1b9>
add    %ebx,%r14d
cmp    $0x9,%r14d
je     13ec <main+0x1cc>
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x9,%edx
call   1090 <read@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    13a2 <main+0x182>
mov    (%r12),%rax
mov    0x2bf6(%rip),%rcx
cmp    %rax,(%rcx)
je     13b0 <main+0x190>
jmp    13a2 <main+0x182>
lea    0xc7d(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
jmp    13a7 <main+0x187>
lea    -0x54(%rbp),%rdi
call   1100 <parse@plt>
cmp    $0xffffffff,%eax
jne    140d <main+0x1ed>
lea    0xcbf(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    %eax,%r14d
mov    %rsp,-0x68(%rbp)
mov    %eax,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rcx
mov    %rax,-0x60(%rbp)
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
test   %r14d,%r14d
je     14a6 <main+0x286>
xor    %eax,%eax
jmp    145a <main+0x23a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x2c(%rbp),%eax
add    %ebx,%eax
cmp    %r14d,%eax
je     149d <main+0x27d>
mov    %eax,-0x2c(%rbp)
nopl   (%rax)
mov    %r13d,%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1090 <read@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1485 <main+0x265>
mov    (%r12),%rax
mov    0x2b48(%rip),%rcx
cmp    %rax,(%rcx)
je     1460 <main+0x240>
cmp    $0xffffffff,%ebx
jne    1450 <main+0x230>
lea    0xbde(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
jmp    1450 <main+0x230>
test   %r14d,%r14d
jne    152d <main+0x30d>
mov    %r15,%rdi
mov    -0x38(%rbp),%rsi
call   1120 <decoder@plt>
mov    %rsp,%r15
sub    -0x60(%rbp),%r15
mov    %r15,%rsp
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
test   %r14d,%r14d
jne    14d7 <main+0x2b7>
mov    -0x68(%rbp),%rsp
xor    %edi,%edi
call   1110 <exit@plt>
xor    %eax,%eax
jmp    14ea <main+0x2ca>
nopl   0x0(%rax,%rax,1)
mov    -0x38(%rbp),%eax
add    %ebx,%eax
cmp    %r14d,%eax
je     14cc <main+0x2ac>
mov    %eax,-0x38(%rbp)
nopl   (%rax)
mov    %r13d,%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1050 <write@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1515 <main+0x2f5>
mov    (%r12),%rax
mov    0x2ab8(%rip),%rcx
cmp    %rax,(%rcx)
je     14f0 <main+0x2d0>
cmp    $0xffffffff,%ebx
jne    14e0 <main+0x2c0>
lea    0xb78(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
jmp    14e0 <main+0x2c0>
xor    %eax,%eax
jmp    154e <main+0x32e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x2c(%rbp),%eax
add    %ebx,%eax
cmp    %r14d,%eax
je     14a6 <main+0x286>
mov    %eax,-0x2c(%rbp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    -0x38(%rbp),%rsi
mov    %r14d,%edx
call   1090 <read@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1586 <main+0x366>
mov    (%r12),%rax
mov    0x2a47(%rip),%rcx
cmp    %rax,(%rcx)
je     1560 <main+0x340>
cmp    $0xffffffff,%ebx
jne    1540 <main+0x320>
lea    0xaf2(%rip),%rdi
mov    $0x1,%esi
call   10c0 <error@plt>
jmp    1540 <main+0x320>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [20 x i8] c"Error. Need port.\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [23 x i8] c"Error opening socket.\0A\00"
@INADDR_ANY = global i32 0
@.str.2 = [18 x i8] c"Error in binding\0A\00"
@.str.3 = [20 x i8] c"Error on accepting\0A\00"
@.str.4 = [12 x i8] c"PID ERROR!\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.5 = [18 x i8] c"Error in somteh.\0A\00"
@.str.6 = [17 x i8] c"Cannot connect.\0A\00"
@.str.7 = [21 x i8] c"Error in reading, 2\0A\00"
@.str.8 = [21 x i8] c"Error in reading, 3\0A\00"
@.str.9 = [21 x i8] c"In writting server.\0A\00"
@.str.10 = [18 x i8] c"Error with endPID\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 %struct.sockaddr_in
%11 = alloca %struct.sockaddr_in
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i64
%16 = alloca [10 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i64
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i8*
%30 = alloca i64
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%35 = load i32, i32* %4
%36 = icmp slt i32 %35, 2
br i1 %36, label %37, label %39
37: ; preds = %2
%38 = call i32 @error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 1)
br label %39
39: ; preds = %37, %2
%40 = load i32, i32* @AF_INET
%41 = load i32, i32* @SOCK_STREAM
%42 = call i32 @socket(i32 %40, i32 %41, i32 0)
store i32 %42, i32* %6
%43 = load i32, i32* %6
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %47
47: ; preds = %45, %39
%48 = bitcast %struct.sockaddr_in* %10 to i8*
%49 = call i32 @memset(i8* %48, i32 0, i32 12)
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i32 @atoi(i8* %52)
store i32 %53, i32* %8
%54 = load i32, i32* @AF_INET
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %54, i32* %55
%56 = load i32, i32* @INADDR_ANY
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%58 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %57, i32 0, i32 0
store i32 %56, i32* %58
%59 = load i32, i32* %8
%60 = call i32 @htons(i32 %59)
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
store i32 %60, i32* %61
%62 = load i32, i32* %6
%63 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%64 = call i64 @bind(i32 %62, %struct.sockaddr* %63, i32 12)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %47
%67 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %68
68: ; preds = %66, %47
%69 = load i32, i32* %6
%70 = call i32 @listen(i32 %69, i32 5)
store i32 12, i32* %9
br label %71
71: ; preds = %68, %239
%72 = load i32, i32* %6
%73 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%74 = call i32 @accept(i32 %72, %struct.sockaddr* %73, i32* %9)
store i32 %74, i32* %7
%75 = load i32, i32* %7
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %71
%78 = call i32 @error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %79
79: ; preds = %77, %71
%80 = call i64 (...) @fork()
store i64 %80, i64* %15
%81 = load i64, i64* %15
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = call i32 @error(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %85
85: ; preds = %83, %79
%86 = load i64, i64* %15
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %229
88: ; preds = %85
%89 = load i32, i32* %6
%90 = call i32 @close(i32 %89)
store i32 9, i32* %17
store i32 0, i32* %18
br label %91
91: ; preds = %114, %88
%92 = load i32, i32* %18
%93 = load i32, i32* %17
%94 = icmp ne i32 %92, %93
br i1 %94, label %95, label %118
95: ; preds = %91
br label %96
96: ; preds = %107, %95
%97 = load i32, i32* %7
%98 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%99 = call i32 @read(i32 %97, i8* %98, i32 9)
store i32 %99, i32* %19
br label %100
100: ; preds = %96
%101 = load i32, i32* %19
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %107
103: ; preds = %100
%104 = load i64, i64* @errno
%105 = load i64, i64* @EINTR
%106 = icmp eq i64 %104, %105
br label %107
107: ; preds = %103, %100
%108 = phi i1 [ false, %100 ], [ %106, %103 ]
br i1 %108, label %96, label %109
109: ; preds = %107
%110 = load i32, i32* %19
%111 = icmp eq i32 %110, -1
br i1 %111, label %112, label %114
112: ; preds = %109
%113 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 1)
br label %114
114: ; preds = %112, %109
%115 = load i32, i32* %19
%116 = load i32, i32* %18
%117 = add nsw i32 %116, %115
store i32 %117, i32* %18
br label %91
118: ; preds = %91
%119 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%120 = call i32 @parse(i8* %119)
store i32 %120, i32* %13
%121 = load i32, i32* %13
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %125
123: ; preds = %118
%124 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %227
125: ; preds = %118
%126 = load i32, i32* %13
%127 = zext i32 %126 to i64
%128 = call i8* @llvm.stacksave()
store i8* %128, i8** %20
%129 = alloca i8, i64 %127
store i64 %127, i64* %21
%130 = load i32, i32* %13
%131 = zext i32 %130 to i64
%132 = alloca i8, i64 %131
store i64 %131, i64* %22
%133 = load i32, i32* %13
store i32 %133, i32* %23
store i32 0, i32* %24
%134 = load i32, i32* %23
store i32 %134, i32* %25
store i32 0, i32* %26
br label %135
135: ; preds = %158, %125
%136 = load i32, i32* %24
%137 = load i32, i32* %23
%138 = icmp ne i32 %136, %137
br i1 %138, label %139, label %162
139: ; preds = %135
br label %140
140: ; preds = %151, %139
%141 = load i32, i32* %7
%142 = load i32, i32* %13
%143 = call i32 @read(i32 %141, i8* %129, i32 %142)
store i32 %143, i32* %27
br label %144
144: ; preds = %140
%145 = load i32, i32* %27
%146 = icmp eq i32 %145, -1
br i1 %146, label %147, label %151
147: ; preds = %144
%148 = load i64, i64* @errno
%149 = load i64, i64* @EINTR
%150 = icmp eq i64 %148, %149
br label %151
151: ; preds = %147, %144
%152 = phi i1 [ false, %144 ], [ %150, %147 ]
br i1 %152, label %140, label %153
153: ; preds = %151
%154 = load i32, i32* %27
%155 = icmp eq i32 %154, -1
br i1 %155, label %156, label %158
156: ; preds = %153
%157 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 1)
br label %158
158: ; preds = %156, %153
%159 = load i32, i32* %27
%160 = load i32, i32* %24
%161 = add nsw i32 %160, %159
store i32 %161, i32* %24
br label %135
162: ; preds = %135
br label %163
163: ; preds = %186, %162
%164 = load i32, i32* %26
%165 = load i32, i32* %25
%166 = icmp ne i32 %164, %165
br i1 %166, label %167, label %190
167: ; preds = %163
br label %168
168: ; preds = %179, %167
%169 = load i32, i32* %7
%170 = load i32, i32* %13
%171 = call i32 @read(i32 %169, i8* %132, i32 %170)
store i32 %171, i32* %28
br label %172
172: ; preds = %168
%173 = load i32, i32* %28
%174 = icmp eq i32 %173, -1
br i1 %174, label %175, label %179
175: ; preds = %172
%176 = load i64, i64* @errno
%177 = load i64, i64* @EINTR
%178 = icmp eq i64 %176, %177
br label %179
179: ; preds = %175, %172
%180 = phi i1 [ false, %172 ], [ %178, %175 ]
br i1 %180, label %168, label %181
181: ; preds = %179
%182 = load i32, i32* %28
%183 = icmp eq i32 %182, -1
br i1 %183, label %184, label %186
184: ; preds = %181
%185 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 1)
br label %186
186: ; preds = %184, %181
%187 = load i32, i32* %28
%188 = load i32, i32* %26
%189 = add nsw i32 %188, %187
store i32 %189, i32* %26
br label %163
190: ; preds = %163
%191 = call i8* @decoder(i8* %129, i8* %132)
store i8* %191, i8** %29
%192 = load i32, i32* %13
%193 = zext i32 %192 to i64
%194 = alloca i8, i64 %193
store i64 %193, i64* %30
%195 = load i8*, i8** %29
%196 = call i32 @strcpy(i8* %194, i8* %195)
%197 = load i32, i32* %13
store i32 %197, i32* %31
store i32 0, i32* %32
br label %198
198: ; preds = %221, %190
%199 = load i32, i32* %32
%200 = load i32, i32* %31
%201 = icmp ne i32 %199, %200
br i1 %201, label %202, label %225
202: ; preds = %198
br label %203
203: ; preds = %214, %202
%204 = load i32, i32* %7
%205 = load i32, i32* %31
%206 = call i32 @write(i32 %204, i8* %194, i32 %205)
store i32 %206, i32* %33
br label %207
207: ; preds = %203
%208 = load i32, i32* %33
%209 = icmp eq i32 %208, -1
br i1 %209, label %210, label %214
210: ; preds = %207
%211 = load i64, i64* @errno
%212 = load i64, i64* @EINTR
%213 = icmp eq i64 %211, %212
br label %214
214: ; preds = %210, %207
%215 = phi i1 [ false, %207 ], [ %213, %210 ]
br i1 %215, label %203, label %216
216: ; preds = %214
%217 = load i32, i32* %33
%218 = icmp eq i32 %217, -1
br i1 %218, label %219, label %221
219: ; preds = %216
%220 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i32 1)
br label %221
221: ; preds = %219, %216
%222 = load i32, i32* %33
%223 = load i32, i32* %32
%224 = add nsw i32 %223, %222
store i32 %224, i32* %32
br label %198
225: ; preds = %198
%226 = load i8*, i8** %20
br label %227
227: ; preds = %225, %123
%228 = call i32 @exit(i32 0)
unreachable
229: ; preds = %85
%230 = load i64, i64* %15
%231 = call i64 @waitpid(i64 %230, i32* %14, i32 0)
store i64 %231, i64* %34
%232 = load i64, i64* %34
%233 = icmp eq i64 %232, -1
br i1 %233, label %234, label %236
234: ; preds = %229
%235 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32 1)
br label %236
236: ; preds = %234, %229
%237 = load i32, i32* %7
%238 = call i32 @close(i32 %237)
br label %239
239: ; preds = %236
br label %71
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [20 x i8] c"Error. Need port.\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [23 x i8] c"Error opening socket.\0A\00"
@INADDR_ANY = global i32 0
@.str.2 = [18 x i8] c"Error in binding\0A\00"
@.str.3 = [20 x i8] c"Error on accepting\0A\00"
@.str.4 = [12 x i8] c"PID ERROR!\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.5 = [18 x i8] c"Error in somteh.\0A\00"
@.str.7 = [21 x i8] c"Error in reading, 2\0A\00"
@.str.8 = [21 x i8] c"Error in reading, 3\0A\00"
@.str.9 = [21 x i8] c"In writting server.\0A\00"
@.str.10 = [18 x i8] c"Error with endPID\00"
@str = [16 x i8] c"Cannot connect.\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 [10 x i8]
%8 = bitcast i32* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = bitcast %struct.sockaddr_in* %5 to i8*
%11 = icmp slt i32 %0, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 1)
br label %14
14: ; preds = %12, %2
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %21
21: ; preds = %19, %14
%22 = call i32 @memset(i8* %9, i32 0, i32 12)
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
%26 = load i32, i32* @AF_INET
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %26, i32* %27
%28 = load i32, i32* @INADDR_ANY
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %28, i32* %29
%30 = call i32 @htons(i32 %25)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %30, i32* %31
%32 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%33 = call i64 @bind(i32 %17, %struct.sockaddr* %32, i32 12)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %21
%36 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %37
37: ; preds = %35, %21
%38 = call i32 @listen(i32 %17, i32 5)
store i32 12, i32* %3
%39 = bitcast i32* %6 to i8*
%40 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
br label %41
41: ; preds = %140, %37
%42 = call i32 @accept(i32 %17, %struct.sockaddr* %40, i32* %3)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %46
46: ; preds = %44, %41
%47 = call i64 (...) @fork()
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 @error(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %135
51: ; preds = %46
%52 = icmp eq i64 %47, 0
br i1 %52, label %53, label %135
53: ; preds = %51
%54 = call i32 @close(i32 %17)
%55 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
br label %56
56: ; preds = %53, %68
%57 = phi i32 [ 0, %53 ], [ %69, %68 ]
br label %58
58: ; preds = %56, %58
%59 = call i32 @read(i32 %42, i8* %55, i32 9)
%60 = icmp eq i32 %59, -1
%61 = load i64, i64* @errno
%62 = load i64, i64* @EINTR
%63 = icmp eq i64 %61, %62
%64 = select i1 %60, i1 %63, i1 false
br i1 %64, label %58, label %65
65: ; preds = %58
br i1 %60, label %66, label %68
66: ; preds = %65
%67 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 1)
br label %68
68: ; preds = %66, %65
%69 = add nsw i32 %59, %57
%70 = icmp eq i32 %69, 9
br i1 %70, label %71, label %56
71: ; preds = %68
%72 = call i32 @parse(i8* %55)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %133
76: ; preds = %71
%77 = zext i32 %72 to i64
%78 = call i8* @llvm.stacksave()
%79 = alloca i8, i64 %77
%80 = alloca i8, i64 %77
%81 = icmp eq i32 %72, 0
br i1 %81, label %113, label %82
82: ; preds = %76, %95
%83 = phi i32 [ %96, %95 ], [ 0, %76 ]
br label %85
84: ; preds = %95
br i1 %81, label %113, label %98
85: ; preds = %82, %85
%86 = call i32 @read(i32 %42, i8* %79, i32 %72)
%87 = icmp eq i32 %86, -1
%88 = load i64, i64* @errno
%89 = load i64, i64* @EINTR
%90 = icmp eq i64 %88, %89
%91 = select i1 %87, i1 %90, i1 false
br i1 %91, label %85, label %92
92: ; preds = %85
br i1 %87, label %93, label %95
93: ; preds = %92
%94 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 1)
br label %95
95: ; preds = %93, %92
%96 = add nsw i32 %86, %83
%97 = icmp eq i32 %96, %72
br i1 %97, label %84, label %82
98: ; preds = %84, %110
%99 = phi i32 [ %111, %110 ], [ 0, %84 ]
br label %100
100: ; preds = %98, %100
%101 = call i32 @read(i32 %42, i8* %80, i32 %72)
%102 = icmp eq i32 %101, -1
%103 = load i64, i64* @errno
%104 = load i64, i64* @EINTR
%105 = icmp eq i64 %103, %104
%106 = select i1 %102, i1 %105, i1 false
br i1 %106, label %100, label %107
107: ; preds = %100
br i1 %102, label %108, label %110
108: ; preds = %107
%109 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 1)
br label %110
110: ; preds = %108, %107
%111 = add nsw i32 %101, %99
%112 = icmp eq i32 %111, %72
br i1 %112, label %113, label %98
113: ; preds = %110, %76, %84
%114 = call i8* @decoder(i8* %79, i8* %80)
%115 = alloca i8, i64 %77
%116 = call i32 @strcpy(i8* %115, i8* %114)
br i1 %81, label %132, label %117
117: ; preds = %113, %129
%118 = phi i32 [ %130, %129 ], [ 0, %113 ]
br label %119
119: ; preds = %117, %119
%120 = call i32 @write(i32 %42, i8* %115, i32 %72)
%121 = icmp eq i32 %120, -1
%122 = load i64, i64* @errno
%123 = load i64, i64* @EINTR
%124 = icmp eq i64 %122, %123
%125 = select i1 %121, i1 %124, i1 false
br i1 %125, label %119, label %126
126: ; preds = %119
br i1 %121, label %127, label %129
127: ; preds = %126
%128 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i32 1)
br label %129
129: ; preds = %127, %126
%130 = add nsw i32 %120, %118
%131 = icmp eq i32 %130, %72
br i1 %131, label %132, label %117
132: ; preds = %129, %113
br label %133
133: ; preds = %132, %74
%134 = call i32 @exit(i32 0)
unreachable
135: ; preds = %49, %51
%136 = call i64 @waitpid(i64 %47, i32* %6, i32 0)
%137 = icmp eq i64 %136, -1
br i1 %137, label %138, label %140
138: ; preds = %135
%139 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32 1)
br label %140
140: ; preds = %138, %135
%141 = call i32 @close(i32 %42)
br label %41
}