#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;
};
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
scalar_t__ EINPROGRESS;
int /*<<< orphan*/ FIONBIO;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int ioctl(int, int /*<<< orphan*/, int *);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int setup_tcp_client_socket(const char *host, const char *port, int nonblock) {
  struct addrinfo hints, *ais, *ai;
  int err, soc, opt;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  err = getaddrinfo(host, port, &hints, &ais);
  if (err) {
    fprintf(stderr,
            "%s: "
            "getaddrinfo: %s, host=%s, port=%s"
            " (%s:%d)\n",
            "warning", gai_strerror(err), (host ? host : "(null)"),
            (port ? port : "(null)"),
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/pandax381/rlogd/refs/heads/master/src/"
            "common.c",
            234);
    ;
    ;
    return -1;
  }
  for (ai = ais; ai; ai = ai->ai_next) {
    soc = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
    if (soc == -1) {
      fprintf(stderr,
              "%s: "
              "socket: %s"
              " (%s:%d)\n",
              "warning", strerror(errno),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/pandax381/rlogd/refs/heads/master/src/"
              "common.c",
              240);
      ;
      ;
      continue;
    }
    if (nonblock) {
      opt = 1;
      if (ioctl(soc, FIONBIO, &opt) == -1) {
        fprintf(stderr,
                "%s: "
                "ioctl [FIONBIO]: %s"
                " (%s:%d)\n",
                "warning", strerror(errno),
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/pandax381/rlogd/refs/heads/"
                "master/src/common.c",
                246);
        ;
        ;
        close(soc);
        continue;
      }
    }
    if (connect(soc, ai->ai_addr, ai->ai_addrlen) == -1) {
      if (!nonblock || errno != EINPROGRESS) {
        fprintf(stderr,
                "%s: "
                "connect: %s, host=%s, port=%s"
                " (%s:%d)\n",
                "warning", strerror(errno), (host ? host : "(null)"),
                (port ? port : "(null)"),
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/pandax381/rlogd/refs/heads/"
                "master/src/common.c",
                253);
        ;
        ;
        close(soc);
        continue;
      }
    }
    freeaddrinfo(ais);
    return soc;
  }
  freeaddrinfo(ais);
  fprintf(stderr,
          "%s: "
          "Can't create any client sockets"
          " (%s:%d)\n",
          "warning",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/pandax381/rlogd/refs/heads/master/src/"
          "common.c",
          262);
  ;
  ;
  return -1;
}


