#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 ai_socktype;
  int ai_family;
  int /*<<< orphan*/ ai_flags;
};

/* Variables and functions */
int /*<<< orphan*/ AI_ADDRCONFIG;
int /*<<< orphan*/ AI_NUMERICHOST;
int /*<<< orphan*/ AI_NUMERICSERV;
int /*<<< orphan*/ AI_PASSIVE;
int PF_INET;
int PF_INET6;
int PF_UNSPEC;
int SOCK_DGRAM;
int SOCK_RAW;
int SOCK_STREAM;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *gai_strerror(int);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
unsigned int strlen(char *);
int setupAddress(char *host, char *port, struct addrinfo **output, int socktype,
                 int protocolFamily) {
  if (host == NULL || port == NULL || output == NULL) {
    return -1;
  }
  struct addrinfo hints;
  memset(&hints, 0x00, sizeof(struct addrinfo));
  hints.ai_flags = 0;
  int hostIsNumeric = 1;
  for (unsigned int i = 0; i < strlen(host); i++) {
    if (host[i] > '9' || host[i] < '.') {
      hostIsNumeric = 0;
      break;
    }
  }
  int portIsNumeric = 1;
  for (unsigned int i = 0; i < strlen(port); i++) {
    if (port[i] > '9' || port[i] < '.') {
      portIsNumeric = 0;
      break;
    }
  }
  if (!hostIsNumeric) {
    if (strcmp(host, "*") == 0 || strcmp(host, "all") == 0) {
      hints.ai_flags |= AI_PASSIVE;
    }
  }
  if ((socktype == SOCK_DGRAM) || (socktype == SOCK_STREAM) ||
      (socktype == SOCK_RAW)) {
    hints.ai_socktype = socktype;
  } else {
    fprintf(stderr, "Unsupported socket type");
    fprintf(stderr, "\r\n");
    return -1;
  }
  fprintf(stderr, "Host/Port numeric? %d %d", hostIsNumeric, portIsNumeric);
  fprintf(stderr, "\r\n");
  if (hostIsNumeric) {
    hints.ai_flags |= AI_NUMERICHOST;
  }
  if (portIsNumeric) {
    hints.ai_flags |= AI_NUMERICSERV;
  }
  hints.ai_flags |= AI_ADDRCONFIG;
  if (protocolFamily == PF_INET || protocolFamily == PF_INET6) {
    hints.ai_family = protocolFamily;
  } else {
    hints.ai_family = PF_UNSPEC;
  }
  int error = getaddrinfo(host, port, &hints, output);
  if (error) {
    fprintf(stderr, "Error getting address info: %s.", gai_strerror(error));
    fprintf(stderr, "\r\n");
    return error;
  }
  return 0;
}


