#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 /*<<< orphan*/ sin6_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct ifaddrs {
  char *ifa_name;
  TYPE_1__ *ifa_addr;
};
typedef int /*<<< orphan*/ buf;
struct TYPE_2__ {
  scalar_t__ sa_family;
};

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
int /*<<< orphan*/ *inet_ntop(scalar_t__, void *, char *, int);
int /*<<< orphan*/ printf(char *, char *, ...);
void show_address_info(struct ifaddrs *ifa) {
  struct sockaddr_in *s4;
  struct sockaddr_in6 *s6;
  char buf[64];
  if (AF_INET == ifa->ifa_addr->sa_family) {
    s4 = (struct sockaddr_in *)(ifa->ifa_addr);
    if (NULL == inet_ntop(ifa->ifa_addr->sa_family, (void *)&(s4->sin_addr),
                          buf, sizeof(buf))) {
      printf("%s: inet_ntop failed!\n", ifa->ifa_name);
    } else {
      printf("IPv4 addr %s: %s\n", ifa->ifa_name, buf);
    }
  } else if (AF_INET6 == ifa->ifa_addr->sa_family) {
    s6 = (struct sockaddr_in6 *)(ifa->ifa_addr);
    if (NULL == inet_ntop(ifa->ifa_addr->sa_family, (void *)&(s6->sin6_addr),
                          buf, sizeof(buf))) {
      printf("%s: inet_ntop failed!\n", ifa->ifa_name);
    } else {
      printf("IPv6 addr %s: %s\n", ifa->ifa_name, buf);
    }
  }
}


