#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 addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int EXIT_FAILURE;
int const EXIT_SUCCESS;
int /*<<< orphan*/ IPPROTO_UDP;
int NI_MAXHOST;
int NI_MAXSERV;
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int const);
int connect(int const, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fatal(int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ gai_strerror(int const);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int getnameinfo(int /*<<< orphan*/, int /*<<< orphan*/, char *, int, char *,
                int, int);
int /*<<< orphan*/ log_debug(char *, char *, char *);
int /*<<< orphan*/ log_warn(char *, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int prepare_addrinfo(struct addrinfo *target_addrinfo,
                     const char *target_address, const char *target_port) {
  struct addrinfo hints = {0};
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_protocol = IPPROTO_UDP;
  struct addrinfo *result_addrinfo;
  const int exit_code =
      getaddrinfo(target_address, target_port, &hints, &result_addrinfo);
  if (exit_code != EXIT_SUCCESS)
    fatal(gai_strerror(exit_code));
  struct addrinfo *iterator;
  for (iterator = result_addrinfo; iterator != NULL;
       iterator = iterator->ai_next) {
    const int outgoing_socket_fd = socket(
        iterator->ai_family, iterator->ai_socktype, iterator->ai_protocol);
    if (outgoing_socket_fd == -1)
      continue;
    if (connect(outgoing_socket_fd, iterator->ai_addr, iterator->ai_addrlen) ==
        -1) {
      close(outgoing_socket_fd);
      continue;
    }
    char host[NI_MAXHOST], service[NI_MAXSERV];
    const int getname_result =
        getnameinfo(iterator->ai_addr, iterator->ai_addrlen, host, NI_MAXHOST,
                    service, NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV);
    if (getname_result == EXIT_SUCCESS) {
      log_debug("Successfully got target info for %s:%s\n", host, service);
    } else {
      log_warn("%s", gai_strerror(getname_result));
    }
    *target_addrinfo = *iterator;
    freeaddrinfo(result_addrinfo);
    close(outgoing_socket_fd);
    return EXIT_SUCCESS;
  }
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<prepare_addrinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2d92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   10b0 <getaddrinfo@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    0x2d83(%rip),%rcx
cmp    (%rcx),%eax
je     1244 <prepare_addrinfo+0x84>
mov    -0x54(%rbp),%edi
call   1030 <gai_strerror@plt>
mov    %eax,%edi
call   10c0 <fatal@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     13e7 <prepare_addrinfo+0x227>
mov    -0x60(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x60(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x60(%rbp),%rax
mov    0x8(%rax),%edx
call   10e0 <socket@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    1283 <prepare_addrinfo+0xc3>
jmp    13d6 <prepare_addrinfo+0x216>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x60(%rbp),%rax
mov    (%rax),%edx
call   10a0 <connect@plt>
cmp    $0xffffffff,%eax
jne    12ae <prepare_addrinfo+0xee>
mov    -0x64(%rbp),%edi
call   1060 <close@plt>
jmp    13d6 <prepare_addrinfo+0x216>
mov    0x2cf3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x98(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x78(%rbp)
mov    0x2cf4(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r8
sub    %rcx,%r8
mov    %r8,-0x90(%rbp)
mov    %r8,%rsp
mov    %rax,-0x80(%rbp)
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x60(%rbp),%rax
mov    (%rax),%esi
mov    0x2c8f(%rip),%rax
mov    (%rax),%ecx
mov    0x2cb6(%rip),%rax
mov    (%rax),%r9d
mov    0x2c94(%rip),%rax
mov    (%rax),%eax
mov    0x2cb3(%rip),%r10
or     (%r10),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    0x2c55(%rip),%rcx
cmp    (%rcx),%eax
jne    1382 <prepare_addrinfo+0x1c2>
mov    -0x90(%rbp),%rdx
mov    -0x98(%rbp),%rsi
lea    0xc8c(%rip),%rdi
call   1040 <log_debug@plt>
jmp    139b <prepare_addrinfo+0x1db>
mov    -0x84(%rbp),%edi
call   1030 <gai_strerror@plt>
mov    %eax,%esi
lea    0xc96(%rip),%rdi
call   1090 <log_warn@plt>
mov    -0x10(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    $0x28,%edx
call   1080 <memcpy@plt>
mov    -0x50(%rbp),%rdi
call   10d0 <freeaddrinfo@plt>
mov    -0x64(%rbp),%edi
call   1060 <close@plt>
mov    0x2beb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,%rsp
jmp    13f3 <prepare_addrinfo+0x233>
mov    -0x60(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    124c <prepare_addrinfo+0x8c>
mov    0x2bca(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepare_addrinfo>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,-0x50(%rbp)
movaps %xmm0,-0x60(%rbp)
movq   $0x0,-0x40(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2dba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
lea    -0x60(%rbp),%rax
lea    -0x30(%rbp),%rcx
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rax,%rdx
call   1090 <getaddrinfo@plt>
test   %eax,%eax
je     1213 <prepare_addrinfo+0x73>
mov    %eax,%edi
call   1030 <gai_strerror@plt>
mov    %eax,%edi
call   10a0 <fatal@plt>
mov    -0x30(%rbp),%rbx
jmp    122c <prepare_addrinfo+0x8c>
nopl   0x0(%rax)
mov    %r13d,%edi
call   1050 <close@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
je     12e1 <prepare_addrinfo+0x141>
mov    0x10(%rbx),%edi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%esi
call   10c0 <socket@plt>
cmp    $0xffffffff,%eax
je     1228 <prepare_addrinfo+0x88>
mov    %eax,%r13d
mov    (%rbx),%edx
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   1080 <connect@plt>
cmp    $0xffffffff,%eax
je     1220 <prepare_addrinfo+0x80>
mov    %rsp,-0x38(%rbp)
mov    0x2d49(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%r15
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r15
mov    %r15,%rsp
mov    0x2d57(%rip),%rcx
mov    (%rcx),%r9d
mov    %rsp,%r12
mov    %r9,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r12
mov    %r12,%rsp
mov    (%rbx),%esi
mov    0x4(%rbx),%edi
mov    (%rax),%ecx
mov    0x2d1a(%rip),%r8
mov    0x2d3b(%rip),%rdx
mov    (%rdx),%eax
or     (%r8),%eax
sub    $0x8,%rsp
mov    %r15,%rdx
mov    %r12,%r8
push   %rax
call   1060 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
je     12ec <prepare_addrinfo+0x14c>
mov    %eax,%edi
call   1030 <gai_strerror@plt>
lea    0xd54(%rip),%rdi
mov    %eax,%esi
call   1070 <log_warn@plt>
jmp    12fe <prepare_addrinfo+0x15e>
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
jmp    132d <prepare_addrinfo+0x18d>
lea    0xd11(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <log_debug@plt>
mov    0x20(%rbx),%rax
mov    %rax,0x20(%r14)
movups (%rbx),%xmm0
movups 0x10(%rbx),%xmm1
movups %xmm1,0x10(%r14)
movups %xmm0,(%r14)
mov    -0x30(%rbp),%rdi
call   10b0 <freeaddrinfo@plt>
mov    %r13d,%edi
call   1050 <close@plt>
xor    %eax,%eax
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@EXIT_SUCCESS = constant i32 0
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str = [40 x i8] c"Successfully got target info for %s:%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@EXIT_FAILURE = global i32 0
define i32 @prepare_addrinfo(%struct.addrinfo* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.addrinfo*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca i32
%11 = alloca %struct.addrinfo*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
store %struct.addrinfo* %0, %struct.addrinfo** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%17 = bitcast %struct.addrinfo* %8 to i8*
%18 = load i32, i32* @AF_UNSPEC
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %18, i32* %19
%20 = load i32, i32* @SOCK_DGRAM
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %20, i32* %21
%22 = load i32, i32* @IPPROTO_UDP
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 2
store i32 %22, i32* %23
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = call i32 @getaddrinfo(i8* %24, i8* %25, %struct.addrinfo* %8, %struct.addrinfo** %9)
store i32 %26, i32* %10
%27 = load i32, i32* %10
%28 = load i32, i32* @EXIT_SUCCESS
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %3
%31 = load i32, i32* %10
%32 = call i32 @gai_strerror(i32 %31)
%33 = call i32 @fatal(i32 %32)
br label %34
34: ; preds = %30, %3
%35 = load %struct.addrinfo*, %struct.addrinfo** %9
store %struct.addrinfo* %35, %struct.addrinfo** %11
br label %36
36: ; preds = %106, %34
%37 = load %struct.addrinfo*, %struct.addrinfo** %11
%38 = icmp ne %struct.addrinfo* %37, null
br i1 %38, label %39, label %110
39: ; preds = %36
%40 = load %struct.addrinfo*, %struct.addrinfo** %11
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i32 0, i32 4
%42 = load i32, i32* %41
%43 = load %struct.addrinfo*, %struct.addrinfo** %11
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i32 0, i32 3
%45 = load i32, i32* %44
%46 = load %struct.addrinfo*, %struct.addrinfo** %11
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i32 0, i32 2
%48 = load i32, i32* %47
%49 = call i32 @socket(i32 %42, i32 %45, i32 %48)
store i32 %49, i32* %12
%50 = load i32, i32* %12
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %53
52: ; preds = %39
br label %106
53: ; preds = %39
%54 = load i32, i32* %12
%55 = load %struct.addrinfo*, %struct.addrinfo** %11
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 1
%57 = load i32, i32* %56
%58 = load %struct.addrinfo*, %struct.addrinfo** %11
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 0
%60 = load i32, i32* %59
%61 = call i32 @connect(i32 %54, i32 %57, i32 %60)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %66
63: ; preds = %53
%64 = load i32, i32* %12
%65 = call i32 @close(i32 %64)
br label %106
66: ; preds = %53
%67 = load i32, i32* @NI_MAXHOST
%68 = zext i32 %67 to i64
%69 = call i8* @llvm.stacksave()
store i8* %69, i8** %13
%70 = alloca i8, i64 %68
store i64 %68, i64* %14
%71 = load i32, i32* @NI_MAXSERV
%72 = zext i32 %71 to i64
%73 = alloca i8, i64 %72
store i64 %72, i64* %15
%74 = load %struct.addrinfo*, %struct.addrinfo** %11
%75 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %74, i32 0, i32 1
%76 = load i32, i32* %75
%77 = load %struct.addrinfo*, %struct.addrinfo** %11
%78 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = load i32, i32* @NI_MAXHOST
%81 = load i32, i32* @NI_MAXSERV
%82 = load i32, i32* @NI_NUMERICHOST
%83 = load i32, i32* @NI_NUMERICSERV
%84 = or i32 %82, %83
%85 = call i32 @getnameinfo(i32 %76, i32 %79, i8* %70, i32 %80, i8* %73, i32 %81, i32 %84)
store i32 %85, i32* %16
%86 = load i32, i32* %16
%87 = load i32, i32* @EXIT_SUCCESS
%88 = icmp eq i32 %86, %87
br i1 %88, label %89, label %91
89: ; preds = %66
%90 = call i32 @log_debug(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %70, i8* %73)
br label %95
91: ; preds = %66
%92 = load i32, i32* %16
%93 = call i32 @gai_strerror(i32 %92)
%94 = call i32 @log_warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %93)
br label %95
95: ; preds = %91, %89
%96 = load %struct.addrinfo*, %struct.addrinfo** %5
%97 = load %struct.addrinfo*, %struct.addrinfo** %11
%98 = bitcast %struct.addrinfo* %96 to i8*
%99 = bitcast %struct.addrinfo* %97 to i8*
%100 = load %struct.addrinfo*, %struct.addrinfo** %9
%101 = call i32 @freeaddrinfo(%struct.addrinfo* %100)
%102 = load i32, i32* %12
%103 = call i32 @close(i32 %102)
%104 = load i32, i32* @EXIT_SUCCESS
store i32 %104, i32* %4
%105 = load i8*, i8** %13
br label %112
106: ; preds = %63, %52
%107 = load %struct.addrinfo*, %struct.addrinfo** %11
%108 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %107, i32 0, i32 5
%109 = load %struct.addrinfo*, %struct.addrinfo** %108
store %struct.addrinfo* %109, %struct.addrinfo** %11
br label %36
110: ; preds = %36
%111 = load i32, i32* @EXIT_FAILURE
store i32 %111, i32* %4
br label %112
112: ; preds = %110, %95
%113 = load i32, i32* %4
ret i32 %113
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@EXIT_SUCCESS = constant i32 0
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str = [40 x i8] c"Successfully got target info for %s:%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@EXIT_FAILURE = global i32 0
define i32 @prepare_addrinfo(%struct.addrinfo* nocapture writeonly %0, i8* %1, i8* %2) {
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = bitcast %struct.addrinfo* %4 to i8*
%7 = load i32, i32* @AF_UNSPEC
%8 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %7, i32* %8
%9 = load i32, i32* @SOCK_DGRAM
%10 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
store i32 %9, i32* %10
%11 = load i32, i32* @IPPROTO_UDP
%12 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 2
store i32 %11, i32* %12
%13 = bitcast %struct.addrinfo** %5 to i8*
%14 = call i32 @getaddrinfo(i8* %1, i8* %2, %struct.addrinfo* %4, %struct.addrinfo** %5)
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %3
%17 = call i32 @gai_strerror(i32 %14)
%18 = call i32 @fatal(i32 %17)
br label %19
19: ; preds = %16, %3
%20 = load %struct.addrinfo*, %struct.addrinfo** %5
%21 = icmp eq %struct.addrinfo* %20, null
br i1 %21, label %74, label %22
22: ; preds = %19, %70
%23 = phi %struct.addrinfo* [ %72, %70 ], [ %20, %19 ]
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 4
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 3
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 2
%29 = load i32, i32* %28
%30 = call i32 @socket(i32 %25, i32 %27, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %70, label %32
32: ; preds = %22
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 1
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 @connect(i32 %30, i32 %34, i32 %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 @close(i32 %30)
br label %70
41: ; preds = %32
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 1
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 0
%44 = load i32, i32* @NI_MAXHOST
%45 = zext i32 %44 to i64
%46 = call i8* @llvm.stacksave()
%47 = alloca i8, i64 %45
%48 = load i32, i32* @NI_MAXSERV
%49 = zext i32 %48 to i64
%50 = alloca i8, i64 %49
%51 = load i32, i32* %42
%52 = load i32, i32* %43
%53 = load i32, i32* @NI_MAXHOST
%54 = load i32, i32* @NI_NUMERICHOST
%55 = load i32, i32* @NI_NUMERICSERV
%56 = or i32 %55, %54
%57 = call i32 @getnameinfo(i32 %51, i32 %52, i8* %47, i32 %53, i8* %50, i32 %48, i32 %56)
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %41
%60 = call i32 @log_debug(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %47, i8* %50)
br label %64
61: ; preds = %41
%62 = call i32 @gai_strerror(i32 %57)
%63 = call i32 @log_warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %61, %59
%65 = bitcast %struct.addrinfo* %0 to i8*
%66 = bitcast %struct.addrinfo* %23 to i8*
%67 = load %struct.addrinfo*, %struct.addrinfo** %5
%68 = call i32 @freeaddrinfo(%struct.addrinfo* %67)
%69 = call i32 @close(i32 %30)
br label %76
70: ; preds = %39, %22
%71 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 5
%72 = load %struct.addrinfo*, %struct.addrinfo** %71
%73 = icmp eq %struct.addrinfo* %72, null
br i1 %73, label %74, label %22
74: ; preds = %70, %19
%75 = load i32, i32* @EXIT_FAILURE
br label %76
76: ; preds = %64, %74
%77 = phi i32 [ %75, %74 ], [ 0, %64 ]
ret i32 %77
}