#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 rtattr {
  int dummy;
};
struct nlmsghdr {
  int nlmsg_len;
  scalar_t__ nlmsg_type;
};
struct in6_addr {
  int dummy;
};
struct ifaddrmsg {
  scalar_t__ ifa_family;
  scalar_t__ ifa_scope;
  int /*<<< orphan*/ ifa_prefixlen;
};

/* Variables and functions */
scalar_t__ AF_INET6;
struct rtattr *IFA_RTA(struct ifaddrmsg *);
int NLMSG_ALIGN(int);
struct in6_addr *RTA_DATA(struct rtattr *);
scalar_t__ RTM_DELADDR;
scalar_t__ RTM_NEWADDR;
scalar_t__ RT_SCOPE_LINK;
int /*<<< orphan*/ add_address(struct in6_addr *, int /*<<< orphan*/);
int /*<<< orphan*/ delete_address(struct in6_addr *, int /*<<< orphan*/);
void rtnl_address_event(struct nlmsghdr *h, struct ifaddrmsg *msg) {
  struct in6_addr *a;
  int attrlen;
  struct rtattr *attr;
  if (msg->ifa_family != AF_INET6)
    return;
  if (msg->ifa_scope >= RT_SCOPE_LINK)
    return;
  attrlen = h->nlmsg_len - NLMSG_ALIGN(sizeof(struct ifaddrmsg));
  if (attrlen >= sizeof(*a) + sizeof(struct rtattr)) {
    attr = IFA_RTA(msg);
    a = RTA_DATA(attr);
    if (h->nlmsg_type == RTM_NEWADDR)
      add_address(a, msg->ifa_prefixlen);
    else if (h->nlmsg_type == RTM_DELADDR)
      delete_address(a, msg->ifa_prefixlen);
  }
}


x86 assembly (clang, -O0):
<rtnl_address_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e72(%rip),%rcx
cmp    (%rcx),%rax
je     117c <rtnl_address_event+0x2c>
jmp    123d <rtnl_address_event+0xed>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%rax
jl     1199 <rtnl_address_event+0x49>
jmp    123d <rtnl_address_event+0xed>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x18,%edi
call   1040 <NLMSG_ALIGN@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x8,%rax
jb     123d <rtnl_address_event+0xed>
mov    -0x10(%rbp),%rdi
call   1060 <IFA_RTA@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <RTA_DATA@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2dfb(%rip),%rcx
cmp    (%rcx),%rax
jne    120b <rtnl_address_event+0xbb>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%esi
call   1050 <add_address@plt>
jmp    1238 <rtnl_address_event+0xe8>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2dae(%rip),%rcx
cmp    (%rcx),%rax
jne    1233 <rtnl_address_event+0xe3>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%esi
call   1030 <delete_address@plt>
jmp    1238 <rtnl_address_event+0xe8>
jmp    123d <rtnl_address_event+0xed>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtnl_address_event>:
push   %rbp
push   %r14
push   %rbx
mov    (%rsi),%rax
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%rax
jne    11d6 <rtnl_address_event+0x86>
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%rax
jge    11d6 <rtnl_address_event+0x86>
mov    %rdi,%r14
mov    (%rdi),%ebp
mov    $0x18,%edi
call   1040 <NLMSG_ALIGN@plt>
sub    %eax,%ebp
cmp    $0x8,%ebp
jb     11d6 <rtnl_address_event+0x86>
mov    %rbx,%rdi
call   1060 <IFA_RTA@plt>
mov    %rax,%rdi
call   1070 <RTA_DATA@plt>
mov    0x8(%r14),%rcx
mov    0x2e41(%rip),%rdx
cmp    (%rdx),%rcx
jne    11bb <rtnl_address_event+0x6b>
mov    0x10(%rbx),%esi
mov    %rax,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <add_address@plt>
mov    0x2e06(%rip),%rdx
cmp    (%rdx),%rcx
jne    11d6 <rtnl_address_event+0x86>
mov    0x10(%rbx),%esi
mov    %rax,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <delete_address@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.nlmsghdr = type { i32, i64 }
%struct.ifaddrmsg = type { i64, i64, i32 }
%struct.in6_addr = type { i32 }
%struct.rtattr = type { i32 }
@AF_INET6 = global i64 0
@RT_SCOPE_LINK = global i64 0
@RTM_NEWADDR = global i64 0
@RTM_DELADDR = global i64 0
define void @rtnl_address_event(%struct.nlmsghdr* %0, %struct.ifaddrmsg* %1) {
%3 = alloca %struct.nlmsghdr*
%4 = alloca %struct.ifaddrmsg*
%5 = alloca %struct.in6_addr*
%6 = alloca i32
%7 = alloca %struct.rtattr*
store %struct.nlmsghdr* %0, %struct.nlmsghdr** %3
store %struct.ifaddrmsg* %1, %struct.ifaddrmsg** %4
%8 = load %struct.ifaddrmsg*, %struct.ifaddrmsg** %4
%9 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %8, i32 0, i32 0
%10 = load i64, i64* %9
%11 = load i64, i64* @AF_INET6
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %2
br label %60
14: ; preds = %2
%15 = load %struct.ifaddrmsg*, %struct.ifaddrmsg** %4
%16 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = load i64, i64* @RT_SCOPE_LINK
%19 = icmp sge i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %14
br label %60
21: ; preds = %14
%22 = load %struct.nlmsghdr*, %struct.nlmsghdr** %3
%23 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @NLMSG_ALIGN(i32 24)
%26 = sub nsw i32 %24, %25
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = icmp uge i64 %28, 8
br i1 %29, label %30, label %60
30: ; preds = %21
%31 = load %struct.ifaddrmsg*, %struct.ifaddrmsg** %4
%32 = call %struct.rtattr* @IFA_RTA(%struct.ifaddrmsg* %31)
store %struct.rtattr* %32, %struct.rtattr** %7
%33 = load %struct.rtattr*, %struct.rtattr** %7
%34 = call %struct.in6_addr* @RTA_DATA(%struct.rtattr* %33)
store %struct.in6_addr* %34, %struct.in6_addr** %5
%35 = load %struct.nlmsghdr*, %struct.nlmsghdr** %3
%36 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %35, i32 0, i32 1
%37 = load i64, i64* %36
%38 = load i64, i64* @RTM_NEWADDR
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %46
40: ; preds = %30
%41 = load %struct.in6_addr*, %struct.in6_addr** %5
%42 = load %struct.ifaddrmsg*, %struct.ifaddrmsg** %4
%43 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %42, i32 0, i32 2
%44 = load i32, i32* %43
%45 = call i32 @add_address(%struct.in6_addr* %41, i32 %44)
br label %59
46: ; preds = %30
%47 = load %struct.nlmsghdr*, %struct.nlmsghdr** %3
%48 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %47, i32 0, i32 1
%49 = load i64, i64* %48
%50 = load i64, i64* @RTM_DELADDR
%51 = icmp eq i64 %49, %50
br i1 %51, label %52, label %58
52: ; preds = %46
%53 = load %struct.in6_addr*, %struct.in6_addr** %5
%54 = load %struct.ifaddrmsg*, %struct.ifaddrmsg** %4
%55 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %54, i32 0, i32 2
%56 = load i32, i32* %55
%57 = call i32 @delete_address(%struct.in6_addr* %53, i32 %56)
br label %58
58: ; preds = %52, %46
br label %59
59: ; preds = %58, %40
br label %60
60: ; preds = %13, %20, %59, %21
ret void
}

