#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 rta_len;
  int rta_type;
};
struct nlmsghdr {
  int nlmsg_len;
};
struct ifinfomsg {
  int dummy;
};

/* Variables and functions */
int NLMSG_ALIGN(int);
struct ifinfomsg *NLMSG_DATA(struct nlmsghdr *);
int RTA_ALIGN(int);
struct rtattr *RTA_NEXT(struct rtattr *, int);
int /*<<< orphan*/ wscEventHandler(char *, int);
void wscNLEventRTMNewlinkHandle(struct nlmsghdr *nlmsgHdr, int len) {
  struct ifinfomsg *ifi;
  int attrlen, nlmsg_len, rta_len;
  struct rtattr *attr;
  do {
  } while (0);
  if (len < sizeof(struct ifinfomsg))
    return;
  ifi = NLMSG_DATA(nlmsgHdr);
  nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
  attrlen = nlmsgHdr->nlmsg_len - nlmsg_len;
  if (attrlen < 0)
    return;
  attr = (struct rtattr *)(((char *)ifi) + nlmsg_len);
  rta_len = RTA_ALIGN(sizeof(struct rtattr));
  while (((attrlen) > 0 && (attr)->rta_len >= sizeof(struct rtattr) &&
          (attr)->rta_len <= (attrlen))) {
    if (attr->rta_type == 11) {
      wscEventHandler(((char *)attr) + rta_len, attr->rta_len - rta_len);
    }
    attr = RTA_NEXT(attr, attrlen);
  }
}


