#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct sockaddr_in6 {
  int dummy;
};
struct sockaddr_in {
  int dummy;
};
struct s_ipv6_addr {
  int dummy;
};
typedef struct s_ipv6_addr s_ipv4_addr;
struct ifaddrs {
  TYPE_1__ *ifa_addr;
  int /*<<< orphan*/ ifa_name;
  struct ifaddrs *ifa_next;
};
typedef int /*<<< orphan*/ ip_text;
struct TYPE_2__ {
  scalar_t__ sa_family;
};

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
int /*<<< orphan*/ NI_NUMERICHOST;
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
int getifaddrs(struct ifaddrs **);
int /*<<< orphan*/ getnameinfo(TYPE_1__ *, int, char *, int,
                               int /*<<< orphan*/ *, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ inet_pton(scalar_t__, char *, struct s_ipv6_addr *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
int cfg_host_ips(char *cinterface, struct s_ipv6_addr *ipv6_addr,
                 struct s_ipv4_addr *ipv4_addr, char *default_ipv4_addr) {
  struct ifaddrs *ifaddr, *ifa;
  char found = 0;
  char ip_text[40];
  if (getifaddrs(&ifaddr) == -1) {
    perror("getifaddrs");
    return 1;
  }
  for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
    if (ifa->ifa_addr == NULL) {
      continue;
    }
    if (!strcmp(ifa->ifa_name, cinterface)) {
      if (ifa->ifa_addr->sa_family == AF_INET6 && !(found & 0x01)) {
        found |= 0x01;
        getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), ip_text,
                    sizeof(ip_text), NULL, 0, NI_NUMERICHOST);
        inet_pton(AF_INET6, ip_text, ipv6_addr);
      } else if (ifa->ifa_addr->sa_family == AF_INET && !(found & 0x02)) {
        found |= 0x02;
        getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), ip_text,
                    sizeof(ip_text), NULL, 0, NI_NUMERICHOST);
        inet_pton(AF_INET, ip_text, ipv4_addr);
      }
    } else {
      if (ifa->ifa_addr->sa_family == AF_INET6 && !(found & 0x05)) {
        found |= 0x04;
        getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), ip_text,
                    sizeof(ip_text), NULL, 0, NI_NUMERICHOST);
        inet_pton(AF_INET6, ip_text, ipv6_addr);
      } else if (ifa->ifa_addr->sa_family == AF_INET && !(found & 0x0a)) {
        found |= 0x08;
        getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), ip_text,
                    sizeof(ip_text), NULL, 0, NI_NUMERICHOST);
        inet_pton(AF_INET, ip_text, ipv4_addr);
      }
    }
    if ((found & 0x03) == 0x03) {
      break;
    }
  }
  if (!(found & 0x0a)) {
    inet_pton(AF_INET, default_ipv4_addr, ipv4_addr);
  }
  if (!(found & 0x05)) {
    inet_pton(AF_INET6, "64:ff9b::E7ad:514", ipv6_addr);
  }
  freeifaddrs(ifaddr);
  return 0;
}


