#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 */

/* Variables and functions */
int /*<<< orphan*/ EAFNOSUPPORT;
int /*<<< orphan*/ ENOSPC;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ mjt_ntop4(void const *, char *, int);
int /*<<< orphan*/ mjt_ntop6(void const *, char *, int);
const char *inet_ntop(int af, const void *src, char *dst, int size) {
  switch (af) {
  case 2:
    if (mjt_ntop4(src, dst, size))
      return dst;
    break;
  case 10:
    if (mjt_ntop6(src, dst, size))
      return dst;
    break;
  default:
    errno = EAFNOSUPPORT;
    return (char *)0;
  }
  errno = ENOSPC;
  return (char *)0;
}


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    $0x2,%eax
je     115b <inet_ntop+0x3b>
jmp    114a <inet_ntop+0x2a>
mov    -0x28(%rbp),%eax
sub    $0xa,%eax
je     1186 <inet_ntop+0x66>
jmp    11b1 <inet_ntop+0x91>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <mjt_ntop4@plt>
cmp    $0x0,%eax
je     1181 <inet_ntop+0x61>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ea <inet_ntop+0xca>
jmp    11d0 <inet_ntop+0xb0>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <mjt_ntop6@plt>
cmp    $0x0,%eax
je     11ac <inet_ntop+0x8c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ea <inet_ntop+0xca>
jmp    11d0 <inet_ntop+0xb0>
mov    0x2e18(%rip),%rax
mov    (%rax),%ecx
mov    0x2e1f(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11ea <inet_ntop+0xca>
mov    0x2e01(%rip),%rax
mov    (%rax),%ecx
mov    0x2e00(%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>:
push   %rbx
mov    %rdx,%rbx
cmp    $0xa,%edi
je     1141 <inet_ntop+0x21>
cmp    $0x2,%edi
jne    115b <inet_ntop+0x3b>
mov    %rsi,%rdi
mov    %rbx,%rsi
mov    %ecx,%edx
call   1040 <mjt_ntop4@plt>
test   %eax,%eax
jne    116f <inet_ntop+0x4f>
jmp    1152 <inet_ntop+0x32>
mov    %rsi,%rdi
mov    %rbx,%rsi
mov    %ecx,%edx
call   1030 <mjt_ntop6@plt>
test   %eax,%eax
jne    116f <inet_ntop+0x4f>
mov    0x2e7f(%rip),%rax
jmp    1162 <inet_ntop+0x42>
mov    0x2e6e(%rip),%rax
mov    (%rax),%eax
mov    0x2e75(%rip),%rcx
mov    %eax,(%rcx)
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@EAFNOSUPPORT = global i32 0
@errno = global i32 0
@ENOSPC = 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 %29 [
i32 2, label %11
i32 10, label %20
]
11: ; preds = %4
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = load i32, i32* %9
%15 = call i32 @mjt_ntop4(i8* %12, i8* %13, i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load i8*, i8** %8
store i8* %18, i8** %5
br label %33
19: ; preds = %11
br label %31
20: ; preds = %4
%21 = load i8*, i8** %7
%22 = load i8*, i8** %8
%23 = load i32, i32* %9
%24 = call i32 @mjt_ntop6(i8* %21, i8* %22, i32 %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = load i8*, i8** %8
store i8* %27, i8** %5
br label %33
28: ; preds = %20
br label %31
29: ; preds = %4
%30 = load i32, i32* @EAFNOSUPPORT
store i32 %30, i32* @errno
store i8* null, i8** %5
br label %33
31: ; preds = %28, %19
%32 = load i32, i32* @ENOSPC
store i32 %32, i32* @errno
store i8* null, i8** %5
br label %33
33: ; preds = %31, %29, %26, %17
%34 = load i8*, i8** %5
ret i8* %34
}

LLVM IR (-O2):
@EAFNOSUPPORT = global i32 0
@errno = global i32 0
@ENOSPC = global i32 0
define i8* @inet_ntop(i32 %0, i8* %1, i8* %2, i32 %3) {
switch i32 %0, label %11 [
i32 2, label %5
i32 10, label %8
]
5: ; preds = %4
%6 = tail call i32 @mjt_ntop4(i8* %1, i8* %2, i32 %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %14
8: ; preds = %4
%9 = tail call i32 @mjt_ntop6(i8* %1, i8* %2, i32 %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %5, %8, %4
%12 = phi i32* [ @EAFNOSUPPORT, %4 ], [ @ENOSPC, %8 ], [ @ENOSPC, %5 ]
%13 = load i32, i32* %12
store i32 %13, i32* @errno
br label %14
14: ; preds = %11, %8, %5
%15 = phi i8* [ %2, %5 ], [ %2, %8 ], [ null, %11 ]
ret i8* %15
}