#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 szl_stream_ops {
  int dummy;
};
struct szl_stream {
  int dummy;
};
struct szl_interp {
  int dummy;
};
struct addrinfo {
  int ai_socktype;
  scalar_t__ ai_addrlen;
  int /*<<< orphan*/ *ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ *ai_next;
  int /*<<< orphan*/ *ai_canonname;
  scalar_t__ ai_flags;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int EINPROGRESS;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int const SOCK_NONBLOCK;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, int /*<<< orphan*/ *, scalar_t__);
int errno;
int fcntl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ getaddrinfo(char const *, char const *, struct addrinfo *,
                       struct addrinfo **);
int socket(int /*<<< orphan*/, int const, scalar_t__);
int /*<<< orphan*/ szl_set_last_strerror(struct szl_interp *, int);
struct szl_stream *szl_socket_new(struct szl_interp *, int,
                                  int /*<<< orphan*/ *, scalar_t__,
                                  struct szl_stream_ops const *,
                                  unsigned int const);
struct szl_stream *szl_socket_new_client(struct szl_interp *interp,
                                         const char *host, const char *service,
                                         const int type, const int sflags,
                                         const struct szl_stream_ops *ops,
                                         const unsigned int flags) {
  struct addrinfo hints, *res;
  struct szl_stream *strm;
  int fd, fl, err;
  hints.ai_flags = 0;
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = type;
  hints.ai_protocol = 0;
  hints.ai_addrlen = 0;
  hints.ai_addr = NULL;
  hints.ai_canonname = NULL;
  hints.ai_next = NULL;
  if (getaddrinfo(host, service, &hints, &res) != 0)
    return NULL;
  fd = socket(res->ai_family, res->ai_socktype | sflags, res->ai_protocol);
  if (fd < 0) {
    err = errno;
    freeaddrinfo(res);
    szl_set_last_strerror(interp, err);
    return NULL;
  }
  if (sflags & SOCK_NONBLOCK) {
    fl = fcntl(fd, F_GETFL);
    if (fl < 0) {
      err = errno;
      freeaddrinfo(res);
      szl_set_last_strerror(interp, err);
      return NULL;
    }
    if (((connect(fd, res->ai_addr, res->ai_addrlen) < 0) &&
         (errno != EINPROGRESS)) ||
        (fcntl(fd, F_SETFL, fl & ~O_NONBLOCK) < 0)) {
      err = errno;
      close(fd);
      freeaddrinfo(res);
      szl_set_last_strerror(interp, err);
      return NULL;
    }
  } else if (connect(fd, res->ai_addr, res->ai_addrlen) < 0) {
    err = errno;
    close(fd);
    freeaddrinfo(res);
    szl_set_last_strerror(interp, err);
    return NULL;
  }
  strm = szl_socket_new(interp, fd, res->ai_addr, res->ai_addrlen, ops, flags);
  if (!strm)
    close(fd);
  freeaddrinfo(res);
  return strm;
}