x86 assembly (clang, -O0):
<cfg_host_ips>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movb   $0x0,-0x39(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <getifaddrs@plt>
cmp    $0xffffffff,%eax
jne    11a9 <cfg_host_ips+0x49>
lea    0xe68(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    146e <cfg_host_ips+0x30e>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     140d <cfg_host_ips+0x2ad>
mov    -0x38(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11cf <cfg_host_ips+0x6f>
jmp    13fc <cfg_host_ips+0x29c>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12e5 <cfg_host_ips+0x185>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    0x2de7(%rip),%rcx
cmp    (%rcx),%rax
jne    1264 <cfg_host_ips+0x104>
movsbl -0x39(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1264 <cfg_host_ips+0x104>
movsbl -0x39(%rbp),%eax
or     $0x1,%eax
mov    %al,-0x39(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rdx
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
mov    $0x4,%esi
mov    $0x28,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
mov    %eax,(%rsp)
call   1030 <getnameinfo@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <inet_pton@plt>
jmp    12e0 <cfg_host_ips+0x180>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    0x2d73(%rip),%rcx
cmp    (%rcx),%rax
jne    12db <cfg_host_ips+0x17b>
movsbl -0x39(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
jne    12db <cfg_host_ips+0x17b>
movsbl -0x39(%rbp),%eax
or     $0x2,%eax
mov    %al,-0x39(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rdx
mov    0x2d26(%rip),%rax
mov    (%rax),%eax
mov    $0x4,%esi
mov    $0x28,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
mov    %eax,(%rsp)
call   1030 <getnameinfo@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <inet_pton@plt>
jmp    12e0 <cfg_host_ips+0x180>
jmp    13e2 <cfg_host_ips+0x282>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    0x2cea(%rip),%rcx
cmp    (%rcx),%rax
jne    1361 <cfg_host_ips+0x201>
movsbl -0x39(%rbp),%eax
and    $0x5,%eax
cmp    $0x0,%eax
jne    1361 <cfg_host_ips+0x201>
movsbl -0x39(%rbp),%eax
or     $0x4,%eax
mov    %al,-0x39(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rdx
mov    0x2ca5(%rip),%rax
mov    (%rax),%eax
mov    $0x4,%esi
mov    $0x28,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
mov    %eax,(%rsp)
call   1030 <getnameinfo@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <inet_pton@plt>
jmp    13dd <cfg_host_ips+0x27d>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    0x2c76(%rip),%rcx
cmp    (%rcx),%rax
jne    13d8 <cfg_host_ips+0x278>
movsbl -0x39(%rbp),%eax
and    $0xa,%eax
cmp    $0x0,%eax
jne    13d8 <cfg_host_ips+0x278>
movsbl -0x39(%rbp),%eax
or     $0x8,%eax
mov    %al,-0x39(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rdx
mov    0x2c29(%rip),%rax
mov    (%rax),%eax
mov    $0x4,%esi
mov    $0x28,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
mov    %eax,(%rsp)
call   1030 <getnameinfo@plt>
mov    0x2c20(%rip),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <inet_pton@plt>
jmp    13dd <cfg_host_ips+0x27d>
jmp    13e2 <cfg_host_ips+0x282>
movsbl -0x39(%rbp),%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    13f7 <cfg_host_ips+0x297>
jmp    140d <cfg_host_ips+0x2ad>
jmp    13fc <cfg_host_ips+0x29c>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    11b1 <cfg_host_ips+0x51>
movsbl -0x39(%rbp),%eax
and    $0xa,%eax
cmp    $0x0,%eax
jne    1434 <cfg_host_ips+0x2d4>
mov    0x2bc4(%rip),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <inet_pton@plt>
movsbl -0x39(%rbp),%eax
and    $0x5,%eax
cmp    $0x0,%eax
jne    145e <cfg_host_ips+0x2fe>
mov    0x2b95(%rip),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rdx
lea    0xbb2(%rip),%rsi
call   1050 <inet_pton@plt>
mov    -0x30(%rbp),%rdi
call   1070 <freeifaddrs@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_host_ips>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,%rbp
mov    %rdx,0x8(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,0x28(%rsp)
lea    0x18(%rsp),%rdi
call   1060 <getifaddrs@plt>
cmp    $0xffffffff,%eax
je     1316 <cfg_host_ips+0x1b6>
mov    0x18(%rsp),%r15
test   %r15,%r15
je     12db <cfg_host_ips+0x17b>
mov    %rbp,0x20(%rsp)
xor    %r14d,%r14d
mov    0x2e30(%rip),%rbx
jmp    1213 <cfg_host_ips+0xb3>
mov    0x2e2f(%rip),%r12
mov    0x8(%rsp),%rbp
or     %al,%r14b
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    $0x4,%esi
lea    0x30(%rsp),%r13
mov    %r13,%rdx
mov    $0x28,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <getnameinfo@plt>
mov    (%r12),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <inet_pton@plt>
mov    %r14d,%eax
not    %al
test   $0x3,%al
je     12ad <cfg_host_ips+0x14d>
mov    0x10(%r15),%r15
test   %r15,%r15
je     12ad <cfg_host_ips+0x14d>
cmpq   $0x0,(%r15)
je     1206 <cfg_host_ips+0xa6>
mov    0x8(%r15),%edi
mov    0x28(%rsp),%rsi
call   1040 <strcmp@plt>
mov    (%r15),%rdi
mov    (%rdi),%rcx
mov    (%rbx),%rdx
test   %eax,%eax
je     1270 <cfg_host_ips+0x110>
cmp    %rdx,%rcx
jne    124f <cfg_host_ips+0xef>
mov    %r14d,%edx
mov    $0x4,%al
mov    %rbx,%r12
mov    0x10(%rsp),%rbp
and    $0x5,%dl
je     11be <cfg_host_ips+0x5e>
mov    0x2d92(%rip),%rax
cmp    (%rax),%rcx
jne    11f9 <cfg_host_ips+0x99>
mov    %r14d,%eax
and    $0xa,%al
jne    11f9 <cfg_host_ips+0x99>
mov    $0x8,%al
jmp    11b2 <cfg_host_ips+0x52>
nopl   0x0(%rax)
cmp    %rdx,%rcx
jne    128b <cfg_host_ips+0x12b>
mov    %r14d,%edx
mov    $0x1,%al
mov    %rbx,%r12
mov    0x10(%rsp),%rbp
and    $0x1,%dl
je     11be <cfg_host_ips+0x5e>
mov    0x2d56(%rip),%rax
cmp    (%rax),%rcx
jne    11f9 <cfg_host_ips+0x99>
mov    %r14d,%eax
and    $0x2,%al
jne    11f9 <cfg_host_ips+0x99>
mov    $0x2,%al
jmp    11b2 <cfg_host_ips+0x52>
movzbl %r14b,%ebx
test   $0xa,%bl
mov    0x20(%rsp),%rbp
je     12dd <cfg_host_ips+0x17d>
test   $0x5,%bl
je     12f9 <cfg_host_ips+0x199>
mov    0x18(%rsp),%rdi
call   1070 <freeifaddrs@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
mov    0x2d04(%rip),%rax
mov    (%rax),%rdi
mov    %rbp,%rsi
mov    0x8(%rsp),%rdx
call   1050 <inet_pton@plt>
test   $0x5,%bl
jne    12c0 <cfg_host_ips+0x160>
mov    0x2ce0(%rip),%rax
mov    (%rax),%rdi
lea    0xd01(%rip),%rsi
mov    0x10(%rsp),%rdx
call   1050 <inet_pton@plt>
jmp    12c0 <cfg_host_ips+0x160>
lea    0xce3(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    12cc <cfg_host_ips+0x16c>

LLVM IR (-O0):
%struct.s_ipv6_addr = type { i32 }
%struct.s_ipv4_addr = type opaque
%struct.ifaddrs = type { %struct.TYPE_2__*, i32, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@.str = [11 x i8] c"getifaddrs\00"
@AF_INET6 = global i64 0
@NI_NUMERICHOST = global i32 0
@AF_INET = global i64 0
@.str.1 = [18 x i8] c"64:ff9b::E7ad:514\00"
define i32 @cfg_host_ips(i8* %0, %struct.s_ipv6_addr* %1, %struct.s_ipv4_addr* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.s_ipv6_addr*
%8 = alloca %struct.s_ipv4_addr*
%9 = alloca i8*
%10 = alloca %struct.ifaddrs*
%11 = alloca %struct.ifaddrs*
%12 = alloca i8
%13 = alloca [40 x i8]
store i8* %0, i8** %6
store %struct.s_ipv6_addr* %1, %struct.s_ipv6_addr** %7
store %struct.s_ipv4_addr* %2, %struct.s_ipv4_addr** %8
store i8* %3, i8** %9
store i8 0, i8* %12
%14 = call i32 @getifaddrs(%struct.ifaddrs** %10)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %4
%17 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %188
18: ; preds = %4
%19 = load %struct.ifaddrs*, %struct.ifaddrs** %10
store %struct.ifaddrs* %19, %struct.ifaddrs** %11
br label %20
20: ; preds = %161, %18
%21 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%22 = icmp ne %struct.ifaddrs* %21, null
br i1 %22, label %23, label %165
23: ; preds = %20
%24 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%25 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %24, i32 0, i32 0
%26 = load %struct.TYPE_2__*, %struct.TYPE_2__** %25
%27 = icmp eq %struct.TYPE_2__* %26, null
br i1 %27, label %28, label %29
28: ; preds = %23
br label %161
29: ; preds = %23
%30 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%31 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = load i8*, i8** %6
%34 = call i32 @strcmp(i32 %32, i8* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %95, label %36
36: ; preds = %29
%37 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%38 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %37, i32 0, i32 0
%39 = load %struct.TYPE_2__*, %struct.TYPE_2__** %38
%40 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %39, i32 0, i32 0
%41 = load i64, i64* %40
%42 = load i64, i64* @AF_INET6
%43 = icmp eq i64 %41, %42
br i1 %43, label %44, label %64
44: ; preds = %36
%45 = load i8, i8* %12
%46 = sext i8 %45 to i32
%47 = and i32 %46, 1
%48 = icmp ne i32 %47, 0
br i1 %48, label %64, label %49
49: ; preds = %44
%50 = load i8, i8* %12
%51 = sext i8 %50 to i32
%52 = or i32 %51, 1
%53 = trunc i32 %52 to i8
store i8 %53, i8* %12
%54 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%55 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %54, i32 0, i32 0
%56 = load %struct.TYPE_2__*, %struct.TYPE_2__** %55
%57 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%58 = load i32, i32* @NI_NUMERICHOST
%59 = call i32 @getnameinfo(%struct.TYPE_2__* %56, i32 4, i8* %57, i32 40, i32* null, i32 0, i32 %58)
%60 = load i64, i64* @AF_INET6
%61 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%62 = load %struct.s_ipv6_addr*, %struct.s_ipv6_addr** %7
%63 = call i32 @inet_pton(i64 %60, i8* %61, %struct.s_ipv6_addr* %62)
br label %94
64: ; preds = %44, %36
%65 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%66 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %65, i32 0, i32 0
%67 = load %struct.TYPE_2__*, %struct.TYPE_2__** %66
%68 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %67, i32 0, i32 0
%69 = load i64, i64* %68
%70 = load i64, i64* @AF_INET
%71 = icmp eq i64 %69, %70
br i1 %71, label %72, label %93
72: ; preds = %64
%73 = load i8, i8* %12
%74 = sext i8 %73 to i32
%75 = and i32 %74, 2
%76 = icmp ne i32 %75, 0
br i1 %76, label %93, label %77
77: ; preds = %72
%78 = load i8, i8* %12
%79 = sext i8 %78 to i32
%80 = or i32 %79, 2
%81 = trunc i32 %80 to i8
store i8 %81, i8* %12
%82 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%83 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %82, i32 0, i32 0
%84 = load %struct.TYPE_2__*, %struct.TYPE_2__** %83
%85 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%86 = load i32, i32* @NI_NUMERICHOST
%87 = call i32 @getnameinfo(%struct.TYPE_2__* %84, i32 4, i8* %85, i32 40, i32* null, i32 0, i32 %86)
%88 = load i64, i64* @AF_INET
%89 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%90 = load %struct.s_ipv4_addr*, %struct.s_ipv4_addr** %8
%91 = bitcast %struct.s_ipv4_addr* %90 to %struct.s_ipv6_addr*
%92 = call i32 @inet_pton(i64 %88, i8* %89, %struct.s_ipv6_addr* %91)
br label %93
93: ; preds = %77, %72, %64
br label %94
94: ; preds = %93, %49
br label %154
95: ; preds = %29
%96 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%97 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %96, i32 0, i32 0
%98 = load %struct.TYPE_2__*, %struct.TYPE_2__** %97
%99 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %98, i32 0, i32 0
%100 = load i64, i64* %99
%101 = load i64, i64* @AF_INET6
%102 = icmp eq i64 %100, %101
br i1 %102, label %103, label %123
103: ; preds = %95
%104 = load i8, i8* %12
%105 = sext i8 %104 to i32
%106 = and i32 %105, 5
%107 = icmp ne i32 %106, 0
br i1 %107, label %123, label %108
108: ; preds = %103
%109 = load i8, i8* %12
%110 = sext i8 %109 to i32
%111 = or i32 %110, 4
%112 = trunc i32 %111 to i8
store i8 %112, i8* %12
%113 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%114 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %113, i32 0, i32 0
%115 = load %struct.TYPE_2__*, %struct.TYPE_2__** %114
%116 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%117 = load i32, i32* @NI_NUMERICHOST
%118 = call i32 @getnameinfo(%struct.TYPE_2__* %115, i32 4, i8* %116, i32 40, i32* null, i32 0, i32 %117)
%119 = load i64, i64* @AF_INET6
%120 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%121 = load %struct.s_ipv6_addr*, %struct.s_ipv6_addr** %7
%122 = call i32 @inet_pton(i64 %119, i8* %120, %struct.s_ipv6_addr* %121)
br label %153
123: ; preds = %103, %95
%124 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%125 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %124, i32 0, i32 0
%126 = load %struct.TYPE_2__*, %struct.TYPE_2__** %125
%127 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %126, i32 0, i32 0
%128 = load i64, i64* %127
%129 = load i64, i64* @AF_INET
%130 = icmp eq i64 %128, %129
br i1 %130, label %131, label %152
131: ; preds = %123
%132 = load i8, i8* %12
%133 = sext i8 %132 to i32
%134 = and i32 %133, 10
%135 = icmp ne i32 %134, 0
br i1 %135, label %152, label %136
136: ; preds = %131
%137 = load i8, i8* %12
%138 = sext i8 %137 to i32
%139 = or i32 %138, 8
%140 = trunc i32 %139 to i8
store i8 %140, i8* %12
%141 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%142 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %141, i32 0, i32 0
%143 = load %struct.TYPE_2__*, %struct.TYPE_2__** %142
%144 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%145 = load i32, i32* @NI_NUMERICHOST
%146 = call i32 @getnameinfo(%struct.TYPE_2__* %143, i32 4, i8* %144, i32 40, i32* null, i32 0, i32 %145)
%147 = load i64, i64* @AF_INET
%148 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%149 = load %struct.s_ipv4_addr*, %struct.s_ipv4_addr** %8
%150 = bitcast %struct.s_ipv4_addr* %149 to %struct.s_ipv6_addr*
%151 = call i32 @inet_pton(i64 %147, i8* %148, %struct.s_ipv6_addr* %150)
br label %152
152: ; preds = %136, %131, %123
br label %153
153: ; preds = %152, %108
br label %154
154: ; preds = %153, %94
%155 = load i8, i8* %12
%156 = sext i8 %155 to i32
%157 = and i32 %156, 3
%158 = icmp eq i32 %157, 3
br i1 %158, label %159, label %160
159: ; preds = %154
br label %165
160: ; preds = %154
br label %161
161: ; preds = %160, %28
%162 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%163 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %162, i32 0, i32 2
%164 = load %struct.ifaddrs*, %struct.ifaddrs** %163
store %struct.ifaddrs* %164, %struct.ifaddrs** %11
br label %20
165: ; preds = %159, %20
%166 = load i8, i8* %12
%167 = sext i8 %166 to i32
%168 = and i32 %167, 10
%169 = icmp ne i32 %168, 0
br i1 %169, label %176, label %170
170: ; preds = %165
%171 = load i64, i64* @AF_INET
%172 = load i8*, i8** %9
%173 = load %struct.s_ipv4_addr*, %struct.s_ipv4_addr** %8
%174 = bitcast %struct.s_ipv4_addr* %173 to %struct.s_ipv6_addr*
%175 = call i32 @inet_pton(i64 %171, i8* %172, %struct.s_ipv6_addr* %174)
br label %176
176: ; preds = %170, %165
%177 = load i8, i8* %12
%178 = sext i8 %177 to i32
%179 = and i32 %178, 5
%180 = icmp ne i32 %179, 0
br i1 %180, label %185, label %181
181: ; preds = %176
%182 = load i64, i64* @AF_INET6
%183 = load %struct.s_ipv6_addr*, %struct.s_ipv6_addr** %7
%184 = call i32 @inet_pton(i64 %182, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.s_ipv6_addr* %183)
br label %185
185: ; preds = %181, %176
%186 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%187 = call i32 @freeifaddrs(%struct.ifaddrs* %186)
store i32 0, i32* %5
br label %188
188: ; preds = %185, %16
%189 = load i32, i32* %5
ret i32 %189
}

LLVM IR (-O2):
%struct.s_ipv6_addr = type { i32 }
%struct.s_ipv4_addr = type opaque
%struct.ifaddrs = type { %struct.TYPE_2__*, i32, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@.str = [11 x i8] c"getifaddrs\00"
@AF_INET6 = global i64 0
@NI_NUMERICHOST = global i32 0
@AF_INET = global i64 0
@.str.1 = [18 x i8] c"64:ff9b::E7ad:514\00"
define i32 @cfg_host_ips(i8* %0, %struct.s_ipv6_addr* %1, %struct.s_ipv4_addr* %2, i8* %3) {
%5 = alloca %struct.ifaddrs*
%6 = alloca [40 x i8]
%7 = bitcast %struct.ifaddrs** %5 to i8*
%8 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%9 = call i32 @getifaddrs(%struct.ifaddrs** %5)
%10 = icmp eq i32 %9, -1
br i1 %10, label %16, label %11
11: ; preds = %4
%12 = load %struct.ifaddrs*, %struct.ifaddrs** %5
%13 = icmp eq %struct.ifaddrs* %12, null
br i1 %13, label %77, label %14
14: ; preds = %11
%15 = bitcast %struct.s_ipv4_addr* %2 to %struct.s_ipv6_addr*
br label %18
16: ; preds = %4
%17 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %92
18: ; preds = %14, %67
%19 = phi %struct.ifaddrs* [ %12, %14 ], [ %70, %67 ]
%20 = phi i8 [ 0, %14 ], [ %68, %67 ]
%21 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %19, i64 0, i32 0
%22 = load %struct.TYPE_2__*, %struct.TYPE_2__** %21
%23 = icmp eq %struct.TYPE_2__* %22, null
br i1 %23, label %67, label %24
24: ; preds = %18
%25 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %19, i64 0, i32 1
%26 = load i32, i32* %25
%27 = call i32 @strcmp(i32 %26, i8* %0)
%28 = icmp eq i32 %27, 0
%29 = load %struct.TYPE_2__*, %struct.TYPE_2__** %21
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i64 0, i32 0
%31 = load i64, i64* %30
%32 = load i64, i64* @AF_INET6
%33 = icmp eq i64 %31, %32
br i1 %28, label %34, label %44
34: ; preds = %24
%35 = and i8 %20, 1
%36 = icmp eq i8 %35, 0
%37 = select i1 %33, i1 %36, i1 false
br i1 %37, label %54, label %38
38: ; preds = %34
%39 = load i64, i64* @AF_INET
%40 = icmp eq i64 %31, %39
%41 = and i8 %20, 2
%42 = icmp eq i8 %41, 0
%43 = select i1 %40, i1 %42, i1 false
br i1 %43, label %54, label %63
44: ; preds = %24
%45 = and i8 %20, 5
%46 = icmp eq i8 %45, 0
%47 = select i1 %33, i1 %46, i1 false
br i1 %47, label %54, label %48
48: ; preds = %44
%49 = load i64, i64* @AF_INET
%50 = icmp eq i64 %31, %49
%51 = and i8 %20, 10
%52 = icmp eq i8 %51, 0
%53 = select i1 %50, i1 %52, i1 false
br i1 %53, label %54, label %63
54: ; preds = %48, %44, %38, %34
%55 = phi i8 [ 1, %34 ], [ 2, %38 ], [ 4, %44 ], [ 8, %48 ]
%56 = phi i64* [ @AF_INET6, %34 ], [ @AF_INET, %38 ], [ @AF_INET6, %44 ], [ @AF_INET, %48 ]
%57 = phi %struct.s_ipv6_addr* [ %1, %34 ], [ %15, %38 ], [ %1, %44 ], [ %15, %48 ]
%58 = or i8 %20, %55
%59 = load i32, i32* @NI_NUMERICHOST
%60 = call i32 @getnameinfo(%struct.TYPE_2__* %29, i32 4, i8* %8, i32 40, i32* null, i32 0, i32 %59)
%61 = load i64, i64* %56
%62 = call i32 @inet_pton(i64 %61, i8* %8, %struct.s_ipv6_addr* %57)
br label %63
63: ; preds = %54, %48, %38
%64 = phi i8 [ %20, %48 ], [ %20, %38 ], [ %58, %54 ]
%65 = and i8 %64, 3
%66 = icmp eq i8 %65, 3
br i1 %66, label %72, label %67
67: ; preds = %63, %18
%68 = phi i8 [ %20, %18 ], [ %64, %63 ]
%69 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %19, i64 0, i32 2
%70 = load %struct.ifaddrs*, %struct.ifaddrs** %69
%71 = icmp eq %struct.ifaddrs* %70, null
br i1 %71, label %72, label %18
72: ; preds = %67, %63
%73 = phi i8 [ %68, %67 ], [ %64, %63 ]
%74 = zext i8 %73 to i32
%75 = and i32 %74, 10
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %82
77: ; preds = %11, %72
%78 = phi i32 [ %74, %72 ], [ 0, %11 ]
%79 = load i64, i64* @AF_INET
%80 = bitcast %struct.s_ipv4_addr* %2 to %struct.s_ipv6_addr*
%81 = call i32 @inet_pton(i64 %79, i8* %3, %struct.s_ipv6_addr* %80)
br label %82
82: ; preds = %77, %72
%83 = phi i32 [ %78, %77 ], [ %74, %72 ]
%84 = and i32 %83, 5
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %82
%87 = load i64, i64* @AF_INET6
%88 = call i32 @inet_pton(i64 %87, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.s_ipv6_addr* %1)
br label %89
89: ; preds = %86, %82
%90 = load %struct.ifaddrs*, %struct.ifaddrs** %5
%91 = call i32 @freeifaddrs(%struct.ifaddrs* %90)
br label %92
92: ; preds = %89, %16
%93 = phi i32 [ 1, %16 ], [ 0, %89 ]
ret i32 %93
}