#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 AF_INET;
int AF_INET6;
int T_A;
int T_AAAA;
int doQuery(char *, int, int /*<<< orphan*/ *, void *, int);
int mygethostbyname(char *name, void *addr, int family) {
  int type;
  if (family == AF_INET)
    type = T_A;
  else if (family == AF_INET6)
    type = T_AAAA;
  else
    type = -1;
  return doQuery(name, type, NULL, addr, family);
}


x86 assembly (clang, -O0):
<mygethostbyname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2ebb(%rip),%rcx
cmp    (%rcx),%eax
jne    1146 <mygethostbyname+0x36>
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    1175 <mygethostbyname+0x65>
mov    -0x14(%rbp),%eax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
jne    1169 <mygethostbyname+0x59>
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <mygethostbyname+0x60>
movl   $0xffffffff,-0x18(%rbp)
jmp    1175 <mygethostbyname+0x65>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edx
call   1030 <doQuery@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mygethostbyname>:
mov    %edx,%r8d
mov    %rsi,%rcx
mov    0x2ecb(%rip),%rax
cmp    %edx,(%rax)
jne    112a <mygethostbyname+0x1a>
mov    0x2eb0(%rip),%rax
jmp    1142 <mygethostbyname+0x32>
mov    0x2e9f(%rip),%rax
mov    $0xffffffff,%esi
cmp    %r8d,(%rax)
jne    1144 <mygethostbyname+0x34>
mov    0x2e9e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
jmp    1030 <doQuery@plt>

LLVM IR (-O0):
@AF_INET = global i32 0
@T_A = global i32 0
@AF_INET6 = global i32 0
@T_AAAA = global i32 0
define i32 @mygethostbyname(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i32, i32* @AF_INET
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = load i32, i32* @T_A
store i32 %12, i32* %7
br label %21
13: ; preds = %3
%14 = load i32, i32* %6
%15 = load i32, i32* @AF_INET6
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i32, i32* @T_AAAA
store i32 %18, i32* %7
br label %20
19: ; preds = %13
store i32 -1, i32* %7
br label %20
20: ; preds = %19, %17
br label %21
21: ; preds = %20, %11
%22 = load i8*, i8** %4
%23 = load i32, i32* %7
%24 = load i8*, i8** %5
%25 = load i32, i32* %6
%26 = call i32 @doQuery(i8* %22, i32 %23, i32* null, i8* %24, i32 %25)
ret i32 %26
}

LLVM IR (-O2):
@AF_INET = global i32 0
@T_A = global i32 0
@AF_INET6 = global i32 0
@T_AAAA = global i32 0
define i32 @mygethostbyname(i8* %0, i8* %1, i32 %2) {
%4 = load i32, i32* @AF_INET
%5 = icmp eq i32 %4, %2
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = load i32, i32* @T_A
br label %13
8: ; preds = %3
%9 = load i32, i32* @AF_INET6
%10 = icmp eq i32 %9, %2
%11 = load i32, i32* @T_AAAA
%12 = select i1 %10, i32 %11, i32 -1
br label %13
13: ; preds = %8, %6
%14 = phi i32 [ %7, %6 ], [ %12, %8 ]
%15 = tail call i32 @doQuery(i8* %0, i32 %14, i32* null, i8* %1, i32 %2)
ret i32 %15
}