x86 assembly (clang, -O0):
<szl_socket_new_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x70(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    -0x78(%rbp),%rcx
call   1080 <getaddrinfo@plt>
cmp    $0x0,%rax
je     1213 <szl_socket_new_client+0x93>
movq   $0x0,-0x8(%rbp)
jmp    1458 <szl_socket_new_client+0x2d8>
mov    -0x78(%rbp),%rax
mov    0x20(%rax),%edi
mov    -0x78(%rbp),%rax
mov    (%rax),%esi
or     -0x28(%rbp),%esi
mov    -0x78(%rbp),%rax
mov    0x18(%rax),%rdx
call   10a0 <socket@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    1277 <szl_socket_new_client+0xf7>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x78(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8c(%rbp),%esi
call   1050 <szl_set_last_strerror@plt>
movq   $0x0,-0x8(%rbp)
jmp    1458 <szl_socket_new_client+0x2d8>
mov    -0x28(%rbp),%eax
mov    0x2d47(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     139d <szl_socket_new_client+0x21d>
mov    -0x84(%rbp),%edi
mov    0x2d17(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x0,-0x88(%rbp)
jge    12e9 <szl_socket_new_client+0x169>
mov    0x2cfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x78(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8c(%rbp),%esi
call   1050 <szl_set_last_strerror@plt>
movq   $0x0,-0x8(%rbp)
jmp    1458 <szl_socket_new_client+0x2d8>
mov    -0x84(%rbp),%edi
mov    -0x78(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x78(%rbp),%rax
mov    0x8(%rax),%rdx
call   1070 <connect@plt>
cmp    $0x0,%rax
jge    1326 <szl_socket_new_client+0x1a6>
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
mov    0x2cc2(%rip),%rcx
cmp    (%rcx),%eax
jne    1359 <szl_socket_new_client+0x1d9>
mov    -0x84(%rbp),%edi
mov    0x2c8d(%rip),%rax
mov    (%rax),%esi
mov    -0x88(%rbp),%edx
mov    0x2ca6(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmp    $0x0,%eax
jge    1398 <szl_socket_new_client+0x218>
mov    0x2c58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x84(%rbp),%edi
call   1040 <close@plt>
mov    -0x78(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8c(%rbp),%esi
call   1050 <szl_set_last_strerror@plt>
movq   $0x0,-0x8(%rbp)
jmp    1458 <szl_socket_new_client+0x2d8>
jmp    1406 <szl_socket_new_client+0x286>
mov    -0x84(%rbp),%edi
mov    -0x78(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x78(%rbp),%rax
mov    0x8(%rax),%rdx
call   1070 <connect@plt>
cmp    $0x0,%rax
jge    1401 <szl_socket_new_client+0x281>
mov    0x2bef(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x84(%rbp),%edi
call   1040 <close@plt>
mov    -0x78(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8c(%rbp),%esi
call   1050 <szl_set_last_strerror@plt>
movq   $0x0,-0x8(%rbp)
jmp    1458 <szl_socket_new_client+0x2d8>
jmp    1406 <szl_socket_new_client+0x286>
mov    -0x10(%rbp),%rdi
mov    -0x84(%rbp),%esi
mov    -0x78(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x78(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9d
call   1060 <szl_socket_new@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
jne    1447 <szl_socket_new_client+0x2c7>
mov    -0x84(%rbp),%edi
call   1040 <close@plt>
mov    -0x78(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x80(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<szl_socket_new_client>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %r9,%r14
mov    %r8d,%ebp
mov    %rdi,%rbx
movq   $0x0,0x48(%rsp)
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    %ecx,0x10(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rsp)
movq   $0x0,0x28(%rsp)
movups %xmm0,0x38(%rsp)
lea    0x10(%rsp),%rax
lea    0x8(%rsp),%rcx
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rax,%rdx
call   1070 <getaddrinfo@plt>
test   %rax,%rax
jne    1280 <szl_socket_new_client+0x110>
mov    0x8(%rsp),%rax
mov    0x20(%rax),%edi
or     (%rax),%ebp
mov    0x18(%rax),%rdx
mov    %ebp,%esi
call   1090 <socket@plt>
test   %eax,%eax
js     1240 <szl_socket_new_client+0xd0>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
mov    0x8(%rax),%rdx
mov    0x10(%rax),%rsi
mov    %ebp,%edi
call   1060 <connect@plt>
test   %rax,%rax
js     125a <szl_socket_new_client+0xea>
mov    0x70(%rsp),%r9d
mov    0x8(%rsp),%rax
mov    0x8(%rax),%rcx
mov    0x10(%rax),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%r8
call   1050 <szl_socket_new@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1234 <szl_socket_new_client+0xc4>
mov    %ebp,%edi
call   1030 <close@plt>
mov    0x8(%rsp),%rdi
call   1080 <freeaddrinfo@plt>
jmp    1282 <szl_socket_new_client+0x112>
mov    0x2d91(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rsp),%rdi
call   1080 <freeaddrinfo@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
jmp    127b <szl_socket_new_client+0x10b>
mov    0x2d77(%rip),%rax
mov    (%rax),%r14d
mov    %ebp,%edi
call   1030 <close@plt>
mov    0x8(%rsp),%rdi
call   1080 <freeaddrinfo@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <szl_set_last_strerror@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.szl_stream = type { i32 }
%struct.szl_interp = type { i32 }
%struct.szl_stream_ops = type { i32 }
%struct.addrinfo = type { i32, i64, i32*, i64, i32, i32*, i32*, i64 }
@AF_UNSPEC = global i32 0
@errno = global i32 0
@SOCK_NONBLOCK = constant i32 0
@F_GETFL = global i32 0
@EINPROGRESS = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define %struct.szl_stream* @szl_socket_new_client(%struct.szl_interp* %0, i8* %1, i8* %2, i32 %3, i32 %4, %struct.szl_stream_ops* %5, i32 %6) {
%8 = alloca %struct.szl_stream*
%9 = alloca %struct.szl_interp*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.szl_stream_ops*
%15 = alloca i32
%16 = alloca %struct.addrinfo
%17 = alloca %struct.addrinfo*
%18 = alloca %struct.szl_stream*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store %struct.szl_interp* %0, %struct.szl_interp** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store %struct.szl_stream_ops* %5, %struct.szl_stream_ops** %14
store i32 %6, i32* %15
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 7
store i64 0, i64* %22
%23 = load i32, i32* @AF_UNSPEC
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 4
store i32 %23, i32* %24
%25 = load i32, i32* %12
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 0
store i32 %25, i32* %26
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 3
store i64 0, i64* %27
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 1
store i64 0, i64* %28
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 2
store i32* null, i32** %29
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 6
store i32* null, i32** %30
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 5
store i32* null, i32** %31
%32 = load i8*, i8** %10
%33 = load i8*, i8** %11
%34 = call i64 @getaddrinfo(i8* %32, i8* %33, %struct.addrinfo* %16, %struct.addrinfo** %17)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %7
store %struct.szl_stream* null, %struct.szl_stream** %8
br label %151
37: ; preds = %7
%38 = load %struct.addrinfo*, %struct.addrinfo** %17
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i32 0, i32 4
%40 = load i32, i32* %39
%41 = load %struct.addrinfo*, %struct.addrinfo** %17
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i32 0, i32 0
%43 = load i32, i32* %42
%44 = load i32, i32* %13
%45 = or i32 %43, %44
%46 = load %struct.addrinfo*, %struct.addrinfo** %17
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i32 0, i32 3
%48 = load i64, i64* %47
%49 = call i32 @socket(i32 %40, i32 %45, i64 %48)
store i32 %49, i32* %19
%50 = load i32, i32* %19
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %37
%53 = load i32, i32* @errno
store i32 %53, i32* %21
%54 = load %struct.addrinfo*, %struct.addrinfo** %17
%55 = call i32 @freeaddrinfo(%struct.addrinfo* %54)
%56 = load %struct.szl_interp*, %struct.szl_interp** %9
%57 = load i32, i32* %21
%58 = call i32 @szl_set_last_strerror(%struct.szl_interp* %56, i32 %57)
store %struct.szl_stream* null, %struct.szl_stream** %8
br label %151
59: ; preds = %37
%60 = load i32, i32* %13
%61 = load i32, i32* @SOCK_NONBLOCK
%62 = and i32 %60, %61
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %110
64: ; preds = %59
%65 = load i32, i32* %19
%66 = load i32, i32* @F_GETFL
%67 = call i32 (i32, i32, ...) @fcntl(i32 %65, i32 %66)
store i32 %67, i32* %20
%68 = load i32, i32* %20
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %77
70: ; preds = %64
%71 = load i32, i32* @errno
store i32 %71, i32* %21
%72 = load %struct.addrinfo*, %struct.addrinfo** %17
%73 = call i32 @freeaddrinfo(%struct.addrinfo* %72)
%74 = load %struct.szl_interp*, %struct.szl_interp** %9
%75 = load i32, i32* %21
%76 = call i32 @szl_set_last_strerror(%struct.szl_interp* %74, i32 %75)
store %struct.szl_stream* null, %struct.szl_stream** %8
br label %151
77: ; preds = %64
%78 = load i32, i32* %19
%79 = load %struct.addrinfo*, %struct.addrinfo** %17
%80 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %79, i32 0, i32 2
%81 = load i32*, i32** %80
%82 = load %struct.addrinfo*, %struct.addrinfo** %17
%83 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %82, i32 0, i32 1
%84 = load i64, i64* %83
%85 = call i64 @connect(i32 %78, i32* %81, i64 %84)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %91
87: ; preds = %77
%88 = load i32, i32* @errno
%89 = load i32, i32* @EINPROGRESS
%90 = icmp ne i32 %88, %89
br i1 %90, label %100, label %91
91: ; preds = %87, %77
%92 = load i32, i32* %19
%93 = load i32, i32* @F_SETFL
%94 = load i32, i32* %20
%95 = load i32, i32* @O_NONBLOCK
%96 = xor i32 %95, -1
%97 = and i32 %94, %96
%98 = call i32 (i32, i32, ...) @fcntl(i32 %92, i32 %93, i32 %97)
%99 = icmp slt i32 %98, 0
br i1 %99, label %100, label %109
100: ; preds = %91, %87
%101 = load i32, i32* @errno
store i32 %101, i32* %21
%102 = load i32, i32* %19
%103 = call i32 @close(i32 %102)
%104 = load %struct.addrinfo*, %struct.addrinfo** %17
%105 = call i32 @freeaddrinfo(%struct.addrinfo* %104)
%106 = load %struct.szl_interp*, %struct.szl_interp** %9
%107 = load i32, i32* %21
%108 = call i32 @szl_set_last_strerror(%struct.szl_interp* %106, i32 %107)
store %struct.szl_stream* null, %struct.szl_stream** %8
br label %151
109: ; preds = %91
br label %130
110: ; preds = %59
%111 = load i32, i32* %19
%112 = load %struct.addrinfo*, %struct.addrinfo** %17
%113 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %112, i32 0, i32 2
%114 = load i32*, i32** %113
%115 = load %struct.addrinfo*, %struct.addrinfo** %17
%116 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %115, i32 0, i32 1
%117 = load i64, i64* %116
%118 = call i64 @connect(i32 %111, i32* %114, i64 %117)
%119 = icmp slt i64 %118, 0
br i1 %119, label %120, label %129
120: ; preds = %110
%121 = load i32, i32* @errno
store i32 %121, i32* %21
%122 = load i32, i32* %19
%123 = call i32 @close(i32 %122)
%124 = load %struct.addrinfo*, %struct.addrinfo** %17
%125 = call i32 @freeaddrinfo(%struct.addrinfo* %124)
%126 = load %struct.szl_interp*, %struct.szl_interp** %9
%127 = load i32, i32* %21
%128 = call i32 @szl_set_last_strerror(%struct.szl_interp* %126, i32 %127)
store %struct.szl_stream* null, %struct.szl_stream** %8
br label %151
129: ; preds = %110
br label %130
130: ; preds = %129, %109
%131 = load %struct.szl_interp*, %struct.szl_interp** %9
%132 = load i32, i32* %19
%133 = load %struct.addrinfo*, %struct.addrinfo** %17
%134 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %133, i32 0, i32 2
%135 = load i32*, i32** %134
%136 = load %struct.addrinfo*, %struct.addrinfo** %17
%137 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %136, i32 0, i32 1
%138 = load i64, i64* %137
%139 = load %struct.szl_stream_ops*, %struct.szl_stream_ops** %14
%140 = load i32, i32* %15
%141 = call %struct.szl_stream* @szl_socket_new(%struct.szl_interp* %131, i32 %132, i32* %135, i64 %138, %struct.szl_stream_ops* %139, i32 %140)
store %struct.szl_stream* %141, %struct.szl_stream** %18
%142 = load %struct.szl_stream*, %struct.szl_stream** %18
%143 = icmp ne %struct.szl_stream* %142, null
br i1 %143, label %147, label %144
144: ; preds = %130
%145 = load i32, i32* %19
%146 = call i32 @close(i32 %145)
br label %147
147: ; preds = %144, %130
%148 = load %struct.addrinfo*, %struct.addrinfo** %17
%149 = call i32 @freeaddrinfo(%struct.addrinfo* %148)
%150 = load %struct.szl_stream*, %struct.szl_stream** %18
store %struct.szl_stream* %150, %struct.szl_stream** %8
br label %151
151: ; preds = %147, %120, %100, %70, %52, %36
%152 = load %struct.szl_stream*, %struct.szl_stream** %8
ret %struct.szl_stream* %152
}

LLVM IR (-O2):
%struct.szl_stream = type { i32 }
%struct.szl_interp = type { i32 }
%struct.szl_stream_ops = type { i32 }
%struct.addrinfo = type { i32, i64, i32*, i64, i32, i32*, i32*, i64 }
@AF_UNSPEC = global i32 0
@errno = global i32 0
@SOCK_NONBLOCK = constant i32 0
@F_GETFL = global i32 0
@EINPROGRESS = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define %struct.szl_stream* @szl_socket_new_client(%struct.szl_interp* %0, i8* %1, i8* %2, i32 %3, i32 %4, %struct.szl_stream_ops* %5, i32 %6) {
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = bitcast %struct.addrinfo* %8 to i8*
%11 = bitcast %struct.addrinfo** %9 to i8*
%12 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 7
store i64 0, i64* %12
%13 = load i32, i32* @AF_UNSPEC
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 4
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 0
store i32 %3, i32* %15
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 1
%17 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 5
%18 = bitcast i64* %16 to i8*
%19 = bitcast i32** %17 to i8*
%20 = call i64 @getaddrinfo(i8* %1, i8* %2, %struct.addrinfo* %8, %struct.addrinfo** %9)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %65
22: ; preds = %7
%23 = load %struct.addrinfo*, %struct.addrinfo** %9
%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 0
%27 = load i32, i32* %26
%28 = or i32 %27, %4
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i64 0, i32 3
%30 = load i64, i64* %29
%31 = call i32 @socket(i32 %25, i32 %28, i64 %30)
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %22
%34 = load i32, i32* @errno
%35 = load %struct.addrinfo*, %struct.addrinfo** %9
%36 = call i32 @freeaddrinfo(%struct.addrinfo* %35)
%37 = call i32 @szl_set_last_strerror(%struct.szl_interp* %0, i32 %34)
br label %65
38: ; preds = %22
%39 = load %struct.addrinfo*, %struct.addrinfo** %9
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 2
%41 = load i32*, i32** %40
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 1
%43 = load i64, i64* %42
%44 = call i64 @connect(i32 %31, i32* %41, i64 %43)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %38
%47 = load i32, i32* @errno
%48 = call i32 @close(i32 %31)
%49 = load %struct.addrinfo*, %struct.addrinfo** %9
%50 = call i32 @freeaddrinfo(%struct.addrinfo* %49)
%51 = call i32 @szl_set_last_strerror(%struct.szl_interp* %0, i32 %47)
br label %65
52: ; preds = %38
%53 = load %struct.addrinfo*, %struct.addrinfo** %9
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 2
%55 = load i32*, i32** %54
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 1
%57 = load i64, i64* %56
%58 = call %struct.szl_stream* @szl_socket_new(%struct.szl_interp* %0, i32 %31, i32* %55, i64 %57, %struct.szl_stream_ops* %5, i32 %6)
%59 = icmp eq %struct.szl_stream* %58, null
br i1 %59, label %60, label %62
60: ; preds = %52
%61 = call i32 @close(i32 %31)
br label %62
62: ; preds = %60, %52
%63 = load %struct.addrinfo*, %struct.addrinfo** %9
%64 = call i32 @freeaddrinfo(%struct.addrinfo* %63)
br label %65
65: ; preds = %7, %62, %46, %33
%66 = phi %struct.szl_stream* [ null, %33 ], [ %58, %62 ], [ null, %46 ], [ null, %7 ]
ret %struct.szl_stream* %66
}