#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  unsigned long s_addr;
};
struct sockaddr_in {
  unsigned short sin_port;
  TYPE_1__ sin_addr;
};
struct addrinfo {
  int ai_flags;
  int ai_family;
  int ai_socktype;
  int ai_addrlen;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ *ai_canonname;
  scalar_t__ ai_addr;
};
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int AF_INET;
int AF_UNSPEC;
#define SOCK_DGRAM 129
#define SOCK_STREAM 128
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int ntohl(unsigned long);
int ntohs(unsigned short);
int /*<<< orphan*/ test_getaddrinfo_err(int, char const *, char const *, int,
                                        int, int, int, char *,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ test_getaddrinfo_err_nr(int, char const *, char const *, int,
                                           int, int, int, int, int);
void test_getaddrinfo(const char *nodename, const char *servname, int passhints,
                      int flags, int family, int socktype, int exp_results,
                      unsigned long exp_ip, int exp_canonname,
                      unsigned short exp_port) {
  struct addrinfo *ai, *ai_cur;
  struct addrinfo hints;
  struct sockaddr_in *sockaddr_in;
  int ai_count_dgram, ai_count_stream, r;
  assert(passhints || !flags);
  assert(passhints || family == AF_UNSPEC);
  assert(passhints || !socktype);
  memset(&hints, 0, sizeof(hints));
  hints.ai_flags = flags;
  hints.ai_family = family;
  hints.ai_socktype = socktype;
  hints.ai_family = family;
  ai = (struct addrinfo *)0xDEADBEEF;
  r = getaddrinfo(nodename, servname, passhints ? &hints : NULL, &ai);
  if (r < 0 || r >= 32 || !((1 << r) & exp_results))
    test_getaddrinfo_err_nr(1, nodename, servname, passhints, flags, family,
                            socktype, exp_results, r);
  if (r)
    return;
  ai_cur = ai;
  ai_count_dgram = 0;
  ai_count_stream = 0;
  while (ai_cur) {
    if (ai_cur->ai_family != AF_INET)
      test_getaddrinfo_err_nr(2, nodename, servname, passhints, flags, family,
                              socktype, AF_INET, ai_cur->ai_family);
    if (socktype && ai_cur->ai_socktype != socktype)
      test_getaddrinfo_err_nr(3, nodename, servname, passhints, flags, family,
                              socktype, socktype, ai_cur->ai_socktype);
    switch (ai_cur->ai_socktype) {
    case SOCK_DGRAM:
      ai_count_dgram++;
      break;
    case SOCK_STREAM:
      ai_count_stream++;
      break;
    }
    if (ai_cur->ai_addrlen != sizeof(struct sockaddr_in))
      test_getaddrinfo_err_nr(4, nodename, servname, passhints, flags, family,
                              socktype, sizeof(struct sockaddr_in),
                              ai_cur->ai_addrlen);
    else {
      sockaddr_in = (struct sockaddr_in *)ai_cur->ai_addr;
      if (sockaddr_in->sin_addr.s_addr != exp_ip)
        test_getaddrinfo_err_nr(5, nodename, servname, passhints, flags, family,
                                socktype, ntohl(exp_ip),
                                ntohl(sockaddr_in->sin_addr.s_addr));
      if (sockaddr_in->sin_port != exp_port)
        test_getaddrinfo_err_nr(6, nodename, servname, passhints, flags, family,
                                socktype, ntohs(exp_port),
                                ntohs(sockaddr_in->sin_port));
    }
    if (exp_canonname && (!ai_cur->ai_canonname || !*ai_cur->ai_canonname))
      test_getaddrinfo_err(7, nodename, servname, passhints, flags, family,
                           socktype, "(anything)", ai_cur->ai_canonname);
    if (!exp_canonname && ai_cur->ai_canonname)
      test_getaddrinfo_err(8, nodename, servname, passhints, flags, family,
                           socktype, NULL, ai_cur->ai_canonname);
    ai_cur = ai_cur->ai_next;
  }
  if (ai_count_dgram != ((socktype == SOCK_STREAM) ? 0 : 1))
    test_getaddrinfo_err_nr(9, nodename, servname, passhints, flags, family,
                            socktype, (socktype == SOCK_STREAM) ? 0 : 1,
                            ai_count_dgram);
  if (ai_count_stream != ((socktype == SOCK_DGRAM) ? 0 : 1))
    test_getaddrinfo_err_nr(10, nodename, servname, passhints, flags, family,
                            socktype, (socktype == SOCK_DGRAM) ? 0 : 1,
                            ai_count_stream);
  freeaddrinfo(ai);
}


x86 assembly (clang, -O0):
<test_getaddrinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    0x28(%rbp),%ax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x6d(%rbp)
jne    11ca <test_getaddrinfo+0x4a>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x6d(%rbp)
mov    -0x6d(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x1,%al
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x6e(%rbp)
jne    11f8 <test_getaddrinfo+0x78>
mov    -0x1c(%rbp),%eax
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
mov    %al,-0x6e(%rbp)
mov    -0x6e(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x1,%al
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x6f(%rbp)
jne    1220 <test_getaddrinfo+0xa0>
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x6f(%rbp)
mov    -0x6f(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    $0xdeadbeef,%eax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1288 <test_getaddrinfo+0x108>
lea    -0x58(%rbp),%rax
mov    %rax,-0x88(%rbp)
jmp    1296 <test_getaddrinfo+0x116>
xor    %eax,%eax
mov    %rax,-0x88(%rbp)
jmp    1296 <test_getaddrinfo+0x116>
mov    -0x78(%rbp),%rsi
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1070 <getaddrinfo@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jl     12db <test_getaddrinfo+0x15b>
cmpl   $0x20,-0x6c(%rbp)
jge    12db <test_getaddrinfo+0x15b>
mov    -0x6c(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
and    0x10(%rbp),%eax
cmp    $0x0,%eax
jne    1310 <test_getaddrinfo+0x190>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    0x10(%rbp),%r10d
mov    -0x6c(%rbp),%eax
mov    $0x1,%edi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <test_getaddrinfo_err_nr@plt>
cmpl   $0x0,-0x6c(%rbp)
je     131f <test_getaddrinfo+0x19f>
jmp    1791 <test_getaddrinfo+0x611>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     16c0 <test_getaddrinfo+0x540>
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%eax
mov    0x2c9a(%rip),%rcx
cmp    (%rcx),%eax
je     1395 <test_getaddrinfo+0x215>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    0x2c74(%rip),%rax
mov    (%rax),%r10d
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0x2,%edi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <test_getaddrinfo_err_nr@plt>
cmpl   $0x0,-0x20(%rbp)
je     13e8 <test_getaddrinfo+0x268>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%eax
cmp    -0x20(%rbp),%eax
je     13e8 <test_getaddrinfo+0x268>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    -0x20(%rbp),%r10d
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x3,%edi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <test_getaddrinfo_err_nr@plt>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x8c(%rbp)
sub    $0x80,%eax
je     1429 <test_getaddrinfo+0x2a9>
jmp    1405 <test_getaddrinfo+0x285>
mov    -0x8c(%rbp),%eax
sub    $0x81,%eax
jne    1432 <test_getaddrinfo+0x2b2>
jmp    141b <test_getaddrinfo+0x29b>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1432 <test_getaddrinfo+0x2b2>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    -0x30(%rbp),%rax
movslq 0xc(%rax),%rax
cmp    $0x10,%rax
je     1481 <test_getaddrinfo+0x301>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r10d
mov    -0x30(%rbp),%rax
mov    0xc(%rax),%eax
mov    $0x4,%edi
mov    %r10d,(%rsp)
movl   $0x10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <test_getaddrinfo_err_nr@plt>
jmp    15f0 <test_getaddrinfo+0x470>
mov    -0x30(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    0x8(%rax),%rax
cmp    0x18(%rbp),%rax
je     153c <test_getaddrinfo+0x3bc>
mov    -0x8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    0x18(%rbp),%rdi
call   1080 <ntohl@plt>
mov    %eax,-0x90(%rbp)
mov    -0x60(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <ntohl@plt>
mov    -0xb0(%rbp),%rsi
mov    -0xa8(%rbp),%rdx
mov    -0xa0(%rbp),%ecx
mov    -0x9c(%rbp),%r8d
mov    -0x98(%rbp),%r9d
mov    -0x94(%rbp),%r11d
mov    -0x90(%rbp),%r10d
mov    $0x5,%edi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <test_getaddrinfo_err_nr@plt>
mov    -0x60(%rbp),%rax
movzwl (%rax),%eax
movzwl 0x28(%rbp),%ecx
cmp    %ecx,%eax
je     15eb <test_getaddrinfo+0x46b>
mov    -0x8(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc4(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xb8(%rbp)
movzwl 0x28(%rbp),%edi
call   1060 <ntohs@plt>
mov    %eax,-0xb4(%rbp)
mov    -0x60(%rbp),%rax
movzwl (%rax),%edi
call   1060 <ntohs@plt>
mov    -0xd8(%rbp),%rsi
mov    -0xd0(%rbp),%rdx
mov    -0xc4(%rbp),%ecx
mov    -0xc0(%rbp),%r8d
mov    -0xbc(%rbp),%r9d
mov    -0xb8(%rbp),%r11d
mov    -0xb4(%rbp),%r10d
mov    $0x6,%edi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <test_getaddrinfo_err_nr@plt>
jmp    15f0 <test_getaddrinfo+0x470>
cmpl   $0x0,0x20(%rbp)
je     1658 <test_getaddrinfo+0x4d8>
mov    -0x30(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     161a <test_getaddrinfo+0x49a>
mov    -0x30(%rbp),%rax
mov    0x18(%rax),%rax
cmpl   $0x0,(%rax)
jne    1658 <test_getaddrinfo+0x4d8>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    -0x30(%rbp),%rax
mov    0x18(%rax),%rax
mov    $0x7,%edi
lea    0x9bb(%rip),%r10
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1090 <test_getaddrinfo_err@plt>
cmpl   $0x0,0x20(%rbp)
jne    16af <test_getaddrinfo+0x52f>
mov    -0x30(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     16af <test_getaddrinfo+0x52f>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r10d
mov    -0x30(%rbp),%rax
mov    0x18(%rax),%rax
mov    $0x8,%edi
xor    %r11d,%r11d
mov    %r10d,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1090 <test_getaddrinfo_err@plt>
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1335 <test_getaddrinfo+0x1b5>
mov    -0x64(%rbp),%eax
mov    -0x20(%rbp),%esi
mov    $0x1,%ecx
xor    %edx,%edx
cmp    $0x80,%esi
cmove  %edx,%ecx
cmp    %ecx,%eax
je     1724 <test_getaddrinfo+0x5a4>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    -0x20(%rbp),%edi
mov    $0x1,%r10d
xor    %eax,%eax
cmp    $0x80,%edi
cmove  %eax,%r10d
mov    -0x64(%rbp),%eax
mov    $0x9,%edi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <test_getaddrinfo_err_nr@plt>
mov    -0x68(%rbp),%eax
mov    -0x20(%rbp),%esi
mov    $0x1,%ecx
xor    %edx,%edx
cmp    $0x81,%esi
cmove  %edx,%ecx
cmp    %ecx,%eax
je     1788 <test_getaddrinfo+0x608>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    -0x20(%rbp),%edi
mov    $0x1,%r10d
xor    %eax,%eax
cmp    $0x81,%edi
cmove  %eax,%r10d
mov    -0x68(%rbp),%eax
mov    $0xa,%edi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <test_getaddrinfo_err_nr@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <freeaddrinfo@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_getaddrinfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9d,%ebx
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %rsi,0x28(%rsp)
mov    %rdi,%r13
test   %ecx,%ecx
sete   %al
xor    %r15d,%r15d
mov    %edx,0xc(%rsp)
test   %edx,%edx
setne  %bpl
lea    0x30(%rsp),%rcx
cmovne %rcx,%r15
or     %bpl,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2e14(%rip),%rax
cmp    %r14d,(%rax)
sete   %al
or     %bpl,%al
movzbl %al,%edi
call   1050 <assert@plt>
test   %ebx,%ebx
sete   %al
or     %bpl,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    %r12d,0x8(%rsp)
mov    %r12d,0x30(%rsp)
mov    %ebx,0x38(%rsp)
mov    %r14d,0x4(%rsp)
mov    %r14d,0x34(%rsp)
mov    $0xdeadbeef,%eax
mov    %rax,0x20(%rsp)
lea    0x20(%rsp),%rcx
mov    %r13,%r12
mov    %r13,%rdi
mov    0x28(%rsp),%rsi
mov    %rsi,%r14
mov    %r15,%rdx
call   1070 <getaddrinfo@plt>
mov    %eax,%ebp
mov    0x90(%rsp),%eax
cmp    $0x1f,%ebp
ja     124e <test_getaddrinfo+0xce>
bt     %ebp,%eax
jb     1277 <test_getaddrinfo+0xf7>
sub    $0x8,%rsp
mov    $0x1,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rbp
push   %rax
push   %rbx
call   1030 <test_getaddrinfo_err_nr@plt>
add    $0x20,%rsp
test   %ebp,%ebp
jne    153e <test_getaddrinfo+0x3be>
mov    0x20(%rsp),%r15
xor    %eax,%eax
test   %r15,%r15
je     14ae <test_getaddrinfo+0x32e>
mov    %rax,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
jmp    12dd <test_getaddrinfo+0x15d>
nopl   (%rax)
sub    $0x8,%rsp
mov    $0x7,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rax
lea    0xd3b(%rip),%rax
push   %rax
push   %rbx
call   1090 <test_getaddrinfo_err@plt>
add    $0x20,%rsp
mov    0x10(%r15),%r15
test   %r15,%r15
je     14ba <test_getaddrinfo+0x33a>
mov    0x4(%r15),%ebp
mov    0x2d00(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%ebp
je     1317 <test_getaddrinfo+0x197>
sub    $0x8,%rsp
mov    $0x2,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rbp
push   %rax
push   %rbx
call   1030 <test_getaddrinfo_err_nr@plt>
add    $0x20,%rsp
test   %ebx,%ebx
je     134c <test_getaddrinfo+0x1cc>
mov    0x8(%r15),%eax
cmp    %ebx,%eax
je     134c <test_getaddrinfo+0x1cc>
sub    $0x8,%rsp
mov    $0x3,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rax
push   %rbx
push   %rbx
call   1030 <test_getaddrinfo_err_nr@plt>
add    $0x20,%rsp
mov    0x8(%r15),%eax
cmp    $0x80,%eax
je     1370 <test_getaddrinfo+0x1f0>
cmp    $0x81,%eax
jne    137d <test_getaddrinfo+0x1fd>
mov    0x10(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x10(%rsp)
jmp    137d <test_getaddrinfo+0x1fd>
nopl   (%rax)
mov    0x18(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x18(%rsp)
mov    0xc(%r15),%eax
cmp    $0x10,%eax
jne    1430 <test_getaddrinfo+0x2b0>
mov    0x20(%r15),%r13
mov    0x98(%rsp),%rax
cmp    %rax,0x8(%r13)
je     13dd <test_getaddrinfo+0x25d>
mov    0x98(%rsp),%rdi
call   1080 <ntohl@plt>
mov    %eax,%ebp
mov    0x8(%r13),%rdi
call   1080 <ntohl@plt>
sub    $0x8,%rsp
mov    $0x5,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rax
push   %rbp
push   %rbx
call   1030 <test_getaddrinfo_err_nr@plt>
add    $0x20,%rsp
movzwl 0xa8(%rsp),%eax
cmp    %ax,0x0(%r13)
je     145a <test_getaddrinfo+0x2da>
movzwl 0xa8(%rsp),%edi
call   1060 <ntohs@plt>
mov    %eax,%ebp
movzwl 0x0(%r13),%edi
call   1060 <ntohs@plt>
sub    $0x8,%rsp
mov    $0x6,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rax
push   %rbp
jmp    1450 <test_getaddrinfo+0x2d0>
cs nopw 0x0(%rax,%rax,1)
sub    $0x8,%rsp
mov    $0x4,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rax
push   $0x10
push   %rbx
call   1030 <test_getaddrinfo_err_nr@plt>
add    $0x20,%rsp
mov    0x18(%r15),%rax
cmpl   $0x0,0xa0(%rsp)
je     1480 <test_getaddrinfo+0x300>
test   %rax,%rax
je     12a0 <test_getaddrinfo+0x120>
cmpl   $0x0,(%rax)
jne    12d0 <test_getaddrinfo+0x150>
jmp    12a0 <test_getaddrinfo+0x120>
nop
test   %rax,%rax
je     12d0 <test_getaddrinfo+0x150>
sub    $0x8,%rsp
mov    $0x8,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rax
push   $0x0
jmp    12c6 <test_getaddrinfo+0x146>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
cmp    $0x80,%ebx
setne  %al
mov    0x10(%rsp),%rbp
cmp    %eax,%ebp
je     14f7 <test_getaddrinfo+0x377>
sub    $0x8,%rsp
mov    $0x9,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rbp
push   %rax
push   %rbx
call   1030 <test_getaddrinfo_err_nr@plt>
add    $0x20,%rsp
xor    %eax,%eax
cmp    $0x81,%ebx
setne  %al
mov    0x18(%rsp),%rbp
cmp    %eax,%ebp
je     1534 <test_getaddrinfo+0x3b4>
sub    $0x8,%rsp
mov    $0xa,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %rbp
push   %rax
push   %rbx
call   1030 <test_getaddrinfo_err_nr@plt>
add    $0x20,%rsp
mov    0x20(%rsp),%rdi
call   10a0 <freeaddrinfo@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, %struct.addrinfo*, i32*, i64 }
%struct.sockaddr_in = type { i16, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
@AF_UNSPEC = global i32 0
@AF_INET = global i32 0
@.str = [11 x i8] c"(anything)\00"
define void @test_getaddrinfo(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i64 %7, i32 %8, i16 zeroext %9) {
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i64
%19 = alloca i32
%20 = alloca i16
%21 = alloca %struct.addrinfo*
%22 = alloca %struct.addrinfo*
%23 = alloca %struct.addrinfo
%24 = alloca %struct.sockaddr_in*
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
store i8* %0, i8** %11
store i8* %1, i8** %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store i32 %6, i32* %17
store i64 %7, i64* %18
store i32 %8, i32* %19
store i16 %9, i16* %20
%28 = load i32, i32* %13
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %10
%31 = load i32, i32* %14
%32 = icmp ne i32 %31, 0
%33 = xor i1 %32, true
br label %34
34: ; preds = %30, %10
%35 = phi i1 [ true, %10 ], [ %33, %30 ]
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %13
%39 = icmp ne i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %34
%41 = load i32, i32* %15
%42 = load i32, i32* @AF_UNSPEC
%43 = icmp eq i32 %41, %42
br label %44
44: ; preds = %40, %34
%45 = phi i1 [ true, %34 ], [ %43, %40 ]
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i32, i32* %13
%49 = icmp ne i32 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %44
%51 = load i32, i32* %16
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
br label %54
54: ; preds = %50, %44
%55 = phi i1 [ true, %44 ], [ %53, %50 ]
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = call i32 @memset(%struct.addrinfo* %23, i32 0, i32 40)
%59 = load i32, i32* %14
%60 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i32 0, i32 0
store i32 %59, i32* %60
%61 = load i32, i32* %15
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i32 0, i32 1
store i32 %61, i32* %62
%63 = load i32, i32* %16
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i32 0, i32 2
store i32 %63, i32* %64
%65 = load i32, i32* %15
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i32 0, i32 1
store i32 %65, i32* %66
store %struct.addrinfo* inttoptr (i64 3735928559 to %struct.addrinfo*), %struct.addrinfo** %21
%67 = load i8*, i8** %11
%68 = load i8*, i8** %12
%69 = load i32, i32* %13
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %54
br label %73
72: ; preds = %54
br label %73
73: ; preds = %72, %71
%74 = phi %struct.addrinfo* [ %23, %71 ], [ null, %72 ]
%75 = call i32 @getaddrinfo(i8* %67, i8* %68, %struct.addrinfo* %74, %struct.addrinfo** %21)
store i32 %75, i32* %27
%76 = load i32, i32* %27
%77 = icmp slt i32 %76, 0
br i1 %77, label %87, label %78
78: ; preds = %73
%79 = load i32, i32* %27
%80 = icmp sge i32 %79, 32
br i1 %80, label %87, label %81
81: ; preds = %78
%82 = load i32, i32* %27
%83 = shl i32 1, %82
%84 = load i32, i32* %17
%85 = and i32 %83, %84
%86 = icmp ne i32 %85, 0
br i1 %86, label %97, label %87
87: ; preds = %81, %78, %73
%88 = load i8*, i8** %11
%89 = load i8*, i8** %12
%90 = load i32, i32* %13
%91 = load i32, i32* %14
%92 = load i32, i32* %15
%93 = load i32, i32* %16
%94 = load i32, i32* %17
%95 = load i32, i32* %27
%96 = call i32 @test_getaddrinfo_err_nr(i32 1, i8* %88, i8* %89, i32 %90, i32 %91, i32 %92, i32 %93, i32 %94, i32 %95)
br label %97
97: ; preds = %87, %81
%98 = load i32, i32* %27
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %101
100: ; preds = %97
br label %312
101: ; preds = %97
%102 = load %struct.addrinfo*, %struct.addrinfo** %21
store %struct.addrinfo* %102, %struct.addrinfo** %22
store i32 0, i32* %25
store i32 0, i32* %26
br label %103
103: ; preds = %265, %101
%104 = load %struct.addrinfo*, %struct.addrinfo** %22
%105 = icmp ne %struct.addrinfo* %104, null
br i1 %105, label %106, label %269
106: ; preds = %103
%107 = load %struct.addrinfo*, %struct.addrinfo** %22
%108 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %107, i32 0, i32 1
%109 = load i32, i32* %108
%110 = load i32, i32* @AF_INET
%111 = icmp ne i32 %109, %110
br i1 %111, label %112, label %124
112: ; preds = %106
%113 = load i8*, i8** %11
%114 = load i8*, i8** %12
%115 = load i32, i32* %13
%116 = load i32, i32* %14
%117 = load i32, i32* %15
%118 = load i32, i32* %16
%119 = load i32, i32* @AF_INET
%120 = load %struct.addrinfo*, %struct.addrinfo** %22
%121 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %120, i32 0, i32 1
%122 = load i32, i32* %121
%123 = call i32 @test_getaddrinfo_err_nr(i32 2, i8* %113, i8* %114, i32 %115, i32 %116, i32 %117, i32 %118, i32 %119, i32 %122)
br label %124
124: ; preds = %112, %106
%125 = load i32, i32* %16
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %145
127: ; preds = %124
%128 = load %struct.addrinfo*, %struct.addrinfo** %22
%129 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %128, i32 0, i32 2
%130 = load i32, i32* %129
%131 = load i32, i32* %16
%132 = icmp ne i32 %130, %131
br i1 %132, label %133, label %145
133: ; preds = %127
%134 = load i8*, i8** %11
%135 = load i8*, i8** %12
%136 = load i32, i32* %13
%137 = load i32, i32* %14
%138 = load i32, i32* %15
%139 = load i32, i32* %16
%140 = load i32, i32* %16
%141 = load %struct.addrinfo*, %struct.addrinfo** %22
%142 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %141, i32 0, i32 2
%143 = load i32, i32* %142
%144 = call i32 @test_getaddrinfo_err_nr(i32 3, i8* %134, i8* %135, i32 %136, i32 %137, i32 %138, i32 %139, i32 %140, i32 %143)
br label %145
145: ; preds = %133, %127, %124
%146 = load %struct.addrinfo*, %struct.addrinfo** %22
%147 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %146, i32 0, i32 2
%148 = load i32, i32* %147
switch i32 %148, label %155 [
i32 129, label %149
i32 128, label %152
]
149: ; preds = %145
%150 = load i32, i32* %25
%151 = add nsw i32 %150, 1
store i32 %151, i32* %25
br label %155
152: ; preds = %145
%153 = load i32, i32* %26
%154 = add nsw i32 %153, 1
store i32 %154, i32* %26
br label %155
155: ; preds = %145, %152, %149
%156 = load %struct.addrinfo*, %struct.addrinfo** %22
%157 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %156, i32 0, i32 3
%158 = load i32, i32* %157
%159 = sext i32 %158 to i64
%160 = icmp ne i64 %159, 16
br i1 %160, label %161, label %172
161: ; preds = %155
%162 = load i8*, i8** %11
%163 = load i8*, i8** %12
%164 = load i32, i32* %13
%165 = load i32, i32* %14
%166 = load i32, i32* %15
%167 = load i32, i32* %16
%168 = load %struct.addrinfo*, %struct.addrinfo** %22
%169 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %168, i32 0, i32 3
%170 = load i32, i32* %169
%171 = call i32 @test_getaddrinfo_err_nr(i32 4, i8* %162, i8* %163, i32 %164, i32 %165, i32 %166, i32 %167, i32 16, i32 %170)
br label %221
172: ; preds = %155
%173 = load %struct.addrinfo*, %struct.addrinfo** %22
%174 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %173, i32 0, i32 6
%175 = load i64, i64* %174
%176 = inttoptr i64 %175 to %struct.sockaddr_in*
store %struct.sockaddr_in* %176, %struct.sockaddr_in** %24
%177 = load %struct.sockaddr_in*, %struct.sockaddr_in** %24
%178 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %177, i32 0, i32 1
%179 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %178, i32 0, i32 0
%180 = load i64, i64* %179
%181 = load i64, i64* %18
%182 = icmp ne i64 %180, %181
br i1 %182, label %183, label %198
183: ; preds = %172
%184 = load i8*, i8** %11
%185 = load i8*, i8** %12
%186 = load i32, i32* %13
%187 = load i32, i32* %14
%188 = load i32, i32* %15
%189 = load i32, i32* %16
%190 = load i64, i64* %18
%191 = call i32 @ntohl(i64 %190)
%192 = load %struct.sockaddr_in*, %struct.sockaddr_in** %24
%193 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %192, i32 0, i32 1
%194 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %193, i32 0, i32 0
%195 = load i64, i64* %194
%196 = call i32 @ntohl(i64 %195)
%197 = call i32 @test_getaddrinfo_err_nr(i32 5, i8* %184, i8* %185, i32 %186, i32 %187, i32 %188, i32 %189, i32 %191, i32 %196)
br label %198
198: ; preds = %183, %172
%199 = load %struct.sockaddr_in*, %struct.sockaddr_in** %24
%200 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %199, i32 0, i32 0
%201 = load i16, i16* %200
%202 = zext i16 %201 to i32
%203 = load i16, i16* %20
%204 = zext i16 %203 to i32
%205 = icmp ne i32 %202, %204
br i1 %205, label %206, label %220
206: ; preds = %198
%207 = load i8*, i8** %11
%208 = load i8*, i8** %12
%209 = load i32, i32* %13
%210 = load i32, i32* %14
%211 = load i32, i32* %15
%212 = load i32, i32* %16
%213 = load i16, i16* %20
%214 = call i32 @ntohs(i16 zeroext %213)
%215 = load %struct.sockaddr_in*, %struct.sockaddr_in** %24
%216 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %215, i32 0, i32 0
%217 = load i16, i16* %216
%218 = call i32 @ntohs(i16 zeroext %217)
%219 = call i32 @test_getaddrinfo_err_nr(i32 6, i8* %207, i8* %208, i32 %209, i32 %210, i32 %211, i32 %212, i32 %214, i32 %218)
br label %220
220: ; preds = %206, %198
br label %221
221: ; preds = %220, %161
%222 = load i32, i32* %19
%223 = icmp ne i32 %222, 0
br i1 %223, label %224, label %246
224: ; preds = %221
%225 = load %struct.addrinfo*, %struct.addrinfo** %22
%226 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %225, i32 0, i32 5
%227 = load i32*, i32** %226
%228 = icmp ne i32* %227, null
br i1 %228, label %229, label %235
229: ; preds = %224
%230 = load %struct.addrinfo*, %struct.addrinfo** %22
%231 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %230, i32 0, i32 5
%232 = load i32*, i32** %231
%233 = load i32, i32* %232
%234 = icmp ne i32 %233, 0
br i1 %234, label %246, label %235
235: ; preds = %229, %224
%236 = load i8*, i8** %11
%237 = load i8*, i8** %12
%238 = load i32, i32* %13
%239 = load i32, i32* %14
%240 = load i32, i32* %15
%241 = load i32, i32* %16
%242 = load %struct.addrinfo*, %struct.addrinfo** %22
%243 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %242, i32 0, i32 5
%244 = load i32*, i32** %243
%245 = call i32 @test_getaddrinfo_err(i32 7, i8* %236, i8* %237, i32 %238, i32 %239, i32 %240, i32 %241, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32* %244)
br label %246
246: ; preds = %235, %229, %221
%247 = load i32, i32* %19
%248 = icmp ne i32 %247, 0
br i1 %248, label %265, label %249
249: ; preds = %246
%250 = load %struct.addrinfo*, %struct.addrinfo** %22
%251 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %250, i32 0, i32 5
%252 = load i32*, i32** %251
%253 = icmp ne i32* %252, null
br i1 %253, label %254, label %265
254: ; preds = %249
%255 = load i8*, i8** %11
%256 = load i8*, i8** %12
%257 = load i32, i32* %13
%258 = load i32, i32* %14
%259 = load i32, i32* %15
%260 = load i32, i32* %16
%261 = load %struct.addrinfo*, %struct.addrinfo** %22
%262 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %261, i32 0, i32 5
%263 = load i32*, i32** %262
%264 = call i32 @test_getaddrinfo_err(i32 8, i8* %255, i8* %256, i32 %257, i32 %258, i32 %259, i32 %260, i8* null, i32* %263)
br label %265
265: ; preds = %254, %249, %246
%266 = load %struct.addrinfo*, %struct.addrinfo** %22
%267 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %266, i32 0, i32 4
%268 = load %struct.addrinfo*, %struct.addrinfo** %267
store %struct.addrinfo* %268, %struct.addrinfo** %22
br label %103
269: ; preds = %103
%270 = load i32, i32* %25
%271 = load i32, i32* %16
%272 = icmp eq i32 %271, 128
%273 = zext i1 %272 to i64
%274 = select i1 %272, i32 0, i32 1
%275 = icmp ne i32 %270, %274
br i1 %275, label %276, label %289
276: ; preds = %269
%277 = load i8*, i8** %11
%278 = load i8*, i8** %12
%279 = load i32, i32* %13
%280 = load i32, i32* %14
%281 = load i32, i32* %15
%282 = load i32, i32* %16
%283 = load i32, i32* %16
%284 = icmp eq i32 %283, 128
%285 = zext i1 %284 to i64
%286 = select i1 %284, i32 0, i32 1
%287 = load i32, i32* %25
%288 = call i32 @test_getaddrinfo_err_nr(i32 9, i8* %277, i8* %278, i32 %279, i32 %280, i32 %281, i32 %282, i32 %286, i32 %287)
br label %289
289: ; preds = %276, %269
%290 = load i32, i32* %26
%291 = load i32, i32* %16
%292 = icmp eq i32 %291, 129
%293 = zext i1 %292 to i64
%294 = select i1 %292, i32 0, i32 1
%295 = icmp ne i32 %290, %294
br i1 %295, label %296, label %309
296: ; preds = %289
%297 = load i8*, i8** %11
%298 = load i8*, i8** %12
%299 = load i32, i32* %13
%300 = load i32, i32* %14
%301 = load i32, i32* %15
%302 = load i32, i32* %16
%303 = load i32, i32* %16
%304 = icmp eq i32 %303, 129
%305 = zext i1 %304 to i64
%306 = select i1 %304, i32 0, i32 1
%307 = load i32, i32* %26
%308 = call i32 @test_getaddrinfo_err_nr(i32 10, i8* %297, i8* %298, i32 %299, i32 %300, i32 %301, i32 %302, i32 %306, i32 %307)
br label %309
309: ; preds = %296, %289
%310 = load %struct.addrinfo*, %struct.addrinfo** %21
%311 = call i32 @freeaddrinfo(%struct.addrinfo* %310)
br label %312
312: ; preds = %309, %100
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, %struct.addrinfo*, i32*, i64 }
%struct.sockaddr_in = type { i16, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
@AF_UNSPEC = global i32 0
@AF_INET = global i32 0
@.str = [11 x i8] c"(anything)\00"
define void @test_getaddrinfo(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i64 %7, i32 %8, i16 zeroext %9) {
%11 = alloca %struct.addrinfo*
%12 = alloca %struct.addrinfo
%13 = bitcast %struct.addrinfo** %11 to i8*
%14 = bitcast %struct.addrinfo* %12 to i8*
%15 = icmp ne i32 %2, 0
%16 = icmp eq i32 %3, 0
%17 = or i1 %15, %16
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = load i32, i32* @AF_UNSPEC
%21 = icmp eq i32 %20, %4
%22 = select i1 %15, i1 true, i1 %21
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = icmp eq i32 %5, 0
%26 = or i1 %15, %25
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = call i32 @memset(%struct.addrinfo* %12, i32 0, i32 40)
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i64 0, i32 0
store i32 %3, i32* %30
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i64 0, i32 1
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i64 0, i32 2
store i32 %5, i32* %32
store i32 %4, i32* %31
store %struct.addrinfo* inttoptr (i64 3735928559 to %struct.addrinfo*), %struct.addrinfo** %11
%33 = select i1 %15, %struct.addrinfo* %12, %struct.addrinfo* null
%34 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %33, %struct.addrinfo** %11)
%35 = icmp ugt i32 %34, 31
br i1 %35, label %40, label %36
36: ; preds = %10
%37 = shl nuw i32 1, %34
%38 = and i32 %37, %6
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36, %10
%41 = call i32 @test_getaddrinfo_err_nr(i32 1, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %34)
br label %42
42: ; preds = %40, %36
%43 = icmp eq i32 %34, 0
br i1 %43, label %44, label %136
44: ; preds = %42
%45 = load %struct.addrinfo*, %struct.addrinfo** %11
%46 = icmp eq %struct.addrinfo* %45, null
br i1 %46, label %119, label %47
47: ; preds = %44
%48 = icmp eq i32 %8, 0
br label %49
49: ; preds = %47, %115
%50 = phi %struct.addrinfo* [ %45, %47 ], [ %117, %115 ]
%51 = phi i32 [ 0, %47 ], [ %75, %115 ]
%52 = phi i32 [ 0, %47 ], [ %74, %115 ]
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i64 0, i32 1
%54 = load i32, i32* %53
%55 = load i32, i32* @AF_INET
%56 = icmp eq i32 %54, %55
br i1 %56, label %59, label %57
57: ; preds = %49
%58 = call i32 @test_getaddrinfo_err_nr(i32 2, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %55, i32 %54)
br label %59
59: ; preds = %57, %49
br i1 %25, label %66, label %60
60: ; preds = %59
%61 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i64 0, i32 2
%62 = load i32, i32* %61
%63 = icmp eq i32 %62, %5
br i1 %63, label %66, label %64
64: ; preds = %60
%65 = call i32 @test_getaddrinfo_err_nr(i32 3, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %5, i32 %62)
br label %66
66: ; preds = %64, %60, %59
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i64 0, i32 2
%68 = load i32, i32* %67
switch i32 %68, label %73 [
i32 129, label %69
i32 128, label %71
]
69: ; preds = %66
%70 = add nsw i32 %52, 1
br label %73
71: ; preds = %66
%72 = add nsw i32 %51, 1
br label %73
73: ; preds = %66, %71, %69
%74 = phi i32 [ %52, %66 ], [ %52, %71 ], [ %70, %69 ]
%75 = phi i32 [ %51, %66 ], [ %72, %71 ], [ %51, %69 ]
%76 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i64 0, i32 3
%77 = load i32, i32* %76
%78 = icmp eq i32 %77, 16
br i1 %78, label %81, label %79
79: ; preds = %73
%80 = call i32 @test_getaddrinfo_err_nr(i32 4, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 16, i32 %77)
br label %102
81: ; preds = %73
%82 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i64 0, i32 6
%83 = load i64, i64* %82
%84 = inttoptr i64 %83 to %struct.sockaddr_in*
%85 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %84, i64 0, i32 1, i32 0
%86 = load i64, i64* %85
%87 = icmp eq i64 %86, %7
br i1 %87, label %93, label %88
88: ; preds = %81
%89 = call i32 @ntohl(i64 %7)
%90 = load i64, i64* %85
%91 = call i32 @ntohl(i64 %90)
%92 = call i32 @test_getaddrinfo_err_nr(i32 5, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %89, i32 %91)
br label %93
93: ; preds = %88, %81
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %84, i64 0, i32 0
%95 = load i16, i16* %94
%96 = icmp eq i16 %95, %9
br i1 %96, label %102, label %97
97: ; preds = %93
%98 = call i32 @ntohs(i16 zeroext %9)
%99 = load i16, i16* %94
%100 = call i32 @ntohs(i16 zeroext %99)
%101 = call i32 @test_getaddrinfo_err_nr(i32 6, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %98, i32 %100)
br label %102
102: ; preds = %93, %97, %79
%103 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i64 0, i32 5
%104 = load i32*, i32** %103
%105 = icmp eq i32* %104, null
br i1 %48, label %112, label %106
106: ; preds = %102
br i1 %105, label %110, label %107
107: ; preds = %106
%108 = load i32, i32* %104
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %115
110: ; preds = %107, %106
%111 = call i32 @test_getaddrinfo_err(i32 7, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32* %104)
br label %115
112: ; preds = %102
br i1 %105, label %115, label %113
113: ; preds = %112
%114 = call i32 @test_getaddrinfo_err(i32 8, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i8* null, i32* %104)
br label %115
115: ; preds = %107, %110, %113, %112
%116 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i64 0, i32 4
%117 = load %struct.addrinfo*, %struct.addrinfo** %116
%118 = icmp eq %struct.addrinfo* %117, null
br i1 %118, label %119, label %49
119: ; preds = %115, %44
%120 = phi i32 [ 0, %44 ], [ %74, %115 ]
%121 = phi i32 [ 0, %44 ], [ %75, %115 ]
%122 = icmp ne i32 %5, 128
%123 = zext i1 %122 to i32
%124 = icmp eq i32 %120, %123
br i1 %124, label %127, label %125
125: ; preds = %119
%126 = call i32 @test_getaddrinfo_err_nr(i32 9, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %123, i32 %120)
br label %127
127: ; preds = %125, %119
%128 = icmp ne i32 %5, 129
%129 = zext i1 %128 to i32
%130 = icmp eq i32 %121, %129
br i1 %130, label %133, label %131
131: ; preds = %127
%132 = call i32 @test_getaddrinfo_err_nr(i32 10, i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %129, i32 %121)
br label %133
133: ; preds = %131, %127
%134 = load %struct.addrinfo*, %struct.addrinfo** %11
%135 = call i32 @freeaddrinfo(%struct.addrinfo* %134)
br label %136
136: ; preds = %42, %133
ret void
}