#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_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ srv_socket_addr;
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOMAXCONN;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(void *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ create_receive_thread(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int htons(unsigned short);
int /*<<< orphan*/ inet_aton(char *, TYPE_1__ *);
char *inet_ntoa(TYPE_1__);
scalar_t__ listen(int, int /*<<< orphan*/);
int ntohs(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
int socket_main(char *ipaddr, int port) {
  int socketFD = -1;
  int acceptFD = -1;
  int sockaddr_size = 0;
  struct sockaddr_in srv_socket_addr;
  struct sockaddr_in clt_socket_addr;
  socklen_t sin_size;
  if (NULL == ipaddr) {
    goto error;
  }
  socketFD = socket(PF_INET, SOCK_STREAM, 0);
  if (socketFD < 0) {
    perror("socket");
    goto error;
  }
  bzero((void *)&srv_socket_addr, sizeof(srv_socket_addr));
  srv_socket_addr.sin_family = PF_INET;
  if (0 == strncmp(ipaddr, "0.0.0.0", 16)) {
    srv_socket_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  } else {
    inet_aton(ipaddr, &(srv_socket_addr.sin_addr));
  }
  srv_socket_addr.sin_port = htons((unsigned short)port);
  printf("1: IP=%s PORT=%d\n", inet_ntoa(srv_socket_addr.sin_addr),
         srv_socket_addr.sin_port);
  sockaddr_size = sizeof(struct sockaddr_in);
  if (bind(socketFD, (struct sockaddr *)&srv_socket_addr, sockaddr_size) < 0) {
    perror("bind");
    goto exit;
  }
  if (listen(socketFD, SOMAXCONN) < 0) {
    perror("listen");
    goto exit;
  }
  printf("2: SOCKET FD=%d\n", socketFD);
  while (1) {
    printf("3: wait in accept\n");
    if ((acceptFD = accept(socketFD, (struct sockaddr *)&clt_socket_addr,
                           &sin_size)) < 0) {
      perror("accept");
      goto exit;
    }
    printf("4: accept FD=%d  connect from %s : %u\n", acceptFD,
           inet_ntoa(clt_socket_addr.sin_addr),
           ntohs(clt_socket_addr.sin_port));
    create_receive_thread(acceptFD);
  }
exit:
  if (-1 != socketFD) {
    close(socketFD);
  }
  return 0;
error:
  return -1;
}


x86 assembly (clang, -O0):
<socket_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1225 <socket_main+0x35>
jmp    13f3 <socket_main+0x203>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    0x2d9b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    125c <socket_main+0x6c>
lea    0xdae(%rip),%rdi
call   10e0 <perror@plt>
jmp    13f3 <socket_main+0x203>
lea    -0x30(%rbp),%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd86(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12af <socket_main+0xbf>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x2c(%rbp)
jmp    12c0 <socket_main+0xd0>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
add    $0x4,%rsi
call   1090 <inet_aton@plt>
mov    -0x14(%rbp),%eax
movzwl %ax,%edi
call   1050 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
mov    -0x30(%rbp),%edx
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xc,-0x20(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    131b <socket_main+0x12b>
lea    0xd10(%rip),%rdi
call   10e0 <perror@plt>
jmp    13d1 <socket_main+0x1e1>
mov    -0x18(%rbp),%edi
mov    0x2cb3(%rip),%rax
mov    (%rax),%esi
call   10a0 <listen@plt>
cmp    $0x0,%rax
jge    1347 <socket_main+0x157>
lea    0xce9(%rip),%rdi
call   10e0 <perror@plt>
jmp    13d1 <socket_main+0x1e1>
mov    -0x18(%rbp),%esi
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x44(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1393 <socket_main+0x1a3>
lea    0xcc8(%rip),%rdi
call   10e0 <perror@plt>
jmp    13d1 <socket_main+0x1e1>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x3c(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%edi
call   10b0 <ntohs@plt>
mov    -0x54(%rbp),%esi
mov    -0x50(%rbp),%rdx
mov    %eax,%ecx
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   10d0 <create_receive_thread@plt>
jmp    1358 <socket_main+0x168>
mov    $0xffffffff,%eax
cmp    -0x18(%rbp),%eax
je     13e7 <socket_main+0x1f7>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    13fa <socket_main+0x20a>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0xffffffff,%r12d
test   %rdi,%rdi
jne    122b <socket_main+0x2b>
mov    %r12d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %esi,%r15d
mov    %rdi,%rbp
mov    0x2d90(%rip),%r14
mov    (%r14),%edi
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
jns    125d <socket_main+0x5d>
lea    0xdaa(%rip),%rdi
call   10f0 <perror@plt>
jmp    1219 <socket_main+0x19>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    (%r14),%eax
mov    %eax,0x10(%rsp)
lea    0xd8b(%rip),%rsi
mov    %rbp,%rdi
mov    $0x10,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    12a2 <socket_main+0xa2>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0xc(%rsp)
jmp    12af <socket_main+0xaf>
lea    0xc(%rsp),%rsi
mov    %rbp,%rdi
call   10a0 <inet_aton@plt>
movzwl %r15w,%edi
call   1060 <htons@plt>
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%edi
call   1050 <inet_ntoa@plt>
mov    0x8(%rsp),%edx
lea    0xd3f(%rip),%rdi
xor    %r12d,%r12d
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %rax,%rax
jns    12ff <socket_main+0xff>
lea    0xd27(%rip),%rdi
jmp    13c9 <socket_main+0x1c9>
mov    0x2cd2(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10b0 <listen@plt>
test   %rax,%rax
jns    1320 <socket_main+0x120>
lea    0xd0b(%rip),%rdi
jmp    13c9 <socket_main+0x1c9>
lea    0xd06(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd2e(%rip),%rdi
call   1040 <puts@plt>
lea    0x18(%rsp),%rsi
lea    0x14(%rsp),%rdx
mov    %ebx,%edi
call   1110 <accept@plt>
lea    0xd1c(%rip),%rdi
test   %eax,%eax
js     13c9 <socket_main+0x1c9>
mov    %eax,%r15d
lea    0xd03(%rip),%rbp
lea    0x18(%rsp),%r13
lea    0x14(%rsp),%r14
nopl   0x0(%rax)
mov    0x1c(%rsp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,%r12
mov    0x18(%rsp),%edi
call   10c0 <ntohs@plt>
lea    0xcb2(%rip),%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,%edi
call   10e0 <create_receive_thread@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    %r14,%rdx
call   1110 <accept@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    1370 <socket_main+0x170>
xor    %r12d,%r12d
lea    0xca7(%rip),%rdi
call   10f0 <perror@plt>
mov    %ebx,%edi
call   1090 <close@plt>
jmp    1219 <socket_main+0x19>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@INADDR_ANY = global i32 0
@.str.2 = [18 x i8] c"1: IP=%s PORT=%d\0A\00"
@.str.3 = [5 x i8] c"bind\00"
@SOMAXCONN = global i32 0
@.str.4 = [7 x i8] c"listen\00"
@.str.5 = [17 x i8] c"2: SOCKET FD=%d\0A\00"
@.str.6 = [19 x i8] c"3: wait in accept\0A\00"
@.str.7 = [7 x i8] c"accept\00"
@.str.8 = [39 x i8] c"4: accept FD=%d connect from %s : %u\0A\00"
define i32 @socket_main(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.sockaddr_in
%11 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 -1, i32* %6
store i32 -1, i32* %7
store i32 0, i32* %8
%12 = load i8*, i8** %4
%13 = icmp eq i8* null, %12
br i1 %13, label %14, label %15
14: ; preds = %2
br label %96
15: ; preds = %2
%16 = load i32, i32* @PF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %96
23: ; preds = %15
%24 = bitcast %struct.sockaddr_in* %9 to i8*
%25 = call i32 @bzero(i8* %24, i32 12)
%26 = load i32, i32* @PF_INET
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %26, i32* %27
%28 = load i8*, i8** %4
%29 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 16)
%30 = icmp eq i64 0, %29
br i1 %30, label %31, label %36
31: ; preds = %23
%32 = load i32, i32* @INADDR_ANY
%33 = call i32 @htonl(i32 %32)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %34, i32 0, i32 0
store i32 %33, i32* %35
br label %40
36: ; preds = %23
%37 = load i8*, i8** %4
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%39 = call i32 @inet_aton(i8* %37, %struct.TYPE_3__* %38)
br label %40
40: ; preds = %36, %31
%41 = load i32, i32* %5
%42 = trunc i32 %41 to i16
%43 = call i32 @htons(i16 zeroext %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %43, i32* %44
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%46 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %45, i32 0, i32 0
%47 = load i32, i32* %46
%48 = call i8* @inet_ntoa(i32 %47)
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %48, i32 %50)
store i32 12, i32* %8
%52 = load i32, i32* %6
%53 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%54 = load i32, i32* %8
%55 = call i64 @bind(i32 %52, %struct.sockaddr* %53, i32 %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %40
%58 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %89
59: ; preds = %40
%60 = load i32, i32* %6
%61 = load i32, i32* @SOMAXCONN
%62 = call i64 @listen(i32 %60, i32 %61)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %59
%65 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %89
66: ; preds = %59
%67 = load i32, i32* %6
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %66, %77
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%71 = load i32, i32* %6
%72 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%73 = call i32 @accept(i32 %71, %struct.sockaddr* %72, i32* %11)
store i32 %73, i32* %7
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %69
%76 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %89
77: ; preds = %69
%78 = load i32, i32* %7
%79 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%80 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %79, i32 0, i32 0
%81 = load i32, i32* %80
%82 = call i8* @inet_ntoa(i32 %81)
%83 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%84 = load i32, i32* %83
%85 = call i32 @ntohs(i32 %84)
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %78, i8* %82, i32 %85)
%87 = load i32, i32* %7
%88 = call i32 @create_receive_thread(i32 %87)
br label %69
89: ; preds = %75, %64, %57
%90 = load i32, i32* %6
%91 = icmp ne i32 -1, %90
br i1 %91, label %92, label %95
92: ; preds = %89
%93 = load i32, i32* %6
%94 = call i32 @close(i32 %93)
br label %95
95: ; preds = %92, %89
store i32 0, i32* %3
br label %97
96: ; preds = %21, %14
store i32 -1, i32* %3
br label %97
97: ; preds = %96, %95
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@INADDR_ANY = global i32 0
@.str.2 = [18 x i8] c"1: IP=%s PORT=%d\0A\00"
@.str.3 = [5 x i8] c"bind\00"
@SOMAXCONN = global i32 0
@.str.4 = [7 x i8] c"listen\00"
@.str.5 = [17 x i8] c"2: SOCKET FD=%d\0A\00"
@.str.7 = [7 x i8] c"accept\00"
@.str.8 = [39 x i8] c"4: accept FD=%d connect from %s : %u\0A\00"
@str = [18 x i8] c"3: wait in accept\00"
define i32 @socket_main(i8* %0, i32 %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp eq i8* %0, null
br i1 %9, label %70, label %10
10: ; preds = %2
%11 = load i32, i32* @PF_INET
%12 = load i32, i32* @SOCK_STREAM
%13 = tail call i32 @socket(i32 %11, i32 %12, i32 0)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %70
17: ; preds = %10
%18 = call i32 @bzero(i8* %6, i32 12)
%19 = load i32, i32* @PF_INET
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %19, i32* %20
%21 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 16)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load i32, i32* @INADDR_ANY
%25 = tail call i32 @htonl(i32 %24)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %25, i32* %26
br label %30
27: ; preds = %17
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%29 = call i32 @inet_aton(i8* %0, %struct.TYPE_3__* %28)
br label %30
30: ; preds = %27, %23
%31 = trunc i32 %1 to i16
%32 = call i32 @htons(i16 zeroext %31)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%35 = load i32, i32* %34
%36 = call i8* @inet_ntoa(i32 %35)
%37 = load i32, i32* %33
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %36, i32 %37)
%39 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%40 = call i64 @bind(i32 %13, %struct.sockaddr* %39, i32 12)
%41 = icmp slt i64 %40, 0
br i1 %41, label %66, label %42
42: ; preds = %30
%43 = load i32, i32* @SOMAXCONN
%44 = call i64 @listen(i32 %13, i32 %43)
%45 = icmp slt i64 %44, 0
br i1 %45, label %66, label %46
46: ; preds = %42
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %13)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%49 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%50 = call i32 @accept(i32 %13, %struct.sockaddr* %49, i32* %5)
%51 = icmp slt i32 %50, 0
br i1 %51, label %66, label %52
52: ; preds = %46
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
br label %55
55: ; preds = %52, %55
%56 = phi i32 [ %50, %52 ], [ %64, %55 ]
%57 = load i32, i32* %53
%58 = call i8* @inet_ntoa(i32 %57)
%59 = load i32, i32* %54
%60 = call i32 @ntohs(i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %56, i8* %58, i32 %60)
%62 = call i32 @create_receive_thread(i32 %56)
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%64 = call i32 @accept(i32 %13, %struct.sockaddr* %49, i32* %5)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %55
66: ; preds = %55, %46, %42, %30
%67 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %30 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %42 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %46 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %55 ]
%68 = call i32 @perror(i8* %67)
%69 = call i32 @close(i32 %13)
br label %70
70: ; preds = %15, %2, %66
%71 = phi i32 [ 0, %66 ], [ -1, %2 ], [ -1, %15 ]
ret i32 %71
}