LLVM IR (-O2):
%struct.nlmsghdr = type { i32, i64 }
%struct.ifaddrmsg = type { i64, i64, i32 }
%struct.rtattr = type { i32 }
%struct.in6_addr = type { i32 }
@AF_INET6 = global i64 0
@RT_SCOPE_LINK = global i64 0
@RTM_NEWADDR = global i64 0
@RTM_DELADDR = global i64 0
define void @rtnl_address_event(%struct.nlmsghdr* nocapture %0, %struct.ifaddrmsg* %1) {
%3 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %1, i64 0, i32 0
%4 = load i64, i64* %3
%5 = load i64, i64* @AF_INET6
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %36
7: ; preds = %2
%8 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %1, i64 0, i32 1
%9 = load i64, i64* %8
%10 = load i64, i64* @RT_SCOPE_LINK
%11 = icmp slt i64 %9, %10
br i1 %11, label %12, label %36
12: ; preds = %7
%13 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %0, i64 0, i32 0
%14 = load i32, i32* %13
%15 = tail call i32 @NLMSG_ALIGN(i32 24)
%16 = sub nsw i32 %14, %15
%17 = icmp ugt i32 %16, 7
br i1 %17, label %18, label %36
18: ; preds = %12
%19 = tail call %struct.rtattr* @IFA_RTA(%struct.ifaddrmsg* %1)
%20 = tail call %struct.in6_addr* @RTA_DATA(%struct.rtattr* %19)
%21 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %0, i64 0, i32 1
%22 = load i64, i64* %21
%23 = load i64, i64* @RTM_NEWADDR
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %1, i64 0, i32 2
%27 = load i32, i32* %26
%28 = tail call i32 @add_address(%struct.in6_addr* %20, i32 %27)
br label %36
29: ; preds = %18
%30 = load i64, i64* @RTM_DELADDR
%31 = icmp eq i64 %22, %30
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %1, i64 0, i32 2
%34 = load i32, i32* %33
%35 = tail call i32 @delete_address(%struct.in6_addr* %20, i32 %34)
br label %36
36: ; preds = %12, %29, %32, %25, %7, %2
ret void
}