#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 */

/* Type definitions */
struct sockaddr_nl {
  int nl_pid;
  int nlmsg_len;
  int nlmsg_pid;
  int msg_namelen;
  int msg_iovlen;
  struct iovec *msg_iov;
  void *msg_name;
  scalar_t__ nlmsg_flags;
  scalar_t__ nl_groups;
  void *nl_family;
};
struct sockaddr {
  int dummy;
};
struct nlmsghdr {
  int nl_pid;
  int nlmsg_len;
  int nlmsg_pid;
  int msg_namelen;
  int msg_iovlen;
  struct iovec *msg_iov;
  void *msg_name;
  scalar_t__ nlmsg_flags;
  scalar_t__ nl_groups;
  void *nl_family;
};
struct msghdr {
  int nl_pid;
  int nlmsg_len;
  int nlmsg_pid;
  int msg_namelen;
  int msg_iovlen;
  struct iovec *msg_iov;
  void *msg_name;
  scalar_t__ nlmsg_flags;
  scalar_t__ nl_groups;
  void *nl_family;
};
struct iovec {
  int iov_len;
  void *iov_base;
};
typedef int /*<<< orphan*/ src_addr;
typedef int /*<<< orphan*/ msg;
typedef int /*<<< orphan*/ dest_addr;

/* Variables and functions */
void *AF_NETLINK;
scalar_t__ NLMSG_DATA(struct sockaddr_nl *);
int NLMSG_SPACE(int);
int /*<<< orphan*/ SOCK_RAW;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(struct sockaddr_nl *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int recvmsg(int, struct sockaddr_nl *, int /*<<< orphan*/);
int sendmsg(int, struct sockaddr_nl *, int /*<<< orphan*/);
int socket(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(scalar_t__, char *);
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int state;
  struct sockaddr_nl src_addr, dest_addr;
  struct nlmsghdr *nlh = NULL;
  struct iovec iov;
  struct msghdr msg;
  int sock_fd, retval;
  int state_smg = 0;
  sock_fd = socket(AF_NETLINK, SOCK_RAW, 25);
  if (sock_fd == -1) {
    printf("error getting socket: %s", strerror(errno));
    return -1;
  }
  memset(&src_addr, 0, sizeof(src_addr));
  src_addr.nl_family = AF_NETLINK;
  src_addr.nl_pid = 100;
  src_addr.nl_groups = 0;
  retval = bind(sock_fd, (struct sockaddr *)&src_addr, sizeof(src_addr));
  if (retval < 0) {
    printf("bind failed: %s", strerror(errno));
    close(sock_fd);
    return -1;
  }
  nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(1024));
  if (!nlh) {
    printf("malloc nlmsghdr error!\n");
    close(sock_fd);
    return -1;
  }
  memset(&dest_addr, 0, sizeof(dest_addr));
  dest_addr.nl_family = AF_NETLINK;
  dest_addr.nl_pid = 0;
  dest_addr.nl_groups = 0;
  nlh->nlmsg_len = NLMSG_SPACE(1024);
  nlh->nlmsg_pid = 100;
  nlh->nlmsg_flags = 0;
  strcpy(NLMSG_DATA(nlh), "Hello you!");
  iov.iov_base = (void *)nlh;
  iov.iov_len = NLMSG_SPACE(1024);
  memset(&msg, 0, sizeof(msg));
  msg.msg_name = (void *)&dest_addr;
  msg.msg_namelen = sizeof(dest_addr);
  msg.msg_iov = &iov;
  msg.msg_iovlen = 1;
  printf("state_smg\n");
  state_smg = sendmsg(sock_fd, &msg, 0);
  if (state_smg == -1) {
    printf("get error sendmsg = %s\n", strerror(errno));
  }
  memset(nlh, 0, NLMSG_SPACE(1024));
  printf("waiting received!\n");
  while (1) {
    printf("In while recvmsg\n");
    state = recvmsg(sock_fd, &msg, 0);
    if (state < 0) {
      printf("state<1");
    }
    printf("Received message: %s\n", (char *)NLMSG_DATA(nlh));
  }
  close(sock_fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0xa0(%rbp)
movl   $0x0,-0xfc(%rbp)
mov    0x2deb(%rip),%rax
mov    (%rax),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
mov    $0x19,%edx
call   10e0 <socket@plt>
mov    %eax,-0xf4(%rbp)
cmpl   $0xffffffff,-0xf4(%rbp)
jne    1249 <main+0x89>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e9 <main+0x329>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x64,-0x58(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0xf4(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x40,%edx
call   10c0 <bind@plt>
mov    %eax,-0xf8(%rbp)
cmpl   $0x0,-0xf8(%rbp)
jge    12d3 <main+0x113>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xf4(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e9 <main+0x329>
mov    $0x400,%edi
call   1080 <NLMSG_SPACE@plt>
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0xa0(%rbp)
cmpq   $0x0,-0xa0(%rbp)
jne    131e <main+0x15e>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xf4(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e9 <main+0x329>
lea    -0x98(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x98(%rbp)
movq   $0x0,-0x68(%rbp)
mov    $0x400,%edi
call   1080 <NLMSG_SPACE@plt>
mov    %eax,%ecx
mov    -0xa0(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xa0(%rbp),%rax
movl   $0x64,0x8(%rax)
mov    -0xa0(%rbp),%rax
movq   $0x0,0x28(%rax)
mov    -0xa0(%rbp),%rdi
call   1090 <NLMSG_DATA@plt>
mov    %rax,%rdi
lea    0xca7(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    $0x400,%edi
call   1080 <NLMSG_SPACE@plt>
mov    %eax,-0xb0(%rbp)
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0x98(%rbp),%rax
mov    %rax,-0xd0(%rbp)
movl   $0x40,-0xe4(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
movl   $0x1,-0xe0(%rbp)
lea    0xc45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xf4(%rbp),%edi
lea    -0xf0(%rbp),%rsi
xor    %edx,%edx
call   1040 <sendmsg@plt>
mov    %eax,-0xfc(%rbp)
cmpl   $0xffffffff,-0xfc(%rbp)
jne    1454 <main+0x294>
mov    0x2b94(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xc0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xa0(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    $0x400,%edi
call   1080 <NLMSG_SPACE@plt>
mov    -0x108(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xbec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xf4(%rbp),%edi
lea    -0xf0(%rbp),%rsi
xor    %edx,%edx
call   10b0 <recvmsg@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    14c7 <main+0x307>
lea    0xbd4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xa0(%rbp),%rdi
call   1090 <NLMSG_DATA@plt>
mov    %rax,%rsi
lea    0xbbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    148a <main+0x2ca>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    0x2df8(%rip),%rbp
mov    0x0(%rbp),%rdi
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
mov    $0x19,%edx
call   10f0 <socket@plt>
cmp    $0xffffffff,%eax
je     13ea <main+0x21a>
mov    %eax,%r15d
lea    0x98(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
mov    0x0(%rbp),%rax
mov    %rax,0xd0(%rsp)
movl   $0x64,0x98(%rsp)
movq   $0x0,0xc8(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x40,%edx
call   10d0 <bind@plt>
test   %eax,%eax
js     140b <main+0x23b>
mov    $0x400,%edi
call   1090 <NLMSG_SPACE@plt>
mov    %eax,%edi
call   10b0 <malloc@plt>
test   %rax,%rax
je     142c <main+0x25c>
mov    %rax,%r12
lea    0x58(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x90(%rsp)
movl   $0x0,0x58(%rsp)
movq   $0x0,0x88(%rsp)
mov    $0x400,%edi
call   1090 <NLMSG_SPACE@plt>
mov    %eax,0x4(%r12)
movl   $0x64,0x8(%r12)
movq   $0x0,0x28(%r12)
mov    %r12,%rdi
call   10a0 <NLMSG_DATA@plt>
lea    0xd4b(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r12,0x10(%rsp)
mov    $0x400,%edi
call   1090 <NLMSG_SPACE@plt>
mov    %eax,0x8(%rsp)
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
mov    %r14,0x38(%rsp)
movabs $0x100000040,%rax
mov    %rax,0x24(%rsp)
lea    0x8(%rsp),%rax
mov    %rax,0x30(%rsp)
lea    0xd4f(%rip),%rdi
call   1050 <puts@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <sendmsg@plt>
cmp    $0xffffffff,%eax
jne    1368 <main+0x198>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xcd6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x400,%edi
call   1090 <NLMSG_SPACE@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1070 <memset@plt>
lea    0xd06(%rip),%rdi
call   1050 <puts@plt>
lea    0xd0c(%rip),%r13
lea    0x18(%rsp),%rbx
lea    0xcaf(%rip),%r14
lea    0xcb0(%rip),%rbp
jmp    13c5 <main+0x1f5>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   10a0 <NLMSG_DATA@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   10c0 <recvmsg@plt>
test   %eax,%eax
jns    13b0 <main+0x1e0>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13b0 <main+0x1e0>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc01(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1440 <main+0x270>
mov    0x2bbe(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xbf9(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1438 <main+0x268>
lea    0xc37(%rip),%rdi
call   1050 <puts@plt>
mov    %r15d,%edi
call   1080 <close@plt>
mov    $0xffffffff,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_nl = type { i32, i32, i32, i32, i32, %struct.iovec*, i8*, i64, i64, i8* }
%struct.iovec = type { i32, i8* }
%struct.nlmsghdr = type { i32, i32, i32, i32, i32, %struct.iovec*, i8*, i64, i64, i8* }
%struct.msghdr = type { i32, i32, i32, i32, i32, %struct.iovec*, i8*, i64, i64, i8* }
%struct.sockaddr = type { i32 }
@AF_NETLINK = global i8* null
@SOCK_RAW = global i32 0
@.str = [25 x i8] c"error getting socket: %s\00"
@errno = global i32 0
@.str.1 = [16 x i8] c"bind failed: %s\00"
@.str.2 = [24 x i8] c"malloc nlmsghdr error!\0A\00"
@.str.3 = [11 x i8] c"Hello you!\00"
@.str.4 = [11 x i8] c"state_smg\0A\00"
@.str.5 = [24 x i8] c"get error sendmsg = %s\0A\00"
@.str.6 = [19 x i8] c"waiting received!\0A\00"
@.str.7 = [18 x i8] c"In while recvmsg\0A\00"
@.str.8 = [8 x i8] c"state<1\00"
@.str.9 = [22 x i8] c"Received 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 %struct.sockaddr_nl
%8 = alloca %struct.sockaddr_nl
%9 = alloca %struct.nlmsghdr*
%10 = alloca %struct.iovec
%11 = alloca %struct.msghdr
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.nlmsghdr* null, %struct.nlmsghdr** %9
store i32 0, i32* %14
%15 = load i8*, i8** @AF_NETLINK
%16 = load i32, i32* @SOCK_RAW
%17 = call i32 @socket(i8* %15, i32 %16, i32 25)
store i32 %17, i32* %12
%18 = load i32, i32* %12
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %22)
store i32 -1, i32* %3
br label %111
24: ; preds = %2
%25 = call i32 @memset(%struct.sockaddr_nl* %7, i32 0, i32 64)
%26 = load i8*, i8** @AF_NETLINK
%27 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %7, i32 0, i32 9
store i8* %26, i8** %27
%28 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %7, i32 0, i32 0
store i32 100, i32* %28
%29 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %7, i32 0, i32 8
store i64 0, i64* %29
%30 = load i32, i32* %12
%31 = bitcast %struct.sockaddr_nl* %7 to %struct.sockaddr*
%32 = call i32 @bind(i32 %30, %struct.sockaddr* %31, i32 64)
store i32 %32, i32* %13
%33 = load i32, i32* %13
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %24
%36 = load i32, i32* @errno
%37 = call i8* @strerror(i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %12
%40 = call i32 @close(i32 %39)
store i32 -1, i32* %3
br label %111
41: ; preds = %24
%42 = call i32 @NLMSG_SPACE(i32 1024)
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to %struct.nlmsghdr*
store %struct.nlmsghdr* %44, %struct.nlmsghdr** %9
%45 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%46 = icmp ne %struct.nlmsghdr* %45, null
br i1 %46, label %51, label %47
47: ; preds = %41
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* %12
%50 = call i32 @close(i32 %49)
store i32 -1, i32* %3
br label %111
51: ; preds = %41
%52 = call i32 @memset(%struct.sockaddr_nl* %8, i32 0, i32 64)
%53 = load i8*, i8** @AF_NETLINK
%54 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %8, i32 0, i32 9
store i8* %53, i8** %54
%55 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %8, i32 0, i32 0
store i32 0, i32* %55
%56 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %8, i32 0, i32 8
store i64 0, i64* %56
%57 = call i32 @NLMSG_SPACE(i32 1024)
%58 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%59 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %58, i32 0, i32 1
store i32 %57, i32* %59
%60 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%61 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %60, i32 0, i32 2
store i32 100, i32* %61
%62 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%63 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %62, i32 0, i32 7
store i64 0, i64* %63
%64 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%65 = bitcast %struct.nlmsghdr* %64 to %struct.sockaddr_nl*
%66 = call i64 @NLMSG_DATA(%struct.sockaddr_nl* %65)
%67 = call i32 @strcpy(i64 %66, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%68 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%69 = bitcast %struct.nlmsghdr* %68 to i8*
%70 = getelementptr inbounds %struct.iovec, %struct.iovec* %10, i32 0, i32 1
store i8* %69, i8** %70
%71 = call i32 @NLMSG_SPACE(i32 1024)
%72 = getelementptr inbounds %struct.iovec, %struct.iovec* %10, i32 0, i32 0
store i32 %71, i32* %72
%73 = bitcast %struct.msghdr* %11 to %struct.sockaddr_nl*
%74 = call i32 @memset(%struct.sockaddr_nl* %73, i32 0, i32 64)
%75 = bitcast %struct.sockaddr_nl* %8 to i8*
%76 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %11, i32 0, i32 6
store i8* %75, i8** %76
%77 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %11, i32 0, i32 3
store i32 64, i32* %77
%78 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %11, i32 0, i32 5
store %struct.iovec* %10, %struct.iovec** %78
%79 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %11, i32 0, i32 4
store i32 1, i32* %79
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%81 = load i32, i32* %12
%82 = bitcast %struct.msghdr* %11 to %struct.sockaddr_nl*
%83 = call i32 @sendmsg(i32 %81, %struct.sockaddr_nl* %82, i32 0)
store i32 %83, i32* %14
%84 = load i32, i32* %14
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %90
86: ; preds = %51
%87 = load i32, i32* @errno
%88 = call i8* @strerror(i32 %87)
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %86, %51
%91 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%92 = bitcast %struct.nlmsghdr* %91 to %struct.sockaddr_nl*
%93 = call i32 @NLMSG_SPACE(i32 1024)
%94 = call i32 @memset(%struct.sockaddr_nl* %92, i32 0, i32 %93)
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %96
96: ; preds = %90, %105
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%98 = load i32, i32* %12
%99 = bitcast %struct.msghdr* %11 to %struct.sockaddr_nl*
%100 = call i32 @recvmsg(i32 %98, %struct.sockaddr_nl* %99, i32 0)
store i32 %100, i32* %6
%101 = load i32, i32* %6
%102 = icmp slt i32 %101, 0
br i1 %102, label %103, label %105
103: ; preds = %96
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %105
105: ; preds = %103, %96
%106 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%107 = bitcast %struct.nlmsghdr* %106 to %struct.sockaddr_nl*
%108 = call i64 @NLMSG_DATA(%struct.sockaddr_nl* %107)
%109 = inttoptr i64 %108 to i8*
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* %109)
br label %96
111: ; preds = %47, %35, %20
%112 = load i32, i32* %3
ret i32 %112
}

LLVM IR (-O2):
%struct.sockaddr_nl = type { i32, i32, i32, i32, i32, %struct.iovec*, i8*, i64, i64, i8* }
%struct.iovec = type { i32, i8* }
%struct.msghdr = type { i32, i32, i32, i32, i32, %struct.iovec*, i8*, i64, i64, i8* }
%struct.nlmsghdr = type { i32, i32, i32, i32, i32, %struct.iovec*, i8*, i64, i64, i8* }
%struct.sockaddr = type { i32 }
@AF_NETLINK = global i8* null
@SOCK_RAW = global i32 0
@.str = [25 x i8] c"error getting socket: %s\00"
@errno = global i32 0
@.str.1 = [16 x i8] c"bind failed: %s\00"
@.str.3 = [11 x i8] c"Hello you!\00"
@.str.5 = [24 x i8] c"get error sendmsg = %s\0A\00"
@.str.8 = [8 x i8] c"state<1\00"
@.str.9 = [22 x i8] c"Received message: %s\0A\00"
@str = [23 x i8] c"malloc nlmsghdr error!\00"
@str.10 = [10 x i8] c"state_smg\00"
@str.11 = [18 x i8] c"waiting received!\00"
@str.12 = [17 x i8] c"In while recvmsg\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_nl
%4 = alloca %struct.sockaddr_nl
%5 = alloca %struct.iovec
%6 = alloca %struct.msghdr
%7 = bitcast %struct.sockaddr_nl* %3 to i8*
%8 = bitcast %struct.sockaddr_nl* %4 to i8*
%9 = bitcast %struct.iovec* %5 to i8*
%10 = bitcast %struct.msghdr* %6 to i8*
%11 = load i8*, i8** @AF_NETLINK
%12 = load i32, i32* @SOCK_RAW
%13 = tail call i32 @socket(i8* %11, i32 %12, i32 25)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %86
19: ; preds = %2
%20 = call i32 @memset(%struct.sockaddr_nl* %3, i32 0, i32 64)
%21 = load i8*, i8** @AF_NETLINK
%22 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %3, i64 0, i32 9
store i8* %21, i8** %22
%23 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %3, i64 0, i32 0
store i32 100, i32* %23
%24 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %3, i64 0, i32 8
store i64 0, i64* %24
%25 = bitcast %struct.sockaddr_nl* %3 to %struct.sockaddr*
%26 = call i32 @bind(i32 %13, %struct.sockaddr* %25, i32 64)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %19
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = call i32 @close(i32 %13)
br label %86
33: ; preds = %19
%34 = call i32 @NLMSG_SPACE(i32 1024)
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to %struct.nlmsghdr*
%37 = icmp eq i64 %35, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%40 = call i32 @close(i32 %13)
br label %86
41: ; preds = %33
%42 = call i32 @memset(%struct.sockaddr_nl* %4, i32 0, i32 64)
%43 = load i8*, i8** @AF_NETLINK
%44 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %4, i64 0, i32 9
store i8* %43, i8** %44
%45 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %4, i64 0, i32 0
store i32 0, i32* %45
%46 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %4, i64 0, i32 8
store i64 0, i64* %46
%47 = call i32 @NLMSG_SPACE(i32 1024)
%48 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %36, i64 0, i32 1
store i32 %47, i32* %48
%49 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %36, i64 0, i32 2
store i32 100, i32* %49
%50 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %36, i64 0, i32 7
store i64 0, i64* %50
%51 = inttoptr i64 %35 to %struct.sockaddr_nl*
%52 = call i64 @NLMSG_DATA(%struct.sockaddr_nl* %51)
%53 = call i32 @strcpy(i64 %52, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%54 = inttoptr i64 %35 to i8*
%55 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i64 0, i32 1
store i8* %54, i8** %55
%56 = call i32 @NLMSG_SPACE(i32 1024)
%57 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i64 0, i32 0
store i32 %56, i32* %57
%58 = bitcast %struct.msghdr* %6 to %struct.sockaddr_nl*
%59 = call i32 @memset(%struct.sockaddr_nl* %58, i32 0, i32 64)
%60 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 6
%61 = bitcast i8** %60 to %struct.sockaddr_nl**
store %struct.sockaddr_nl* %4, %struct.sockaddr_nl** %61
%62 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 3
store i32 64, i32* %62
%63 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 5
store %struct.iovec* %5, %struct.iovec** %63
%64 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 4
store i32 1, i32* %64
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%66 = call i32 @sendmsg(i32 %13, %struct.sockaddr_nl* %58, i32 0)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %72
68: ; preds = %41
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %68, %41
%73 = call i32 @NLMSG_SPACE(i32 1024)
%74 = call i32 @memset(%struct.sockaddr_nl* %51, i32 0, i32 %73)
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.11, i64 0, i64 0))
br label %76
76: ; preds = %82, %72
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%78 = call i32 @recvmsg(i32 %13, %struct.sockaddr_nl* %58, i32 0)
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %82
82: ; preds = %80, %76
%83 = call i64 @NLMSG_DATA(%struct.sockaddr_nl* %51)
%84 = inttoptr i64 %83 to i8*
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* %84)
br label %76
86: ; preds = %38, %28, %15
ret i32 -1
}