#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_net_pton_ipv4(char const *, void *, size_t);
int inet_net_pton_ipv6(char const *, void *, size_t);
int inet_net_pton(int af, const char *src, void *dst, size_t size) {
  switch (af) {
  case AF_INET:
    return (inet_net_pton_ipv4(src, dst, size));
  case AF_INET6:
    return (inet_net_pton_ipv6(src, dst, size));
  default:
    errno = EAFNOSUPPORT;
    return (-1);
  }
}


x86 assembly (clang, -O0):
<inet_net_pton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x80,%eax
je     1179 <inet_net_pton+0x59>
jmp    114d <inet_net_pton+0x2d>
mov    -0x24(%rbp),%eax
sub    $0x81,%eax
jne    1192 <inet_net_pton+0x72>
jmp    1160 <inet_net_pton+0x40>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <inet_net_pton_ipv4@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <inet_net_pton+0x8b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <inet_net_pton_ipv6@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <inet_net_pton+0x8b>
mov    0x2e3f(%rip),%rax
mov    (%rax),%ecx
mov    0x2e3e(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_net_pton>:
cmp    $0x80,%edi
je     113e <inet_net_pton+0x1e>
cmp    $0x81,%edi
jne    114c <inet_net_pton+0x2c>
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
jmp    1040 <inet_net_pton_ipv4@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
jmp    1030 <inet_net_pton_ipv6@plt>
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    0x2e84(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@EAFNOSUPPORT = global i32 0
@errno = global i32 0
define i32 @inet_net_pton(i32 %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i64 %3, i64* %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 i64, i64* %9
%15 = call i32 @inet_net_pton_ipv4(i8* %12, i8* %13, i64 %14)
store i32 %15, i32* %5
br label %23
16: ; preds = %4
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = load i64, i64* %9
%20 = call i32 @inet_net_pton_ipv6(i8* %17, i8* %18, i64 %19)
store i32 %20, i32* %5
br label %23
21: ; preds = %4
%22 = load i32, i32* @EAFNOSUPPORT
store i32 %22, i32* @errno
store i32 -1, i32* %5
br label %23
23: ; preds = %21, %16, %11
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
@EAFNOSUPPORT = global i32 0
@errno = global i32 0
define i32 @inet_net_pton(i32 %0, i8* %1, i8* %2, i64 %3) {
switch i32 %0, label %9 [
i32 129, label %5
i32 128, label %7
]
5: ; preds = %4
%6 = tail call i32 @inet_net_pton_ipv4(i8* %1, i8* %2, i64 %3)
br label %11
7: ; preds = %4
%8 = tail call i32 @inet_net_pton_ipv6(i8* %1, i8* %2, i64 %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 i32 [ -1, %9 ], [ %8, %7 ], [ %6, %5 ]
ret i32 %12
}