#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 sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct addrinfo {
  scalar_t__ ai_family;
  int ai_addrlen;
  char *ai_canonname;
  struct addrinfo *ai_next;
  scalar_t__ ai_addr;
};
typedef int /*<<< orphan*/ hints;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ AF_INET;
int EAI_SYSTEM;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ gai_strerror(int);
int getaddrinfo(char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                struct addrinfo **);
char *inet_ntop(scalar_t__, void const *, char *, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_errlog(char *, int, int /*<<< orphan*/, char *,
                                char *);
int /*<<< orphan*/ print_log(char *, char *, ...);
int fill_sockaddr(char *host, struct sockaddr_in *addr) {
  struct addrinfo hints;
  struct addrinfo *res, *info;
  int s;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_INET;
  res = NULL;
  s = getaddrinfo(host, NULL, NULL, &res);
  if (s == 0) {
    info = res;
    while (info) {
      if (info->ai_family == AF_INET && info->ai_addr &&
          info->ai_addrlen >= sizeof(*addr)) {
        struct sockaddr_in *in = (struct sockaddr_in *)info->ai_addr;
        const char *ip;
        char buf[INET_ADDRSTRLEN * 2];
        addr->sin_family = in->sin_family;
        addr->sin_addr = in->sin_addr;
        ip =
            inet_ntop(AF_INET, (const void *)&addr->sin_addr, buf, sizeof(buf));
        print_log("Address for host. host=%s addr=%s canonicalname=%s", host,
                  ip ? ip : "null",
                  info->ai_canonname ? info->ai_canonname : "null");
        break;
      }
      info = info->ai_next;
    }
    if (info == NULL) {
      print_log("No addresses for the host. host=%s", host);
      s = -1;
    }
  } else {
    if (s == EAI_SYSTEM) {
      do {
        print_errlog("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/jam2in/arcus-misc/refs/"
                     "heads/master/acp-c/common.c",
                     418, errno,
                     "Failed to get the address of the host. host=%s", host);
      } while (0);
    } else {
      print_log("Failed to get the address of the host. host=%s error=%s", host,
                gai_strerror(s));
    }
    s = -1;
  }
  if (res)
    freeaddrinfo(res);
  return s;
}


x86 assembly (clang, -O0):
<fill_sockaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x40(%rbp),%rcx
mov    %rdx,%rsi
call   1080 <getaddrinfo@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jne    1355 <fill_sockaddr+0x1e5>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     132c <fill_sockaddr+0x1bc>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    0x2dfd(%rip),%rcx
cmp    (%rcx),%rax
jne    131b <fill_sockaddr+0x1ab>
mov    -0x48(%rbp),%rax
cmpq   $0x0,0x20(%rax)
je     131b <fill_sockaddr+0x1ab>
mov    -0x48(%rbp),%rax
movslq 0x8(%rax),%rax
cmp    $0x8,%rax
jb     131b <fill_sockaddr+0x1ab>
mov    -0x48(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x58(%rbp)
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,%rsp
mov    %rax,-0x70(%rbp)
mov    -0x58(%rbp),%rcx
mov    0x4(%rcx),%esi
mov    -0x10(%rbp),%rcx
mov    %esi,0x4(%rcx)
mov    -0x58(%rbp),%rcx
mov    (%rcx),%esi
mov    -0x10(%rbp),%rcx
mov    %esi,(%rcx)
mov    0x2d7c(%rip),%rcx
mov    (%rcx),%rdi
mov    -0x10(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     129e <fill_sockaddr+0x12e>
mov    -0x60(%rbp),%rax
mov    %rax,-0x80(%rbp)
jmp    12ae <fill_sockaddr+0x13e>
lea    0xd8e(%rip),%rax
mov    %rax,-0x80(%rbp)
jmp    12ae <fill_sockaddr+0x13e>
mov    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x48(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     12dc <fill_sockaddr+0x16c>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x90(%rbp)
jmp    12ef <fill_sockaddr+0x17f>
lea    0xd50(%rip),%rax
mov    %rax,-0x90(%rbp)
jmp    12ef <fill_sockaddr+0x17f>
mov    -0x88(%rbp),%rdx
mov    -0x78(%rbp),%rsi
mov    -0x90(%rbp),%rcx
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1040 <print_log@plt>
mov    -0x68(%rbp),%rax
mov    %rax,%rsp
jmp    132c <fill_sockaddr+0x1bc>
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    11d2 <fill_sockaddr+0x62>
cmpq   $0x0,-0x48(%rbp)
jne    1350 <fill_sockaddr+0x1e0>
mov    -0x8(%rbp),%rsi
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1040 <print_log@plt>
movl   $0xffffffff,-0x4c(%rbp)
jmp    13c7 <fill_sockaddr+0x257>
mov    -0x4c(%rbp),%eax
mov    0x2c81(%rip),%rcx
cmp    (%rcx),%eax
jne    1396 <fill_sockaddr+0x226>
jmp    136c <fill_sockaddr+0x1fc>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%r8
lea    0xcdb(%rip),%rdi
mov    $0x1a2,%esi
lea    0xd5c(%rip),%rcx
call   1070 <print_errlog@plt>
jmp    13c0 <fill_sockaddr+0x250>
mov    -0x8(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x4c(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1040 <print_log@plt>
movl   $0xffffffff,-0x4c(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     13db <fill_sockaddr+0x26b>
mov    -0x40(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x4c(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_sockaddr>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
mov    0x2e4a(%rip),%r12
mov    (%r12),%rax
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x30(%rbp)
lea    -0x30(%rbp),%rcx
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <getaddrinfo@plt>
test   %eax,%eax
je     11fa <fill_sockaddr+0x8a>
mov    0x2e17(%rip),%rcx
cmp    (%rcx),%eax
jne    12ab <fill_sockaddr+0x13b>
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
lea    0xe7a(%rip),%rdi
lea    0xf00(%rip),%rcx
mov    $0x1a2,%esi
mov    %r15,%r8
call   1070 <print_errlog@plt>
jmp    12c5 <fill_sockaddr+0x155>
mov    -0x30(%rbp),%rbx
test   %rbx,%rbx
je     1298 <fill_sockaddr+0x128>
mov    (%r12),%rcx
jmp    1219 <fill_sockaddr+0xa9>
nopl   (%rax)
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
je     1298 <fill_sockaddr+0x128>
cmp    %rcx,(%rbx)
jne    1210 <fill_sockaddr+0xa0>
mov    0x20(%rbx),%rax
test   %rax,%rax
je     1210 <fill_sockaddr+0xa0>
cmpl   $0x8,0x8(%rbx)
jb     1210 <fill_sockaddr+0xa0>
mov    %rsp,%r13
mov    0x2d91(%rip),%rcx
mov    (%rcx),%ecx
add    %ecx,%ecx
mov    %rsp,%rdx
lea    0xf(%rcx),%rsi
and    $0xfffffffffffffff0,%rsi
sub    %rsi,%rdx
mov    %rdx,%rsp
mov    0x4(%rax),%esi
mov    %esi,0x4(%r14)
mov    (%rax),%eax
mov    %eax,(%r14)
mov    (%r12),%rdi
mov    %r14,%rsi
call   1030 <inet_ntop@plt>
test   %rax,%rax
lea    0xdc5(%rip),%rdx
cmove  %rdx,%rax
mov    0x10(%rbx),%rcx
test   %rcx,%rcx
cmove  %rdx,%rcx
lea    0xd7c(%rip),%rdi
xor    %ebx,%ebx
mov    %r15,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <print_log@plt>
mov    %r13,%rsp
jmp    12ca <fill_sockaddr+0x15a>
lea    0xd99(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <print_log@plt>
jmp    12c5 <fill_sockaddr+0x155>
mov    %eax,%edi
call   1050 <gai_strerror@plt>
lea    0xe5e(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <print_log@plt>
mov    $0xffffffff,%ebx
mov    -0x30(%rbp),%rdi
test   %rdi,%rdi
je     12d8 <fill_sockaddr+0x168>
call   1090 <freeaddrinfo@plt>
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.addrinfo = type { i64, i32, i8*, %struct.addrinfo*, i64 }
@AF_INET = global i64 0
@INET_ADDRSTRLEN = global i32 0
@.str = [51 x i8] c"Address for host. host=%s addr=%s canonicalname=%s\00"
@.str.1 = [5 x i8] c"null\00"
@.str.2 = [35 x i8] c"No addresses for the host. host=%s\00"
@EAI_SYSTEM = global i32 0
@.str.3 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jam2in/arcus-misc/refs/heads/master/acp-c/common.c\00"
@errno = global i32 0
@.str.4 = [47 x i8] c"Failed to get the address of the host. host=%s\00"
@.str.5 = [56 x i8] c"Failed to get the address of the host. host=%s error=%s\00"
define i32 @fill_sockaddr(i8* %0, %struct.sockaddr_in* %1) {
%3 = alloca i8*
%4 = alloca %struct.sockaddr_in*
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = alloca %struct.addrinfo*
%8 = alloca i32
%9 = alloca %struct.sockaddr_in*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
store i8* %0, i8** %3
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %4
%13 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 40)
%14 = load i64, i64* @AF_INET
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 0
store i64 %14, i64* %15
store %struct.addrinfo* null, %struct.addrinfo** %6
%16 = load i8*, i8** %3
%17 = call i32 @getaddrinfo(i8* %16, i32* null, i32* null, %struct.addrinfo** %6)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %100
20: ; preds = %2
%21 = load %struct.addrinfo*, %struct.addrinfo** %6
store %struct.addrinfo* %21, %struct.addrinfo** %7
br label %22
22: ; preds = %89, %20
%23 = load %struct.addrinfo*, %struct.addrinfo** %7
%24 = icmp ne %struct.addrinfo* %23, null
br i1 %24, label %25, label %93
25: ; preds = %22
%26 = load %struct.addrinfo*, %struct.addrinfo** %7
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = load i64, i64* @AF_INET
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %89
31: ; preds = %25
%32 = load %struct.addrinfo*, %struct.addrinfo** %7
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i32 0, i32 4
%34 = load i64, i64* %33
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %89
36: ; preds = %31
%37 = load %struct.addrinfo*, %struct.addrinfo** %7
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i32 0, i32 1
%39 = load i32, i32* %38
%40 = sext i32 %39 to i64
%41 = icmp uge i64 %40, 8
br i1 %41, label %42, label %89
42: ; preds = %36
%43 = load %struct.addrinfo*, %struct.addrinfo** %7
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i32 0, i32 4
%45 = load i64, i64* %44
%46 = inttoptr i64 %45 to %struct.sockaddr_in*
store %struct.sockaddr_in* %46, %struct.sockaddr_in** %9
%47 = load i32, i32* @INET_ADDRSTRLEN
%48 = mul nsw i32 %47, 2
%49 = zext i32 %48 to i64
%50 = call i8* @llvm.stacksave()
store i8* %50, i8** %11
%51 = alloca i8, i64 %49
store i64 %49, i64* %12
%52 = load %struct.sockaddr_in*, %struct.sockaddr_in** %9
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %52, i32 0, i32 1
%54 = load i32, i32* %53
%55 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %55, i32 0, i32 1
store i32 %54, i32* %56
%57 = load %struct.sockaddr_in*, %struct.sockaddr_in** %9
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %57, i32 0, i32 0
%59 = load i32, i32* %58
%60 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %60, i32 0, i32 0
store i32 %59, i32* %61
%62 = load i64, i64* @AF_INET
%63 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%64 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %63, i32 0, i32 0
%65 = bitcast i32* %64 to i8*
%66 = trunc i64 %49 to i32
%67 = call i8* @inet_ntop(i64 %62, i8* %65, i8* %51, i32 %66)
store i8* %67, i8** %10
%68 = load i8*, i8** %3
%69 = load i8*, i8** %10
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %73
71: ; preds = %42
%72 = load i8*, i8** %10
br label %74
73: ; preds = %42
br label %74
74: ; preds = %73, %71
%75 = phi i8* [ %72, %71 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %73 ]
%76 = load %struct.addrinfo*, %struct.addrinfo** %7
%77 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %76, i32 0, i32 2
%78 = load i8*, i8** %77
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %84
80: ; preds = %74
%81 = load %struct.addrinfo*, %struct.addrinfo** %7
%82 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %81, i32 0, i32 2
%83 = load i8*, i8** %82
br label %85
84: ; preds = %74
br label %85
85: ; preds = %84, %80
%86 = phi i8* [ %83, %80 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %84 ]
%87 = call i32 (i8*, i8*, ...) @print_log(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %68, i8* %75, i8* %86)
%88 = load i8*, i8** %11
br label %93
89: ; preds = %36, %31, %25
%90 = load %struct.addrinfo*, %struct.addrinfo** %7
%91 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %90, i32 0, i32 3
%92 = load %struct.addrinfo*, %struct.addrinfo** %91
store %struct.addrinfo* %92, %struct.addrinfo** %7
br label %22
93: ; preds = %85, %22
%94 = load %struct.addrinfo*, %struct.addrinfo** %7
%95 = icmp eq %struct.addrinfo* %94, null
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = load i8*, i8** %3
%98 = call i32 (i8*, i8*, ...) @print_log(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %97)
store i32 -1, i32* %8
br label %99
99: ; preds = %96, %93
br label %116
100: ; preds = %2
%101 = load i32, i32* %8
%102 = load i32, i32* @EAI_SYSTEM
%103 = icmp eq i32 %101, %102
br i1 %103, label %104, label %110
104: ; preds = %100
br label %105
105: ; preds = %104
%106 = load i32, i32* @errno
%107 = load i8*, i8** %3
%108 = call i32 @print_errlog(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.3, i64 0, i64 0), i32 418, i32 %106, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %107)
br label %109
109: ; preds = %105
br label %115
110: ; preds = %100
%111 = load i8*, i8** %3
%112 = load i32, i32* %8
%113 = call i32 @gai_strerror(i32 %112)
%114 = call i32 (i8*, i8*, ...) @print_log(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %111, i32 %113)
br label %115
115: ; preds = %110, %109
store i32 -1, i32* %8
br label %116
116: ; preds = %115, %99
%117 = load %struct.addrinfo*, %struct.addrinfo** %6
%118 = icmp ne %struct.addrinfo* %117, null
br i1 %118, label %119, label %122
119: ; preds = %116
%120 = load %struct.addrinfo*, %struct.addrinfo** %6
%121 = call i32 @freeaddrinfo(%struct.addrinfo* %120)
br label %122
122: ; preds = %119, %116
%123 = load i32, i32* %8
ret i32 %123
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.addrinfo = type { i64, i32, i8*, %struct.addrinfo*, i64 }
@AF_INET = global i64 0
@INET_ADDRSTRLEN = global i32 0
@.str = [51 x i8] c"Address for host. host=%s addr=%s canonicalname=%s\00"
@.str.1 = [5 x i8] c"null\00"
@.str.2 = [35 x i8] c"No addresses for the host. host=%s\00"
@EAI_SYSTEM = global i32 0
@.str.3 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jam2in/arcus-misc/refs/heads/master/acp-c/common.c\00"
@errno = global i32 0
@.str.4 = [47 x i8] c"Failed to get the address of the host. host=%s\00"
@.str.5 = [56 x i8] c"Failed to get the address of the host. host=%s error=%s\00"
define i32 @fill_sockaddr(i8* %0, %struct.sockaddr_in* %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = bitcast %struct.addrinfo* %3 to i8*
%6 = bitcast %struct.addrinfo** %4 to i8*
%7 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 40)
%8 = load i64, i64* @AF_INET
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 0
store i64 %8, i64* %9
store %struct.addrinfo* null, %struct.addrinfo** %4
%10 = call i32 @getaddrinfo(i8* %0, i32* null, i32* null, %struct.addrinfo** %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %59
12: ; preds = %2
%13 = load %struct.addrinfo*, %struct.addrinfo** %4
%14 = icmp eq %struct.addrinfo* %13, null
br i1 %14, label %57, label %15
15: ; preds = %12
%16 = load i64, i64* @AF_INET
br label %17
17: ; preds = %15, %53
%18 = phi %struct.addrinfo* [ %13, %15 ], [ %55, %53 ]
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i64 0, i32 0
%20 = load i64, i64* %19
%21 = icmp eq i64 %20, %16
br i1 %21, label %22, label %53
22: ; preds = %17
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i64 0, i32 4
%24 = load i64, i64* %23
%25 = icmp eq i64 %24, 0
br i1 %25, label %53, label %26
26: ; preds = %22
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i64 0, i32 1
%28 = load i32, i32* %27
%29 = icmp ugt i32 %28, 7
br i1 %29, label %30, label %53
30: ; preds = %26
%31 = inttoptr i64 %24 to %struct.sockaddr_in*
%32 = load i32, i32* @INET_ADDRSTRLEN
%33 = shl nsw i32 %32, 1
%34 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
%36 = alloca i8, i64 %34
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %31, i64 0, i32 1
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %38, i32* %39
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %31, i64 0, i32 0
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %41, i32* %42
%43 = load i64, i64* @AF_INET
%44 = bitcast %struct.sockaddr_in* %1 to i8*
%45 = call i8* @inet_ntop(i64 %43, i8* %44, i8* %36, i32 %33)
%46 = icmp eq i8* %45, null
%47 = select i1 %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %45
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i64 0, i32 2
%49 = load i8*, i8** %48
%50 = icmp eq i8* %49, null
%51 = select i1 %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %49
%52 = call i32 (i8*, i8*, ...) @print_log(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %47, i8* %51)
br label %68
53: ; preds = %26, %22, %17
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i64 0, i32 3
%55 = load %struct.addrinfo*, %struct.addrinfo** %54
%56 = icmp eq %struct.addrinfo* %55, null
br i1 %56, label %57, label %17
57: ; preds = %53, %12
%58 = call i32 (i8*, i8*, ...) @print_log(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %68
59: ; preds = %2
%60 = load i32, i32* @EAI_SYSTEM
%61 = icmp eq i32 %10, %60
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i32, i32* @errno
%64 = call i32 @print_errlog(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.3, i64 0, i64 0), i32 418, i32 %63, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %68
65: ; preds = %59
%66 = call i32 @gai_strerror(i32 %10)
%67 = call i32 (i8*, i8*, ...) @print_log(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %66)
br label %68
68: ; preds = %30, %62, %65, %57
%69 = phi i32 [ -1, %57 ], [ 0, %30 ], [ -1, %65 ], [ -1, %62 ]
%70 = load %struct.addrinfo*, %struct.addrinfo** %4
%71 = icmp eq %struct.addrinfo* %70, null
br i1 %71, label %74, label %72
72: ; preds = %68
%73 = call i32 @freeaddrinfo(%struct.addrinfo* %70)
br label %74
74: ; preds = %72, %68
ret i32 %69
}