x86 assembly (clang, -O0):
<show_address_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rcx
cmp    (%rcx),%rax
jne    11b6 <show_address_info+0x96>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x40,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1198 <show_address_info+0x78>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b1 <show_address_info+0x91>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    -0x60(%rbp),%rdx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1245 <show_address_info+0x125>
mov    0x2e23(%rip),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rcx
cmp    (%rcx),%rax
jne    1240 <show_address_info+0x120>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x40,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1222 <show_address_info+0x102>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123b <show_address_info+0x11b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    -0x60(%rbp),%rdx
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1240 <show_address_info+0x120>
jmp    1245 <show_address_info+0x125>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_address_info>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
mov    0x2eb9(%rip),%rax
mov    (%rax),%rax
mov    0x8(%rdi),%rsi
mov    (%rsi),%rdi
cmp    %rdi,%rax
jne    115f <show_address_info+0x3f>
mov    %rsp,%rdx
mov    %rax,%rdi
mov    $0x40,%ecx
call   1030 <inet_ntop@plt>
mov    (%rbx),%rsi
test   %rax,%rax
je     1193 <show_address_info+0x73>
lea    0xeba(%rip),%rdi
jmp    1187 <show_address_info+0x67>
mov    0x2e7a(%rip),%rax
cmp    %rdi,(%rax)
jne    11a1 <show_address_info+0x81>
mov    %rsp,%rdx
mov    $0x40,%ecx
call   1030 <inet_ntop@plt>
mov    (%rbx),%rsi
test   %rax,%rax
je     1193 <show_address_info+0x73>
lea    0xea2(%rip),%rdi
mov    %rsp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a1 <show_address_info+0x81>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__* }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
@AF_INET = global i64 0
@.str = [23 x i8] c"%s: inet_ntop failed!\0A\00"
@.str.1 = [18 x i8] c"IPv4 addr %s: %s\0A\00"
@AF_INET6 = global i64 0
@.str.2 = [18 x i8] c"IPv6 addr %s: %s\0A\00"
define void @show_address_info(%struct.ifaddrs* %0) {
%2 = alloca %struct.ifaddrs*
%3 = alloca %struct.sockaddr_in*
%4 = alloca %struct.sockaddr_in6*
%5 = alloca [64 x i8]
store %struct.ifaddrs* %0, %struct.ifaddrs** %2
%6 = load i64, i64* @AF_INET
%7 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%8 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %7, i32 0, i32 1
%9 = load %struct.TYPE_2__*, %struct.TYPE_2__** %8
%10 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = icmp eq i64 %6, %11
br i1 %12, label %13, label %41
13: ; preds = %1
%14 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%15 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %14, i32 0, i32 1
%16 = load %struct.TYPE_2__*, %struct.TYPE_2__** %15
%17 = bitcast %struct.TYPE_2__* %16 to %struct.sockaddr_in*
store %struct.sockaddr_in* %17, %struct.sockaddr_in** %3
%18 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%19 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %18, i32 0, i32 1
%20 = load %struct.TYPE_2__*, %struct.TYPE_2__** %19
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 0
%22 = load i64, i64* %21
%23 = load %struct.sockaddr_in*, %struct.sockaddr_in** %3
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %23, i32 0, i32 0
%25 = bitcast i32* %24 to i8*
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%27 = call i32* @inet_ntop(i64 %22, i8* %25, i8* %26, i32 64)
%28 = icmp eq i32* null, %27
br i1 %28, label %29, label %34
29: ; preds = %13
%30 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%31 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %30, i32 0, i32 0
%32 = load i8*, i8** %31
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %32)
br label %40
34: ; preds = %13
%35 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%36 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %35, i32 0, i32 0
%37 = load i8*, i8** %36
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %37, i8* %38)
br label %40
40: ; preds = %34, %29
br label %78
41: ; preds = %1
%42 = load i64, i64* @AF_INET6
%43 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%44 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %43, i32 0, i32 1
%45 = load %struct.TYPE_2__*, %struct.TYPE_2__** %44
%46 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %45, i32 0, i32 0
%47 = load i64, i64* %46
%48 = icmp eq i64 %42, %47
br i1 %48, label %49, label %77
49: ; preds = %41
%50 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%51 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %50, i32 0, i32 1
%52 = load %struct.TYPE_2__*, %struct.TYPE_2__** %51
%53 = bitcast %struct.TYPE_2__* %52 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %53, %struct.sockaddr_in6** %4
%54 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%55 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %54, i32 0, i32 1
%56 = load %struct.TYPE_2__*, %struct.TYPE_2__** %55
%57 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %56, i32 0, i32 0
%58 = load i64, i64* %57
%59 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %4
%60 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %59, i32 0, i32 0
%61 = bitcast i32* %60 to i8*
%62 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%63 = call i32* @inet_ntop(i64 %58, i8* %61, i8* %62, i32 64)
%64 = icmp eq i32* null, %63
br i1 %64, label %65, label %70
65: ; preds = %49
%66 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%67 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %66, i32 0, i32 0
%68 = load i8*, i8** %67
%69 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %68)
br label %76
70: ; preds = %49
%71 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%72 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %71, i32 0, i32 0
%73 = load i8*, i8** %72
%74 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%75 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %73, i8* %74)
br label %76
76: ; preds = %70, %65
br label %77
77: ; preds = %76, %41
br label %78
78: ; preds = %77, %40
ret void
}

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__* }
%struct.TYPE_2__ = type { i64 }
@AF_INET = global i64 0
@.str = [23 x i8] c"%s: inet_ntop failed!\0A\00"
@.str.1 = [18 x i8] c"IPv4 addr %s: %s\0A\00"
@AF_INET6 = global i64 0
@.str.2 = [18 x i8] c"IPv6 addr %s: %s\0A\00"
define void @show_address_info(%struct.ifaddrs* nocapture %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = load i64, i64* @AF_INET
%5 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %0, i64 0, i32 1
%6 = load %struct.TYPE_2__*, %struct.TYPE_2__** %5
%7 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp eq i64 %4, %8
br i1 %9, label %10, label %20
10: ; preds = %1
%11 = bitcast %struct.TYPE_2__* %6 to i8*
%12 = call i32* @inet_ntop(i64 %4, i8* %11, i8* %3, i32 64)
%13 = icmp eq i32* %12, null
%14 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %0, i64 0, i32 0
%15 = load i8*, i8** %14
br i1 %13, label %16, label %18
16: ; preds = %10
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %33
18: ; preds = %10
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %3)
br label %33
20: ; preds = %1
%21 = load i64, i64* @AF_INET6
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = bitcast %struct.TYPE_2__* %6 to i8*
%25 = call i32* @inet_ntop(i64 %8, i8* %24, i8* %3, i32 64)
%26 = icmp eq i32* %25, null
%27 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %0, i64 0, i32 0
%28 = load i8*, i8** %27
br i1 %26, label %29, label %31
29: ; preds = %23
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %33
31: ; preds = %23
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %3)
br label %33
33: ; preds = %20, %31, %29, %16, %18
ret void
}