#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_cidr_pton_ipv4(char const *, void *, int *, int /*<<< orphan*/);
int inet_cidr_pton_ipv6(char const *, void *, int *);
int inet_cidr_pton(int af, const char *src, void *dst, int *bits) {
  switch (af) {
  case AF_INET:
    return (inet_cidr_pton_ipv4(src, dst, bits, 0));
  case AF_INET6:
    return (inet_cidr_pton_ipv6(src, dst, bits));
  default:
    errno = EAFNOSUPPORT;
    return (-1);
  }
}


x86 assembly (clang, -O0):
<inet_cidr_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     117b <inet_cidr_pton+0x5b>
jmp    114d <inet_cidr_pton+0x2d>
mov    -0x24(%rbp),%eax
sub    $0x81,%eax
jne    1194 <inet_cidr_pton+0x74>
jmp    1160 <inet_cidr_pton+0x40>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <inet_cidr_pton_ipv4@plt>
mov    %eax,-0x4(%rbp)
jmp    11ad <inet_cidr_pton+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <inet_cidr_pton_ipv6@plt>
mov    %eax,-0x4(%rbp)
jmp    11ad <inet_cidr_pton+0x8d>
mov    0x2e3d(%rip),%rax
mov    (%rax),%ecx
mov    0x2e3c(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_cidr_pton>:
cmp    $0x80,%edi
je     1140 <inet_cidr_pton+0x20>
cmp    $0x81,%edi
jne    114e <inet_cidr_pton+0x2e>
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
xor    %ecx,%ecx
jmp    1040 <inet_cidr_pton_ipv4@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
jmp    1030 <inet_cidr_pton_ipv6@plt>
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    0x2e82(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret

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