#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*/ errno;
int inet_pton4(char const *, void *);
int inet_pton6(char const *, void *);
int inet_pton(int af, const char *__restrict src, void *__restrict dst) {
  switch (af) {
  case AF_INET:
    return (inet_pton4(src, dst));
  case AF_INET6:
    return (inet_pton6(src, dst));
  default:
    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     1171 <inet_pton+0x51>
jmp    1149 <inet_pton+0x29>
mov    -0x1c(%rbp),%eax
sub    $0x81,%eax
jne    1186 <inet_pton+0x66>
jmp    115c <inet_pton+0x3c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <inet_pton4@plt>
mov    %eax,-0x4(%rbp)
jmp    119f <inet_pton+0x7f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <inet_pton6@plt>
mov    %eax,-0x4(%rbp)
jmp    119f <inet_pton+0x7f>
mov    0x2e4b(%rip),%rax
mov    (%rax),%ecx
mov    0x2e4a(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_pton>:
cmp    $0x80,%edi
je     113b <inet_pton+0x1b>
cmp    $0x81,%edi
jne    1146 <inet_pton+0x26>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1040 <inet_pton4@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1030 <inet_pton6@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    0x2e8a(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@EAFNOSUPPORT = global i32 0
@errno = global i32 0
define i32 @inet_pton(i32 %0, i8* noalias %1, i8* noalias %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 %19
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 %19
17: ; preds = %3
%18 = load i32, i32* @EAFNOSUPPORT
store i32 %18, i32* @errno
store i32 -1, i32* %4
br label %19
19: ; preds = %17, %13, %9
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
@EAFNOSUPPORT = global i32 0
@errno = global i32 0
define i32 @inet_pton(i32 %0, i8* noalias %1, i8* noalias %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 %10
6: ; preds = %3
%7 = tail call i32 @inet_pton6(i8* %1, i8* %2)
br label %10
8: ; preds = %3
%9 = load i32, i32* @EAFNOSUPPORT
store i32 %9, i32* @errno
br label %10
10: ; preds = %8, %6, %4
%11 = phi i32 [ -1, %8 ], [ %7, %6 ], [ %5, %4 ]
ret i32 %11
}