#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 */
typedef int /*<<< orphan*/ va;
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;
};
struct msghdr {
  int msg_iovlen;
  scalar_t__ msg_controllen;
  void *msg_control;
  struct iovec *msg_iov;
  scalar_t__ msg_namelen;
  scalar_t__ msg_name;
};
struct iovec {
  char *iov_base;
  int iov_len;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sin;
typedef int /*<<< orphan*/ pid_t;
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_OOBINLINE;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int listen(int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int recvmsg(int, struct msghdr *, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
char *strerror(int);
int main() {
  int sock = 0, ret = 0, val = 0, len = 0, tfd = 0;
  int csk[5];
  struct sockaddr_in sin;
  pid_t pid;
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = inet_addr("10.151.12.112");
  sin.sin_port = htons(10292);
  if ((pid = fork()) == 0) {
    int fd, len;
    int va = 0;
    int cnt, scnt;
    char buff[1024];
    sock = socket(AF_INET, SOCK_STREAM, 0);
    if (sock == -1) {
      perror("socket failed");
      exit(-1);
    }
    printf("sock %d\n", sock);
    ret = bind(sock, (struct sockaddr *)&sin, sizeof(struct sockaddr_in));
    if (ret == -1) {
      perror("bind failed");
      printf("errno = %d(%s)\n", errno, strerror(errno));
      exit(-1);
    }
    va = 0;
    setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, &va, sizeof(va));
    ret = listen(sock, 3);
    if (ret == -1) {
      perror("listen failed");
      printf("errno = %d(%s)\n", errno, strerror(errno));
      exit(-1);
    }
    len = (socklen_t)sizeof(sin);
    fd = accept(sock, (struct sockaddr *)&sin, &len);
    while ((cnt = recv(fd, buff, sizeof(buff), 0)) != 0) {
      if (cnt == -1)
        continue;
      scnt = send(fd, buff, cnt, 0);
      if (scnt == -1) {
        printf("server send failed %s\n", strerror(errno));
        return -1;
      }
    }
    sleep(100);
    exit(1);
  }
  sleep(3);
  val = 0;
  {
    csk[val] = socket(AF_INET, SOCK_STREAM, 0);
    if (csk[val] == -1) {
      perror("csk socket failed");
      exit(-1);
    }
    struct msghdr rhdr;
    struct iovec riov[5];
    char rbuf[1024];
    int i;
    memset(rbuf, 0, 1024);
    rhdr.msg_name = 0;
    rhdr.msg_namelen = 0;
    rhdr.msg_iov = riov;
    rhdr.msg_iovlen = 4;
    rhdr.msg_control = (void *)0;
    rhdr.msg_controllen = 0;
    for (i = 0; i < 4; i++) {
      riov[i].iov_base = &rbuf[i * 5];
      riov[i].iov_len = 5;
    }
    ret = recvmsg(csk[val], (struct msghdr *)&rhdr, 0);
    if (ret == -1) {
      printf("recvmsg failed client errno = %d(%s)\n", errno, strerror(errno));
      exit(-1);
    } else
      printf("recvmsg %d(%s)\n", ret, rbuf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2d94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
lea    0xda8(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x2834,%edi
call   1050 <htons@plt>
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
jne    147b <main+0x26b>
movl   $0x0,-0x50(%rbp)
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    12c3 <main+0xb3>
lea    0xd98(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    -0x8(%rbp),%esi
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    133c <main+0x12c>
lea    0xd1e(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2cc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8e8(%rbp)
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x8e8(%rbp),%esi
mov    %rax,%rdx
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2c9b(%rip),%rax
mov    (%rax),%esi
mov    0x2c6a(%rip),%rax
mov    (%rax),%edx
lea    -0x50(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   10a0 <listen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    13cb <main+0x1bb>
lea    0xc9b(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2c34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8ec(%rbp)
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x8ec(%rbp),%esi
mov    %rax,%rdx
lea    0xcb6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
movl   $0xc,-0x4c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   10e0 <accept@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%edi
lea    -0x460(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
je     1467 <main+0x257>
cmpl   $0xffffffff,-0x54(%rbp)
jne    1416 <main+0x206>
jmp    13e5 <main+0x1d5>
mov    -0x48(%rbp),%edi
lea    -0x460(%rbp),%rsi
mov    -0x54(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    1462 <main+0x252>
mov    0x2b8a(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xbe2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    161d <main+0x40d>
jmp    13e5 <main+0x1d5>
mov    $0x64,%edi
call   1110 <sleep@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    $0x3,%edi
call   1110 <sleep@plt>
movl   $0x0,-0x10(%rbp)
mov    0x2b4d(%rip),%rax
mov    (%rax),%edi
mov    0x2b34(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
movslq -0x10(%rbp),%rax
cmpl   $0xffffffff,-0x30(%rbp,%rax,4)
jne    14d4 <main+0x2c4>
lea    0xb83(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
lea    -0x8e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
movq   $0x0,-0x468(%rbp)
movq   $0x0,-0x470(%rbp)
lea    -0x4e0(%rbp),%rax
mov    %rax,-0x478(%rbp)
movl   $0x4,-0x490(%rbp)
movq   $0x0,-0x480(%rbp)
movq   $0x0,-0x488(%rbp)
movl   $0x0,-0x8e4(%rbp)
cmpl   $0x4,-0x8e4(%rbp)
jge    159d <main+0x38d>
imul   $0x5,-0x8e4(%rbp),%eax
cltq
lea    -0x8e0(%rbp),%rcx
add    %rax,%rcx
movslq -0x8e4(%rbp),%rdx
lea    -0x4e0(%rbp),%rax
shl    $0x4,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
movslq -0x8e4(%rbp),%rcx
lea    -0x4e0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movl   $0x5,0x8(%rax)
mov    -0x8e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8e4(%rbp)
jmp    1535 <main+0x325>
movslq -0x10(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
lea    -0x490(%rbp),%rsi
xor    %edx,%edx
call   10b0 <recvmsg@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    15fe <main+0x3ee>
mov    0x2a01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8f0(%rbp)
mov    0x29f2(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x8f0(%rbp),%esi
mov    %rax,%rdx
lea    0xa6d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    -0xc(%rbp),%esi
lea    -0x8e0(%rbp),%rdx
lea    0xa71(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x490,%rsp
mov    0x2dbe(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
lea    0xdd1(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x4(%rsp)
mov    $0x2834,%edi
call   1050 <htons@plt>
mov    %eax,(%rsp)
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     1333 <main+0x123>
mov    $0x3,%edi
call   1110 <sleep@plt>
mov    (%rbx),%edi
mov    0x2d69(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
je     1453 <main+0x243>
mov    %eax,%ebp
lea    0x90(%rsp),%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x30(%rsp)
lea    0x40(%rsp),%rax
mov    %rax,0x28(%rsp)
movl   $0x4,0x10(%rsp)
movups %xmm0,0x18(%rsp)
mov    %r14,0x40(%rsp)
movl   $0x5,0x48(%rsp)
lea    0x95(%rsp),%rax
mov    %rax,0x50(%rsp)
movl   $0x5,0x58(%rsp)
lea    0x9a(%rsp),%rax
mov    %rax,0x60(%rsp)
movl   $0x5,0x68(%rsp)
lea    0x9f(%rsp),%rax
mov    %rax,0x70(%rsp)
movl   $0x5,0x78(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
xor    %edx,%edx
call   10b0 <recvmsg@plt>
cmp    $0xffffffff,%eax
je     145c <main+0x24c>
lea    0xd63(%rip),%rdi
lea    0x90(%rsp),%rdx
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1431 <main+0x221>
mov    (%rbx),%edi
mov    0x2c94(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
je     1475 <main+0x265>
mov    %eax,%ebx
lea    0xcb7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
je     148b <main+0x27b>
movl   $0x0,0x10(%rsp)
mov    0x2c61(%rip),%rax
mov    (%rax),%esi
mov    0x2c30(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    %ebx,%edi
mov    $0x3,%esi
call   10a0 <listen@plt>
cmp    $0xffffffff,%eax
je     1494 <main+0x284>
movl   $0xc,0x40(%rsp)
mov    %rsp,%rsi
lea    0x40(%rsp),%rdx
mov    %ebx,%edi
call   10e0 <accept@plt>
mov    %eax,%ebx
lea    0x90(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     13e0 <main+0x1d0>
test   %eax,%eax
je     143f <main+0x22f>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    13e0 <main+0x1d0>
mov    0x2bb4(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc0f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x490,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x64,%edi
call   1110 <sleep@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xbee(%rip),%rdi
jmp    147c <main+0x26c>
mov    0x2b65(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xbe7(%rip),%rdi
jmp    14b7 <main+0x2a7>
lea    0xbd0(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
lea    0xb85(%rip),%rdi
jmp    149b <main+0x28b>
lea    0xb88(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2b21(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xbb9(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.msghdr = type { i32, i64, i8*, %struct.iovec*, i64, i64 }
%struct.iovec = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@.str = [14 x i8] c"10.151.12.112\00"
@SOCK_STREAM = global i32 0
@.str.1 = [14 x i8] c"socket failed\00"
@.str.2 = [9 x i8] c"sock %d\0A\00"
@.str.3 = [12 x i8] c"bind failed\00"
@.str.4 = [16 x i8] c"errno = %d(%s)\0A\00"
@errno = global i32 0
@SOL_SOCKET = global i32 0
@SO_OOBINLINE = global i32 0
@.str.5 = [14 x i8] c"listen failed\00"
@.str.6 = [23 x i8] c"server send failed %s\0A\00"
@.str.7 = [18 x i8] c"csk socket failed\00"
@.str.8 = [38 x i8] c"recvmsg failed client errno = %d(%s)\0A\00"
@.str.9 = [16 x i8] c"recvmsg %d(%s)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [5 x i32]
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [1024 x i8]
%16 = alloca %struct.msghdr
%17 = alloca [5 x %struct.iovec]
%18 = alloca [1024 x i8]
%19 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%20 = load i32, i32* @AF_INET
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %20, i32* %21
%22 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
store i32 %22, i32* %24
%25 = call i32 @htons(i32 10292)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %25, i32* %26
%27 = call i32 (...) @fork()
store i32 %27, i32* %9
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %97
29: ; preds = %0
store i32 0, i32* %12
%30 = load i32, i32* @AF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = call i32 @socket(i32 %30, i32 %31, i32 0)
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %29
%39 = load i32, i32* %2
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %2
%42 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%43 = call i32 @bind(i32 %41, %struct.sockaddr* %42, i32 12)
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %53
46: ; preds = %38
%47 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%48 = load i32, i32* @errno
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %48, i8* %50)
%52 = call i32 @exit(i32 -1)
unreachable
53: ; preds = %38
store i32 0, i32* %12
%54 = load i32, i32* %2
%55 = load i32, i32* @SOL_SOCKET
%56 = load i32, i32* @SO_OOBINLINE
%57 = call i32 @setsockopt(i32 %54, i32 %55, i32 %56, i32* %12, i32 4)
%58 = load i32, i32* %2
%59 = call i32 @listen(i32 %58, i32 3)
store i32 %59, i32* %3
%60 = load i32, i32* %3
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %69
62: ; preds = %53
%63 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%64 = load i32, i32* @errno
%65 = load i32, i32* @errno
%66 = call i8* @strerror(i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %64, i8* %66)
%68 = call i32 @exit(i32 -1)
unreachable
69: ; preds = %53
store i32 12, i32* %11
%70 = load i32, i32* %2
%71 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%72 = call i32 @accept(i32 %70, %struct.sockaddr* %71, i32* %11)
store i32 %72, i32* %10
br label %73
73: ; preds = %93, %81, %69
%74 = load i32, i32* %10
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%76 = call i32 @recv(i32 %74, i8* %75, i32 1024, i32 0)
store i32 %76, i32* %13
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %94
78: ; preds = %73
%79 = load i32, i32* %13
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %82
81: ; preds = %78
br label %73
82: ; preds = %78
%83 = load i32, i32* %10
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%85 = load i32, i32* %13
%86 = call i32 @send(i32 %83, i8* %84, i32 %85, i32 0)
store i32 %86, i32* %14
%87 = load i32, i32* %14
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %93
89: ; preds = %82
%90 = load i32, i32* @errno
%91 = call i8* @strerror(i32 %90)
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %91)
store i32 -1, i32* %1
br label %161
93: ; preds = %82
br label %73
94: ; preds = %73
%95 = call i32 @sleep(i32 100)
%96 = call i32 @exit(i32 1)
unreachable
97: ; preds = %0
%98 = call i32 @sleep(i32 3)
store i32 0, i32* %4
%99 = load i32, i32* @AF_INET
%100 = load i32, i32* @SOCK_STREAM
%101 = call i32 @socket(i32 %99, i32 %100, i32 0)
%102 = load i32, i32* %4
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %103
store i32 %101, i32* %104
%105 = load i32, i32* %4
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %106
%108 = load i32, i32* %107
%109 = icmp eq i32 %108, -1
br i1 %109, label %110, label %113
110: ; preds = %97
%111 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%112 = call i32 @exit(i32 -1)
unreachable
113: ; preds = %97
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%115 = call i32 @memset(i8* %114, i32 0, i32 1024)
%116 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %16, i32 0, i32 5
store i64 0, i64* %116
%117 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %16, i32 0, i32 4
store i64 0, i64* %117
%118 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %17, i64 0, i64 0
%119 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %16, i32 0, i32 3
store %struct.iovec* %118, %struct.iovec** %119
%120 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %16, i32 0, i32 0
store i32 4, i32* %120
%121 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %16, i32 0, i32 2
store i8* null, i8** %121
%122 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %16, i32 0, i32 1
store i64 0, i64* %122
store i32 0, i32* %19
br label %123
123: ; preds = %139, %113
%124 = load i32, i32* %19
%125 = icmp slt i32 %124, 4
br i1 %125, label %126, label %142
126: ; preds = %123
%127 = load i32, i32* %19
%128 = mul nsw i32 %127, 5
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 %129
%131 = load i32, i32* %19
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %17, i64 0, i64 %132
%134 = getelementptr inbounds %struct.iovec, %struct.iovec* %133, i32 0, i32 0
store i8* %130, i8** %134
%135 = load i32, i32* %19
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %17, i64 0, i64 %136
%138 = getelementptr inbounds %struct.iovec, %struct.iovec* %137, i32 0, i32 1
store i32 5, i32* %138
br label %139
139: ; preds = %126
%140 = load i32, i32* %19
%141 = add nsw i32 %140, 1
store i32 %141, i32* %19
br label %123
142: ; preds = %123
%143 = load i32, i32* %4
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %144
%146 = load i32, i32* %145
%147 = call i32 @recvmsg(i32 %146, %struct.msghdr* %16, i32 0)
store i32 %147, i32* %3
%148 = load i32, i32* %3
%149 = icmp eq i32 %148, -1
br i1 %149, label %150, label %156
150: ; preds = %142
%151 = load i32, i32* @errno
%152 = load i32, i32* @errno
%153 = call i8* @strerror(i32 %152)
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %151, i8* %153)
%155 = call i32 @exit(i32 -1)
unreachable
156: ; preds = %142
%157 = load i32, i32* %3
%158 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %157, i8* %158)
br label %160
160: ; preds = %156
store i32 0, i32* %1
br label %161
161: ; preds = %160, %89
%162 = load i32, i32* %1
ret i32 %162
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.msghdr = type { i32, i64, i8*, %struct.iovec*, i64, i64 }
%struct.iovec = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@.str = [14 x i8] c"10.151.12.112\00"
@SOCK_STREAM = global i32 0
@.str.1 = [14 x i8] c"socket failed\00"
@.str.2 = [9 x i8] c"sock %d\0A\00"
@.str.3 = [12 x i8] c"bind failed\00"
@.str.4 = [16 x i8] c"errno = %d(%s)\0A\00"
@errno = global i32 0
@SOL_SOCKET = global i32 0
@SO_OOBINLINE = global i32 0
@.str.5 = [14 x i8] c"listen failed\00"
@.str.6 = [23 x i8] c"server send failed %s\0A\00"
@.str.7 = [18 x i8] c"csk socket failed\00"
@.str.8 = [38 x i8] c"recvmsg failed client errno = %d(%s)\0A\00"
@.str.9 = [16 x i8] c"recvmsg %d(%s)\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca %struct.msghdr
%6 = alloca [5 x %struct.iovec]
%7 = alloca [1024 x i8]
%8 = bitcast %struct.sockaddr_in* %1 to i8*
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %9, i32* %10
%11 = tail call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %11, i32* %12
%13 = tail call i32 @htons(i32 10292)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %13, i32* %14
%15 = tail call i32 (...) @fork()
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %66
17: ; preds = %0
%18 = bitcast i32* %2 to i8*
%19 = bitcast i32* %3 to i8*
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%21 = load i32, i32* @AF_INET
%22 = load i32, i32* @SOCK_STREAM
%23 = tail call i32 @socket(i32 %21, i32 %22, i32 0)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%27 = tail call i32 @exit(i32 -1)
unreachable
28: ; preds = %17
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%30 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%31 = call i32 @bind(i32 %23, %struct.sockaddr* %30, i32 12)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %39
33: ; preds = %28
%34 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %35, i8* %36)
%38 = call i32 @exit(i32 -1)
unreachable
39: ; preds = %28
store i32 0, i32* %3
%40 = load i32, i32* @SOL_SOCKET
%41 = load i32, i32* @SO_OOBINLINE
%42 = call i32 @setsockopt(i32 %23, i32 %40, i32 %41, i32* %3, i32 4)
%43 = call i32 @listen(i32 %23, i32 3)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %51
45: ; preds = %39
%46 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%47 = load i32, i32* @errno
%48 = call i8* @strerror(i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %47, i8* %48)
%50 = call i32 @exit(i32 -1)
unreachable
51: ; preds = %39
store i32 12, i32* %2
%52 = call i32 @accept(i32 %23, %struct.sockaddr* %30, i32* %2)
br label %53
53: ; preds = %58, %51
%54 = call i32 @recv(i32 %52, i8* %20, i32 1024, i32 0)
switch i32 %54, label %55 [
i32 0, label %63
i32 -1, label %58
]
55: ; preds = %53
%56 = call i32 @send(i32 %52, i8* %20, i32 %54, i32 0)
%57 = icmp eq i32 %56, -1
br i1 %57, label %59, label %58
58: ; preds = %55, %53
br label %53
59: ; preds = %55
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %61)
br label %107
63: ; preds = %53
%64 = call i32 @sleep(i32 100)
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %0
%67 = tail call i32 @sleep(i32 3)
%68 = load i32, i32* @AF_INET
%69 = load i32, i32* @SOCK_STREAM
%70 = tail call i32 @socket(i32 %68, i32 %69, i32 0)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %75
72: ; preds = %66
%73 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%74 = tail call i32 @exit(i32 -1)
unreachable
75: ; preds = %66
%76 = bitcast %struct.msghdr* %5 to i8*
%77 = bitcast [5 x %struct.iovec]* %6 to i8*
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%79 = call i32 @memset(i8* %78, i32 0, i32 1024)
%80 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 4
%81 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 0
%82 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 3
%83 = bitcast i64* %80 to i8*
store %struct.iovec* %81, %struct.iovec** %82
%84 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 0
store i32 4, i32* %84
%85 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 1
%86 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 0, i32 0
%87 = bitcast i64* %85 to i8*
store i8* %78, i8** %86
%88 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 0, i32 1
store i32 5, i32* %88
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 5
%90 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 1, i32 0
store i8* %89, i8** %90
%91 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 1, i32 1
store i32 5, i32* %91
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 10
%93 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 2, i32 0
store i8* %92, i8** %93
%94 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 2, i32 1
store i32 5, i32* %94
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 15
%96 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 3, i32 0
store i8* %95, i8** %96
%97 = getelementptr inbounds [5 x %struct.iovec], [5 x %struct.iovec]* %6, i64 0, i64 3, i32 1
store i32 5, i32* %97
%98 = call i32 @recvmsg(i32 %70, %struct.msghdr* %5, i32 0)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %105
100: ; preds = %75
%101 = load i32, i32* @errno
%102 = call i8* @strerror(i32 %101)
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %101, i8* %102)
%104 = call i32 @exit(i32 -1)
unreachable
105: ; preds = %75
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %98, i8* %78)
br label %107
107: ; preds = %105, %59
%108 = phi i32 [ -1, %59 ], [ 0, %105 ]
ret i32 %108
}