#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;
  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;
  scalar_t__ nlmsg_flags;
  scalar_t__ nl_groups;
  void *nl_family;
};
typedef int /*<<< orphan*/ src_addr;
typedef int /*<<< orphan*/ dest_addr;

/* Variables and functions */
void *AF_NETLINK;
scalar_t__ NLMSG_DATA(struct sockaddr_nl *);
int /*<<< orphan*/ NLMSG_LENGTH(int);
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 recvfrom(int, struct sockaddr_nl *, int /*<<< orphan*/, int /*<<< orphan*/,
             int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sendto(int, struct sockaddr_nl *, int /*<<< orphan*/,
                          int /*<<< orphan*/, struct sockaddr *, int);
int socket(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(scalar_t__, char *);
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct sockaddr_nl src_addr, dest_addr;
  struct nlmsghdr *nlh = NULL;
  int sock_fd, retval;
  int state, 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!");
  printf("state_smg\n");
  sendto(sock_fd, nlh, NLMSG_LENGTH(1024), 0, (struct sockaddr *)(&dest_addr),
         sizeof(dest_addr));
  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 = recvfrom(sock_fd, nlh, NLMSG_LENGTH(1024), 0, NULL, NULL);
    if (state < 0) {
      printf("state<1");
    }
    printf("Received message: %s\n", (char *)NLMSG_DATA(nlh));
    memset(nlh, 0, NLMSG_SPACE(1024));
  }
  close(sock_fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x68(%rbp)
movl   $0x0,-0x78(%rbp)
mov    0x2de1(%rip),%rax
mov    (%rax),%rdi
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
mov    $0x19,%edx
call   10f0 <socket@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    124d <main+0x7d>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c7 <main+0x2f7>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x64,-0x38(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x6c(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x28,%edx
call   10d0 <bind@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    12cb <main+0xfb>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x6c(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c7 <main+0x2f7>
mov    $0x400,%edi
call   1090 <NLMSG_SPACE@plt>
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    130d <main+0x13d>
lea    0xd37(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x6c(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c7 <main+0x2f7>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
mov    0x2cbc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x60(%rbp)
movq   $0x0,-0x48(%rbp)
mov    $0x400,%edi
call   1090 <NLMSG_SPACE@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x68(%rbp),%rax
movl   $0x64,0x8(%rax)
mov    -0x68(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    -0x68(%rbp),%rdi
call   10a0 <NLMSG_DATA@plt>
mov    %rax,%rdi
lea    0xcca(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    $0x400,%edi
call   1040 <NLMSG_LENGTH@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
lea    -0x60(%rbp),%r8
xor    %ecx,%ecx
mov    $0x28,%r9d
call   1070 <sendto@plt>
cmpl   $0xffffffff,-0x78(%rbp)
jne    13eb <main+0x21b>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xc73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    $0x400,%edi
call   1090 <NLMSG_SPACE@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xc58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    $0x400,%edi
call   1040 <NLMSG_LENGTH@plt>
mov    -0x9c(%rbp),%edi
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10c0 <recvfrom@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jge    1483 <main+0x2b3>
lea    0xc18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rdi
call   10a0 <NLMSG_DATA@plt>
mov    %rax,%rsi
lea    0xc06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    $0x400,%edi
call   1090 <NLMSG_SPACE@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
jmp    141e <main+0x24e>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    0x2ded(%rip),%rbp
mov    0x0(%rbp),%rdi
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
mov    $0x19,%edx
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
je     13a2 <main+0x1c2>
mov    %eax,%r14d
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x48(%rsp)
movl   $0x64,0x28(%rsp)
movq   $0x0,0x40(%rsp)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x28,%edx
call   10e0 <bind@plt>
test   %eax,%eax
js     13c3 <main+0x1e3>
mov    $0x400,%edi
call   10a0 <NLMSG_SPACE@plt>
mov    %eax,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     13e4 <main+0x204>
mov    %rax,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x20(%rsp)
movl   $0x0,(%rsp)
movq   $0x0,0x18(%rsp)
mov    $0x400,%edi
call   10a0 <NLMSG_SPACE@plt>
mov    %eax,0x4(%rbx)
movl   $0x64,0x8(%rbx)
movq   $0x0,0x10(%rbx)
mov    %rbx,%rdi
call   10b0 <NLMSG_DATA@plt>
lea    0xd5a(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xd8b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x400,%edi
call   1050 <NLMSG_LENGTH@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    $0x28,%r9d
call   1080 <sendto@plt>
mov    $0x400,%edi
call   10a0 <NLMSG_SPACE@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1070 <memset@plt>
lea    0xd51(%rip),%rdi
call   1040 <puts@plt>
lea    0xd57(%rip),%r12
lea    0xcff(%rip),%r15
lea    0xd00(%rip),%rbp
jmp    136b <main+0x18b>
xchg   %ax,%ax
mov    %rbx,%rdi
call   10b0 <NLMSG_DATA@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x400,%edi
call   10a0 <NLMSG_SPACE@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1070 <memset@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    $0x400,%edi
call   1050 <NLMSG_LENGTH@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10d0 <recvfrom@plt>
test   %eax,%eax
jns    1340 <main+0x160>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1340 <main+0x160>
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc49(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13f8 <main+0x218>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc41(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13f0 <main+0x210>
lea    0xc67(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   1090 <close@plt>
mov    $0xffffffff,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.sockaddr_nl = type { i32, i32, i32, i64, i64, i8* }
%struct.nlmsghdr = type { i32, i32, i32, 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.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 = bitcast %struct.sockaddr_nl* %3 to i8*
%6 = bitcast %struct.sockaddr_nl* %4 to i8*
%7 = load i8*, i8** @AF_NETLINK
%8 = load i32, i32* @SOCK_RAW
%9 = tail call i32 @socket(i8* %7, i32 %8, i32 25)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %70
15: ; preds = %2
%16 = call i32 @memset(%struct.sockaddr_nl* %3, i32 0, i32 40)
%17 = load i8*, i8** @AF_NETLINK
%18 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %3, i64 0, i32 5
store i8* %17, i8** %18
%19 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %3, i64 0, i32 0
store i32 100, i32* %19
%20 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %3, i64 0, i32 4
store i64 0, i64* %20
%21 = bitcast %struct.sockaddr_nl* %3 to %struct.sockaddr*
%22 = call i32 @bind(i32 %9, %struct.sockaddr* %21, i32 40)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %15
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 @close(i32 %9)
br label %70
29: ; preds = %15
%30 = call i32 @NLMSG_SPACE(i32 1024)
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to %struct.nlmsghdr*
%33 = icmp eq i64 %31, 0
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%36 = call i32 @close(i32 %9)
br label %70
37: ; preds = %29
%38 = call i32 @memset(%struct.sockaddr_nl* %4, i32 0, i32 40)
%39 = load i8*, i8** @AF_NETLINK
%40 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %4, i64 0, i32 5
store i8* %39, i8** %40
%41 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %4, i64 0, i32 0
store i32 0, i32* %41
%42 = getelementptr inbounds %struct.sockaddr_nl, %struct.sockaddr_nl* %4, i64 0, i32 4
store i64 0, i64* %42
%43 = call i32 @NLMSG_SPACE(i32 1024)
%44 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %32, i64 0, i32 1
store i32 %43, i32* %44
%45 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %32, i64 0, i32 2
store i32 100, i32* %45
%46 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %32, i64 0, i32 3
store i64 0, i64* %46
%47 = inttoptr i64 %31 to %struct.sockaddr_nl*
%48 = call i64 @NLMSG_DATA(%struct.sockaddr_nl* %47)
%49 = call i32 @strcpy(i64 %48, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%51 = call i32 @NLMSG_LENGTH(i32 1024)
%52 = bitcast %struct.sockaddr_nl* %4 to %struct.sockaddr*
%53 = call i32 @sendto(i32 %9, %struct.sockaddr_nl* %47, i32 %51, i32 0, %struct.sockaddr* %52, i32 40)
%54 = call i32 @NLMSG_SPACE(i32 1024)
%55 = call i32 @memset(%struct.sockaddr_nl* %47, i32 0, i32 %54)
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.11, i64 0, i64 0))
br label %57
57: ; preds = %64, %37
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%59 = call i32 @NLMSG_LENGTH(i32 1024)
%60 = call i32 @recvfrom(i32 %9, %struct.sockaddr_nl* %47, i32 %59, i32 0, i32* null, i32* null)
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %57
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %64
64: ; preds = %62, %57
%65 = call i64 @NLMSG_DATA(%struct.sockaddr_nl* %47)
%66 = inttoptr i64 %65 to i8*
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* %66)
%68 = call i32 @NLMSG_SPACE(i32 1024)
%69 = call i32 @memset(%struct.sockaddr_nl* %47, i32 0, i32 %68)
br label %57
70: ; preds = %34, %24, %11
ret i32 -1
}