#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 nlmsghdr {
  unsigned int nlmsg_seq;
  int nlmsg_len;
  scalar_t__ nlmsg_type;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int EINTR;
int /*<<< orphan*/ NETLINK_ROUTE;
scalar_t__ NLMSG_ERROR;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int netlink_open(int /*<<< orphan*/);
scalar_t__ nlmsg_do_send(int, void *, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
char *strerror(int);
int nlmsg_send(void *req, unsigned int size) {
  char buf[(1024 * 32) + (sizeof(struct nlmsghdr) + sizeof(unsigned int))];
  int r;
  int nlfd = -1;
  struct nlmsghdr *msg;
  unsigned int seqnum;
  unsigned int ack_err;
  errno = 0;
  if (req == NULL)
    return -1;
  memset(buf, 0, sizeof(buf));
  seqnum = ((struct nlmsghdr *)req)->nlmsg_seq;
  nlfd = netlink_open(NETLINK_ROUTE);
  if (nlfd == -1) {
    printf("couldn't open netlink socket\n");
    goto fail;
  }
  if (nlmsg_do_send(nlfd, req, size)) {
    printf("send error\r\n");
    goto fail;
  }
  while (1) {
    errno = 0;
    r = recv(nlfd, buf, sizeof(buf), 0);
    if (r == -1 && errno == EINTR) {
      continue;
    } else if (r <= 0) {
      printf("rtnl recvmsg error: %s\n", strerror(errno));
      goto fail;
    } else if ((unsigned int)r >=
               (sizeof(struct nlmsghdr) + sizeof(unsigned int))) {
      break;
    } else {
      printf("recv size error\n");
      goto fail;
    }
  }
  msg = (struct nlmsghdr *)buf;
  if (msg->nlmsg_len < (sizeof(struct nlmsghdr) + sizeof(unsigned int))) {
    printf("invalid response\n");
    goto fail;
  }
  if (msg->nlmsg_type != NLMSG_ERROR) {
    printf("unexpected message\n");
    goto fail;
  }
  ack_err = *((unsigned int *)(msg + 1));
  if (ack_err == 0) {
    goto ok;
  }
  if ((unsigned int)r !=
      size + (sizeof(struct nlmsghdr) + sizeof(unsigned int))) {
    printf("invalid nack\n");
    goto fail;
  }
  msg = (struct nlmsghdr *)(buf +
                            (sizeof(struct nlmsghdr) + sizeof(unsigned int)));
  if (msg->nlmsg_len != size) {
    printf("bad netlink msg\n");
    goto fail;
  }
  if (msg->nlmsg_seq != seqnum) {
    printf("bad netlink sequence number\n");
    goto fail;
  }
  if (msg->nlmsg_type == NLMSG_ERROR) {
    printf("netlink message error\n");
    goto fail;
  }
  close(nlfd);
  errno = -(int)ack_err;
  return errno;
fail:
  close(nlfd);
  return -1;
ok:
  close(nlfd);
  return 0;
}


x86 assembly (clang, -O0):
<nlmsg_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8050,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0xffffffff,-0x8038(%rbp)
ff ff ff
mov    0x2e45(%rip),%rax
movl   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
jne    11b0 <nlmsg_send+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    1479 <nlmsg_send+0x309>
lea    -0x8030(%rbp),%rdi
xor    %esi,%esi
mov    $0x8014,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x8044(%rbp)
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1080 <netlink_open@plt>
mov    %eax,-0x8038(%rbp)
cmpl   $0xffffffff,-0x8038(%rbp)
jne    1203 <nlmsg_send+0x93>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
mov    -0x8038(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <nlmsg_do_send@plt>
cmp    $0x0,%rax
je     1232 <nlmsg_send+0xc2>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
jmp    1237 <nlmsg_send+0xc7>
mov    0x2d9a(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8038(%rbp),%edi
lea    -0x8030(%rbp),%rsi
mov    $0x8014,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x8034(%rbp)
cmpl   $0xffffffff,-0x8034(%rbp)
jne    128d <nlmsg_send+0x11d>
mov    0x2d61(%rip),%rax
mov    (%rax),%eax
mov    0x2d50(%rip),%rcx
cmp    (%rcx),%eax
jne    128d <nlmsg_send+0x11d>
jmp    1237 <nlmsg_send+0xc7>
cmpl   $0x0,-0x8034(%rbp)
jg     12be <nlmsg_send+0x14e>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rsi
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
mov    -0x8034(%rbp),%eax
cmp    $0x14,%rax
jb     12d3 <nlmsg_send+0x163>
jmp    12e6 <nlmsg_send+0x176>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
lea    -0x8030(%rbp),%rax
mov    %rax,-0x8040(%rbp)
mov    -0x8040(%rbp),%rax
movslq 0x4(%rax),%rax
cmp    $0x14,%rax
jae    131c <nlmsg_send+0x1ac>
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
mov    -0x8040(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2cba(%rip),%rcx
cmp    (%rcx),%rax
je     134a <nlmsg_send+0x1da>
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
mov    -0x8040(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x8048(%rbp)
cmpl   $0x0,-0x8048(%rbp)
jne    136c <nlmsg_send+0x1fc>
jmp    1467 <nlmsg_send+0x2f7>
mov    -0x8034(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x14,%rcx
cmp    %rcx,%rax
je     1395 <nlmsg_send+0x225>
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
lea    -0x8030(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x8040(%rbp)
mov    -0x8040(%rbp),%rax
mov    0x4(%rax),%eax
cmp    -0x14(%rbp),%eax
je     13cd <nlmsg_send+0x25d>
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
mov    -0x8040(%rbp),%rax
mov    (%rax),%eax
cmp    -0x8044(%rbp),%eax
je     13f5 <nlmsg_send+0x285>
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
mov    -0x8040(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2be1(%rip),%rcx
cmp    (%rcx),%rax
jne    1423 <nlmsg_send+0x2b3>
lea    0xc9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1450 <nlmsg_send+0x2e0>
mov    -0x8038(%rbp),%edi
call   1060 <close@plt>
xor    %ecx,%ecx
sub    -0x8048(%rbp),%ecx
mov    0x2b9b(%rip),%rax
mov    %ecx,(%rax)
mov    0x2b92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1479 <nlmsg_send+0x309>
mov    -0x8038(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1479 <nlmsg_send+0x309>
mov    -0x8038(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nlmsg_send>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8028,%rsp
mov    0x2e40(%rip),%rbp
movl   $0x0,0x0(%rbp)
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     120a <nlmsg_send+0x8a>
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x8014,%edx
call   1060 <memset@plt>
mov    (%rbx),%r13d
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1090 <netlink_open@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
je     11f6 <nlmsg_send+0x76>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1080 <nlmsg_do_send@plt>
test   %rax,%rax
je     121f <nlmsg_send+0x9f>
lea    0xea7(%rip),%rdi
jmp    11fd <nlmsg_send+0x7d>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
mov    %r12d,%edi
call   1070 <close@plt>
mov    %r14d,%eax
add    $0x8028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13d,0xc(%rsp)
lea    0x10(%rsp),%rbx
mov    0x2da0(%rip),%r13
movl   $0x0,0x0(%rbp)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x8014,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
jne    1259 <nlmsg_send+0xd9>
mov    0x0(%rbp),%edi
cmp    0x0(%r13),%edi
je     1230 <nlmsg_send+0xb0>
jmp    1275 <nlmsg_send+0xf5>
test   %eax,%eax
jle    1272 <nlmsg_send+0xf2>
cmp    $0x13,%eax
jbe    1290 <nlmsg_send+0x110>
cmpl   $0x13,0x14(%rsp)
ja     129c <nlmsg_send+0x11c>
lea    0xe1a(%rip),%rdi
jmp    11fd <nlmsg_send+0x7d>
mov    0x0(%rbp),%edi
call   10a0 <strerror@plt>
lea    0xd7f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1202 <nlmsg_send+0x82>
lea    0xd81(%rip),%rdi
jmp    11fd <nlmsg_send+0x7d>
mov    0x18(%rsp),%rcx
mov    0x2d40(%rip),%rdx
cmp    (%rdx),%rcx
jne    12e7 <nlmsg_send+0x167>
mov    0x20(%rsp),%ebx
test   %ebx,%ebx
je     12f3 <nlmsg_send+0x173>
mov    %eax,%eax
mov    %r15d,%edx
add    $0x14,%rdx
cmp    %rax,%rdx
jne    1303 <nlmsg_send+0x183>
cmp    %r15d,0x28(%rsp)
jne    130f <nlmsg_send+0x18f>
mov    0xc(%rsp),%eax
cmp    %eax,0x24(%rsp)
jne    131b <nlmsg_send+0x19b>
cmp    %rcx,0x2c(%rsp)
jne    1327 <nlmsg_send+0x1a7>
lea    0xd46(%rip),%rdi
jmp    11fd <nlmsg_send+0x7d>
lea    0xd89(%rip),%rdi
jmp    11fd <nlmsg_send+0x7d>
mov    %r12d,%edi
call   1070 <close@plt>
xor    %r14d,%r14d
jmp    120a <nlmsg_send+0x8a>
lea    0xd60(%rip),%rdi
jmp    11fd <nlmsg_send+0x7d>
lea    0xd44(%rip),%rdi
jmp    11fd <nlmsg_send+0x7d>
lea    0xd1c(%rip),%rdi
jmp    11fd <nlmsg_send+0x7d>
mov    %r12d,%edi
call   1070 <close@plt>
neg    %ebx
mov    %ebx,0x0(%rbp)
mov    %ebx,%r14d
jmp    120a <nlmsg_send+0x8a>

LLVM IR (-O0):
%struct.nlmsghdr = type { i32, i32, i64 }
@errno = global i32 0
@NETLINK_ROUTE = global i32 0
@.str = [30 x i8] c"couldn't open netlink socket\0A\00"
@.str.1 = [13 x i8] c"send error\0D\0A\00"
@EINTR = global i32 0
@.str.2 = [24 x i8] c"rtnl recvmsg error: %s\0A\00"
@.str.3 = [17 x i8] c"recv size error\0A\00"
@.str.4 = [18 x i8] c"invalid response\0A\00"
@NLMSG_ERROR = global i64 0
@.str.5 = [20 x i8] c"unexpected message\0A\00"
@.str.6 = [14 x i8] c"invalid nack\0A\00"
@.str.7 = [17 x i8] c"bad netlink msg\0A\00"
@.str.8 = [29 x i8] c"bad netlink sequence number\0A\00"
@.str.9 = [23 x i8] c"netlink message error\0A\00"
define i32 @nlmsg_send(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [32788 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.nlmsghdr*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 -1, i32* %8
store i32 0, i32* @errno
%12 = load i8*, i8** %4
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
br label %136
15: ; preds = %2
%16 = getelementptr inbounds [32788 x i8], [32788 x i8]* %6, i64 0, i64 0
%17 = call i32 @memset(i8* %16, i32 0, i32 32788)
%18 = load i8*, i8** %4
%19 = bitcast i8* %18 to %struct.nlmsghdr*
%20 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %19, i32 0, i32 0
%21 = load i32, i32* %20
store i32 %21, i32* %10
%22 = load i32, i32* @NETLINK_ROUTE
%23 = call i32 @netlink_open(i32 %22)
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %15
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %130
28: ; preds = %15
%29 = load i32, i32* %8
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = call i64 @nlmsg_do_send(i32 %29, i8* %30, i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %130
36: ; preds = %28
br label %37
37: ; preds = %36, %47
store i32 0, i32* @errno
%38 = load i32, i32* %8
%39 = getelementptr inbounds [32788 x i8], [32788 x i8]* %6, i64 0, i64 0
%40 = call i32 @recv(i32 %38, i8* %39, i32 32788, i32 0)
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %48
43: ; preds = %37
%44 = load i32, i32* @errno
%45 = load i32, i32* @EINTR
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %48
47: ; preds = %43
br label %37
48: ; preds = %43, %37
%49 = load i32, i32* %7
%50 = icmp sle i32 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i32, i32* @errno
%53 = call i8* @strerror(i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %53)
br label %130
55: ; preds = %48
%56 = load i32, i32* %7
%57 = zext i32 %56 to i64
%58 = icmp uge i64 %57, 20
br i1 %58, label %59, label %60
59: ; preds = %55
br label %62
60: ; preds = %55
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %130
62: ; preds = %59
%63 = getelementptr inbounds [32788 x i8], [32788 x i8]* %6, i64 0, i64 0
%64 = bitcast i8* %63 to %struct.nlmsghdr*
store %struct.nlmsghdr* %64, %struct.nlmsghdr** %9
%65 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%66 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %65, i32 0, i32 1
%67 = load i32, i32* %66
%68 = sext i32 %67 to i64
%69 = icmp ult i64 %68, 20
br i1 %69, label %70, label %72
70: ; preds = %62
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %130
72: ; preds = %62
%73 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%74 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %73, i32 0, i32 2
%75 = load i64, i64* %74
%76 = load i64, i64* @NLMSG_ERROR
%77 = icmp ne i64 %75, %76
br i1 %77, label %78, label %80
78: ; preds = %72
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %130
80: ; preds = %72
%81 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%82 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %81, i64 1
%83 = bitcast %struct.nlmsghdr* %82 to i32*
%84 = load i32, i32* %83
store i32 %84, i32* %11
%85 = load i32, i32* %11
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %80
br label %133
88: ; preds = %80
%89 = load i32, i32* %7
%90 = zext i32 %89 to i64
%91 = load i32, i32* %5
%92 = zext i32 %91 to i64
%93 = add i64 %92, 20
%94 = icmp ne i64 %90, %93
br i1 %94, label %95, label %97
95: ; preds = %88
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %130
97: ; preds = %88
%98 = getelementptr inbounds [32788 x i8], [32788 x i8]* %6, i64 0, i64 0
%99 = getelementptr inbounds i8, i8* %98, i64 20
%100 = bitcast i8* %99 to %struct.nlmsghdr*
store %struct.nlmsghdr* %100, %struct.nlmsghdr** %9
%101 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%102 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %101, i32 0, i32 1
%103 = load i32, i32* %102
%104 = load i32, i32* %5
%105 = icmp ne i32 %103, %104
br i1 %105, label %106, label %108
106: ; preds = %97
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %130
108: ; preds = %97
%109 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%110 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %109, i32 0, i32 0
%111 = load i32, i32* %110
%112 = load i32, i32* %10
%113 = icmp ne i32 %111, %112
br i1 %113, label %114, label %116
114: ; preds = %108
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %130
116: ; preds = %108
%117 = load %struct.nlmsghdr*, %struct.nlmsghdr** %9
%118 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %117, i32 0, i32 2
%119 = load i64, i64* %118
%120 = load i64, i64* @NLMSG_ERROR
%121 = icmp eq i64 %119, %120
br i1 %121, label %122, label %124
122: ; preds = %116
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
br label %130
124: ; preds = %116
%125 = load i32, i32* %8
%126 = call i32 @close(i32 %125)
%127 = load i32, i32* %11
%128 = sub nsw i32 0, %127
store i32 %128, i32* @errno
%129 = load i32, i32* @errno
store i32 %129, i32* %3
br label %136
130: ; preds = %122, %114, %106, %95, %78, %70, %60, %51, %34, %26
%131 = load i32, i32* %8
%132 = call i32 @close(i32 %131)
store i32 -1, i32* %3
br label %136
133: ; preds = %87
%134 = load i32, i32* %8
%135 = call i32 @close(i32 %134)
store i32 0, i32* %3
br label %136
136: ; preds = %133, %130, %124, %14
%137 = load i32, i32* %3
ret i32 %137
}

LLVM IR (-O2):
@errno = global i32 0
@NETLINK_ROUTE = global i32 0
@EINTR = global i32 0
@.str.2 = [24 x i8] c"rtnl recvmsg error: %s\0A\00"
@NLMSG_ERROR = global i64 0
@str = [16 x i8] c"recv size error\00"
@str.10 = [22 x i8] c"netlink message error\00"
@str.11 = [28 x i8] c"bad netlink sequence number\00"
@str.12 = [16 x i8] c"bad netlink msg\00"
@str.13 = [13 x i8] c"invalid nack\00"
@str.14 = [19 x i8] c"unexpected message\00"
@str.15 = [17 x i8] c"invalid response\00"
@str.16 = [12 x i8] c"send error\0D\00"
@str.17 = [29 x i8] c"couldn't open netlink socket\00"
define i32 @nlmsg_send(i8* %0, i32 %1) {
%3 = alloca [32788 x i8]
%4 = getelementptr inbounds [32788 x i8], [32788 x i8]* %3, i64 0, i64 0
store i32 0, i32* @errno
%5 = icmp eq i8* %0, null
br i1 %5, label %94, label %6
6: ; preds = %2
%7 = call i32 @memset(i8* %4, i32 0, i32 32788)
%8 = bitcast i8* %0 to i32*
%9 = load i32, i32* %8
%10 = load i32, i32* @NETLINK_ROUTE
%11 = call i32 @netlink_open(i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.17, i64 0, i64 0))
br label %90
15: ; preds = %6
%16 = call i64 @nlmsg_do_send(i32 %11, i8* %0, i32 %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.16, i64 0, i64 0))
br label %90
20: ; preds = %15, %23
store i32 0, i32* @errno
%21 = call i32 @recv(i32 %11, i8* %4, i32 32788, i32 0)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* @errno
%25 = load i32, i32* @EINTR
%26 = icmp eq i32 %24, %25
br i1 %26, label %20, label %31
27: ; preds = %20
%28 = icmp slt i32 %21, 1
br i1 %28, label %29, label %35
29: ; preds = %27
%30 = load i32, i32* @errno
br label %31
31: ; preds = %23, %29
%32 = phi i32 [ %30, %29 ], [ %24, %23 ]
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %90
35: ; preds = %27
%36 = zext i32 %21 to i64
%37 = icmp ugt i32 %21, 19
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %90
40: ; preds = %35
%41 = getelementptr inbounds [32788 x i8], [32788 x i8]* %3, i64 0, i64 4
%42 = bitcast i8* %41 to i32*
%43 = load i32, i32* %42
%44 = icmp ult i32 %43, 20
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.15, i64 0, i64 0))
br label %90
47: ; preds = %40
%48 = getelementptr inbounds [32788 x i8], [32788 x i8]* %3, i64 0, i64 8
%49 = bitcast i8* %48 to i64*
%50 = load i64, i64* %49
%51 = load i64, i64* @NLMSG_ERROR
%52 = icmp eq i64 %50, %51
br i1 %52, label %55, label %53
53: ; preds = %47
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.14, i64 0, i64 0))
br label %90
55: ; preds = %47
%56 = getelementptr inbounds [32788 x i8], [32788 x i8]* %3, i64 0, i64 16
%57 = bitcast i8* %56 to i32*
%58 = load i32, i32* %57
%59 = icmp eq i32 %58, 0
br i1 %59, label %92, label %60
60: ; preds = %55
%61 = zext i32 %1 to i64
%62 = add nuw nsw i64 %61, 20
%63 = icmp eq i64 %62, %36
br i1 %63, label %66, label %64
64: ; preds = %60
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
br label %90
66: ; preds = %60
%67 = getelementptr inbounds [32788 x i8], [32788 x i8]* %3, i64 0, i64 24
%68 = bitcast i8* %67 to i32*
%69 = load i32, i32* %68
%70 = icmp eq i32 %69, %1
br i1 %70, label %73, label %71
71: ; preds = %66
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
br label %90
73: ; preds = %66
%74 = getelementptr inbounds [32788 x i8], [32788 x i8]* %3, i64 0, i64 20
%75 = bitcast i8* %74 to i32*
%76 = load i32, i32* %75
%77 = icmp eq i32 %76, %9
br i1 %77, label %80, label %78
78: ; preds = %73
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.11, i64 0, i64 0))
br label %90
80: ; preds = %73
%81 = getelementptr inbounds [32788 x i8], [32788 x i8]* %3, i64 0, i64 28
%82 = bitcast i8* %81 to i64*
%83 = load i64, i64* %82
%84 = icmp eq i64 %83, %50
br i1 %84, label %85, label %87
85: ; preds = %80
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
br label %90
87: ; preds = %80
%88 = call i32 @close(i32 %11)
%89 = sub nsw i32 0, %58
store i32 %89, i32* @errno
br label %94
90: ; preds = %85, %78, %71, %64, %53, %45, %38, %31, %18, %13
%91 = call i32 @close(i32 %11)
br label %94
92: ; preds = %55
%93 = call i32 @close(i32 %11)
br label %94
94: ; preds = %2, %92, %90, %87
%95 = phi i32 [ -1, %90 ], [ 0, %92 ], [ %89, %87 ], [ -1, %2 ]
ret i32 %95
}