#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_type;
};
struct in_addr {
  int dummy;
};
struct in6_addr {
  int dummy;
};
struct ifaddrmsg {
  int /*<<< orphan*/ ifa_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_INET6;
#define IFA_ADDRESS 129
#define IFA_LOCAL 128
void *RTA_DATA(struct rtattr const *);
int RTA_PAYLOAD(struct rtattr const *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
void parseRouteMsg(const struct rtattr *attr, struct ifaddrmsg *ifa,
                   void **addr) {
  switch (attr->rta_type) {
  case IFA_ADDRESS:
    if (*addr != NULL)
      break;
  case IFA_LOCAL:
    if (ifa->ifa_family == AF_INET &&
        RTA_PAYLOAD(attr) < sizeof(struct in_addr)) {
      {
        fprintf(stderr,
                "IPv4 address is to short (%i)"
                "\n",
                RTA_PAYLOAD(attr));
        fflush(stderr);
      };
    } else if (ifa->ifa_family == AF_INET6 &&
               RTA_PAYLOAD(attr) < sizeof(struct in6_addr)) {
      {
        fprintf(stderr,
                "IPv6 address is to short (%i)"
                "\n",
                RTA_PAYLOAD(attr));
        fflush(stderr);
      };
    } else {
      *addr = RTA_DATA(attr);
    }
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<parseRouteMsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x80,%eax
je     1198 <parseRouteMsg+0x58>
jmp    116d <parseRouteMsg+0x2d>
mov    -0x1c(%rbp),%eax
sub    $0x81,%eax
jne    127b <parseRouteMsg+0x13b>
jmp    1180 <parseRouteMsg+0x40>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1193 <parseRouteMsg+0x53>
jmp    1280 <parseRouteMsg+0x140>
jmp    1198 <parseRouteMsg+0x58>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e43(%rip),%rcx
cmp    (%rcx),%eax
jne    11fb <parseRouteMsg+0xbb>
mov    -0x8(%rbp),%rdi
call   1030 <RTA_PAYLOAD@plt>
cltq
cmp    $0x4,%rax
jae    11fb <parseRouteMsg+0xbb>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <RTA_PAYLOAD@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%edx
lea    0xe1d(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    1276 <parseRouteMsg+0x136>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2dd8(%rip),%rcx
cmp    (%rcx),%eax
jne    125e <parseRouteMsg+0x11e>
mov    -0x8(%rbp),%rdi
call   1030 <RTA_PAYLOAD@plt>
cltq
cmp    $0x4,%rax
jae    125e <parseRouteMsg+0x11e>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <RTA_PAYLOAD@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%edx
lea    0xdd9(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    1271 <parseRouteMsg+0x131>
mov    -0x8(%rbp),%rdi
call   1060 <RTA_DATA@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1276 <parseRouteMsg+0x136>
jmp    1280 <parseRouteMsg+0x140>
jmp    1280 <parseRouteMsg+0x140>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseRouteMsg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdi),%eax
cmp    $0x80,%eax
je     116e <parseRouteMsg+0x2e>
cmp    $0x81,%eax
jne    11fe <parseRouteMsg+0xbe>
cmpq   $0x0,(%r14)
jne    11fe <parseRouteMsg+0xbe>
mov    (%r15),%eax
mov    0x2e70(%rip),%rcx
cmp    (%rcx),%eax
jne    11a7 <parseRouteMsg+0x67>
mov    %rbx,%rdi
call   1030 <RTA_PAYLOAD@plt>
cmp    $0x4,%eax
jae    11a4 <parseRouteMsg+0x64>
mov    0x2e40(%rip),%r14
mov    (%r14),%ebp
mov    %rbx,%rdi
call   1030 <RTA_PAYLOAD@plt>
lea    0xe5e(%rip),%rsi
jmp    11d8 <parseRouteMsg+0x98>
mov    (%r15),%eax
mov    0x2e32(%rip),%rcx
cmp    (%rcx),%eax
jne    11f3 <parseRouteMsg+0xb3>
mov    %rbx,%rdi
call   1030 <RTA_PAYLOAD@plt>
cmp    $0x3,%eax
ja     11f3 <parseRouteMsg+0xb3>
mov    0x2e0a(%rip),%r14
mov    (%r14),%ebp
mov    %rbx,%rdi
call   1030 <RTA_PAYLOAD@plt>
lea    0xe47(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    (%r14),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>
mov    %rbx,%rdi
call   1060 <RTA_DATA@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rtattr = type { i32 }
%struct.ifaddrmsg = type { i32 }
@AF_INET = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"IPv4 address is to short (%i)\0A\00"
@AF_INET6 = global i32 0
@.str.1 = [31 x i8] c"IPv6 address is to short (%i)\0A\00"
define void @parseRouteMsg(%struct.rtattr* %0, %struct.ifaddrmsg* %1, i8** %2) {
%4 = alloca %struct.rtattr*
%5 = alloca %struct.ifaddrmsg*
%6 = alloca i8**
store %struct.rtattr* %0, %struct.rtattr** %4
store %struct.ifaddrmsg* %1, %struct.ifaddrmsg** %5
store i8** %2, i8*** %6
%7 = load %struct.rtattr*, %struct.rtattr** %4
%8 = getelementptr inbounds %struct.rtattr, %struct.rtattr* %7, i32 0, i32 0
%9 = load i32, i32* %8
switch i32 %9, label %58 [
i32 129, label %10
i32 128, label %16
]
10: ; preds = %3
%11 = load i8**, i8*** %6
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %10
br label %59
15: ; preds = %10
br label %16
16: ; preds = %3, %15
%17 = load %struct.ifaddrmsg*, %struct.ifaddrmsg** %5
%18 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i32, i32* @AF_INET
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %16
%23 = load %struct.rtattr*, %struct.rtattr** %4
%24 = call i32 @RTA_PAYLOAD(%struct.rtattr* %23)
%25 = sext i32 %24 to i64
%26 = icmp ult i64 %25, 4
br i1 %26, label %27, label %34
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = load %struct.rtattr*, %struct.rtattr** %4
%30 = call i32 @RTA_PAYLOAD(%struct.rtattr* %29)
%31 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* @stderr
%33 = call i32 @fflush(i32 %32)
br label %57
34: ; preds = %22, %16
%35 = load %struct.ifaddrmsg*, %struct.ifaddrmsg** %5
%36 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %35, i32 0, i32 0
%37 = load i32, i32* %36
%38 = load i32, i32* @AF_INET6
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %52
40: ; preds = %34
%41 = load %struct.rtattr*, %struct.rtattr** %4
%42 = call i32 @RTA_PAYLOAD(%struct.rtattr* %41)
%43 = sext i32 %42 to i64
%44 = icmp ult i64 %43, 4
br i1 %44, label %45, label %52
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = load %struct.rtattr*, %struct.rtattr** %4
%48 = call i32 @RTA_PAYLOAD(%struct.rtattr* %47)
%49 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = load i32, i32* @stderr
%51 = call i32 @fflush(i32 %50)
br label %56
52: ; preds = %40, %34
%53 = load %struct.rtattr*, %struct.rtattr** %4
%54 = call i8* @RTA_DATA(%struct.rtattr* %53)
%55 = load i8**, i8*** %6
store i8* %54, i8** %55
br label %56
56: ; preds = %52, %45
br label %57
57: ; preds = %56, %27
br label %59
58: ; preds = %3
br label %59
59: ; preds = %58, %57, %14
ret void
}

LLVM IR (-O2):
%struct.rtattr = type { i32 }
%struct.ifaddrmsg = type { i32 }
@AF_INET = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"IPv4 address is to short (%i)\0A\00"
@AF_INET6 = global i32 0
@.str.1 = [31 x i8] c"IPv6 address is to short (%i)\0A\00"
define void @parseRouteMsg(%struct.rtattr* %0, %struct.ifaddrmsg* nocapture %1, i8** nocapture %2) {
%4 = getelementptr inbounds %struct.rtattr, %struct.rtattr* %0, i64 0, i32 0
%5 = load i32, i32* %4
switch i32 %5, label %40 [
i32 129, label %6
i32 128, label %9
]
6: ; preds = %3
%7 = load i8*, i8** %2
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %40
9: ; preds = %6, %3
%10 = getelementptr inbounds %struct.ifaddrmsg, %struct.ifaddrmsg* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = load i32, i32* @AF_INET
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = tail call i32 @RTA_PAYLOAD(%struct.rtattr* %0)
%16 = icmp ult i32 %15, 4
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = load i32, i32* %10
br label %25
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = tail call i32 @RTA_PAYLOAD(%struct.rtattr* %0)
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @stderr
%24 = tail call i32 @fflush(i32 %23)
br label %40
25: ; preds = %17, %9
%26 = phi i32 [ %18, %17 ], [ %11, %9 ]
%27 = load i32, i32* @AF_INET6
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = tail call i32 @RTA_PAYLOAD(%struct.rtattr* %0)
%31 = icmp ult i32 %30, 4
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = tail call i32 @RTA_PAYLOAD(%struct.rtattr* %0)
%35 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* @stderr
%37 = tail call i32 @fflush(i32 %36)
br label %40
38: ; preds = %29, %25
%39 = tail call i8* @RTA_DATA(%struct.rtattr* %0)
store i8* %39, i8** %2
br label %40
40: ; preds = %3, %19, %38, %32, %6
ret void
}