#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 uint8_t;
typedef int uint16_t;
typedef int /*<<< orphan*/ address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_INET6;
char *inet_ntop(int /*<<< orphan*/, int const *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void parse_attached_subnet(const uint8_t *data_item, uint16_t item_len,
                           int changeable) {
  char address[46] = {0};
  if (changeable) {
    if (data_item[0] == 1)
      printf("Add ");
    else
      printf("Drop ");
  }
  if (item_len == 6)
    printf("IPv4 attached subnet: %s/%u\n",
           inet_ntop(AF_INET, data_item + 1, address, sizeof(address)),
           (unsigned int)data_item[5]);
  else
    printf("IPv6 attached subnet: %s/%u\n",
           inet_ntop(AF_INET6, data_item + 1, address, sizeof(address)),
           (unsigned int)data_item[17]);
}


x86 assembly (clang, -O0):
<parse_attached_subnet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x2e,%edx
call   1050 <memset@plt>
cmpl   $0x0,-0x10(%rbp)
je     118f <parse_attached_subnet+0x5f>
mov    -0x8(%rbp),%rax
cmpl   $0x1,(%rax)
jne    117c <parse_attached_subnet+0x4c>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    118a <parse_attached_subnet+0x5a>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    118f <parse_attached_subnet+0x5f>
cmpl   $0x6,-0xc(%rbp)
jne    11d5 <parse_attached_subnet+0xa5>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
lea    -0x40(%rbp),%rdx
mov    $0x2e,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120c <parse_attached_subnet+0xdc>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
lea    -0x40(%rbp),%rdx
mov    $0x2e,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rax
mov    0x44(%rax),%edx
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_attached_subnet>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movups %xmm0,0x1e(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
test   %edx,%edx
je     115c <parse_attached_subnet+0x3c>
cmpl   $0x1,(%rbx)
lea    0xeb6(%rip),%rax
lea    0xeb4(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rbx),%rsi
lea    0x44(%rbx),%rax
add    $0x14,%rbx
cmp    $0x6,%ebp
lea    0xe99(%rip),%rcx
lea    0xeaf(%rip),%rbp
cmove  %rcx,%rbp
mov    0x2e5c(%rip),%rcx
cmove  0x2e5c(%rip),%rcx
mov    (%rcx),%edi
cmovne %rax,%rbx
mov    %rsp,%rdx
mov    $0x2e,%ecx
call   1030 <inet_ntop@plt>
mov    (%rbx),%edx
mov    %rbp,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"Add \00"
@.str.1 = [6 x i8] c"Drop \00"
@.str.2 = [29 x i8] c"IPv4 attached subnet: %s/%u\0A\00"
@AF_INET = global i32 0
@.str.3 = [29 x i8] c"IPv6 attached subnet: %s/%u\0A\00"
@AF_INET6 = global i32 0
define void @parse_attached_subnet(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [46 x i8]
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = bitcast [46 x i8]* %7 to i8*
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %3
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %20
18: ; preds = %11
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
br label %21
21: ; preds = %20, %3
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 6
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32, i32* @AF_INET
%26 = load i32*, i32** %4
%27 = getelementptr inbounds i32, i32* %26, i64 1
%28 = getelementptr inbounds [46 x i8], [46 x i8]* %7, i64 0, i64 0
%29 = call i8* @inet_ntop(i32 %25, i32* %27, i8* %28, i32 46)
%30 = load i32*, i32** %4
%31 = getelementptr inbounds i32, i32* %30, i64 5
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %29, i32 %32)
br label %44
34: ; preds = %21
%35 = load i32, i32* @AF_INET6
%36 = load i32*, i32** %4
%37 = getelementptr inbounds i32, i32* %36, i64 1
%38 = getelementptr inbounds [46 x i8], [46 x i8]* %7, i64 0, i64 0
%39 = call i8* @inet_ntop(i32 %35, i32* %37, i8* %38, i32 46)
%40 = load i32*, i32** %4
%41 = getelementptr inbounds i32, i32* %40, i64 17
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %39, i32 %42)
br label %44
44: ; preds = %34, %24
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"Add \00"
@.str.1 = [6 x i8] c"Drop \00"
@.str.2 = [29 x i8] c"IPv4 attached subnet: %s/%u\0A\00"
@AF_INET = global i32 0
@.str.3 = [29 x i8] c"IPv6 attached subnet: %s/%u\0A\00"
@AF_INET6 = global i32 0
define void @parse_attached_subnet(i32* %0, i32 %1, i32 %2) {
%4 = alloca [46 x i8]
%5 = getelementptr inbounds [46 x i8], [46 x i8]* %4, i64 0, i64 0
%6 = icmp eq i32 %2, 0
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = load i32, i32* %0
%9 = icmp eq i32 %8, 1
%10 = select i1 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %7, %3
%13 = icmp eq i32 %1, 6
%14 = select i1 %13, i64 5, i64 17
%15 = select i1 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0)
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @AF_INET6
%18 = select i1 %13, i32 %16, i32 %17
%19 = getelementptr inbounds i32, i32* %0, i64 1
%20 = call i8* @inet_ntop(i32 %18, i32* %19, i8* %5, i32 46)
%21 = getelementptr inbounds i32, i32* %0, i64 %14
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, i8* %20, i32 %22)
ret void
}