#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ timeout;
struct timeval {
  int tv_sec;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ *ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ *ai_next;
  int /*<<< orphan*/ *ai_canonname;
  int /*<<< orphan*/ ai_flags;
};
struct addrinfo {
  int tv_sec;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ *ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ *ai_next;
  int /*<<< orphan*/ *ai_canonname;
  int /*<<< orphan*/ ai_flags;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_KEEPALIVE;
int /*<<< orphan*/ SO_RCVTIMEO;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ SO_SNDTIMEO;
int /*<<< orphan*/ TCP_NODELAY;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int atoi(char *);
int bind(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int connect(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *gai_strerror(int);
int genstring(int, int /*<<< orphan*/ *, int);
int getaddrinfo(char *, char *, struct timeval *, struct timeval **);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(struct timeval *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int dosocket(int argc, char *argv[], uint8_t *dlmagic, int *dlmagiclen,
             int *sleeptime, int *lfd) {
  int fd;
  int i = 1;
  struct addrinfo *a;
  int flag = 1;
  int listening = 0;
  struct addrinfo hints;
  struct timeval timeout;
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  hints.ai_protocol = 0;
  hints.ai_canonname = NULL;
  hints.ai_addr = NULL;
  hints.ai_next = NULL;
  if (argc < 4 || strcmp(argv[1], "-h") == 0 ||
      strcmp(argv[1], "--help") == 0) {
    usage(argv[0]);
    exit(0);
  }
  *dlmagiclen = genstring(atoi(argv[i++]), dlmagic, *dlmagiclen);
  if (argv[i][0] == '-') {
    if (argv[i][1] == 'u') {
      hints.ai_socktype = SOCK_DGRAM;
    } else if (argv[i][1] == 'l') {
      listening = 1;
    } else {
      fprintf(stderr, "Choose one of -l or -u\n");
      exit(1);
    }
    i++;
  }
  printf("Sleeptime: %s\n", argv[i + 2]);
  *sleeptime = atoi(argv[i + 2]);
  printf("%s:%s\n", argv[i], argv[i + 1]);
  if ((fd = getaddrinfo(listening ? NULL : argv[i], argv[i + 1], &hints, &a)) !=
      0) {
    fprintf(stderr, "getaddrinfoL %s", gai_strerror(fd));
    exit(1);
  }
  fd = socket(a->ai_family, a->ai_socktype, a->ai_protocol);
  if (fd == -1) {
    perror("socket");
    exit(1);
  }
  setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
  setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof(int));
  setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&flag, sizeof(int));
  memset(&timeout, 0, sizeof(timeout));
  timeout.tv_sec = 10;
  setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
  setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout));
  if (listening) {
    if (bind(fd, a->ai_addr, a->ai_addrlen) == -1) {
      perror("bind");
      exit(1);
    }
    *lfd = fd;
    listen(fd, 16);
    fd = accept(fd, a->ai_addr, &a->ai_addrlen);
  } else {
    if (connect(fd, a->ai_addr, a->ai_addrlen) == -1) {
      perror("connect");
      exit(1);
    }
  }
  return fd;
}


