#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint16_t;
struct nlmsghdr {
  int nlmsg_len;
  int nlmsg_type;
  int nlmsg_flags;
  int nlmsg_seq;
  scalar_t__ nlmsg_pid;
};
struct nfgenmsg {
  int /*<<< orphan*/ res_id;
  int /*<<< orphan*/ version;
  int /*<<< orphan*/ nfgen_family;
};
struct nfattr {
  int /*<<< orphan*/ nfa_len;
  int /*<<< orphan*/ nfa_type;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int NFA_ALIGN(int /*<<< orphan*/);
int /*<<< orphan*/ NFA_DATA(struct nfattr *);
int /*<<< orphan*/ NFA_LENGTH(int);
int /*<<< orphan*/ NFNETLINK_V0;
int NFNL_SUBSYS_ULOG;
int NFULNL_MSG_CONFIG;
int NLMSG_ALIGN(int);
scalar_t__ NLMSG_DATA(struct nlmsghdr *);
int NLMSG_ERROR;
int NLMSG_LENGTH(int);
int NLMSG_OK(struct nlmsghdr *, int);
int NLM_F_ACK;
int NLM_F_REQUEST;
int errno;
int /*<<< orphan*/ error(int, int, char *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, void *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ send(int, char *, int, int /*<<< orphan*/);
void __nflog_sendcmd(int fd, uint8_t cmd, void *msg, int msglen,
                     uint16_t family, uint16_t group_id) {
  static int seq_id;
  char buf[1024] __attribute__((aligned));
  struct nlmsghdr *nh;
  struct nfgenmsg *ng;
  struct nfattr *nfa;
  int ret;
  memset(buf, 0, sizeof(buf));
  nh = (void *)buf;
  ng = (void *)buf + sizeof(*nh);
  nh->nlmsg_len = NLMSG_LENGTH(sizeof(*ng));
  nh->nlmsg_type = (NFNL_SUBSYS_ULOG << 8) | NFULNL_MSG_CONFIG;
  nh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
  nh->nlmsg_pid = 0;
  nh->nlmsg_seq = ++seq_id;
  ng->nfgen_family = family;
  ng->version = NFNETLINK_V0;
  ng->res_id = htons(group_id);
  nfa = (void *)buf + NLMSG_ALIGN(nh->nlmsg_len);
  nfa->nfa_type = cmd;
  nfa->nfa_len = NFA_LENGTH(msglen);
  memcpy(NFA_DATA(nfa), msg, msglen);
  nh->nlmsg_len = NLMSG_ALIGN(nh->nlmsg_len) + NFA_ALIGN(nfa->nfa_len);
  if (send(fd, buf, nh->nlmsg_len, 0) != nh->nlmsg_len)
    error(1, errno, "sendcmd");
  ret = recv(fd, buf, sizeof(buf), 0);
  if (ret == -1)
    error(1, errno, "recv ctrl: sock error");
  if (ret < NLMSG_OK(nh, ret))
    error(1, 0, "recv ctrl: insufficient length");
  if (nh->nlmsg_type != NLMSG_ERROR)
    error(1, 0, "recv ctrl: unexpected type");
  ret = *(int *)NLMSG_DATA(nh);
  if (ret)
    error(1, ret, "recv ctrl: nflog error");
}


x86 assembly (clang, -O0):
<__nflog_sendcmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x430(%rbp)
mov    $0xc,%edi
call   1040 <NLMSG_LENGTH@plt>
mov    %eax,%ecx
mov    -0x428(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2db1(%rip),%rax
mov    (%rax),%ecx
shl    $0x8,%ecx
mov    0x2d65(%rip),%rax
or     (%rax),%ecx
mov    -0x428(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    0x2d72(%rip),%rax
mov    (%rax),%ecx
mov    0x2d61(%rip),%rax
or     (%rax),%ecx
mov    -0x428(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x428(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    0x2e04(%rip),%ecx
add    $0x1,%ecx
mov    %ecx,0x2dfb(%rip)
mov    -0x428(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x430(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    0x2d31(%rip),%rax
mov    (%rax),%ecx
mov    -0x430(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1c(%rbp),%edi
call   1070 <htons@plt>
mov    %eax,%ecx
mov    -0x430(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x420(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x428(%rbp),%rax
mov    (%rax),%edi
call   1060 <NLMSG_ALIGN@plt>
mov    %eax,%ecx
mov    -0x448(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x438(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x438(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x14(%rbp),%edi
call   10f0 <NFA_LENGTH@plt>
mov    %eax,%ecx
mov    -0x438(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x438(%rbp),%rdi
call   10b0 <NFA_DATA@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   10a0 <memcpy@plt>
mov    -0x428(%rbp),%rax
mov    (%rax),%edi
call   1060 <NLMSG_ALIGN@plt>
mov    %eax,-0x440(%rbp)
mov    -0x438(%rbp),%rax
mov    (%rax),%edi
call   10e0 <NFA_ALIGN@plt>
mov    -0x440(%rbp),%ecx
add    %eax,%ecx
mov    -0x428(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x428(%rbp),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0x428(%rbp),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
je     13b4 <__nflog_sendcmd+0x1e4>
mov    0x2c17(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xc51(%rip),%rdx
call   10d0 <error@plt>
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x43c(%rbp)
cmpl   $0xffffffff,-0x43c(%rbp)
jne    13f7 <__nflog_sendcmd+0x227>
mov    0x2bd4(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xc16(%rip),%rdx
call   10d0 <error@plt>
mov    -0x43c(%rbp),%eax
mov    %eax,-0x44c(%rbp)
mov    -0x428(%rbp),%rdi
mov    -0x43c(%rbp),%esi
call   1050 <NLMSG_OK@plt>
mov    %eax,%ecx
mov    -0x44c(%rbp),%eax
cmp    %ecx,%eax
jge    1438 <__nflog_sendcmd+0x268>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xbeb(%rip),%rdx
call   10d0 <error@plt>
mov    -0x428(%rbp),%rax
mov    0x4(%rax),%eax
mov    0x2b8f(%rip),%rcx
cmp    (%rcx),%eax
je     1464 <__nflog_sendcmd+0x294>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xbde(%rip),%rdx
call   10d0 <error@plt>
mov    -0x428(%rbp),%rdi
call   10c0 <NLMSG_DATA@plt>
mov    (%rax),%eax
mov    %eax,-0x43c(%rbp)
cmpl   $0x0,-0x43c(%rbp)
je     149c <__nflog_sendcmd+0x2cc>
mov    -0x43c(%rbp),%esi
mov    $0x1,%edi
lea    0xbc1(%rip),%rdx
call   10d0 <error@plt>
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__nflog_sendcmd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %r9d,%ebx
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdx,0x8(%rsp)
mov    %esi,%r13d
mov    %edi,%r12d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    $0xc,%edi
call   1040 <NLMSG_LENGTH@plt>
mov    %eax,0x10(%rsp)
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
shl    $0x8,%eax
mov    0x2d89(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x14(%rsp)
mov    0x2d9c(%rip),%rax
mov    0x2d8d(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ecx,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mov    0x2e3a(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e31(%rip)
mov    %eax,0x1c(%rsp)
mov    %r14d,0x30(%rsp)
mov    0x2d75(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    %ebx,%edi
call   1070 <htons@plt>
mov    %eax,0x28(%rsp)
mov    0x10(%rsp),%edi
call   1060 <NLMSG_ALIGN@plt>
movslq %eax,%rbp
lea    (%rsp,%rbp,1),%rbx
add    $0x10,%rbx
mov    %r13d,0x14(%rsp,%rbp,1)
mov    %r15d,%edi
call   10f0 <NFA_LENGTH@plt>
mov    %eax,0x10(%rsp,%rbp,1)
mov    %rbx,%rdi
call   10b0 <NFA_DATA@plt>
mov    %eax,%edi
mov    0x8(%rsp),%rsi
mov    %r15d,%edx
call   10a0 <memcpy@plt>
mov    0x10(%rsp),%edi
call   1060 <NLMSG_ALIGN@plt>
mov    %eax,%ebx
mov    0x10(%rsp,%rbp,1),%edi
call   10e0 <NFA_ALIGN@plt>
add    %eax,%ebx
mov    %ebx,0x10(%rsp)
mov    %r12d,%edi
lea    0x10(%rsp),%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
movslq 0x10(%rsp),%rcx
cmp    %rcx,%rax
je     1307 <__nflog_sendcmd+0x137>
mov    0x2cc4(%rip),%rax
mov    (%rax),%esi
lea    0xd03(%rip),%rdx
mov    $0x1,%edi
call   10d0 <error@plt>
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    133c <__nflog_sendcmd+0x16c>
mov    0x2c8f(%rip),%rax
mov    (%rax),%esi
lea    0xcd6(%rip),%rdx
mov    $0x1,%edi
call   10d0 <error@plt>
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1050 <NLMSG_OK@plt>
cmp    %eax,%ebx
jge    135f <__nflog_sendcmd+0x18f>
lea    0xccb(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
call   10d0 <error@plt>
mov    0x14(%rsp),%eax
mov    0x2c6e(%rip),%rcx
cmp    (%rcx),%eax
je     1381 <__nflog_sendcmd+0x1b1>
lea    0xcc8(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
call   10d0 <error@plt>
lea    0x10(%rsp),%rdi
call   10c0 <NLMSG_DATA@plt>
mov    (%rax),%esi
test   %esi,%esi
je     13a2 <__nflog_sendcmd+0x1d2>
lea    0xcc0(%rip),%rdx
mov    $0x1,%edi
call   10d0 <error@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.nlmsghdr = type { i32, i32, i32, i32, i64 }
%struct.nfgenmsg = type { i32, i32, i32 }
%struct.nfattr = type { i32, i32 }
@__nflog_sendcmd.seq_id = internal global i32 0
@NFNL_SUBSYS_ULOG = global i32 0
@NFULNL_MSG_CONFIG = global i32 0
@NLM_F_REQUEST = global i32 0
@NLM_F_ACK = global i32 0
@NFNETLINK_V0 = global i32 0
@errno = global i32 0
@.str = [8 x i8] c"sendcmd\00"
@.str.1 = [22 x i8] c"recv ctrl: sock error\00"
@.str.2 = [31 x i8] c"recv ctrl: insufficient length\00"
@NLMSG_ERROR = global i32 0
@.str.3 = [27 x i8] c"recv ctrl: unexpected type\00"
@.str.4 = [23 x i8] c"recv ctrl: nflog error\00"
define void @__nflog_sendcmd(i32 %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [1024 x i8]
%14 = alloca %struct.nlmsghdr*
%15 = alloca %struct.nfgenmsg*
%16 = alloca %struct.nfattr*
%17 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%19 = call i32 @memset(i8* %18, i32 0, i32 1024)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%21 = bitcast i8* %20 to %struct.nlmsghdr*
store %struct.nlmsghdr* %21, %struct.nlmsghdr** %14
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%23 = getelementptr i8, i8* %22, i64 24
%24 = bitcast i8* %23 to %struct.nfgenmsg*
store %struct.nfgenmsg* %24, %struct.nfgenmsg** %15
%25 = call i32 @NLMSG_LENGTH(i32 12)
%26 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%27 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %26, i32 0, i32 0
store i32 %25, i32* %27
%28 = load i32, i32* @NFNL_SUBSYS_ULOG
%29 = shl i32 %28, 8
%30 = load i32, i32* @NFULNL_MSG_CONFIG
%31 = or i32 %29, %30
%32 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%33 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %32, i32 0, i32 1
store i32 %31, i32* %33
%34 = load i32, i32* @NLM_F_REQUEST
%35 = load i32, i32* @NLM_F_ACK
%36 = or i32 %34, %35
%37 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%38 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %37, i32 0, i32 2
store i32 %36, i32* %38
%39 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%40 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %39, i32 0, i32 4
store i64 0, i64* %40
%41 = load i32, i32* @__nflog_sendcmd.seq_id
%42 = add nsw i32 %41, 1
store i32 %42, i32* @__nflog_sendcmd.seq_id
%43 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%44 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %43, i32 0, i32 3
store i32 %42, i32* %44
%45 = load i32, i32* %11
%46 = load %struct.nfgenmsg*, %struct.nfgenmsg** %15
%47 = getelementptr inbounds %struct.nfgenmsg, %struct.nfgenmsg* %46, i32 0, i32 2
store i32 %45, i32* %47
%48 = load i32, i32* @NFNETLINK_V0
%49 = load %struct.nfgenmsg*, %struct.nfgenmsg** %15
%50 = getelementptr inbounds %struct.nfgenmsg, %struct.nfgenmsg* %49, i32 0, i32 1
store i32 %48, i32* %50
%51 = load i32, i32* %12
%52 = call i32 @htons(i32 %51)
%53 = load %struct.nfgenmsg*, %struct.nfgenmsg** %15
%54 = getelementptr inbounds %struct.nfgenmsg, %struct.nfgenmsg* %53, i32 0, i32 0
store i32 %52, i32* %54
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%56 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%57 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %56, i32 0, i32 0
%58 = load i32, i32* %57
%59 = call i32 @NLMSG_ALIGN(i32 %58)
%60 = sext i32 %59 to i64
%61 = getelementptr i8, i8* %55, i64 %60
%62 = bitcast i8* %61 to %struct.nfattr*
store %struct.nfattr* %62, %struct.nfattr** %16
%63 = load i32, i32* %8
%64 = load %struct.nfattr*, %struct.nfattr** %16
%65 = getelementptr inbounds %struct.nfattr, %struct.nfattr* %64, i32 0, i32 1
store i32 %63, i32* %65
%66 = load i32, i32* %10
%67 = call i32 @NFA_LENGTH(i32 %66)
%68 = load %struct.nfattr*, %struct.nfattr** %16
%69 = getelementptr inbounds %struct.nfattr, %struct.nfattr* %68, i32 0, i32 0
store i32 %67, i32* %69
%70 = load %struct.nfattr*, %struct.nfattr** %16
%71 = call i32 @NFA_DATA(%struct.nfattr* %70)
%72 = load i8*, i8** %9
%73 = load i32, i32* %10
%74 = call i32 @memcpy(i32 %71, i8* %72, i32 %73)
%75 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%76 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %75, i32 0, i32 0
%77 = load i32, i32* %76
%78 = call i32 @NLMSG_ALIGN(i32 %77)
%79 = load %struct.nfattr*, %struct.nfattr** %16
%80 = getelementptr inbounds %struct.nfattr, %struct.nfattr* %79, i32 0, i32 0
%81 = load i32, i32* %80
%82 = call i32 @NFA_ALIGN(i32 %81)
%83 = add nsw i32 %78, %82
%84 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%85 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %84, i32 0, i32 0
store i32 %83, i32* %85
%86 = load i32, i32* %7
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%88 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%89 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %88, i32 0, i32 0
%90 = load i32, i32* %89
%91 = call i64 @send(i32 %86, i8* %87, i32 %90, i32 0)
%92 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%93 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %92, i32 0, i32 0
%94 = load i32, i32* %93
%95 = sext i32 %94 to i64
%96 = icmp ne i64 %91, %95
br i1 %96, label %97, label %100
97: ; preds = %6
%98 = load i32, i32* @errno
%99 = call i32 @error(i32 1, i32 %98, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %100
100: ; preds = %97, %6
%101 = load i32, i32* %7
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%103 = call i32 @recv(i32 %101, i8* %102, i32 1024, i32 0)
store i32 %103, i32* %17
%104 = load i32, i32* %17
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %109
106: ; preds = %100
%107 = load i32, i32* @errno
%108 = call i32 @error(i32 1, i32 %107, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %109
109: ; preds = %106, %100
%110 = load i32, i32* %17
%111 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%112 = load i32, i32* %17
%113 = call i32 @NLMSG_OK(%struct.nlmsghdr* %111, i32 %112)
%114 = icmp slt i32 %110, %113
br i1 %114, label %115, label %117
115: ; preds = %109
%116 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %117
117: ; preds = %115, %109
%118 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%119 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %118, i32 0, i32 1
%120 = load i32, i32* %119
%121 = load i32, i32* @NLMSG_ERROR
%122 = icmp ne i32 %120, %121
br i1 %122, label %123, label %125
123: ; preds = %117
%124 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %125
125: ; preds = %123, %117
%126 = load %struct.nlmsghdr*, %struct.nlmsghdr** %14
%127 = call i64 @NLMSG_DATA(%struct.nlmsghdr* %126)
%128 = inttoptr i64 %127 to i32*
%129 = load i32, i32* %128
store i32 %129, i32* %17
%130 = load i32, i32* %17
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %135
132: ; preds = %125
%133 = load i32, i32* %17
%134 = call i32 @error(i32 1, i32 %133, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %135
135: ; preds = %132, %125
ret void
}

LLVM IR (-O2):
%struct.nlmsghdr = type { i32, i32, i32, i32, i64 }
%struct.nfattr = type { i32, i32 }
@__nflog_sendcmd.seq_id = internal unnamed_addr global i32 0
@NFNL_SUBSYS_ULOG = global i32 0
@NFULNL_MSG_CONFIG = global i32 0
@NLM_F_REQUEST = global i32 0
@NLM_F_ACK = global i32 0
@NFNETLINK_V0 = global i32 0
@errno = global i32 0
@.str = [8 x i8] c"sendcmd\00"
@.str.1 = [22 x i8] c"recv ctrl: sock error\00"
@.str.2 = [31 x i8] c"recv ctrl: insufficient length\00"
@NLMSG_ERROR = global i32 0
@.str.3 = [27 x i8] c"recv ctrl: unexpected type\00"
@.str.4 = [23 x i8] c"recv ctrl: nflog error\00"
define void @__nflog_sendcmd(i32 %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca [1024 x i8]
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 1024)
%10 = bitcast [1024 x i8]* %7 to %struct.nlmsghdr*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 24
%12 = call i32 @NLMSG_LENGTH(i32 12)
%13 = bitcast [1024 x i8]* %7 to i32*
store i32 %12, i32* %13
%14 = load i32, i32* @NFNL_SUBSYS_ULOG
%15 = shl i32 %14, 8
%16 = load i32, i32* @NFULNL_MSG_CONFIG
%17 = or i32 %15, %16
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 4
%19 = bitcast i8* %18 to i32*
store i32 %17, i32* %19
%20 = load i32, i32* @NLM_F_REQUEST
%21 = load i32, i32* @NLM_F_ACK
%22 = or i32 %21, %20
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 8
%24 = bitcast i8* %23 to i32*
store i32 %22, i32* %24
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 16
%26 = bitcast i8* %25 to i64*
store i64 0, i64* %26
%27 = load i32, i32* @__nflog_sendcmd.seq_id
%28 = add nsw i32 %27, 1
store i32 %28, i32* @__nflog_sendcmd.seq_id
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 12
%30 = bitcast i8* %29 to i32*
store i32 %28, i32* %30
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 32
%32 = bitcast i8* %31 to i32*
store i32 %4, i32* %32
%33 = load i32, i32* @NFNETLINK_V0
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 28
%35 = bitcast i8* %34 to i32*
store i32 %33, i32* %35
%36 = call i32 @htons(i32 %5)
%37 = bitcast i8* %11 to i32*
store i32 %36, i32* %37
%38 = load i32, i32* %13
%39 = call i32 @NLMSG_ALIGN(i32 %38)
%40 = sext i32 %39 to i64
%41 = getelementptr [1024 x i8], [1024 x i8]* %7, i64 0, i64 %40
%42 = bitcast i8* %41 to %struct.nfattr*
%43 = getelementptr inbounds i8, i8* %41, i64 4
%44 = bitcast i8* %43 to i32*
store i32 %1, i32* %44
%45 = call i32 @NFA_LENGTH(i32 %3)
%46 = bitcast i8* %41 to i32*
store i32 %45, i32* %46
%47 = call i32 @NFA_DATA(%struct.nfattr* %42)
%48 = call i32 @memcpy(i32 %47, i8* %2, i32 %3)
%49 = load i32, i32* %13
%50 = call i32 @NLMSG_ALIGN(i32 %49)
%51 = load i32, i32* %46
%52 = call i32 @NFA_ALIGN(i32 %51)
%53 = add nsw i32 %52, %50
store i32 %53, i32* %13
%54 = call i64 @send(i32 %0, i8* %8, i32 %53, i32 0)
%55 = load i32, i32* %13
%56 = sext i32 %55 to i64
%57 = icmp eq i64 %54, %56
br i1 %57, label %61, label %58
58: ; preds = %6
%59 = load i32, i32* @errno
%60 = call i32 @error(i32 1, i32 %59, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %61
61: ; preds = %58, %6
%62 = call i32 @recv(i32 %0, i8* %8, i32 1024, i32 0)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i32, i32* @errno
%66 = call i32 @error(i32 1, i32 %65, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %67
67: ; preds = %64, %61
%68 = call i32 @NLMSG_OK(%struct.nlmsghdr* %10, i32 %62)
%69 = icmp slt i32 %62, %68
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %72
72: ; preds = %70, %67
%73 = load i32, i32* %19
%74 = load i32, i32* @NLMSG_ERROR
%75 = icmp eq i32 %73, %74
br i1 %75, label %78, label %76
76: ; preds = %72
%77 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %76, %72
%79 = call i64 @NLMSG_DATA(%struct.nlmsghdr* %10)
%80 = inttoptr i64 %79 to i32*
%81 = load i32, i32* %80
%82 = icmp eq i32 %81, 0
br i1 %82, label %85, label %83
83: ; preds = %78
%84 = call i32 @error(i32 1, i32 %81, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %85
85: ; preds = %83, %78
ret void
}