#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 */
struct option {
  char *member_0;
  int member_1;
  char member_3;
  int /*<<< orphan*/ member_2;
};
struct addrinfo {
  struct addrinfo *ai_next;
  int /*<<< orphan*/ ai_flags;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ AI_ADDRCONFIG;
int /*<<< orphan*/ AI_CANONNAME;
int /*<<< orphan*/ AI_PASSIVE;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int getopt_long(int, char **, char const *, struct option const *, int *);
char *optarg;
size_t optind;
int /*<<< orphan*/ print_addrinfo(struct addrinfo *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  static const struct option longopts[] = {{"help", 0, 0, 'h'},
                                           {"verbose", 0, 0, 'v'},
                                           {"node", 1, 0, 'n'},
                                           {"host", 1, 0, 'n'},
                                           {"service", 0, 0, 's'},
                                           {"ipv4", 0, 0, '4'},
                                           {"ipv6", 0, 0, '6'},
                                           {"raw", 0, 0, 'R'},
                                           {"stream", 0, 0, 'S'},
                                           {"dgram", 0, 0, 'D'},
                                           {"datagram", 0, 0, 'D'},
                                           {"tcp", 0, 0, 'T'},
                                           {"udp", 0, 0, 'U'},
                                           {"passive", 0, 0, 'p'},
                                           {"addrconfig", 0, 0, 'a'},
                                           {"canonname", 0, 0, 'c'},
                                           {NULL, 0, 0, 0}};
  static const char *opts = "hvn:s:46RSDTUpac";
  int opt, idx = 0;
  char *nodename = NULL, *servname = NULL;
  struct addrinfo hints = {0};
  struct addrinfo *result;
  while ((opt = getopt_long(argc, argv, opts, longopts, &idx)) != -1) {
    switch (opt) {
    case 'h':
      fprintf(stderr, "-h,--help -- help\n"
                      "-n,--node <nodename> -- node name\n"
                      "-s,--service <servname> -- service name\n"
                      "-4,--ipv4 -- IPv4 only query\n"
                      "-6,--ipv6 -- IPv6 only query\n"
                      "--raw -- raw socket type (SOCK_RAW)\n"
                      "--stream -- stream socket type (SOCK_STREAM)\n"
                      "--dgram -- datagram socket type (SOCK_DGRAM)\n"
                      "--tcp -- TCP protocol (IPPROTO_TCP)\n"
                      "--udp -- UDP protocol (IPPROTO_UDP)\n"
                      "--passive -- AI_PASSIVE\n"
                      "--addrconfig -- AI_ADDRCONFIG\n"
                      "--canonname -- AI_CANONNAME\n");
      exit(EXIT_SUCCESS);
    case 'n':
      nodename = optarg;
      break;
    case 's':
      servname = optarg;
      break;
    case '4':
      hints.ai_family = AF_INET;
      break;
    case '6':
      hints.ai_family = AF_INET6;
      break;
    case 'R':
      hints.ai_socktype = SOCK_RAW;
      break;
    case 'S':
      hints.ai_socktype = SOCK_STREAM;
      break;
    case 'D':
      hints.ai_socktype = SOCK_DGRAM;
      break;
    case 'T':
      hints.ai_protocol = IPPROTO_TCP;
      break;
    case 'U':
      hints.ai_protocol = IPPROTO_UDP;
      break;
    case 'p':
      hints.ai_flags |= AI_PASSIVE;
      break;
    case 'a':
      hints.ai_flags |= AI_ADDRCONFIG;
      break;
    case 'c':
      hints.ai_flags |= AI_CANONNAME;
      break;
    default:
      exit(EXIT_FAILURE);
    }
  }
  if (argv[optind])
    nodename = argv[optind++];
  if (argv[optind])
    servname = argv[optind++];
  if (argv[optind]) {
    fprintf(stderr, "Too many arguments.");
    exit(1);
  }
  printf("query:\n");
  printf("  nodename = %s\n", nodename);
  printf("  servname = %s\n", servname);
  print_addrinfo(&hints);
  int status = getaddrinfo(nodename, servname, &hints, &result);
  printf("status = %d\n", status);
  if (status)
    exit(1);
  int count = 0;
  for (struct addrinfo *item = result; item; item = item->ai_next) {
    printf("#%d:\n", count++);
    print_addrinfo(item);
  }
  freeaddrinfo(result);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e95(%rip),%rdx
lea    0x2a3e(%rip),%rcx
lea    -0x18(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     131f <main+0x19f>
mov    -0x14(%rbp),%eax
add    $0xffffffcc,%eax
mov    %eax,%ecx
mov    %rcx,-0x68(%rbp)
sub    $0x3f,%eax
ja     130c <main+0x18c>
mov    -0x68(%rbp),%rax
lea    0xdf9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xf59(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    131a <main+0x19a>
mov    0x2dab(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    131a <main+0x19a>
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    131a <main+0x19a>
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    131a <main+0x19a>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
jmp    131a <main+0x19a>
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
jmp    131a <main+0x19a>
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
jmp    131a <main+0x19a>
mov    0x2d0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
jmp    131a <main+0x19a>
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
jmp    131a <main+0x19a>
mov    0x2d09(%rip),%rax
mov    (%rax),%eax
or     -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    131a <main+0x19a>
mov    0x2c7d(%rip),%rax
mov    (%rax),%eax
or     -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    131a <main+0x19a>
mov    0x2cc9(%rip),%rax
mov    (%rax),%eax
or     -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    131a <main+0x19a>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11bd <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x2c86(%rip),%rcx
mov    (%rcx),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     135f <main+0x1df>
mov    -0x10(%rbp),%rax
mov    0x2c6d(%rip),%rcx
mov    (%rcx),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    0x2c5c(%rip),%rdx
mov    %rsi,(%rdx)
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2c46(%rip),%rcx
mov    (%rcx),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     139f <main+0x21f>
mov    -0x10(%rbp),%rax
mov    0x2c2d(%rip),%rcx
mov    (%rcx),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    0x2c1c(%rip),%rdx
mov    %rsi,(%rdx)
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2c06(%rip),%rcx
mov    (%rcx),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     13d7 <main+0x257>
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
lea    0xf60(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xf5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xf54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xf53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x48(%rbp),%rdi
call   1030 <print_addrinfo@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   1090 <getaddrinfo@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%esi
lea    0xf32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x54(%rbp)
je     144f <main+0x2cf>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     149b <main+0x31b>
mov    -0x58(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x60(%rbp),%rdi
call   1030 <print_addrinfo@plt>
mov    -0x60(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    145e <main+0x2de>
mov    -0x50(%rbp),%rdi
call   10a0 <freeaddrinfo@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
xor    %r13d,%r13d
lea    0x2a5e(%rip),%r15
lea    0xc(%rsp),%r12
lea    0xe42(%rip),%r14
xor    %eax,%eax
mov    %rax,(%rsp)
xor    %eax,%eax
jmp    11da <main+0x5a>
nopl   0x0(%rax,%rax,1)
mov    0x2e21(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x38(%rsp)
jmp    11ee <main+0x6e>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
lea    0x1042(%rip),%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1050 <getopt_long@plt>
add    $0x1,%eax
cmp    $0x74,%eax
ja     13ba <main+0x23a>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    0x2db7(%rip),%rax
jmp    122a <main+0xaa>
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
jmp    11ee <main+0x6e>
mov    0x2d87(%rip),%rax
jmp    1279 <main+0xf9>
mov    0x2d86(%rip),%rax
jmp    128b <main+0x10b>
mov    0x2d6d(%rip),%rax
jmp    11e8 <main+0x68>
mov    0x2d3c(%rip),%rax
jmp    11e8 <main+0x68>
mov    0x2d0b(%rip),%rax
jmp    128b <main+0x10b>
mov    0x2d92(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rsp)
jmp    11ee <main+0x6e>
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
jmp    11ee <main+0x6e>
mov    0x2d55(%rip),%rax
or     (%rax),%r13d
mov    %r13d,0x18(%rsp)
jmp    11ee <main+0x6e>
mov    0x2d11(%rip),%rcx
mov    (%rcx),%rax
mov    (%rbx,%rax,8),%rbp
test   %rbp,%rbp
je     12e5 <main+0x165>
lea    0x1(%rax),%rdx
mov    %rdx,(%rcx)
mov    0x8(%rbx,%rax,8),%r14
test   %r14,%r14
je     12f0 <main+0x170>
lea    0x2(%rax),%rdx
mov    %rdx,(%rcx)
cmpq   $0x0,0x10(%rbx,%rax,8)
je     12f4 <main+0x174>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
lea    0x1121(%rip),%rsi
call   1070 <fprintf@plt>
jmp    13eb <main+0x26b>
mov    (%rsp),%r14
mov    0x38(%rsp),%rbp
jmp    12f4 <main+0x174>
mov    (%rsp),%r14
lea    0x114a(%rip),%rdi
call   1030 <puts@plt>
lea    0x1109(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1109(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <print_addrinfo@plt>
lea    0x40(%rsp),%rcx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1090 <getaddrinfo@plt>
mov    %eax,%ebx
lea    0x10e7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebx,%ebx
jne    13eb <main+0x26b>
mov    0x40(%rsp),%rbx
xor    %edi,%edi
test   %rbx,%rbx
je     13a4 <main+0x224>
lea    0x10d0(%rip),%r14
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rsi),%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <print_addrinfo@plt>
mov    (%rbx),%rbx
mov    %ebp,%esi
test   %rbx,%rbx
jne    1380 <main+0x200>
mov    0x40(%rsp),%rdi
call   10a0 <freeaddrinfo@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bc7(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2bc9(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b9c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i32, i8, i32 }
%struct.addrinfo = type { %struct.addrinfo*, i32, i32, i32, i32, i32 }
@main.longopts = internal constant [17 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 0, i8 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 0, i8 0, i32 118 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 1, i8 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 1, i8 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i32 0, i8 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i32 0, i8 0, i32 52 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i32 0, i8 0, i32 54 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i32 0, i8 0, i32 82 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i32 0, i8 0, i32 83 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0), i32 0, i8 0, i32 68 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i32 0, i32 0), i32 0, i8 0, i32 68 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i32 0, i8 0, i32 84 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i32 0, i8 0, i32 85 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i32 0, i32 0), i32 0, i8 0, i32 112 }, %struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i32 0, i32 0), i32 0, i8 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i32 0, i32 0), i32 0, i8 0, i32 99 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [5 x i8] c"node\00"
@.str.3 = [5 x i8] c"host\00"
@.str.4 = [8 x i8] c"service\00"
@.str.5 = [5 x i8] c"ipv4\00"
@.str.6 = [5 x i8] c"ipv6\00"
@.str.7 = [4 x i8] c"raw\00"
@.str.8 = [7 x i8] c"stream\00"
@.str.9 = [6 x i8] c"dgram\00"
@.str.10 = [9 x i8] c"datagram\00"
@.str.11 = [4 x i8] c"tcp\00"
@.str.12 = [4 x i8] c"udp\00"
@.str.13 = [8 x i8] c"passive\00"
@.str.14 = [11 x i8] c"addrconfig\00"
@.str.15 = [10 x i8] c"canonname\00"
@main.opts = internal global i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i32 0, i32 0)
@.str.16 = [17 x i8] c"hvn:s:46RSDTUpac\00"
@stderr = global i32 0
@.str.17 = [431 x i8] c"-h,--help -- help\0A-n,--node <nodename> -- node name\0A-s,--service <servname> -- service name\0A-4,--ipv4 -- IPv4 only query\0A-6,--ipv6 -- IPv6 only query\0A--raw -- raw socket type (SOCK_RAW)\0A--stream -- stream socket type (SOCK_STREAM)\0A--dgram -- datagram socket type (SOCK_DGRAM)\0A--tcp -- TCP protocol (IPPROTO_TCP)\0A--udp -- UDP protocol (IPPROTO_UDP)\0A--passive -- AI_PASSIVE\0A--addrconfig -- AI_ADDRCONFIG\0A--canonname -- AI_CANONNAME\0A\00"
@EXIT_SUCCESS = global i32 0
@optarg = global i8* null
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@SOCK_RAW = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_TCP = global i32 0
@IPPROTO_UDP = global i32 0
@AI_PASSIVE = global i32 0
@AI_ADDRCONFIG = global i32 0
@AI_CANONNAME = global i32 0
@EXIT_FAILURE = global i32 0
@optind = global i64 0
@.str.18 = [20 x i8] c"Too many arguments.\00"
@.str.19 = [8 x i8] c"query:\0A\00"
@.str.20 = [17 x i8] c" nodename = %s\0A\00"
@.str.21 = [17 x i8] c" servname = %s\0A\00"
@.str.22 = [13 x i8] c"status = %d\0A\00"
@.str.23 = [6 x i8] c"#%d:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.addrinfo*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i8* null, i8** %8
store i8* null, i8** %9
%15 = bitcast %struct.addrinfo* %10 to i8*
br label %16
16: ; preds = %72, %2
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = load i8*, i8** @main.opts
%20 = call i32 @getopt_long(i32 %17, i8** %18, i8* %19, %struct.option* getelementptr inbounds ([17 x %struct.option], [17 x %struct.option]* @main.longopts, i64 0, i64 0), i32* %7)
store i32 %20, i32* %6
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %73
22: ; preds = %16
%23 = load i32, i32* %6
switch i32 %23, label %69 [
i32 104, label %24
i32 110, label %29
i32 115, label %31
i32 52, label %33
i32 54, label %36
i32 82, label %39
i32 83, label %42
i32 68, label %45
i32 84, label %48
i32 85, label %51
i32 112, label %54
i32 97, label %59
i32 99, label %64
]
24: ; preds = %22
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([431 x i8], [431 x i8]* @.str.17, i64 0, i64 0))
%27 = load i32, i32* @EXIT_SUCCESS
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %22
%30 = load i8*, i8** @optarg
store i8* %30, i8** %8
br label %72
31: ; preds = %22
%32 = load i8*, i8** @optarg
store i8* %32, i8** %9
br label %72
33: ; preds = %22
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 4
store i32 %34, i32* %35
br label %72
36: ; preds = %22
%37 = load i32, i32* @AF_INET6
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 4
store i32 %37, i32* %38
br label %72
39: ; preds = %22
%40 = load i32, i32* @SOCK_RAW
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 3
store i32 %40, i32* %41
br label %72
42: ; preds = %22
%43 = load i32, i32* @SOCK_STREAM
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 3
store i32 %43, i32* %44
br label %72
45: ; preds = %22
%46 = load i32, i32* @SOCK_DGRAM
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 3
store i32 %46, i32* %47
br label %72
48: ; preds = %22
%49 = load i32, i32* @IPPROTO_TCP
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 2
store i32 %49, i32* %50
br label %72
51: ; preds = %22
%52 = load i32, i32* @IPPROTO_UDP
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 2
store i32 %52, i32* %53
br label %72
54: ; preds = %22
%55 = load i32, i32* @AI_PASSIVE
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 1
%57 = load i32, i32* %56
%58 = or i32 %57, %55
store i32 %58, i32* %56
br label %72
59: ; preds = %22
%60 = load i32, i32* @AI_ADDRCONFIG
%61 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 1
%62 = load i32, i32* %61
%63 = or i32 %62, %60
store i32 %63, i32* %61
br label %72
64: ; preds = %22
%65 = load i32, i32* @AI_CANONNAME
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 1
%67 = load i32, i32* %66
%68 = or i32 %67, %65
store i32 %68, i32* %66
br label %72
69: ; preds = %22
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @exit(i32 %70)
unreachable
72: ; preds = %64, %59, %54, %51, %48, %45, %42, %39, %36, %33, %31, %29
br label %16
73: ; preds = %16
%74 = load i8**, i8*** %5
%75 = load i64, i64* @optind
%76 = getelementptr inbounds i8*, i8** %74, i64 %75
%77 = load i8*, i8** %76
%78 = icmp ne i8* %77, null
br i1 %78, label %79, label %85
79: ; preds = %73
%80 = load i8**, i8*** %5
%81 = load i64, i64* @optind
%82 = add i64 %81, 1
store i64 %82, i64* @optind
%83 = getelementptr inbounds i8*, i8** %80, i64 %81
%84 = load i8*, i8** %83
store i8* %84, i8** %8
br label %85
85: ; preds = %79, %73
%86 = load i8**, i8*** %5
%87 = load i64, i64* @optind
%88 = getelementptr inbounds i8*, i8** %86, i64 %87
%89 = load i8*, i8** %88
%90 = icmp ne i8* %89, null
br i1 %90, label %91, label %97
91: ; preds = %85
%92 = load i8**, i8*** %5
%93 = load i64, i64* @optind
%94 = add i64 %93, 1
store i64 %94, i64* @optind
%95 = getelementptr inbounds i8*, i8** %92, i64 %93
%96 = load i8*, i8** %95
store i8* %96, i8** %9
br label %97
97: ; preds = %91, %85
%98 = load i8**, i8*** %5
%99 = load i64, i64* @optind
%100 = getelementptr inbounds i8*, i8** %98, i64 %99
%101 = load i8*, i8** %100
%102 = icmp ne i8* %101, null
br i1 %102, label %103, label %107
103: ; preds = %97
%104 = load i32, i32* @stderr
%105 = call i32 @fprintf(i32 %104, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0))
%106 = call i32 @exit(i32 1)
unreachable
107: ; preds = %97
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0))
%109 = load i8*, i8** %8
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i8* %109)
%111 = load i8*, i8** %9
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.21, i64 0, i64 0), i8* %111)
%113 = call i32 @print_addrinfo(%struct.addrinfo* %10)
%114 = load i8*, i8** %8
%115 = load i8*, i8** %9
%116 = call i32 @getaddrinfo(i8* %114, i8* %115, %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %116, i32* %12
%117 = load i32, i32* %12
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.22, i64 0, i64 0), i32 %117)
%119 = load i32, i32* %12
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %107
%122 = call i32 @exit(i32 1)
unreachable
123: ; preds = %107
store i32 0, i32* %13
%124 = load %struct.addrinfo*, %struct.addrinfo** %11
store %struct.addrinfo* %124, %struct.addrinfo** %14
br label %125
125: ; preds = %134, %123
%126 = load %struct.addrinfo*, %struct.addrinfo** %14
%127 = icmp ne %struct.addrinfo* %126, null
br i1 %127, label %128, label %138
128: ; preds = %125
%129 = load i32, i32* %13
%130 = add nsw i32 %129, 1
store i32 %130, i32* %13
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.23, i64 0, i64 0), i32 %129)
%132 = load %struct.addrinfo*, %struct.addrinfo** %14
%133 = call i32 @print_addrinfo(%struct.addrinfo* %132)
br label %134
134: ; preds = %128
%135 = load %struct.addrinfo*, %struct.addrinfo** %14
%136 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %135, i32 0, i32 0
%137 = load %struct.addrinfo*, %struct.addrinfo** %136
store %struct.addrinfo* %137, %struct.addrinfo** %14
br label %125
138: ; preds = %125
%139 = load %struct.addrinfo*, %struct.addrinfo** %11
%140 = call i32 @freeaddrinfo(%struct.addrinfo* %139)
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i8, i32 }
%struct.addrinfo = type { %struct.addrinfo*, i32, i32, i32, i32, i32 }
@main.longopts = internal constant [17 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 0, i8 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 0, i8 0, i32 118 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 1, i8 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 1, i8 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i32 0, i8 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i32 0, i8 0, i32 52 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i32 0, i8 0, i32 54 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i32 0, i8 0, i32 82 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i32 0, i8 0, i32 83 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0), i32 0, i8 0, i32 68 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i32 0, i32 0), i32 0, i8 0, i32 68 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i32 0, i8 0, i32 84 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i32 0, i8 0, i32 85 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i32 0, i32 0), i32 0, i8 0, i32 112 }, %struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i32 0, i32 0), i32 0, i8 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i32 0, i32 0), i32 0, i8 0, i32 99 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [5 x i8] c"node\00"
@.str.3 = [5 x i8] c"host\00"
@.str.4 = [8 x i8] c"service\00"
@.str.5 = [5 x i8] c"ipv4\00"
@.str.6 = [5 x i8] c"ipv6\00"
@.str.7 = [4 x i8] c"raw\00"
@.str.8 = [7 x i8] c"stream\00"
@.str.9 = [6 x i8] c"dgram\00"
@.str.10 = [9 x i8] c"datagram\00"
@.str.11 = [4 x i8] c"tcp\00"
@.str.12 = [4 x i8] c"udp\00"
@.str.13 = [8 x i8] c"passive\00"
@.str.14 = [11 x i8] c"addrconfig\00"
@.str.15 = [10 x i8] c"canonname\00"
@.str.16 = [17 x i8] c"hvn:s:46RSDTUpac\00"
@stderr = global i32 0
@.str.17 = [431 x i8] c"-h,--help -- help\0A-n,--node <nodename> -- node name\0A-s,--service <servname> -- service name\0A-4,--ipv4 -- IPv4 only query\0A-6,--ipv6 -- IPv6 only query\0A--raw -- raw socket type (SOCK_RAW)\0A--stream -- stream socket type (SOCK_STREAM)\0A--dgram -- datagram socket type (SOCK_DGRAM)\0A--tcp -- TCP protocol (IPPROTO_TCP)\0A--udp -- UDP protocol (IPPROTO_UDP)\0A--passive -- AI_PASSIVE\0A--addrconfig -- AI_ADDRCONFIG\0A--canonname -- AI_CANONNAME\0A\00"
@EXIT_SUCCESS = global i32 0
@optarg = global i8* null
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@SOCK_RAW = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_TCP = global i32 0
@IPPROTO_UDP = global i32 0
@AI_PASSIVE = global i32 0
@AI_ADDRCONFIG = global i32 0
@AI_CANONNAME = global i32 0
@EXIT_FAILURE = global i32 0
@optind = global i64 0
@.str.18 = [20 x i8] c"Too many arguments.\00"
@.str.20 = [17 x i8] c" nodename = %s\0A\00"
@.str.21 = [17 x i8] c" servname = %s\0A\00"
@.str.22 = [13 x i8] c"status = %d\0A\00"
@.str.23 = [6 x i8] c"#%d:\0A\00"
@str = [7 x i8] c"query:\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast %struct.addrinfo* %4 to i8*
%8 = bitcast %struct.addrinfo** %5 to i8*
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 1
%10 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 2
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
%12 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
br label %13
13: ; preds = %50, %2
%14 = phi i32 [ 0, %2 ], [ %51, %50 ]
%15 = phi i8* [ null, %2 ], [ %52, %50 ]
%16 = phi i8* [ null, %2 ], [ %53, %50 ]
%17 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), %struct.option* getelementptr inbounds ([17 x %struct.option], [17 x %struct.option]* @main.longopts, i64 0, i64 0), i32* %3)
switch i32 %17, label %54 [
i32 -1, label %57
i32 104, label %18
i32 110, label %23
i32 115, label %25
i32 52, label %27
i32 54, label %29
i32 82, label %31
i32 83, label %33
i32 68, label %35
i32 84, label %37
i32 85, label %39
i32 112, label %41
i32 97, label %44
i32 99, label %47
]
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([431 x i8], [431 x i8]* @.str.17, i64 0, i64 0))
%21 = load i32, i32* @EXIT_SUCCESS
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %13
%24 = load i8*, i8** @optarg
br label %50
25: ; preds = %13
%26 = load i8*, i8** @optarg
br label %50
27: ; preds = %13
%28 = load i32, i32* @AF_INET
store i32 %28, i32* %12
br label %50
29: ; preds = %13
%30 = load i32, i32* @AF_INET6
store i32 %30, i32* %12
br label %50
31: ; preds = %13
%32 = load i32, i32* @SOCK_RAW
store i32 %32, i32* %11
br label %50
33: ; preds = %13
%34 = load i32, i32* @SOCK_STREAM
store i32 %34, i32* %11
br label %50
35: ; preds = %13
%36 = load i32, i32* @SOCK_DGRAM
store i32 %36, i32* %11
br label %50
37: ; preds = %13
%38 = load i32, i32* @IPPROTO_TCP
store i32 %38, i32* %10
br label %50
39: ; preds = %13
%40 = load i32, i32* @IPPROTO_UDP
store i32 %40, i32* %10
br label %50
41: ; preds = %13
%42 = load i32, i32* @AI_PASSIVE
%43 = or i32 %14, %42
store i32 %43, i32* %9
br label %50
44: ; preds = %13
%45 = load i32, i32* @AI_ADDRCONFIG
%46 = or i32 %14, %45
store i32 %46, i32* %9
br label %50
47: ; preds = %13
%48 = load i32, i32* @AI_CANONNAME
%49 = or i32 %14, %48
store i32 %49, i32* %9
br label %50
50: ; preds = %47, %44, %41, %39, %37, %35, %33, %31, %29, %27, %25, %23
%51 = phi i32 [ %49, %47 ], [ %46, %44 ], [ %43, %41 ], [ %14, %39 ], [ %14, %37 ], [ %14, %35 ], [ %14, %33 ], [ %14, %31 ], [ %14, %29 ], [ %14, %27 ], [ %14, %25 ], [ %14, %23 ]
%52 = phi i8* [ %15, %47 ], [ %15, %44 ], [ %15, %41 ], [ %15, %39 ], [ %15, %37 ], [ %15, %35 ], [ %15, %33 ], [ %15, %31 ], [ %15, %29 ], [ %15, %27 ], [ %26, %25 ], [ %15, %23 ]
%53 = phi i8* [ %16, %47 ], [ %16, %44 ], [ %16, %41 ], [ %16, %39 ], [ %16, %37 ], [ %16, %35 ], [ %16, %33 ], [ %16, %31 ], [ %16, %29 ], [ %16, %27 ], [ %16, %25 ], [ %24, %23 ]
br label %13
54: ; preds = %13
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %13
%58 = load i64, i64* @optind
%59 = getelementptr inbounds i8*, i8** %1, i64 %58
%60 = load i8*, i8** %59
%61 = icmp eq i8* %60, null
br i1 %61, label %76, label %62
62: ; preds = %57
%63 = add i64 %58, 1
store i64 %63, i64* @optind
%64 = getelementptr inbounds i8*, i8** %1, i64 %63
%65 = load i8*, i8** %64
%66 = icmp eq i8* %65, null
br i1 %66, label %76, label %67
67: ; preds = %62
%68 = add i64 %58, 2
store i64 %68, i64* @optind
%69 = getelementptr inbounds i8*, i8** %1, i64 %68
%70 = load i8*, i8** %69
%71 = icmp eq i8* %70, null
br i1 %71, label %76, label %72
72: ; preds = %67
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %57, %62, %67
%77 = phi i8* [ %65, %67 ], [ %15, %62 ], [ %15, %57 ]
%78 = phi i8* [ %60, %67 ], [ %60, %62 ], [ %16, %57 ]
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i8* %78)
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.21, i64 0, i64 0), i8* %77)
%82 = call i32 @print_addrinfo(%struct.addrinfo* %4)
%83 = call i32 @getaddrinfo(i8* %78, i8* %77, %struct.addrinfo* %4, %struct.addrinfo** %5)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.22, i64 0, i64 0), i32 %83)
%85 = icmp eq i32 %83, 0
br i1 %85, label %86, label %89
86: ; preds = %76
%87 = load %struct.addrinfo*, %struct.addrinfo** %5
%88 = icmp eq %struct.addrinfo* %87, null
br i1 %88, label %93, label %96
89: ; preds = %76
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %96
%92 = load %struct.addrinfo*, %struct.addrinfo** %5
br label %93
93: ; preds = %91, %86
%94 = phi %struct.addrinfo* [ %92, %91 ], [ null, %86 ]
%95 = call i32 @freeaddrinfo(%struct.addrinfo* %94)
ret i32 0
96: ; preds = %86, %96
%97 = phi %struct.addrinfo* [ %103, %96 ], [ %87, %86 ]
%98 = phi i32 [ %99, %96 ], [ 0, %86 ]
%99 = add nuw nsw i32 %98, 1
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.23, i64 0, i64 0), i32 %98)
%101 = call i32 @print_addrinfo(%struct.addrinfo* %97)
%102 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %97, i64 0, i32 0
%103 = load %struct.addrinfo*, %struct.addrinfo** %102
%104 = icmp eq %struct.addrinfo* %103, null
br i1 %104, label %91, label %96
}