x86 assembly (clang, -O0):
<setup_tcp_client_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2def(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1090 <getaddrinfo@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     12bc <setup_tcp_client_socket+0x11c>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x54(%rbp),%edi
call   1030 <gai_strerror@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1230 <setup_tcp_client_socket+0x90>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
jmp    1240 <setup_tcp_client_socket+0xa0>
lea    0xe00(%rip),%rax
mov    %rax,-0x78(%rbp)
jmp    1240 <setup_tcp_client_socket+0xa0>
mov    -0x78(%rbp),%rax
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1263 <setup_tcp_client_socket+0xc3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
jmp    1276 <setup_tcp_client_socket+0xd6>
lea    0xdcd(%rip),%rax
mov    %rax,-0x88(%rbp)
jmp    1276 <setup_tcp_client_socket+0xd6>
mov    -0x80(%rbp),%r8
mov    -0x68(%rbp),%rcx
mov    -0x6c(%rbp),%edi
mov    -0x88(%rbp),%r9
lea    0xd71(%rip),%rsi
lea    0xd99(%rip),%rdx
lea    0xda1(%rip),%rax
mov    %rax,(%rsp)
movl   $0xea,0x8(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1554 <setup_tcp_client_socket+0x3b4>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1519 <setup_tcp_client_socket+0x379>
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x50(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%edx
call   10c0 <socket@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    1344 <setup_tcp_client_socket+0x1a4>
mov    0x2cd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    0x2cb4(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x8c(%rbp),%edi
mov    %rax,%rcx
lea    0xda3(%rip),%rsi
lea    0xd04(%rip),%rdx
lea    0xd0c(%rip),%r8
mov    $0xf0,%r9d
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1508 <setup_tcp_client_socket+0x368>
cmpl   $0x0,-0x1c(%rbp)
je     13ce <setup_tcp_client_socket+0x22e>
movl   $0x1,-0x5c(%rbp)
mov    -0x58(%rbp),%edi
mov    0x2c59(%rip),%rax
mov    (%rax),%esi
lea    -0x5c(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    13c9 <setup_tcp_client_socket+0x229>
mov    0x2c56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x90(%rbp)
mov    0x2c37(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x90(%rbp),%edi
mov    %rax,%rcx
lea    0xd3e(%rip),%rsi
lea    0xc87(%rip),%rdx
lea    0xc8f(%rip),%r8
mov    $0xf6,%r9d
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x58(%rbp),%edi
call   1060 <close@plt>
jmp    1508 <setup_tcp_client_socket+0x368>
jmp    13ce <setup_tcp_client_socket+0x22e>
mov    -0x58(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
call   1080 <connect@plt>
cmp    $0xffffffff,%eax
jne    14f4 <setup_tcp_client_socket+0x354>
cmpl   $0x0,-0x1c(%rbp)
je     1410 <setup_tcp_client_socket+0x270>
mov    0x2bc3(%rip),%rax
mov    (%rax),%rax
mov    0x2be1(%rip),%rcx
cmp    (%rcx),%rax
je     14ef <setup_tcp_client_socket+0x34f>
mov    0x2bb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9c(%rbp)
mov    0x2b9a(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1450 <setup_tcp_client_socket+0x2b0>
mov    -0x10(%rbp),%rax
mov    %rax,-0xa8(%rbp)
jmp    1463 <setup_tcp_client_socket+0x2c3>
lea    0xbe0(%rip),%rax
mov    %rax,-0xa8(%rbp)
jmp    1463 <setup_tcp_client_socket+0x2c3>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     148c <setup_tcp_client_socket+0x2ec>
mov    -0x18(%rbp),%rax
mov    %rax,-0xb8(%rbp)
jmp    149f <setup_tcp_client_socket+0x2ff>
lea    0xba4(%rip),%rax
mov    %rax,-0xb8(%rbp)
jmp    149f <setup_tcp_client_socket+0x2ff>
mov    -0xb0(%rbp),%r8
mov    -0x98(%rbp),%rcx
mov    -0x9c(%rbp),%edi
mov    -0xb8(%rbp),%r9
lea    0xc3f(%rip),%rsi
lea    0xb67(%rip),%rdx
lea    0xb6f(%rip),%rax
mov    %rax,(%rsp)
movl   $0xfd,0x8(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x58(%rbp),%edi
call   1060 <close@plt>
jmp    1508 <setup_tcp_client_socket+0x368>
jmp    14f4 <setup_tcp_client_socket+0x354>
mov    -0x48(%rbp),%rdi
call   10b0 <freeaddrinfo@plt>
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1554 <setup_tcp_client_socket+0x3b4>
mov    -0x50(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    12c4 <setup_tcp_client_socket+0x124>
mov    -0x48(%rbp),%rdi
call   10b0 <freeaddrinfo@plt>
mov    0x2aa7(%rip),%rax
mov    (%rax),%edi
lea    0xbf9(%rip),%rsi
lea    0xaf6(%rip),%rdx
lea    0xafe(%rip),%rcx
mov    $0x106,%r8d
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_tcp_client_socket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2de9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1090 <getaddrinfo@plt>
test   %eax,%eax
je     125e <setup_tcp_client_socket+0xbe>
mov    0x2dcd(%rip),%rcx
mov    (%rcx),%ebp
mov    %eax,%edi
call   1030 <gai_strerror@plt>
test   %rbx,%rbx
lea    0xe21(%rip),%rcx
cmove  %rcx,%rbx
test   %r14,%r14
cmove  %rcx,%r14
lea    0xe16(%rip),%r10
lea    0xdd1(%rip),%rsi
lea    0xdf9(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0xea
push   %r10
call   1070 <fprintf@plt>
add    $0x10,%rsp
mov    $0xffffffff,%r15d
jmp    142f <setup_tcp_client_socket+0x28f>
mov    0x8(%rsp),%r13
test   %r13,%r13
je     13e4 <setup_tcp_client_socket+0x244>
test   %r12d,%r12d
setne  0x7(%rsp)
test   %rbx,%rbx
lea    0xdb9(%rip),%rax
cmove  %rax,%rbx
test   %r14,%r14
cmove  %rax,%r14
jmp    12dc <setup_tcp_client_socket+0x13c>
nopl   0x0(%rax,%rax,1)
mov    0x2d39(%rip),%rax
mov    (%rax),%ebp
mov    0x2d20(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %ebp,%edi
lea    0xe16(%rip),%rsi
lea    0xd77(%rip),%rdx
mov    %rax,%rcx
lea    0xd7c(%rip),%r8
mov    $0xf0,%r9d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x18(%r13),%r13
test   %r13,%r13
je     13e8 <setup_tcp_client_socket+0x248>
mov    0x10(%r13),%edi
mov    0x8(%r13),%edx
mov    0xc(%r13),%esi
call   10c0 <socket@plt>
cmp    $0xffffffff,%eax
je     1290 <setup_tcp_client_socket+0xf0>
mov    %eax,%r15d
test   %r12d,%r12d
je     131d <setup_tcp_client_socket+0x17d>
movl   $0x1,0x14(%rsp)
mov    0x2caf(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
lea    0x14(%rsp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1398 <setup_tcp_client_socket+0x1f8>
mov    0x0(%r13),%edx
mov    0x4(%r13),%esi
mov    %r15d,%edi
call   1080 <connect@plt>
cmp    $0xffffffff,%eax
jne    1425 <setup_tcp_client_socket+0x285>
mov    0x2c83(%rip),%rax
mov    (%rax),%rdi
mov    0x2ca1(%rip),%rax
cmp    (%rax),%rdi
sete   %al
test   %al,0x7(%rsp)
jne    1425 <setup_tcp_client_socket+0x285>
mov    0x2c72(%rip),%rax
mov    (%rax),%ebp
call   10a0 <strerror@plt>
mov    %ebp,%edi
lea    0xd92(%rip),%rsi
lea    0xcba(%rip),%rdx
mov    %rax,%rcx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0xfd
lea    0xcb2(%rip),%rbp
push   %rbp
call   1070 <fprintf@plt>
add    $0x10,%rsp
jmp    13d7 <setup_tcp_client_socket+0x237>
mov    0x2c31(%rip),%rax
mov    (%rax),%ebp
mov    0x2c18(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %ebp,%edi
lea    0xd26(%rip),%rsi
lea    0xc6f(%rip),%rdx
mov    %rax,%rcx
lea    0xc74(%rip),%r8
mov    $0xf6,%r9d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15d,%edi
call   1060 <close@plt>
jmp    12cf <setup_tcp_client_socket+0x12f>
xor    %edi,%edi
jmp    13ed <setup_tcp_client_socket+0x24d>
mov    0x8(%rsp),%rdi
call   10b0 <freeaddrinfo@plt>
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
lea    0xd29(%rip),%rsi
lea    0xc26(%rip),%rdx
lea    0xc2e(%rip),%rcx
mov    $0x106,%r8d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%r15d
jmp    142f <setup_tcp_client_socket+0x28f>
mov    0x8(%rsp),%rdi
call   10b0 <freeaddrinfo@plt>
mov    %r15d,%eax
add    $0x38,%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* }
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [47 x i8] c"%s: getaddrinfo: %s, host=%s, port=%s (%s:%d)\0A\00"
@.str.1 = [8 x i8] c"warning\00"
@.str.2 = [7 x i8] c"(null)\00"
@.str.3 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pandax381/rlogd/refs/heads/master/src/common.c\00"
@.str.4 = [24 x i8] c"%s: socket: %s (%s:%d)\0A\00"
@errno = global i64 0
@FIONBIO = global i32 0
@.str.5 = [33 x i8] c"%s: ioctl [FIONBIO]: %s (%s:%d)\0A\00"
@EINPROGRESS = global i64 0
@.str.6 = [43 x i8] c"%s: connect: %s, host=%s, port=%s (%s:%d)\0A\00"
@.str.7 = [45 x i8] c"%s: Can't create any client sockets (%s:%d)\0A\00"
define i32 @setup_tcp_client_socket(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca %struct.addrinfo*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%14 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 32)
%15 = load i32, i32* @AF_UNSPEC
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %15, i32* %16
%17 = load i32, i32* @SOCK_STREAM
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %17, i32* %18
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = call i32 @getaddrinfo(i8* %19, i8* %20, %struct.addrinfo* %8, %struct.addrinfo** %9)
store i32 %21, i32* %11
%22 = load i32, i32* %11
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %43
24: ; preds = %3
%25 = load i32, i32* @stderr
%26 = load i32, i32* %11
%27 = call i8* @gai_strerror(i32 %26)
%28 = load i8*, i8** %5
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = load i8*, i8** %5
br label %33
32: ; preds = %24
br label %33
33: ; preds = %32, %30
%34 = phi i8* [ %31, %30 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %32 ]
%35 = load i8*, i8** %6
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i8*, i8** %6
br label %40
39: ; preds = %33
br label %40
40: ; preds = %39, %37
%41 = phi i8* [ %38, %37 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %39 ]
%42 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %34, i8* %41, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 234)
store i32 -1, i32* %4
br label %134
43: ; preds = %3
%44 = load %struct.addrinfo*, %struct.addrinfo** %9
store %struct.addrinfo* %44, %struct.addrinfo** %10
br label %45
45: ; preds = %125, %43
%46 = load %struct.addrinfo*, %struct.addrinfo** %10
%47 = icmp ne %struct.addrinfo* %46, null
br i1 %47, label %48, label %129
48: ; preds = %45
%49 = load %struct.addrinfo*, %struct.addrinfo** %10
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i32 0, i32 4
%51 = load i32, i32* %50
%52 = load %struct.addrinfo*, %struct.addrinfo** %10
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 3
%54 = load i32, i32* %53
%55 = load %struct.addrinfo*, %struct.addrinfo** %10
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 2
%57 = load i32, i32* %56
%58 = call i32 @socket(i32 %51, i32 %54, i32 %57)
store i32 %58, i32* %12
%59 = load i32, i32* %12
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %66
61: ; preds = %48
%62 = load i32, i32* @stderr
%63 = load i64, i64* @errno
%64 = call i8* @strerror(i64 %63)
%65 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %64, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 240)
br label %125
66: ; preds = %48
%67 = load i32, i32* %7
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %82
69: ; preds = %66
store i32 1, i32* %13
%70 = load i32, i32* %12
%71 = load i32, i32* @FIONBIO
%72 = call i32 @ioctl(i32 %70, i32 %71, i32* %13)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %81
74: ; preds = %69
%75 = load i32, i32* @stderr
%76 = load i64, i64* @errno
%77 = call i8* @strerror(i64 %76)
%78 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %77, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 246)
%79 = load i32, i32* %12
%80 = call i32 @close(i32 %79)
br label %125
81: ; preds = %69
br label %82
82: ; preds = %81, %66
%83 = load i32, i32* %12
%84 = load %struct.addrinfo*, %struct.addrinfo** %10
%85 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %84, i32 0, i32 1
%86 = load i32, i32* %85
%87 = load %struct.addrinfo*, %struct.addrinfo** %10
%88 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %87, i32 0, i32 0
%89 = load i32, i32* %88
%90 = call i32 @connect(i32 %83, i32 %86, i32 %89)
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %121
92: ; preds = %82
%93 = load i32, i32* %7
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %92
%96 = load i64, i64* @errno
%97 = load i64, i64* @EINPROGRESS
%98 = icmp ne i64 %96, %97
br i1 %98, label %99, label %120
99: ; preds = %95, %92
%100 = load i32, i32* @stderr
%101 = load i64, i64* @errno
%102 = call i8* @strerror(i64 %101)
%103 = load i8*, i8** %5
%104 = icmp ne i8* %103, null
br i1 %104, label %105, label %107
105: ; preds = %99
%106 = load i8*, i8** %5
br label %108
107: ; preds = %99
br label %108
108: ; preds = %107, %105
%109 = phi i8* [ %106, %105 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %107 ]
%110 = load i8*, i8** %6
%111 = icmp ne i8* %110, null
br i1 %111, label %112, label %114
112: ; preds = %108
%113 = load i8*, i8** %6
br label %115
114: ; preds = %108
br label %115
115: ; preds = %114, %112
%116 = phi i8* [ %113, %112 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %114 ]
%117 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %102, i8* %109, i8* %116, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 253)
%118 = load i32, i32* %12
%119 = call i32 @close(i32 %118)
br label %125
120: ; preds = %95
br label %121
121: ; preds = %120, %82
%122 = load %struct.addrinfo*, %struct.addrinfo** %9
%123 = call i32 @freeaddrinfo(%struct.addrinfo* %122)
%124 = load i32, i32* %12
store i32 %124, i32* %4
br label %134
125: ; preds = %115, %74, %61
%126 = load %struct.addrinfo*, %struct.addrinfo** %10
%127 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %126, i32 0, i32 5
%128 = load %struct.addrinfo*, %struct.addrinfo** %127
store %struct.addrinfo* %128, %struct.addrinfo** %10
br label %45
129: ; preds = %45
%130 = load %struct.addrinfo*, %struct.addrinfo** %9
%131 = call i32 @freeaddrinfo(%struct.addrinfo* %130)
%132 = load i32, i32* @stderr
%133 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 262)
store i32 -1, i32* %4
br label %134
134: ; preds = %129, %121, %40
%135 = load i32, i32* %4
ret i32 %135
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [47 x i8] c"%s: getaddrinfo: %s, host=%s, port=%s (%s:%d)\0A\00"
@.str.1 = [8 x i8] c"warning\00"
@.str.2 = [7 x i8] c"(null)\00"
@.str.3 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pandax381/rlogd/refs/heads/master/src/common.c\00"
@.str.4 = [24 x i8] c"%s: socket: %s (%s:%d)\0A\00"
@errno = global i64 0
@FIONBIO = global i32 0
@.str.5 = [33 x i8] c"%s: ioctl [FIONBIO]: %s (%s:%d)\0A\00"
@EINPROGRESS = global i64 0
@.str.6 = [43 x i8] c"%s: connect: %s, host=%s, port=%s (%s:%d)\0A\00"
@.str.7 = [45 x i8] c"%s: Can't create any client sockets (%s:%d)\0A\00"
define i32 @setup_tcp_client_socket(i8* %0, i8* %1, i32 %2) {
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = alloca i32
%7 = bitcast %struct.addrinfo* %4 to i8*
%8 = bitcast %struct.addrinfo** %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 32)
%11 = load i32, i32* @AF_UNSPEC
%12 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %11, i32* %12
%13 = load i32, i32* @SOCK_STREAM
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
store i32 %13, i32* %14
%15 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %4, %struct.addrinfo** %5)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %3
%18 = load %struct.addrinfo*, %struct.addrinfo** %5
%19 = icmp eq %struct.addrinfo* %18, null
br i1 %19, label %87, label %20
20: ; preds = %17
%21 = icmp eq i32 %2, 0
%22 = icmp eq i8* %0, null
%23 = select i1 %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0
%24 = icmp eq i8* %1, null
%25 = select i1 %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %1
%26 = xor i1 %21, true
br label %35
27: ; preds = %3
%28 = load i32, i32* @stderr
%29 = call i8* @gai_strerror(i32 %15)
%30 = icmp eq i8* %0, null
%31 = select i1 %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0
%32 = icmp eq i8* %1, null
%33 = select i1 %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %1
%34 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %31, i8* %33, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 234)
br label %92
35: ; preds = %20, %81
%36 = phi %struct.addrinfo* [ %18, %20 ], [ %83, %81 ]
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 4
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 3
%40 = load i32, i32* %39
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 2
%42 = load i32, i32* %41
%43 = call i32 @socket(i32 %38, i32 %40, i32 %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %50
45: ; preds = %35
%46 = load i32, i32* @stderr
%47 = load i64, i64* @errno
%48 = call i8* @strerror(i64 %47)
%49 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %48, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 240)
br label %81
50: ; preds = %35
br i1 %21, label %61, label %51
51: ; preds = %50
store i32 1, i32* %6
%52 = load i32, i32* @FIONBIO
%53 = call i32 @ioctl(i32 %43, i32 %52, i32* %6)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %61
55: ; preds = %51
%56 = load i32, i32* @stderr
%57 = load i64, i64* @errno
%58 = call i8* @strerror(i64 %57)
%59 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %58, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 246)
%60 = call i32 @close(i32 %43)
br label %81
61: ; preds = %51, %50
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 1
%63 = load i32, i32* %62
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 0
%65 = load i32, i32* %64
%66 = call i32 @connect(i32 %43, i32 %63, i32 %65)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %78
68: ; preds = %61
%69 = load i64, i64* @errno
%70 = load i64, i64* @EINPROGRESS
%71 = icmp eq i64 %69, %70
%72 = select i1 %26, i1 %71, i1 false
br i1 %72, label %78, label %73
73: ; preds = %68
%74 = load i32, i32* @stderr
%75 = call i8* @strerror(i64 %69)
%76 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %75, i8* %23, i8* %25, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 253)
%77 = call i32 @close(i32 %43)
br label %81
78: ; preds = %68, %61
%79 = load %struct.addrinfo*, %struct.addrinfo** %5
%80 = call i32 @freeaddrinfo(%struct.addrinfo* %79)
br label %92
81: ; preds = %73, %55, %45
%82 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 5
%83 = load %struct.addrinfo*, %struct.addrinfo** %82
%84 = icmp eq %struct.addrinfo* %83, null
br i1 %84, label %85, label %35
85: ; preds = %81
%86 = load %struct.addrinfo*, %struct.addrinfo** %5
br label %87
87: ; preds = %85, %17
%88 = phi %struct.addrinfo* [ %86, %85 ], [ null, %17 ]
%89 = call i32 @freeaddrinfo(%struct.addrinfo* %88)
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 262)
br label %92
92: ; preds = %87, %78, %27
%93 = phi i32 [ -1, %27 ], [ %43, %78 ], [ -1, %87 ]
ret i32 %93
}