x86 assembly (clang, -O0):
<wscNLEventRTMNewlinkHandle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
jmp    1164 <wscNLEventRTMNewlinkHandle+0x14>
movslq -0xc(%rbp),%rax
cmp    $0x4,%rax
jae    1177 <wscNLEventRTMNewlinkHandle+0x27>
jmp    1248 <wscNLEventRTMNewlinkHandle+0xf8>
mov    -0x8(%rbp),%rdi
call   1070 <NLMSG_DATA@plt>
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
call   1050 <NLMSG_ALIGN@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11ac <wscNLEventRTMNewlinkHandle+0x5c>
jmp    1248 <wscNLEventRTMNewlinkHandle+0xf8>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    $0x8,%edi
call   1040 <RTA_ALIGN@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x31(%rbp)
jle    11fc <wscNLEventRTMNewlinkHandle+0xac>
mov    -0x30(%rbp),%rax
movslq (%rax),%rcx
xor    %eax,%eax
cmp    $0x8,%rcx
mov    %al,-0x31(%rbp)
jb     11fc <wscNLEventRTMNewlinkHandle+0xac>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
cmp    -0x1c(%rbp),%eax
setle  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    120c <wscNLEventRTMNewlinkHandle+0xbc>
jmp    1248 <wscNLEventRTMNewlinkHandle+0xf8>
mov    -0x30(%rbp),%rax
cmpl   $0xb,0x4(%rax)
jne    1233 <wscNLEventRTMNewlinkHandle+0xe3>
mov    -0x30(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
sub    -0x24(%rbp),%esi
call   1060 <wscEventHandler@plt>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <RTA_NEXT@plt>
mov    %rax,-0x30(%rbp)
jmp    11c8 <wscNLEventRTMNewlinkHandle+0x78>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wscNLEventRTMNewlinkHandle>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x4,%esi
jb     11ca <wscNLEventRTMNewlinkHandle+0x7a>
mov    %rdi,%rbp
call   1070 <NLMSG_DATA@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1050 <NLMSG_ALIGN@plt>
mov    0x0(%rbp),%ebp
sub    %eax,%ebp
js     11ca <wscNLEventRTMNewlinkHandle+0x7a>
mov    %eax,%r14d
mov    $0x8,%edi
call   1040 <RTA_ALIGN@plt>
test   %ebp,%ebp
je     11ca <wscNLEventRTMNewlinkHandle+0x7a>
movslq %r14d,%rcx
mov    (%rbx,%rcx,1),%esi
cmp    $0x8,%esi
jb     11ca <wscNLEventRTMNewlinkHandle+0x7a>
cmp    %ebp,%esi
jg     11ca <wscNLEventRTMNewlinkHandle+0x7a>
add    %rcx,%rbx
movslq %eax,%r14
nopl   0x0(%rax,%rax,1)
cmpl   $0xb,0x4(%rbx)
jne    11b2 <wscNLEventRTMNewlinkHandle+0x62>
lea    (%rbx,%r14,1),%rdi
sub    %r14d,%esi
call   1060 <wscEventHandler@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <RTA_NEXT@plt>
mov    (%rax),%esi
cmp    $0x8,%esi
jb     11ca <wscNLEventRTMNewlinkHandle+0x7a>
mov    %rax,%rbx
cmp    %ebp,%esi
jle    11a0 <wscNLEventRTMNewlinkHandle+0x50>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.nlmsghdr = type { i32 }
%struct.ifinfomsg = type { i32 }
%struct.rtattr = type { i32, i32 }
define void @wscNLEventRTMNewlinkHandle(%struct.nlmsghdr* %0, i32 %1) {
%3 = alloca %struct.nlmsghdr*
%4 = alloca i32
%5 = alloca %struct.ifinfomsg*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.rtattr*
store %struct.nlmsghdr* %0, %struct.nlmsghdr** %3
store i32 %1, i32* %4
br label %10
10: ; preds = %2
br label %11
11: ; preds = %10
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %13, 4
br i1 %14, label %15, label %16
15: ; preds = %11
br label %74
16: ; preds = %11
%17 = load %struct.nlmsghdr*, %struct.nlmsghdr** %3
%18 = call %struct.ifinfomsg* @NLMSG_DATA(%struct.nlmsghdr* %17)
store %struct.ifinfomsg* %18, %struct.ifinfomsg** %5
%19 = call i32 @NLMSG_ALIGN(i32 4)
store i32 %19, i32* %7
%20 = load %struct.nlmsghdr*, %struct.nlmsghdr** %3
%21 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load i32, i32* %7
%24 = sub nsw i32 %22, %23
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %16
br label %74
28: ; preds = %16
%29 = load %struct.ifinfomsg*, %struct.ifinfomsg** %5
%30 = bitcast %struct.ifinfomsg* %29 to i8*
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = bitcast i8* %33 to %struct.rtattr*
store %struct.rtattr* %34, %struct.rtattr** %9
%35 = call i32 @RTA_ALIGN(i32 8)
store i32 %35, i32* %8
br label %36
36: ; preds = %70, %28
%37 = load i32, i32* %6
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %51
39: ; preds = %36
%40 = load %struct.rtattr*, %struct.rtattr** %9
%41 = getelementptr inbounds %struct.rtattr, %struct.rtattr* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = sext i32 %42 to i64
%44 = icmp uge i64 %43, 8
br i1 %44, label %45, label %51
45: ; preds = %39
%46 = load %struct.rtattr*, %struct.rtattr** %9
%47 = getelementptr inbounds %struct.rtattr, %struct.rtattr* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = load i32, i32* %6
%50 = icmp sle i32 %48, %49
br label %51
51: ; preds = %45, %39, %36
%52 = phi i1 [ false, %39 ], [ false, %36 ], [ %50, %45 ]
br i1 %52, label %53, label %74
53: ; preds = %51
%54 = load %struct.rtattr*, %struct.rtattr** %9
%55 = getelementptr inbounds %struct.rtattr, %struct.rtattr* %54, i32 0, i32 1
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 11
br i1 %57, label %58, label %70
58: ; preds = %53
%59 = load %struct.rtattr*, %struct.rtattr** %9
%60 = bitcast %struct.rtattr* %59 to i8*
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load %struct.rtattr*, %struct.rtattr** %9
%65 = getelementptr inbounds %struct.rtattr, %struct.rtattr* %64, i32 0, i32 0
%66 = load i32, i32* %65
%67 = load i32, i32* %8
%68 = sub nsw i32 %66, %67
%69 = call i32 @wscEventHandler(i8* %63, i32 %68)
br label %70
70: ; preds = %58, %53
%71 = load %struct.rtattr*, %struct.rtattr** %9
%72 = load i32, i32* %6
%73 = call %struct.rtattr* @RTA_NEXT(%struct.rtattr* %71, i32 %72)
store %struct.rtattr* %73, %struct.rtattr** %9
br label %36
74: ; preds = %15, %27, %51
ret void
}

LLVM IR (-O2):
%struct.nlmsghdr = type { i32 }
%struct.ifinfomsg = type { i32 }
%struct.rtattr = type { i32, i32 }
define void @wscNLEventRTMNewlinkHandle(%struct.nlmsghdr* %0, i32 %1) {
%3 = icmp ult i32 %1, 4
br i1 %3, label %44, label %4
4: ; preds = %2
%5 = tail call %struct.ifinfomsg* @NLMSG_DATA(%struct.nlmsghdr* %0)
%6 = tail call i32 @NLMSG_ALIGN(i32 4)
%7 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = sub nsw i32 %8, %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %44, label %11
11: ; preds = %4
%12 = tail call i32 @RTA_ALIGN(i32 8)
%13 = icmp eq i32 %9, 0
br i1 %13, label %44, label %14
14: ; preds = %11
%15 = bitcast %struct.ifinfomsg* %5 to i8*
%16 = sext i32 %6 to i64
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = sext i32 %12 to i64
%19 = bitcast i8* %17 to i32*
%20 = load i32, i32* %19
%21 = icmp ult i32 %20, 8
%22 = icmp sgt i32 %20, %9
%23 = select i1 %21, i1 true, i1 %22
br i1 %23, label %44, label %24
24: ; preds = %14
%25 = bitcast i8* %17 to %struct.rtattr*
br label %26
26: ; preds = %24, %37
%27 = phi i32 [ %20, %24 ], [ %40, %37 ]
%28 = phi %struct.rtattr* [ %25, %24 ], [ %38, %37 ]
%29 = getelementptr inbounds %struct.rtattr, %struct.rtattr* %28, i64 0, i32 1
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 11
br i1 %31, label %32, label %37
32: ; preds = %26
%33 = bitcast %struct.rtattr* %28 to i8*
%34 = getelementptr inbounds i8, i8* %33, i64 %18
%35 = sub nsw i32 %27, %12
%36 = tail call i32 @wscEventHandler(i8* %34, i32 %35)
br label %37
37: ; preds = %32, %26
%38 = tail call %struct.rtattr* @RTA_NEXT(%struct.rtattr* %28, i32 %9)
%39 = getelementptr inbounds %struct.rtattr, %struct.rtattr* %38, i64 0, i32 0
%40 = load i32, i32* %39
%41 = icmp ult i32 %40, 8
%42 = icmp sgt i32 %40, %9
%43 = select i1 %41, i1 true, i1 %42
br i1 %43, label %44, label %26
44: ; preds = %37, %14, %11, %4, %2
ret void
}