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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
unsigned int INADDR_LOOPBACK;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ enable_reuse_socket(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getpid();
int /*<<< orphan*/ htonl(unsigned int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int parseIP(char *, unsigned int *);
int /*<<< orphan*/ parsePort(char *, int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int write(int, char *, int);
int main(int argc, char *argv[]) {
  unsigned int ip = INADDR_LOOPBACK;
  int port = 3456;
  bool exit_due_to_arg_error;
  switch (argc) {
  case 1:
    fprintf(stderr, "You should, at least, give an IP for the server.");
    exit_due_to_arg_error = true;
    break;
  case 2:
    fprintf(stdout,
            "The argument %s will be interpreted as an IP. And port is "
            "supposed to be %d.",
            argv[1], 3456);
    exit_due_to_arg_error = parseIP(argv[1], &ip);
    break;
  case 3:
    exit_due_to_arg_error = parsePort(argv[2], &port) && parseIP(argv[1], &ip);
    break;
  default:
    fprintf(stderr, "Too many arguments we can not handle that!");
    exit_due_to_arg_error = true;
    break;
  }
  if (exit_due_to_arg_error) {
    exit(2);
  }
  int socket_desc;
  socket_desc = socket(AF_INET, SOCK_STREAM, 0);
  if (socket_desc < 0) {
    printf("Socket creation error\n");
    exit(1);
  }
  enable_reuse_socket(socket_desc);
  struct sockaddr_in addr;
  memset((char *)&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_port = htons(port);
  addr.sin_addr.s_addr = htonl(ip);
  printf("Socket is opened with description: %d\n", socket_desc);
  int i =
      connect(socket_desc, (struct sockaddr *)&addr, sizeof(struct sockaddr));
  if (i < 0)
    printf("Failed to connect to server");
  char *string = "Hello.";
  if (write(socket_desc, string, 6) != 6) {
    printf("Failed to connect to server\n");
    exit(3);
  }
  bool reading = true;
  bool not_closed = true;
  char buffer[255];
  int j = 0;
  do {
    char c;
    ssize_t x = read(socket_desc, &c, 1);
    if (x > 0) {
      buffer[j] = c;
      if (buffer[j] == '.') {
        j++;
        buffer[j] = '\0';
        reading = false;
      }
      j++;
    } else {
      not_closed = false;
    }
  } while (reading);
  printf("%d: Recieve message : %s\n", getpid(), buffer);
  sleep(10);
  close(socket_desc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0xd80,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x164(%rbp)
sub    $0x1,%eax
je     126b <main+0x6b>
jmp    1243 <main+0x43>
mov    -0x164(%rbp),%eax
sub    $0x2,%eax
je     128e <main+0x8e>
jmp    1257 <main+0x57>
mov    -0x164(%rbp),%eax
sub    $0x3,%eax
je     12cb <main+0xcb>
jmp    131f <main+0x11f>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    133d <main+0x13d>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd8b(%rip),%rsi
mov    $0xd80,%ecx
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <parseIP@plt>
mov    %eax,-0x1c(%rbp)
jmp    133d <main+0x13d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1120 <parsePort@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x165(%rbp)
je     130c <main+0x10c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <parseIP@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x165(%rbp)
mov    -0x165(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    133d <main+0x13d>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
lea    0xd4f(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1351 <main+0x151>
mov    $0x2,%edi
call   10e0 <exit@plt>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
mov    0x2c67(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    138f <main+0x18f>
lea    0xd2b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%edi
call   1060 <enable_reuse_socket@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10a0 <memset@plt>
mov    0x2c3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <htonl@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%esi
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   10f0 <connect@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1406 <main+0x206>
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xcf6(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x6,%edx
call   1040 <write@plt>
cmp    $0x6,%eax
je     1443 <main+0x243>
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x3,%edi
call   10e0 <exit@plt>
movl   $0x1,-0x44(%rbp)
movl   $0x1,-0x48(%rbp)
movl   $0x0,-0x154(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x155(%rbp),%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
mov    %rax,-0x160(%rbp)
cmpq   $0x0,-0x160(%rbp)
jle    14e9 <main+0x2e9>
mov    -0x155(%rbp),%cl
movslq -0x154(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
movslq -0x154(%rbp),%rax
movsbl -0x150(%rbp,%rax,1),%eax
ff
cmp    $0x2e,%eax
jne    14d5 <main+0x2d5>
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
movslq -0x154(%rbp),%rax
movb   $0x0,-0x150(%rbp,%rax,1)
movl   $0x0,-0x44(%rbp)
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    14f0 <main+0x2f0>
movl   $0x0,-0x48(%rbp)
jmp    14f5 <main+0x2f5>
cmpl   $0x0,-0x44(%rbp)
jne    145b <main+0x25b>
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,%esi
lea    -0x150(%rbp),%rdx
lea    0xc11(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0xa,%edi
call   1100 <sleep@plt>
mov    -0x20(%rbp),%edi
call   10b0 <close@plt>
xor    %eax,%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x128,%rsp
mov    %rsi,%rbx
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
movl   $0xd80,0xc(%rsp)
cmp    $0x2,%edi
je     126e <main+0x5e>
cmp    $0x3,%edi
jne    13e4 <main+0x1d4>
mov    0x10(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   1130 <parsePort@plt>
test   %eax,%eax
je     12a4 <main+0x94>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1030 <parseIP@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
setne  %al
jmp    129c <main+0x8c>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdaf(%rip),%rsi
mov    $0xd80,%ecx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1030 <parseIP@plt>
test   %eax,%eax
jne    1435 <main+0x225>
mov    0x2d3d(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d14(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
js     13f2 <main+0x1e2>
mov    %eax,%r15d
mov    %eax,%edi
call   1070 <enable_reuse_socket@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10b0 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    0xc(%rsp),%edi
call   1080 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rsp),%edi
call   10a0 <htonl@plt>
mov    %eax,0x10(%rsp)
lea    0xd9f(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1100 <connect@plt>
test   %eax,%eax
jns    1336 <main+0x126>
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd93(%rip),%rsi
mov    %r15d,%edi
mov    $0x6,%edx
call   1050 <write@plt>
cmp    $0x6,%eax
jne    1408 <main+0x1f8>
xor    %ebp,%ebp
lea    0x7(%rsp),%r14
jmp    1367 <main+0x157>
nopl   0x0(%rax)
add    $0x1,%ebp
test   %ebx,%ebx
je     13a6 <main+0x196>
mov    $0x1,%ebx
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10d0 <read@plt>
test   %rax,%rax
jle    1363 <main+0x153>
movzbl 0x7(%rsp),%ecx
movslq %ebp,%rax
mov    %cl,0x20(%rsp,%rax,1)
mov    $0x1,%ebx
cmp    $0x2e,%cl
jne    1360 <main+0x150>
movb   $0x0,0x21(%rsp,%rax,1)
add    $0x1,%rax
xor    %ebx,%ebx
mov    %eax,%ebp
jmp    1360 <main+0x150>
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xd23(%rip),%rdi
lea    0x20(%rsp),%rdx
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1110 <sleep@plt>
mov    %r15d,%edi
call   10c0 <close@plt>
xor    %eax,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x1,%edi
jne    141e <main+0x20e>
lea    0xc10(%rip),%rsi
jmp    1425 <main+0x215>
lea    0xd14(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xce2(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3,%edi
call   10f0 <exit@plt>
lea    0xc59(%rip),%rsi
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x2,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@INADDR_LOOPBACK = global i32 0
@stderr = global i32 0
@.str = [49 x i8] c"You should, at least, give an IP for the server.\00"
@stdout = global i32 0
@.str.1 = [77 x i8] c"The argument %s will be interpreted as an IP. And port is supposed to be %d.\00"
@.str.2 = [43 x i8] c"Too many arguments we can not handle that!\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [23 x i8] c"Socket creation error\0A\00"
@.str.4 = [39 x i8] c"Socket is opened with description: %d\0A\00"
@.str.5 = [28 x i8] c"Failed to connect to server\00"
@.str.6 = [7 x i8] c"Hello.\00"
@.str.7 = [29 x i8] c"Failed to connect to server\0A\00"
@.str.8 = [26 x i8] c"%d: Recieve message : %s\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 i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca [255 x i8]
%16 = alloca i32
%17 = alloca i8
%18 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* @INADDR_LOOPBACK
store i32 %19, i32* %6
store i32 3456, i32* %7
%20 = load i32, i32* %4
switch i32 %20, label %49 [
i32 1, label %21
i32 2, label %24
i32 3, label %34
]
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %8
br label %52
24: ; preds = %2
%25 = load i32, i32* @stdout
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i8* %28, i32 3456)
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @parseIP(i8* %32, i32* %6)
store i32 %33, i32* %8
br label %52
34: ; preds = %2
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @parsePort(i8* %37, i32* %7)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %34
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 @parseIP(i8* %43, i32* %6)
%45 = icmp ne i32 %44, 0
br label %46
46: ; preds = %40, %34
%47 = phi i1 [ false, %34 ], [ %45, %40 ]
%48 = zext i1 %47 to i32
store i32 %48, i32* %8
br label %52
49: ; preds = %2
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %8
br label %52
52: ; preds = %49, %46, %24, %21
%53 = load i32, i32* %8
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 @exit(i32 2)
unreachable
57: ; preds = %52
%58 = load i32, i32* @AF_INET
%59 = load i32, i32* @SOCK_STREAM
%60 = call i32 @socket(i32 %58, i32 %59, i32 0)
store i32 %60, i32* %9
%61 = load i32, i32* %9
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %57
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %57
%67 = load i32, i32* %9
%68 = call i32 @enable_reuse_socket(i32 %67)
%69 = bitcast %struct.sockaddr_in* %10 to i8*
%70 = call i32 @memset(i8* %69, i32 0, i32 12)
%71 = load i32, i32* @AF_INET
%72 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %71, i32* %72
%73 = load i32, i32* %7
%74 = call i32 @htons(i32 %73)
%75 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %74, i32* %75
%76 = load i32, i32* %6
%77 = call i32 @htonl(i32 %76)
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%79 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %78, i32 0, i32 0
store i32 %77, i32* %79
%80 = load i32, i32* %9
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %80)
%82 = load i32, i32* %9
%83 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%84 = call i32 @connect(i32 %82, %struct.sockaddr* %83, i32 4)
store i32 %84, i32* %11
%85 = load i32, i32* %11
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %66
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %89
89: ; preds = %87, %66
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %12
%90 = load i32, i32* %9
%91 = load i8*, i8** %12
%92 = call i32 @write(i32 %90, i8* %91, i32 6)
%93 = icmp ne i32 %92, 6
br i1 %93, label %94, label %97
94: ; preds = %89
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%96 = call i32 @exit(i32 3)
unreachable
97: ; preds = %89
store i32 1, i32* %13
store i32 1, i32* %14
store i32 0, i32* %16
br label %98
98: ; preds = %125, %97
%99 = load i32, i32* %9
%100 = call i64 @read(i32 %99, i8* %17, i32 1)
store i64 %100, i64* %18
%101 = load i64, i64* %18
%102 = icmp sgt i64 %101, 0
br i1 %102, label %103, label %123
103: ; preds = %98
%104 = load i8, i8* %17
%105 = load i32, i32* %16
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 %106
store i8 %104, i8* %107
%108 = load i32, i32* %16
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 %109
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 46
br i1 %113, label %114, label %120
114: ; preds = %103
%115 = load i32, i32* %16
%116 = add nsw i32 %115, 1
store i32 %116, i32* %16
%117 = load i32, i32* %16
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 %118
store i8 0, i8* %119
store i32 0, i32* %13
br label %120
120: ; preds = %114, %103
%121 = load i32, i32* %16
%122 = add nsw i32 %121, 1
store i32 %122, i32* %16
br label %124
123: ; preds = %98
store i32 0, i32* %14
br label %124
124: ; preds = %123, %120
br label %125
125: ; preds = %124
%126 = load i32, i32* %13
%127 = icmp ne i32 %126, 0
br i1 %127, label %98, label %128
128: ; preds = %125
%129 = call i32 (...) @getpid()
%130 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 0
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %129, i8* %130)
%132 = call i32 @sleep(i32 10)
%133 = load i32, i32* %9
%134 = call i32 @close(i32 %133)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@INADDR_LOOPBACK = global i32 0
@stderr = global i32 0
@.str = [49 x i8] c"You should, at least, give an IP for the server.\00"
@stdout = global i32 0
@.str.1 = [77 x i8] c"The argument %s will be interpreted as an IP. And port is supposed to be %d.\00"
@.str.2 = [43 x i8] c"Too many arguments we can not handle that!\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.4 = [39 x i8] c"Socket is opened with description: %d\0A\00"
@.str.6 = [7 x i8] c"Hello.\00"
@.str.8 = [26 x i8] c"%d: Recieve message : %s\0A\00"
@str = [28 x i8] c"Failed to connect to server\00"
@str.9 = [22 x i8] c"Socket creation error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca [255 x i8]
%7 = alloca i8
%8 = bitcast i32* %3 to i8*
%9 = load i32, i32* @INADDR_LOOPBACK
store i32 %9, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 3456, i32* %4
switch i32 %0, label %29 [
i32 1, label %33
i32 2, label %11
i32 3, label %18
]
11: ; preds = %2
%12 = load i32, i32* @stdout
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i8* %14, i32 3456)
%16 = load i8*, i8** %13
%17 = call i32 @parseIP(i8* %16, i32* %3)
br label %30
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @parsePort(i8* %20, i32* %4)
%22 = icmp eq i32 %21, 0
br i1 %22, label %39, label %23
23: ; preds = %18
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @parseIP(i8* %25, i32* %3)
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i32
br label %30
29: ; preds = %2
br label %33
30: ; preds = %23, %11
%31 = phi i32 [ %17, %11 ], [ %28, %23 ]
%32 = icmp eq i32 %31, 0
br i1 %32, label %39, label %37
33: ; preds = %2, %29
%34 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), %29 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), %2 ]
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* %34)
br label %37
37: ; preds = %33, %30
%38 = call i32 @exit(i32 2)
unreachable
39: ; preds = %18, %30
%40 = load i32, i32* @AF_INET
%41 = load i32, i32* @SOCK_STREAM
%42 = call i32 @socket(i32 %40, i32 %41, i32 0)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %39
%48 = call i32 @enable_reuse_socket(i32 %42)
%49 = bitcast %struct.sockaddr_in* %5 to i8*
%50 = call i32 @memset(i8* %49, i32 0, i32 12)
%51 = load i32, i32* @AF_INET
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %51, i32* %52
%53 = load i32, i32* %4
%54 = call i32 @htons(i32 %53)
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i32 %54, i32* %55
%56 = load i32, i32* %3
%57 = call i32 @htonl(i32 %56)
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
store i32 %57, i32* %58
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%60 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%61 = call i32 @connect(i32 %42, %struct.sockaddr* %60, i32 4)
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %47
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %65
65: ; preds = %63, %47
%66 = call i32 @write(i32 %42, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%67 = icmp eq i32 %66, 6
br i1 %67, label %71, label %68
68: ; preds = %65
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%70 = call i32 @exit(i32 3)
unreachable
71: ; preds = %65
%72 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
br label %73
73: ; preds = %90, %71
%74 = phi i32 [ 0, %71 ], [ %92, %90 ]
%75 = call i64 @read(i32 %42, i8* %7, i32 1)
%76 = icmp sgt i64 %75, 0
br i1 %76, label %77, label %90
77: ; preds = %73
%78 = load i8, i8* %7
%79 = sext i32 %74 to i64
%80 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %79
store i8 %78, i8* %80
%81 = icmp eq i8 %78, 46
br i1 %81, label %82, label %86
82: ; preds = %77
%83 = add nsw i32 %74, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %84
store i8 0, i8* %85
br label %86
86: ; preds = %82, %77
%87 = phi i32 [ 0, %82 ], [ 1, %77 ]
%88 = phi i32 [ %83, %82 ], [ %74, %77 ]
%89 = add nsw i32 %88, 1
br label %90
90: ; preds = %73, %86
%91 = phi i32 [ %87, %86 ], [ 1, %73 ]
%92 = phi i32 [ %89, %86 ], [ %74, %73 ]
%93 = icmp eq i32 %91, 0
br i1 %93, label %94, label %73
94: ; preds = %90
%95 = call i32 (...) @getpid()
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %95, i8* %72)
%97 = call i32 @sleep(i32 10)
%98 = call i32 @close(i32 %42)
ret i32 0
}