x86 assembly (clang, -O0):
<setupAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119c <setupAddress+0x3c>
cmpq   $0x0,-0x18(%rbp)
je     119c <setupAddress+0x3c>
cmpq   $0x0,-0x20(%rbp)
jne    11a8 <setupAddress+0x48>
movl   $0xffffffff,-0x4(%rbp)
jmp    1491 <setupAddress+0x331>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
cmp    %ecx,%eax
jae    1230 <setupAddress+0xd0>
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jg     1211 <setupAddress+0xb1>
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jge    121d <setupAddress+0xbd>
movl   $0x0,-0x3c(%rbp)
jmp    1230 <setupAddress+0xd0>
jmp    1222 <setupAddress+0xc2>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11cd <setupAddress+0x6d>
movl   $0x1,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jae    12a1 <setupAddress+0x141>
mov    -0x18(%rbp),%rax
mov    -0x48(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jg     1282 <setupAddress+0x122>
mov    -0x18(%rbp),%rax
mov    -0x48(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jge    128e <setupAddress+0x12e>
movl   $0x0,-0x44(%rbp)
jmp    12a1 <setupAddress+0x141>
jmp    1293 <setupAddress+0x133>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    123e <setupAddress+0xde>
cmpl   $0x0,-0x3c(%rbp)
jne    12f3 <setupAddress+0x193>
mov    -0x10(%rbp),%rdi
lea    0xd4a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12df <setupAddress+0x17f>
mov    -0x10(%rbp),%rdi
lea    0xd32(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ee <setupAddress+0x18e>
mov    0x2cf2(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    12f3 <setupAddress+0x193>
mov    -0x24(%rbp),%eax
mov    0x2cbb(%rip),%rcx
cmp    (%rcx),%eax
je     1329 <setupAddress+0x1c9>
mov    -0x24(%rbp),%eax
mov    0x2c91(%rip),%rcx
cmp    (%rcx),%eax
je     1329 <setupAddress+0x1c9>
mov    -0x24(%rbp),%eax
mov    0x2ca7(%rip),%rcx
cmp    (%rcx),%eax
jne    1334 <setupAddress+0x1d4>
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    136e <setupAddress+0x20e>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
lea    0xcc2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
lea    0xcc3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1491 <setupAddress+0x331>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
mov    -0x44(%rbp),%ecx
lea    0xc9d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
lea    0xc83(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x3c(%rbp)
je     13bb <setupAddress+0x25b>
mov    0x2c0d(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     13d4 <setupAddress+0x274>
mov    0x2c2c(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2bad(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
mov    0x2bab(%rip),%rcx
cmp    (%rcx),%eax
je     1407 <setupAddress+0x2a7>
mov    -0x28(%rbp),%eax
mov    0x2bd1(%rip),%rcx
cmp    (%rcx),%eax
jne    1412 <setupAddress+0x2b2>
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    141e <setupAddress+0x2be>
mov    0x2bc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
lea    -0x38(%rbp),%rdx
call   1080 <getaddrinfo@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     148a <setupAddress+0x32a>
mov    0x2b61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x4c(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%rdx
lea    0xbd9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2b39(%rip),%rax
mov    (%rax),%edi
lea    0xba6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1491 <setupAddress+0x331>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setupAddress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0xffffffff,%r13d
test   %rdi,%rdi
je     13d0 <setupAddress+0x270>
mov    %rsi,%r15
test   %rsi,%rsi
je     13d0 <setupAddress+0x270>
test   %rdx,%rdx
je     13d0 <setupAddress+0x270>
mov    %ecx,%ebp
mov    %rdi,%rbx
mov    %r8d,0x1c(%rsp)
mov    %rdx,0x20(%rsp)
mov    %rsp,%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
movl   $0x0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movl   $0x1,0xc(%rsp)
test   %eax,%eax
je     1210 <setupAddress+0xb0>
mov    %ebp,%r12d
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%rbp,1),%eax
add    $0xc6,%al
cmp    $0xf4,%al
setb   %r14b
jb     120b <setupAddress+0xab>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbp
jb     11e0 <setupAddress+0x80>
mov    $0x1,%eax
mov    %rax,0x10(%rsp)
mov    %r12d,%ebp
jmp    121a <setupAddress+0xba>
mov    $0x1,%eax
mov    %rax,0x10(%rsp)
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1254 <setupAddress+0xf4>
mov    %ebp,%r13d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbp,1),%eax
add    $0xc6,%al
cmp    $0xf4,%al
setb   %r12b
jb     125e <setupAddress+0xfe>
add    $0x1,%rbp
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbp
jb     1230 <setupAddress+0xd0>
jmp    1266 <setupAddress+0x106>
xor    %r12d,%r12d
test   %r14b,%r14b
jne    126e <setupAddress+0x10e>
jmp    12a3 <setupAddress+0x143>
movl   $0x0,0xc(%rsp)
mov    %r13d,%ebp
test   %r14b,%r14b
je     12a3 <setupAddress+0x143>
lea    0xd8b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1296 <setupAddress+0x136>
lea    0xd79(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12a3 <setupAddress+0x143>
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
or     %eax,0x8(%rsp)
mov    0x2d0e(%rip),%rax
cmp    %ebp,(%rax)
je     12e6 <setupAddress+0x186>
mov    0x2ceb(%rip),%rax
cmp    %ebp,(%rax)
je     12e6 <setupAddress+0x186>
mov    0x2d08(%rip),%rax
cmp    %ebp,(%rax)
je     12e6 <setupAddress+0x186>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%r13d
jmp    13b9 <setupAddress+0x259>
mov    %ebp,(%rsp)
mov    0x2cb8(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xd27(%rip),%rsi
xor    %r13d,%r13d
mov    0x10(%rsp),%rdx
mov    0xc(%rsp),%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xd07(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %r14b,%r14b
jne    1330 <setupAddress+0x1d0>
mov    0x2c96(%rip),%rax
mov    (%rax),%eax
or     %eax,0x8(%rsp)
mov    $0x0,%eax
test   %r12b,%r12b
mov    0x1c(%rsp),%esi
jne    1347 <setupAddress+0x1e7>
mov    0x2cb3(%rip),%rax
mov    (%rax),%eax
or     0x8(%rsp),%eax
mov    0x2c36(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x8(%rsp)
mov    0x2c39(%rip),%rax
mov    (%rax),%eax
mov    0x2c68(%rip),%rdx
mov    %esi,%ecx
cmp    %esi,(%rdx)
je     1377 <setupAddress+0x217>
mov    0x2c6b(%rip),%rcx
mov    (%rcx),%ecx
cmp    %esi,%eax
cmove  %esi,%ecx
mov    %ecx,0x4(%rsp)
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    0x20(%rsp),%rcx
call   1080 <getaddrinfo@plt>
test   %eax,%eax
je     13d0 <setupAddress+0x270>
mov    %eax,%ebx
mov    0x0(%rbp),%ebp
mov    %eax,%edi
call   1040 <gai_strerror@plt>
lea    0xc90(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebx,%r13d
mov    0x2be8(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r13d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32 }
@.str = [2 x i8] c"*\00"
@.str.1 = [4 x i8] c"all\00"
@AI_PASSIVE = global i32 0
@SOCK_DGRAM = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_RAW = global i32 0
@stderr = global i32 0
@.str.2 = [24 x i8] c"Unsupported socket type\00"
@.str.3 = [3 x i8] c"\0D\0A\00"
@.str.4 = [25 x i8] c"Host/Port numeric? %d %d\00"
@AI_NUMERICHOST = global i32 0
@AI_NUMERICSERV = global i32 0
@AI_ADDRCONFIG = global i32 0
@PF_INET = global i32 0
@PF_INET6 = global i32 0
@PF_UNSPEC = global i32 0
@.str.5 = [32 x i8] c"Error getting address info: %s.\00"
define i32 @setupAddress(i8* %0, i8* %1, %struct.addrinfo** %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.addrinfo**
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.addrinfo
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store %struct.addrinfo** %2, %struct.addrinfo*** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%18 = load i8*, i8** %7
%19 = icmp eq i8* %18, null
br i1 %19, label %26, label %20
20: ; preds = %5
%21 = load i8*, i8** %8
%22 = icmp eq i8* %21, null
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load %struct.addrinfo**, %struct.addrinfo*** %9
%25 = icmp eq %struct.addrinfo** %24, null
br i1 %25, label %26, label %27
26: ; preds = %23, %20, %5
store i32 -1, i32* %6
br label %176
27: ; preds = %23
%28 = call i32 @memset(%struct.addrinfo* %12, i32 0, i32 12)
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 2
store i32 0, i32* %29
store i32 1, i32* %13
store i32 0, i32* %14
br label %30
30: ; preds = %53, %27
%31 = load i32, i32* %14
%32 = load i8*, i8** %7
%33 = call i32 @strlen(i8* %32)
%34 = icmp ult i32 %31, %33
br i1 %34, label %35, label %56
35: ; preds = %30
%36 = load i8*, i8** %7
%37 = load i32, i32* %14
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp sgt i32 %41, 57
br i1 %42, label %51, label %43
43: ; preds = %35
%44 = load i8*, i8** %7
%45 = load i32, i32* %14
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp slt i32 %49, 46
br i1 %50, label %51, label %52
51: ; preds = %43, %35
store i32 0, i32* %13
br label %56
52: ; preds = %43
br label %53
53: ; preds = %52
%54 = load i32, i32* %14
%55 = add i32 %54, 1
store i32 %55, i32* %14
br label %30
56: ; preds = %51, %30
store i32 1, i32* %15
store i32 0, i32* %16
br label %57
57: ; preds = %80, %56
%58 = load i32, i32* %16
%59 = load i8*, i8** %8
%60 = call i32 @strlen(i8* %59)
%61 = icmp ult i32 %58, %60
br i1 %61, label %62, label %83
62: ; preds = %57
%63 = load i8*, i8** %8
%64 = load i32, i32* %16
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp sgt i32 %68, 57
br i1 %69, label %78, label %70
70: ; preds = %62
%71 = load i8*, i8** %8
%72 = load i32, i32* %16
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp slt i32 %76, 46
br i1 %77, label %78, label %79
78: ; preds = %70, %62
store i32 0, i32* %15
br label %83
79: ; preds = %70
br label %80
80: ; preds = %79
%81 = load i32, i32* %16
%82 = add i32 %81, 1
store i32 %82, i32* %16
br label %57
83: ; preds = %78, %57
%84 = load i32, i32* %13
%85 = icmp ne i32 %84, 0
br i1 %85, label %100, label %86
86: ; preds = %83
%87 = load i8*, i8** %7
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %94, label %90
90: ; preds = %86
%91 = load i8*, i8** %7
%92 = call i64 @strcmp(i8* %91, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %99
94: ; preds = %90, %86
%95 = load i32, i32* @AI_PASSIVE
%96 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 2
%97 = load i32, i32* %96
%98 = or i32 %97, %95
store i32 %98, i32* %96
br label %99
99: ; preds = %94, %90
br label %100
100: ; preds = %99, %83
%101 = load i32, i32* %10
%102 = load i32, i32* @SOCK_DGRAM
%103 = icmp eq i32 %101, %102
br i1 %103, label %112, label %104
104: ; preds = %100
%105 = load i32, i32* %10
%106 = load i32, i32* @SOCK_STREAM
%107 = icmp eq i32 %105, %106
br i1 %107, label %112, label %108
108: ; preds = %104
%109 = load i32, i32* %10
%110 = load i32, i32* @SOCK_RAW
%111 = icmp eq i32 %109, %110
br i1 %111, label %112, label %115
112: ; preds = %108, %104, %100
%113 = load i32, i32* %10
%114 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 0
store i32 %113, i32* %114
br label %120
115: ; preds = %108
%116 = load i32, i32* @stderr
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%118 = load i32, i32* @stderr
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %6
br label %176
120: ; preds = %112
%121 = load i32, i32* @stderr
%122 = load i32, i32* %13
%123 = load i32, i32* %15
%124 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %122, i32 %123)
%125 = load i32, i32* @stderr
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%127 = load i32, i32* %13
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %134
129: ; preds = %120
%130 = load i32, i32* @AI_NUMERICHOST
%131 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 2
%132 = load i32, i32* %131
%133 = or i32 %132, %130
store i32 %133, i32* %131
br label %134
134: ; preds = %129, %120
%135 = load i32, i32* %15
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %142
137: ; preds = %134
%138 = load i32, i32* @AI_NUMERICSERV
%139 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 2
%140 = load i32, i32* %139
%141 = or i32 %140, %138
store i32 %141, i32* %139
br label %142
142: ; preds = %137, %134
%143 = load i32, i32* @AI_ADDRCONFIG
%144 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 2
%145 = load i32, i32* %144
%146 = or i32 %145, %143
store i32 %146, i32* %144
%147 = load i32, i32* %11
%148 = load i32, i32* @PF_INET
%149 = icmp eq i32 %147, %148
br i1 %149, label %154, label %150
150: ; preds = %142
%151 = load i32, i32* %11
%152 = load i32, i32* @PF_INET6
%153 = icmp eq i32 %151, %152
br i1 %153, label %154, label %157
154: ; preds = %150, %142
%155 = load i32, i32* %11
%156 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 1
store i32 %155, i32* %156
br label %160
157: ; preds = %150
%158 = load i32, i32* @PF_UNSPEC
%159 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 1
store i32 %158, i32* %159
br label %160
160: ; preds = %157, %154
%161 = load i8*, i8** %7
%162 = load i8*, i8** %8
%163 = load %struct.addrinfo**, %struct.addrinfo*** %9
%164 = call i32 @getaddrinfo(i8* %161, i8* %162, %struct.addrinfo* %12, %struct.addrinfo** %163)
store i32 %164, i32* %17
%165 = load i32, i32* %17
%166 = icmp ne i32 %165, 0
br i1 %166, label %167, label %175
167: ; preds = %160
%168 = load i32, i32* @stderr
%169 = load i32, i32* %17
%170 = call i8* @gai_strerror(i32 %169)
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %168, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %170)
%172 = load i32, i32* @stderr
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%174 = load i32, i32* %17
store i32 %174, i32* %6
br label %176
175: ; preds = %160
store i32 0, i32* %6
br label %176
176: ; preds = %175, %167, %115, %26
%177 = load i32, i32* %6
ret i32 %177
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32 }
@.str = [2 x i8] c"*\00"
@.str.1 = [4 x i8] c"all\00"
@AI_PASSIVE = global i32 0
@SOCK_DGRAM = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_RAW = global i32 0
@stderr = global i32 0
@.str.2 = [24 x i8] c"Unsupported socket type\00"
@.str.3 = [3 x i8] c"\0D\0A\00"
@.str.4 = [25 x i8] c"Host/Port numeric? %d %d\00"
@AI_NUMERICHOST = global i32 0
@AI_NUMERICSERV = global i32 0
@AI_ADDRCONFIG = global i32 0
@PF_INET = global i32 0
@PF_INET6 = global i32 0
@PF_UNSPEC = global i32 0
@.str.5 = [32 x i8] c"Error getting address info: %s.\00"
define i32 @setupAddress(i8* %0, i8* %1, %struct.addrinfo** %2, i32 %3, i32 %4) {
%6 = alloca %struct.addrinfo
%7 = icmp eq i8* %0, null
%8 = icmp eq i8* %1, null
%9 = or i1 %7, %8
%10 = icmp eq %struct.addrinfo** %2, null
%11 = or i1 %9, %10
br i1 %11, label %107, label %12
12: ; preds = %5
%13 = bitcast %struct.addrinfo* %6 to i8*
%14 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 12)
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 2
store i32 0, i32* %15
%16 = call i32 @strlen(i8* %0)
%17 = icmp eq i32 %16, 0
br i1 %17, label %29, label %22
18: ; preds = %22
%19 = call i32 @strlen(i8* %0)
%20 = zext i32 %19 to i64
%21 = icmp ult i64 %28, %20
br i1 %21, label %22, label %29
22: ; preds = %12, %18
%23 = phi i64 [ %28, %18 ], [ 0, %12 ]
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = add i8 %25, -58
%27 = icmp ult i8 %26, -12
%28 = add nuw nsw i64 %23, 1
br i1 %27, label %29, label %18
29: ; preds = %18, %22, %12
%30 = phi i1 [ false, %12 ], [ %27, %22 ], [ %27, %18 ]
%31 = phi i32 [ 1, %12 ], [ 1, %18 ], [ 0, %22 ]
%32 = call i32 @strlen(i8* %1)
%33 = icmp eq i32 %32, 0
br i1 %33, label %45, label %38
34: ; preds = %38
%35 = call i32 @strlen(i8* %1)
%36 = zext i32 %35 to i64
%37 = icmp ult i64 %44, %36
br i1 %37, label %38, label %45
38: ; preds = %29, %34
%39 = phi i64 [ %44, %34 ], [ 0, %29 ]
%40 = getelementptr inbounds i8, i8* %1, i64 %39
%41 = load i8, i8* %40
%42 = add i8 %41, -58
%43 = icmp ult i8 %42, -12
%44 = add nuw nsw i64 %39, 1
br i1 %43, label %45, label %34
45: ; preds = %34, %38, %29
%46 = phi i1 [ false, %29 ], [ %43, %38 ], [ %43, %34 ]
%47 = phi i32 [ 1, %29 ], [ 1, %34 ], [ 0, %38 ]
br i1 %30, label %48, label %58
48: ; preds = %45
%49 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51, %48
%55 = load i32, i32* @AI_PASSIVE
%56 = load i32, i32* %15
%57 = or i32 %56, %55
store i32 %57, i32* %15
br label %58
58: ; preds = %51, %54, %45
%59 = load i32, i32* @SOCK_DGRAM
%60 = icmp eq i32 %59, %3
%61 = load i32, i32* @SOCK_STREAM
%62 = icmp eq i32 %61, %3
%63 = select i1 %60, i1 true, i1 %62
%64 = load i32, i32* @SOCK_RAW
%65 = icmp eq i32 %64, %3
%66 = select i1 %63, i1 true, i1 %65
br i1 %66, label %67, label %73
67: ; preds = %58
%68 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 0
store i32 %3, i32* %68
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %47)
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br i1 %30, label %80, label %76
73: ; preds = %58
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %101
76: ; preds = %67
%77 = load i32, i32* @AI_NUMERICHOST
%78 = load i32, i32* %15
%79 = or i32 %78, %77
store i32 %79, i32* %15
br label %80
80: ; preds = %76, %67
%81 = load i32, i32* %15
%82 = load i32, i32* @AI_NUMERICSERV
%83 = select i1 %46, i32 0, i32 %82
%84 = or i32 %81, %83
%85 = load i32, i32* @AI_ADDRCONFIG
%86 = or i32 %84, %85
store i32 %86, i32* %15
%87 = load i32, i32* @PF_INET
%88 = icmp eq i32 %87, %4
%89 = load i32, i32* @PF_INET6
%90 = icmp eq i32 %89, %4
%91 = select i1 %88, i1 true, i1 %90
%92 = load i32, i32* @PF_UNSPEC
%93 = select i1 %91, i32 %4, i32 %92
%94 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 1
store i32 %93, i32* %94
%95 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %6, %struct.addrinfo** %2)
%96 = icmp eq i32 %95, 0
br i1 %96, label %105, label %97
97: ; preds = %80
%98 = load i32, i32* @stderr
%99 = call i8* @gai_strerror(i32 %95)
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %99)
br label %101
101: ; preds = %73, %97
%102 = phi i32 [ %95, %97 ], [ -1, %73 ]
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %105
105: ; preds = %101, %80
%106 = phi i32 [ 0, %80 ], [ %102, %101 ]
br label %107
107: ; preds = %5, %105
%108 = phi i32 [ %106, %105 ], [ -1, %5 ]
ret i32 %108
}