#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*/ errno;
int mjt_pton4(char const *, void *);
int mjt_pton6(char const *, void *);
int inet_pton(int af, const char *src, void *dst) {
  switch (af) {
  case 2:
    return mjt_pton4(src, dst);
  case 10:
    return mjt_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    $0x2,%eax
je     1158 <inet_pton+0x38>
jmp    1147 <inet_pton+0x27>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     116d <inet_pton+0x4d>
jmp    1182 <inet_pton+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <mjt_pton4@plt>
mov    %eax,-0x4(%rbp)
jmp    119b <inet_pton+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <mjt_pton6@plt>
mov    %eax,-0x4(%rbp)
jmp    119b <inet_pton+0x7b>
mov    0x2e4f(%rip),%rax
mov    (%rax),%ecx
mov    0x2e4e(%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    $0xa,%edi
je     1135 <inet_pton+0x15>
cmp    $0x2,%edi
jne    1140 <inet_pton+0x20>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1030 <mjt_pton4@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1040 <mjt_pton6@plt>
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    0x2e90(%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* %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 2, label %9
i32 10, label %13
]
9: ; preds = %3
%10 = load i8*, i8** %6
%11 = load i8*, i8** %7
%12 = call i32 @mjt_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 @mjt_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* %1, i8* %2) {
switch i32 %0, label %8 [
i32 2, label %4
i32 10, label %6
]
4: ; preds = %3
%5 = tail call i32 @mjt_pton4(i8* %1, i8* %2)
br label %10
6: ; preds = %3
%7 = tail call i32 @mjt_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
}