#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ s6_addr;
};
struct sockaddr_in6 {
  TYPE_2__ sin6_addr;
};
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
};
struct sockaddr {
  int sa_family;
};

/* Variables and functions */
#define AF_INET 129
#define AF_INET6 128
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ print_ip4(int /*<<< orphan*/);
int /*<<< orphan*/ print_ip6(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
void debug(const struct sockaddr *before, struct sockaddr *after) {
  printf("bind_public: ");
  switch (before->sa_family) {
  case AF_INET:
    print_ip4(((struct sockaddr_in *)before)->sin_addr.s_addr);
    printf(" --> ");
    print_ip4(((struct sockaddr_in *)after)->sin_addr.s_addr);
    printf("\n");
    break;
  case AF_INET6:
    print_ip6(((struct sockaddr_in6 *)before)->sin6_addr.s6_addr);
    printf(" --> ");
    print_ip6(((struct sockaddr_in6 *)after)->sin6_addr.s6_addr);
    printf("\n");
    break;
  default:
    printf("UNKNOWN --> UNKNOWN\n");
    break;
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<debug>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x80,%eax
je     11bb <debug+0x7b>
jmp    1175 <debug+0x35>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
jne    11ee <debug+0xae>
jmp    1188 <debug+0x48>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <print_ip4@plt>
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <print_ip4@plt>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <debug+0xba>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1050 <print_ip6@plt>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1050 <print_ip6@plt>
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <debug+0xba>
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
mov    (%rbx),%eax
cmp    $0x80,%eax
je     11a6 <debug+0x46>
cmp    $0x81,%eax
jne    11d0 <debug+0x70>
mov    $0x81,%edi
call   1060 <print_ip4@plt>
lea    0xe77(%rip),%rdi
call   1050 <printf@plt>
mov    (%r14),%edi
call   1060 <print_ip4@plt>
jmp    11c4 <debug+0x64>
mov    $0x80,%edi
call   1070 <print_ip6@plt>
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
mov    (%r14),%edi
call   1070 <print_ip6@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11dc <debug+0x7c>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <fflush@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
%struct.sockaddr_in6 = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@.str = [14 x i8] c"bind_public: \00"
@.str.1 = [6 x i8] c" --> \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [21 x i8] c"UNKNOWN --> UNKNOWN\0A\00"
@stdout = global i32 0
define void @debug(%struct.sockaddr* %0, %struct.sockaddr* %1) {
%3 = alloca %struct.sockaddr*
%4 = alloca %struct.sockaddr*
store %struct.sockaddr* %0, %struct.sockaddr** %3
store %struct.sockaddr* %1, %struct.sockaddr** %4
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%6 = load %struct.sockaddr*, %struct.sockaddr** %3
%7 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %6, i32 0, i32 0
%8 = load i32, i32* %7
switch i32 %8, label %39 [
i32 129, label %9
i32 128, label %24
]
9: ; preds = %2
%10 = load %struct.sockaddr*, %struct.sockaddr** %3
%11 = bitcast %struct.sockaddr* %10 to %struct.sockaddr_in*
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @print_ip4(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = load %struct.sockaddr*, %struct.sockaddr** %4
%18 = bitcast %struct.sockaddr* %17 to %struct.sockaddr_in*
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 0
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @print_ip4(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %41
24: ; preds = %2
%25 = load %struct.sockaddr*, %struct.sockaddr** %3
%26 = bitcast %struct.sockaddr* %25 to %struct.sockaddr_in6*
%27 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %26, i32 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = call i32 @print_ip6(i32 %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%32 = load %struct.sockaddr*, %struct.sockaddr** %4
%33 = bitcast %struct.sockaddr* %32 to %struct.sockaddr_in6*
%34 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %33, i32 0, i32 0
%35 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 @print_ip6(i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %41
39: ; preds = %2
%40 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %24, %9
%42 = load i32, i32* @stdout
%43 = call i32 @fflush(i32 %42)
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@.str = [14 x i8] c"bind_public: \00"
@.str.1 = [6 x i8] c" --> \00"
@stdout = global i32 0
@str = [20 x i8] c"UNKNOWN --> UNKNOWN\00"
define void @debug(%struct.sockaddr* nocapture %0, %struct.sockaddr* nocapture %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 0, i32 0
%5 = load i32, i32* %4
switch i32 %5, label %20 [
i32 129, label %6
i32 128, label %13
]
6: ; preds = %2
%7 = tail call i32 @print_ip4(i32 129)
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr %struct.sockaddr, %struct.sockaddr* %1, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i32 @print_ip4(i32 %10)
%12 = tail call i32 @putchar(i32 10)
br label %22
13: ; preds = %2
%14 = tail call i32 @print_ip6(i32 128)
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr %struct.sockaddr, %struct.sockaddr* %1, i64 0, i32 0
%17 = load i32, i32* %16
%18 = tail call i32 @print_ip6(i32 %17)
%19 = tail call i32 @putchar(i32 10)
br label %22
20: ; preds = %2
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %13, %6
%23 = load i32, i32* @stdout
%24 = tail call i32 @fflush(i32 %23)
ret void
}