#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 */
#define AF_INET 129
#define AF_INET6 128
int /*<<< orphan*/ EAFNOSUPPORT;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int inet_pton4(char const *, void *);
int inet_pton6(char const *, void *);
int __inet_pton(int af, const char *src, void *dst) {
  switch (af) {
  case AF_INET:
    return (inet_pton4(src, dst));
  case AF_INET6:
    return (inet_pton6(src, dst));
  default:
    __set_errno(EAFNOSUPPORT);
    return (-1);
  }
}


x86 assembly (clang, -O0):
<__inet_pton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x80,%eax
je     1181 <__inet_pton+0x51>
jmp    1159 <__inet_pton+0x29>
mov    -0x1c(%rbp),%eax
sub    $0x81,%eax
jne    1196 <__inet_pton+0x66>
jmp    116c <__inet_pton+0x3c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <inet_pton4@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <__inet_pton+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <inet_pton6@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <__inet_pton+0x7b>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__inet_pton>:
cmp    $0x80,%edi
je     114b <__inet_pton+0x1b>
cmp    $0x81,%edi
jne    1156 <__inet_pton+0x26>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1050 <inet_pton4@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1040 <inet_pton6@plt>
push   %rax
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

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

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