x86 assembly (clang, -O0):
<dosocket>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x1,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1070 <memset@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2d2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x60(%rbp)
cmpl   $0x4,-0x4(%rbp)
jl     12e1 <dosocket+0xd1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd4c(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12e1 <dosocket+0xd1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd31(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12f4 <dosocket+0xe4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x38(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   10f0 <atoi@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
call   1040 <genstring@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    13be <dosocket+0x1ae>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x75,%eax
jne    136a <dosocket+0x15a>
mov    0x2c58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
jmp    13b5 <dosocket+0x1a5>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6c,%eax
jne    138f <dosocket+0x17f>
movl   $0x1,-0x48(%rbp)
jmp    13b0 <dosocket+0x1a0>
mov    0x2c0a(%rip),%rax
mov    (%rax),%edi
lea    0xc6b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    13b5 <dosocket+0x1a5>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   10f0 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x48(%rbp)
je     143e <dosocket+0x22e>
xor    %eax,%eax
mov    %rax,-0xc0(%rbp)
jmp    1451 <dosocket+0x241>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0xc0(%rbp)
mov    -0xc0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    -0x80(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1120 <getaddrinfo@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
je     14ba <dosocket+0x2aa>
mov    0x2b17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    -0x34(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0xc4(%rbp),%edi
mov    %rax,%rdx
lea    0xb8f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x40(%rbp),%rax
mov    0x1c(%rax),%edi
mov    -0x40(%rbp),%rax
mov    0x18(%rax),%esi
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%rdx
call   1130 <socket@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    14f8 <dosocket+0x2e8>
lea    0xb5f(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x34(%rbp),%edi
mov    0x2abe(%rip),%rax
mov    (%rax),%esi
mov    0x2acd(%rip),%rax
mov    (%rax),%edx
lea    -0x44(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    -0x34(%rbp),%edi
mov    0x2aba(%rip),%rax
mov    (%rax),%esi
mov    0x2a61(%rip),%rax
mov    (%rax),%edx
lea    -0x44(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    -0x34(%rbp),%edi
mov    0x2a96(%rip),%rax
mov    (%rax),%esi
mov    0x2a2d(%rip),%rax
mov    (%rax),%edx
lea    -0x44(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
lea    -0xb8(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1070 <memset@plt>
movl   $0xa,-0xb8(%rbp)
mov    -0x34(%rbp),%edi
mov    0x2a55(%rip),%rax
mov    (%rax),%esi
mov    0x2a14(%rip),%rax
mov    (%rax),%edx
lea    -0xb8(%rbp),%rcx
mov    $0x38,%r8d
call   1030 <setsockopt@plt>
mov    -0x34(%rbp),%edi
mov    0x2a2e(%rip),%rax
mov    (%rax),%esi
mov    0x2a35(%rip),%rax
mov    (%rax),%edx
lea    -0xb8(%rbp),%rcx
mov    $0x38,%r8d
call   1030 <setsockopt@plt>
cmpl   $0x0,-0x48(%rbp)
je     1645 <dosocket+0x435>
mov    -0x34(%rbp),%edi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    160f <dosocket+0x3ff>
lea    0xa4f(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%edi
mov    $0x10,%esi
call   10a0 <listen@plt>
mov    -0x34(%rbp),%edi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x40(%rbp),%rdx
add    $0x4,%rdx
call   10e0 <accept@plt>
mov    %eax,-0x34(%rbp)
jmp    1680 <dosocket+0x470>
mov    -0x34(%rbp),%edi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edx
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
jne    167b <dosocket+0x46b>
lea    0x9e8(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    1680 <dosocket+0x470>
mov    -0x34(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dosocket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x1,0x14(%rsp)
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1070 <memset@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
mov    0x2d39(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x48(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rsp)
movups %xmm0,0x38(%rsp)
cmp    $0x4,%ebp
jl     14ba <dosocket+0x2aa>
mov    0x8(%rbx),%rdi
lea    0xd6d(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     14ba <dosocket+0x2aa>
mov    0x8(%rbx),%rdi
lea    0xd57(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     14ba <dosocket+0x2aa>
mov    0x8(%rbx),%rdi
call   10f0 <atoi@plt>
mov    (%r12),%edx
mov    %eax,%edi
mov    %r13,%rsi
call   1040 <genstring@plt>
mov    %eax,(%r12)
mov    0x10(%rbx),%rcx
mov    $0x1,%r13b
mov    $0x2,%eax
cmpb   $0x2d,(%rcx)
jne    130e <dosocket+0xfe>
mov    0x1(%rcx),%cl
mov    $0x3,%eax
cmp    $0x6c,%cl
je     130b <dosocket+0xfb>
cmp    $0x75,%cl
jne    1515 <dosocket+0x305>
mov    0x2cb5(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x30(%rsp)
jmp    130e <dosocket+0xfe>
xor    %r13d,%r13d
mov    %eax,%ebp
mov    0x10(%rbx,%rbp,8),%rsi
lea    0xd06(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx,%rbp,8),%rdi
call   10f0 <atoi@plt>
mov    %eax,(%r15)
lea    0x1(%rbp),%r15
mov    (%rbx,%rbp,8),%rsi
mov    0x8(%rbx,%rbp,8),%rdx
lea    0xcea(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r13b,%r13b
je     1357 <dosocket+0x147>
mov    (%rbx,%rbp,8),%r12
mov    (%rbx,%r15,8),%rsi
lea    0x18(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %r12,%rdi
call   1120 <getaddrinfo@plt>
test   %eax,%eax
jne    14c9 <dosocket+0x2b9>
mov    0x8(%rsp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
je     14f6 <dosocket+0x2e6>
mov    %eax,%ebx
mov    0x2c25(%rip),%rax
mov    (%rax),%esi
mov    0x2c34(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    0x2c1e(%rip),%r15
mov    (%r15),%esi
mov    0x2bc4(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %rbp,%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    (%r15),%esi
mov    0x2b98(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %rbp,%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
lea    0x50(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1070 <memset@plt>
movl   $0xa,0x50(%rsp)
mov    (%r15),%esi
mov    0x2b88(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %rbp,%rcx
mov    $0x38,%r8d
call   1030 <setsockopt@plt>
mov    (%r15),%esi
mov    0x2bb4(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %rbp,%rcx
mov    $0x38,%r8d
call   1030 <setsockopt@plt>
mov    0x8(%rsp),%rax
mov    0x8(%rax),%rsi
mov    0x4(%rax),%edx
mov    %ebx,%edi
test   %r13b,%r13b
je     1477 <dosocket+0x267>
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
jne    14a6 <dosocket+0x296>
lea    0xbe2(%rip),%rdi
jmp    1506 <dosocket+0x2f6>
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
je     14ff <dosocket+0x2ef>
mov    %ebx,(%r14)
mov    %ebx,%edi
mov    $0x10,%esi
call   10a0 <listen@plt>
mov    0x8(%rsp),%rdx
mov    0x8(%rdx),%rsi
add    $0x4,%rdx
mov    %ebx,%edi
call   10e0 <accept@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rdi
call   10b0 <usage@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    0x2ad0(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xb58(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xb4b(%rip),%rdi
jmp    1506 <dosocket+0x2f6>
lea    0xb49(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2a84(%rip),%rax
mov    (%rax),%edi
lea    0xae5(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32*, i64, i32, i32, i32*, i32*, i32 }
%struct.timeval = type { i32, i32, i32*, i64, i32, i32, i32*, i32*, i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@SOCK_DGRAM = global i32 0
@stderr = global i32 0
@.str.2 = [24 x i8] c"Choose one of -l or -u\0A\00"
@.str.3 = [15 x i8] c"Sleeptime: %s\0A\00"
@.str.4 = [7 x i8] c"%s:%s\0A\00"
@.str.5 = [16 x i8] c"getaddrinfoL %s\00"
@.str.6 = [7 x i8] c"socket\00"
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@SO_KEEPALIVE = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
@.str.7 = [5 x i8] c"bind\00"
@.str.8 = [8 x i8] c"connect\00"
define i32 @dosocket(i32 %0, i8** %1, i32* %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.addrinfo*
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.addrinfo
%19 = alloca %struct.timeval
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
store i32 1, i32* %14
store i32 1, i32* %16
store i32 0, i32* %17
%20 = bitcast %struct.addrinfo* %18 to %struct.timeval*
%21 = call i32 @memset(%struct.timeval* %20, i32 0, i32 56)
%22 = load i32, i32* @AF_INET
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 5
store i32 %22, i32* %23
%24 = load i32, i32* @SOCK_STREAM
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 4
store i32 %24, i32* %25
%26 = load i32, i32* @AI_PASSIVE
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 8
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 3
store i64 0, i64* %28
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 7
store i32* null, i32** %29
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 2
store i32* null, i32** %30
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 6
store i32* null, i32** %31
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 4
br i1 %33, label %46, label %34
34: ; preds = %6
%35 = load i8**, i8*** %8
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %34
%41 = load i8**, i8*** %8
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %40, %34, %6
%47 = load i8**, i8*** %8
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @usage(i8* %49)
%51 = call i32 @exit(i32 0)
unreachable
52: ; preds = %40
%53 = load i8**, i8*** %8
%54 = load i32, i32* %14
%55 = add nsw i32 %54, 1
store i32 %55, i32* %14
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds i8*, i8** %53, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @atoi(i8* %58)
%60 = load i32*, i32** %9
%61 = load i32*, i32** %10
%62 = load i32, i32* %61
%63 = call i32 @genstring(i32 %59, i32* %60, i32 %62)
%64 = load i32*, i32** %10
store i32 %63, i32* %64
%65 = load i8**, i8*** %8
%66 = load i32, i32* %14
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = getelementptr inbounds i8, i8* %69, i64 0
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 45
br i1 %73, label %74, label %106
74: ; preds = %52
%75 = load i8**, i8*** %8
%76 = load i32, i32* %14
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %75, i64 %77
%79 = load i8*, i8** %78
%80 = getelementptr inbounds i8, i8* %79, i64 1
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 117
br i1 %83, label %84, label %87
84: ; preds = %74
%85 = load i32, i32* @SOCK_DGRAM
%86 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 4
store i32 %85, i32* %86
br label %103
87: ; preds = %74
%88 = load i8**, i8*** %8
%89 = load i32, i32* %14
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8*, i8** %88, i64 %90
%92 = load i8*, i8** %91
%93 = getelementptr inbounds i8, i8* %92, i64 1
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 108
br i1 %96, label %97, label %98
97: ; preds = %87
store i32 1, i32* %17
br label %102
98: ; preds = %87
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %97
br label %103
103: ; preds = %102, %84
%104 = load i32, i32* %14
%105 = add nsw i32 %104, 1
store i32 %105, i32* %14
br label %106
106: ; preds = %103, %52
%107 = load i8**, i8*** %8
%108 = load i32, i32* %14
%109 = add nsw i32 %108, 2
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8*, i8** %107, i64 %110
%112 = load i8*, i8** %111
%113 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %112)
%114 = load i8**, i8*** %8
%115 = load i32, i32* %14
%116 = add nsw i32 %115, 2
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8*, i8** %114, i64 %117
%119 = load i8*, i8** %118
%120 = call i32 @atoi(i8* %119)
%121 = load i32*, i32** %11
store i32 %120, i32* %121
%122 = load i8**, i8*** %8
%123 = load i32, i32* %14
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8*, i8** %122, i64 %124
%126 = load i8*, i8** %125
%127 = load i8**, i8*** %8
%128 = load i32, i32* %14
%129 = add nsw i32 %128, 1
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i8*, i8** %127, i64 %130
%132 = load i8*, i8** %131
%133 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %126, i8* %132)
%134 = load i32, i32* %17
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %137
136: ; preds = %106
br label %143
137: ; preds = %106
%138 = load i8**, i8*** %8
%139 = load i32, i32* %14
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8*, i8** %138, i64 %140
%142 = load i8*, i8** %141
br label %143
143: ; preds = %137, %136
%144 = phi i8* [ null, %136 ], [ %142, %137 ]
%145 = load i8**, i8*** %8
%146 = load i32, i32* %14
%147 = add nsw i32 %146, 1
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i8*, i8** %145, i64 %148
%150 = load i8*, i8** %149
%151 = bitcast %struct.addrinfo* %18 to %struct.timeval*
%152 = bitcast %struct.addrinfo** %15 to %struct.timeval**
%153 = call i32 @getaddrinfo(i8* %144, i8* %150, %struct.timeval* %151, %struct.timeval** %152)
store i32 %153, i32* %13
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %161
155: ; preds = %143
%156 = load i32, i32* @stderr
%157 = load i32, i32* %13
%158 = call i8* @gai_strerror(i32 %157)
%159 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %158)
%160 = call i32 @exit(i32 1)
unreachable
161: ; preds = %143
%162 = load %struct.addrinfo*, %struct.addrinfo** %15
%163 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %162, i32 0, i32 5
%164 = load i32, i32* %163
%165 = load %struct.addrinfo*, %struct.addrinfo** %15
%166 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %165, i32 0, i32 4
%167 = load i32, i32* %166
%168 = load %struct.addrinfo*, %struct.addrinfo** %15
%169 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %168, i32 0, i32 3
%170 = load i64, i64* %169
%171 = call i32 @socket(i32 %164, i32 %167, i64 %170)
store i32 %171, i32* %13
%172 = load i32, i32* %13
%173 = icmp eq i32 %172, -1
br i1 %173, label %174, label %177
174: ; preds = %161
%175 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%176 = call i32 @exit(i32 1)
unreachable
177: ; preds = %161
%178 = load i32, i32* %13
%179 = load i32, i32* @IPPROTO_TCP
%180 = load i32, i32* @TCP_NODELAY
%181 = bitcast i32* %16 to i8*
%182 = call i32 @setsockopt(i32 %178, i32 %179, i32 %180, i8* %181, i32 4)
%183 = load i32, i32* %13
%184 = load i32, i32* @SOL_SOCKET
%185 = load i32, i32* @SO_REUSEADDR
%186 = bitcast i32* %16 to i8*
%187 = call i32 @setsockopt(i32 %183, i32 %184, i32 %185, i8* %186, i32 4)
%188 = load i32, i32* %13
%189 = load i32, i32* @SOL_SOCKET
%190 = load i32, i32* @SO_KEEPALIVE
%191 = bitcast i32* %16 to i8*
%192 = call i32 @setsockopt(i32 %188, i32 %189, i32 %190, i8* %191, i32 4)
%193 = call i32 @memset(%struct.timeval* %19, i32 0, i32 56)
%194 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
store i32 10, i32* %194
%195 = load i32, i32* %13
%196 = load i32, i32* @SOL_SOCKET
%197 = load i32, i32* @SO_RCVTIMEO
%198 = bitcast %struct.timeval* %19 to i8*
%199 = call i32 @setsockopt(i32 %195, i32 %196, i32 %197, i8* %198, i32 56)
%200 = load i32, i32* %13
%201 = load i32, i32* @SOL_SOCKET
%202 = load i32, i32* @SO_SNDTIMEO
%203 = bitcast %struct.timeval* %19 to i8*
%204 = call i32 @setsockopt(i32 %200, i32 %201, i32 %202, i8* %203, i32 56)
%205 = load i32, i32* %17
%206 = icmp ne i32 %205, 0
br i1 %206, label %207, label %232
207: ; preds = %177
%208 = load i32, i32* %13
%209 = load %struct.addrinfo*, %struct.addrinfo** %15
%210 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %209, i32 0, i32 2
%211 = load i32*, i32** %210
%212 = load %struct.addrinfo*, %struct.addrinfo** %15
%213 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %212, i32 0, i32 1
%214 = load i32, i32* %213
%215 = call i32 @bind(i32 %208, i32* %211, i32 %214)
%216 = icmp eq i32 %215, -1
br i1 %216, label %217, label %220
217: ; preds = %207
%218 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%219 = call i32 @exit(i32 1)
unreachable
220: ; preds = %207
%221 = load i32, i32* %13
%222 = load i32*, i32** %12
store i32 %221, i32* %222
%223 = load i32, i32* %13
%224 = call i32 @listen(i32 %223, i32 16)
%225 = load i32, i32* %13
%226 = load %struct.addrinfo*, %struct.addrinfo** %15
%227 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %226, i32 0, i32 2
%228 = load i32*, i32** %227
%229 = load %struct.addrinfo*, %struct.addrinfo** %15
%230 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %229, i32 0, i32 1
%231 = call i32 @accept(i32 %225, i32* %228, i32* %230)
store i32 %231, i32* %13
br label %246
232: ; preds = %177
%233 = load i32, i32* %13
%234 = load %struct.addrinfo*, %struct.addrinfo** %15
%235 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %234, i32 0, i32 2
%236 = load i32*, i32** %235
%237 = load %struct.addrinfo*, %struct.addrinfo** %15
%238 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %237, i32 0, i32 1
%239 = load i32, i32* %238
%240 = call i32 @connect(i32 %233, i32* %236, i32 %239)
%241 = icmp eq i32 %240, -1
br i1 %241, label %242, label %245
242: ; preds = %232
%243 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%244 = call i32 @exit(i32 1)
unreachable
245: ; preds = %232
br label %246
246: ; preds = %245, %220
%247 = load i32, i32* %13
ret i32 %247
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32*, i64, i32, i32, i32*, i32*, i32 }
%struct.timeval = type { i32, i32, i32*, i64, i32, i32, i32*, i32*, i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@SOCK_DGRAM = global i32 0
@stderr = global i32 0
@.str.2 = [24 x i8] c"Choose one of -l or -u\0A\00"
@.str.3 = [15 x i8] c"Sleeptime: %s\0A\00"
@.str.4 = [7 x i8] c"%s:%s\0A\00"
@.str.5 = [16 x i8] c"getaddrinfoL %s\00"
@.str.6 = [7 x i8] c"socket\00"
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@SO_KEEPALIVE = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
@.str.7 = [5 x i8] c"bind\00"
@.str.8 = [8 x i8] c"connect\00"
define i32 @dosocket(i32 %0, i8** nocapture %1, i32* %2, i32* nocapture %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5) {
%7 = alloca %struct.addrinfo*
%8 = alloca i32
%9 = alloca %struct.addrinfo
%10 = alloca %struct.timeval
%11 = bitcast %struct.addrinfo** %7 to i8*
%12 = bitcast i32* %8 to i8*
store i32 1, i32* %8
%13 = bitcast %struct.addrinfo* %9 to i8*
%14 = bitcast %struct.timeval* %10 to i8*
%15 = bitcast %struct.addrinfo* %9 to %struct.timeval*
%16 = call i32 @memset(%struct.timeval* %15, i32 0, i32 56)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i64 0, i32 5
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_STREAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i64 0, i32 4
store i32 %19, i32* %20
%21 = load i32, i32* @AI_PASSIVE
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i64 0, i32 8
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i64 0, i32 2
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i64 0, i32 6
%25 = icmp slt i32 %0, 4
%26 = bitcast i32** %23 to i8*
%27 = bitcast i32** %24 to i8*
br i1 %25, label %37, label %28
28: ; preds = %6
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %28
%34 = load i8*, i8** %29
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %33, %28, %6
%38 = load i8*, i8** %1
%39 = call i32 @usage(i8* %38)
%40 = call i32 @exit(i32 0)
unreachable
41: ; preds = %33
%42 = load i8*, i8** %29
%43 = call i32 @atoi(i8* %42)
%44 = load i32, i32* %3
%45 = call i32 @genstring(i32 %43, i32* %2, i32 %44)
store i32 %45, i32* %3
%46 = getelementptr inbounds i8*, i8** %1, i64 2
%47 = load i8*, i8** %46
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 45
br i1 %49, label %50, label %59
50: ; preds = %41
%51 = getelementptr inbounds i8, i8* %47, i64 1
%52 = load i8, i8* %51
switch i8 %52, label %55 [
i8 117, label %53
i8 108, label %59
]
53: ; preds = %50
%54 = load i32, i32* @SOCK_DGRAM
store i32 %54, i32* %20
br label %59
55: ; preds = %50
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %53, %50, %41
%60 = phi i32 [ 2, %41 ], [ 3, %50 ], [ 3, %53 ]
%61 = phi i1 [ true, %41 ], [ false, %50 ], [ true, %53 ]
%62 = add nuw nsw i32 %60, 2
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %1, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %65)
%67 = load i8*, i8** %64
%68 = call i32 @atoi(i8* %67)
store i32 %68, i32* %4
%69 = zext i32 %60 to i64
%70 = getelementptr inbounds i8*, i8** %1, i64 %69
%71 = load i8*, i8** %70
%72 = add nuw nsw i32 %60, 1
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %1, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %71, i8* %75)
br i1 %61, label %77, label %79
77: ; preds = %59
%78 = load i8*, i8** %70
br label %79
79: ; preds = %59, %77
%80 = phi i8* [ %78, %77 ], [ null, %59 ]
%81 = load i8*, i8** %74
%82 = bitcast %struct.addrinfo** %7 to %struct.timeval**
%83 = call i32 @getaddrinfo(i8* %80, i8* %81, %struct.timeval* %15, %struct.timeval** %82)
%84 = icmp eq i32 %83, 0
br i1 %84, label %90, label %85
85: ; preds = %79
%86 = load i32, i32* @stderr
%87 = call i8* @gai_strerror(i32 %83)
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %87)
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %79
%91 = load %struct.addrinfo*, %struct.addrinfo** %7
%92 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %91, i64 0, i32 5
%93 = load i32, i32* %92
%94 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %91, i64 0, i32 4
%95 = load i32, i32* %94
%96 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %91, i64 0, i32 3
%97 = load i64, i64* %96
%98 = call i32 @socket(i32 %93, i32 %95, i64 %97)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %103
100: ; preds = %90
%101 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %90
%104 = load i32, i32* @IPPROTO_TCP
%105 = load i32, i32* @TCP_NODELAY
%106 = call i32 @setsockopt(i32 %98, i32 %104, i32 %105, i8* %12, i32 4)
%107 = load i32, i32* @SOL_SOCKET
%108 = load i32, i32* @SO_REUSEADDR
%109 = call i32 @setsockopt(i32 %98, i32 %107, i32 %108, i8* %12, i32 4)
%110 = load i32, i32* @SOL_SOCKET
%111 = load i32, i32* @SO_KEEPALIVE
%112 = call i32 @setsockopt(i32 %98, i32 %110, i32 %111, i8* %12, i32 4)
%113 = call i32 @memset(%struct.timeval* %10, i32 0, i32 56)
%114 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
store i32 10, i32* %114
%115 = load i32, i32* @SOL_SOCKET
%116 = load i32, i32* @SO_RCVTIMEO
%117 = call i32 @setsockopt(i32 %98, i32 %115, i32 %116, i8* %14, i32 56)
%118 = load i32, i32* @SOL_SOCKET
%119 = load i32, i32* @SO_SNDTIMEO
%120 = call i32 @setsockopt(i32 %98, i32 %118, i32 %119, i8* %14, i32 56)
%121 = load %struct.addrinfo*, %struct.addrinfo** %7
%122 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %121, i64 0, i32 2
%123 = load i32*, i32** %122
%124 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %121, i64 0, i32 1
%125 = load i32, i32* %124
br i1 %61, label %139, label %126
126: ; preds = %103
%127 = call i32 @bind(i32 %98, i32* %123, i32 %125)
%128 = icmp eq i32 %127, -1
br i1 %128, label %129, label %132
129: ; preds = %126
%130 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%131 = call i32 @exit(i32 1)
unreachable
132: ; preds = %126
store i32 %98, i32* %5
%133 = call i32 @listen(i32 %98, i32 16)
%134 = load %struct.addrinfo*, %struct.addrinfo** %7
%135 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %134, i64 0, i32 2
%136 = load i32*, i32** %135
%137 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %134, i64 0, i32 1
%138 = call i32 @accept(i32 %98, i32* %136, i32* %137)
br label %145
139: ; preds = %103
%140 = call i32 @connect(i32 %98, i32* %123, i32 %125)
%141 = icmp eq i32 %140, -1
br i1 %141, label %142, label %145
142: ; preds = %139
%143 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%144 = call i32 @exit(i32 1)
unreachable
145: ; preds = %139, %132
%146 = phi i32 [ %138, %132 ], [ %98, %139 ]
ret i32 %146
}