#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 /*<<< orphan*/ socklen_t;

/* Variables and functions */
#define AF_INET 129
#define AF_INET6 128
int /*<<< orphan*/ EAFNOSUPPORT;
int /*<<< orphan*/ errno;
char const *inet_ntop4(void const *, char *, int /*<<< orphan*/);
char const *inet_ntop6(void const *, char *, int /*<<< orphan*/);
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) {
  switch (af) {
  case AF_INET:
    return inet_ntop4(src, dst, size);
  case AF_INET6:
    return inet_ntop6(src, dst, size);
  default:
    errno = EAFNOSUPPORT;
    return NULL;
  }
}


x86 assembly (clang, -O0):
<inet_ntop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x80,%eax
je     1178 <inet_ntop+0x58>
jmp    114c <inet_ntop+0x2c>
mov    -0x28(%rbp),%eax
sub    $0x81,%eax
jne    1191 <inet_ntop+0x71>
jmp    115f <inet_ntop+0x3f>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <inet_ntop4@plt>
mov    %rax,-0x8(%rbp)
jmp    11ab <inet_ntop+0x8b>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <inet_ntop6@plt>
mov    %rax,-0x8(%rbp)
jmp    11ab <inet_ntop+0x8b>
mov    0x2e40(%rip),%rax
mov    (%rax),%ecx
mov    0x2e3f(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntop>:
cmp    $0x80,%edi
je     113d <inet_ntop+0x1d>
cmp    $0x81,%edi
jne    114a <inet_ntop+0x2a>
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
jmp    1040 <inet_ntop4@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
jmp    1030 <inet_ntop6@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    0x2e86(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
ret

LLVM IR (-O0):
@EAFNOSUPPORT = global i32 0
@errno = global i32 0
define i8* @inet_ntop(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%10 = load i32, i32* %6
switch i32 %10, label %21 [
i32 129, label %11
i32 128, label %16
]
11: ; preds = %4
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = load i32, i32* %9
%15 = call i8* @inet_ntop4(i8* %12, i8* %13, i32 %14)
store i8* %15, i8** %5
br label %23
16: ; preds = %4
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = load i32, i32* %9
%20 = call i8* @inet_ntop6(i8* %17, i8* %18, i32 %19)
store i8* %20, i8** %5
br label %23
21: ; preds = %4
%22 = load i32, i32* @EAFNOSUPPORT
store i32 %22, i32* @errno
store i8* null, i8** %5
br label %23
23: ; preds = %21, %16, %11
%24 = load i8*, i8** %5
ret i8* %24
}

LLVM IR (-O2):
@EAFNOSUPPORT = global i32 0
@errno = global i32 0
define i8* @inet_ntop(i32 %0, i8* %1, i8* %2, i32 %3) {
switch i32 %0, label %9 [
i32 129, label %5
i32 128, label %7
]
5: ; preds = %4
%6 = tail call i8* @inet_ntop4(i8* %1, i8* %2, i32 %3)
br label %11
7: ; preds = %4
%8 = tail call i8* @inet_ntop6(i8* %1, i8* %2, i32 %3)
br label %11
9: ; preds = %4
%10 = load i32, i32* @EAFNOSUPPORT
store i32 %10, i32* @errno
br label %11
11: ; preds = %9, %7, %5
%12 = phi i8* [ null, %9 ], [ %8, %7 ], [ %6, %5 ]
ret i8* %12
}