#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr {
  int dummy;
};
struct addrinfo {
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  struct addrinfo *ai_next;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
char *gai_strerror(int);
int /*<<< orphan*/ get_in_addr(struct sockaddr *);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
char *getenv(char *);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                             int);
char *malloc(int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ send_all(int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
char *strtok_r(char *, char *, char **);
int open_irc_socket(char **host, char **port, char **chan, char **nick,
                    char **pass, char **name) {
  char path[512], *buf, *saveptr, *field, *value;
  char res[512];
  FILE *file;
  int len, pos;
  struct addrinfo hints, *servinfo, *p;
  int sockfd, rv;
  char s[INET6_ADDRSTRLEN];
  char *irc_host, *irc_port, *irc_chan, *irc_nick, *irc_pass, *irc_name;
  snprintf(path, 512, "%s/.konabotrc", getenv("HOME"));
  file = fopen(path, "r");
  if (!file) {
    return -1;
  }
  if (fseek(file, 0, SEEK_END) != 0) {
    fclose(file);
    return -1;
  }
  len = ftell(file);
  buf = malloc(len + 1);
  pos = 0;
  rewind(file);
  while (pos < len) {
    int ret;
    ret = fread(buf, len - pos, 1, file);
    if (ret <= 0) {
      if (feof(file))
        break;
      else {
        fclose(file);
        free(buf);
        return -1;
      }
    }
    pos += ret;
  }
  irc_host = NULL;
  irc_port = NULL;
  irc_chan = NULL;
  irc_nick = NULL;
  irc_pass = NULL;
  irc_name = NULL;
  field = strtok_r(buf, "\n", &saveptr);
  while (field) {
    value = strchr(field, '=');
    if (value) {
      *value = '\0';
      value++;
      if (strcmp(field, "irc_host") == 0)
        irc_host = value;
      else if (strcmp(field, "irc_port") == 0)
        irc_port = value;
      else if (strcmp(field, "irc_chan") == 0)
        irc_chan = value;
      else if (strcmp(field, "irc_nick") == 0)
        irc_nick = value;
      else if (strcmp(field, "irc_pass") == 0)
        irc_pass = value;
      else if (strcmp(field, "irc_name") == 0)
        irc_name = value;
    }
    field = strtok_r(NULL, "\n", &saveptr);
  }
  fclose(file);
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((rv = getaddrinfo(irc_host, irc_port, &hints, &servinfo)) != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
    return -1;
  }
  for (p = servinfo; p != NULL; p = p->ai_next) {
    if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
      perror("socket");
      continue;
    }
    if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
      close(sockfd);
      perror("connect");
      continue;
    }
    break;
  }
  if (p == NULL) {
    fprintf(stderr, "Failed to connect\n");
    return -1;
  }
  inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr), s,
            sizeof s);
  printf("Connecting to %s\n", s);
  freeaddrinfo(servinfo);
  snprintf(res, 512, "NICK %s\r\n", irc_nick);
  send_all(sockfd, res);
  snprintf(res, 512, "USER %s 0 * :%s\r\n", irc_nick, irc_name);
  send_all(sockfd, res);
  if (irc_pass && irc_pass[0] != '\0') {
    snprintf(res, 512, "PRIVMSG NickServ :IDENTIFY %s\r\n", irc_pass);
    send_all(sockfd, res);
  }
  snprintf(res, 512, "JOIN %s\r\n", irc_chan);
  send_all(sockfd, res);
  *host = strdup(irc_host);
  *port = strdup(irc_port);
  *chan = strdup(irc_chan);
  *nick = strdup(irc_nick);
  *pass = strdup(irc_pass);
  *name = strdup(irc_name);
  free(buf);
  return sockfd;
}


x86 assembly (clang, -O0):
<open_irc_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x510,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    0x2cfe(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x508(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x4b0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x500(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x4b8(%rbp)
lea    -0x240(%rbp),%rax
mov    %rax,-0x4f8(%rbp)
lea    0xcda(%rip),%rdi
call   1040 <getenv@plt>
mov    -0x4f8(%rbp),%rdi
mov    %rax,%rcx
mov    $0x200,%esi
lea    0xcb1(%rip),%rdx
mov    $0x0,%al
call   10c0 <snprintf@plt>
lea    -0x240(%rbp),%rdi
lea    0xcaf(%rip),%rsi
call   1170 <fopen@plt>
mov    %rax,-0x468(%rbp)
cmpq   $0x0,-0x468(%rbp)
jne    1394 <open_irc_socket+0xd4>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4ec(%rbp)
jmp    1a6c <open_irc_socket+0x7ac>
mov    -0x468(%rbp),%rdi
mov    0x2c3e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1160 <fseek@plt>
cmp    $0x0,%rax
je     13d7 <open_irc_socket+0x117>
mov    -0x468(%rbp),%rdi
call   1080 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4ec(%rbp)
jmp    1a6c <open_irc_socket+0x7ac>
mov    -0x468(%rbp),%rdi
call   1130 <ftell@plt>
mov    %eax,-0x46c(%rbp)
mov    -0x46c(%rbp),%edi
add    $0x1,%edi
call   1150 <malloc@plt>
mov    %rax,-0x248(%rbp)
movl   $0x0,-0x470(%rbp)
mov    -0x468(%rbp),%rdi
call   10b0 <rewind@plt>
mov    -0x470(%rbp),%eax
cmp    -0x46c(%rbp),%eax
jge    14bd <open_irc_socket+0x1fd>
mov    -0x248(%rbp),%rdi
mov    -0x46c(%rbp),%esi
sub    -0x470(%rbp),%esi
mov    -0x468(%rbp),%rcx
mov    $0x1,%edx
call   1070 <fread@plt>
mov    %eax,-0x4f0(%rbp)
cmpl   $0x0,-0x4f0(%rbp)
jg     14a6 <open_irc_socket+0x1e6>
mov    -0x468(%rbp),%rdi
call   1140 <feof@plt>
cmp    $0x0,%rax
je     1478 <open_irc_socket+0x1b8>
jmp    14bd <open_irc_socket+0x1fd>
mov    -0x468(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x248(%rbp),%rdi
call   1050 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4ec(%rbp)
jmp    1a6c <open_irc_socket+0x7ac>
mov    -0x4f0(%rbp),%eax
add    -0x470(%rbp),%eax
mov    %eax,-0x470(%rbp)
jmp    1414 <open_irc_socket+0x154>
movq   $0x0,-0x4c0(%rbp)
movq   $0x0,-0x4c8(%rbp)
movq   $0x0,-0x4d0(%rbp)
movq   $0x0,-0x4d8(%rbp)
movq   $0x0,-0x4e0(%rbp)
movq   $0x0,-0x4e8(%rbp)
mov    -0x248(%rbp),%rdi
lea    0xb8b(%rip),%rsi
lea    -0x250(%rbp),%rdx
call   1100 <strtok_r@plt>
mov    %rax,-0x258(%rbp)
cmpq   $0x0,-0x258(%rbp)
je     16cc <open_irc_socket+0x40c>
mov    -0x258(%rbp),%rdi
mov    $0x3d,%esi
call   1090 <strchr@plt>
mov    %rax,-0x260(%rbp)
cmpq   $0x0,-0x260(%rbp)
je     16a9 <open_irc_socket+0x3e9>
mov    -0x260(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x260(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x260(%rbp)
mov    -0x258(%rbp),%rdi
lea    0xa97(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    15a0 <open_irc_socket+0x2e0>
mov    -0x260(%rbp),%rax
mov    %rax,-0x4c0(%rbp)
jmp    16a4 <open_irc_socket+0x3e4>
mov    -0x258(%rbp),%rdi
lea    0xa70(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    15d0 <open_irc_socket+0x310>
mov    -0x260(%rbp),%rax
mov    %rax,-0x4c8(%rbp)
jmp    169f <open_irc_socket+0x3df>
mov    -0x258(%rbp),%rdi
lea    0xa49(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    1600 <open_irc_socket+0x340>
mov    -0x260(%rbp),%rax
mov    %rax,-0x4d0(%rbp)
jmp    169a <open_irc_socket+0x3da>
mov    -0x258(%rbp),%rdi
lea    0xa22(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    1630 <open_irc_socket+0x370>
mov    -0x260(%rbp),%rax
mov    %rax,-0x4d8(%rbp)
jmp    1695 <open_irc_socket+0x3d5>
mov    -0x258(%rbp),%rdi
lea    0x9fb(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    1660 <open_irc_socket+0x3a0>
mov    -0x260(%rbp),%rax
mov    %rax,-0x4e0(%rbp)
jmp    1690 <open_irc_socket+0x3d0>
mov    -0x258(%rbp),%rdi
lea    0x9d4(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
jne    168b <open_irc_socket+0x3cb>
mov    -0x260(%rbp),%rax
mov    %rax,-0x4e8(%rbp)
jmp    1690 <open_irc_socket+0x3d0>
jmp    1695 <open_irc_socket+0x3d5>
jmp    169a <open_irc_socket+0x3da>
jmp    169f <open_irc_socket+0x3df>
jmp    16a4 <open_irc_socket+0x3e4>
jmp    16a9 <open_irc_socket+0x3e9>
xor    %eax,%eax
mov    %eax,%edi
lea    0x9e4(%rip),%rsi
lea    -0x250(%rbp),%rdx
call   1100 <strtok_r@plt>
mov    %rax,-0x258(%rbp)
jmp    1520 <open_irc_socket+0x260>
mov    -0x468(%rbp),%rdi
call   1080 <fclose@plt>
lea    -0x490(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10e0 <memset@plt>
mov    0x28e6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x488(%rbp)
mov    0x28bf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x47c(%rbp)
mov    -0x4c0(%rbp),%rdi
mov    -0x4c8(%rbp),%rsi
lea    -0x490(%rbp),%rdx
lea    -0x498(%rbp),%rcx
call   11a0 <getaddrinfo@plt>
mov    %eax,-0x4a8(%rbp)
cmp    $0x0,%eax
je     1780 <open_irc_socket+0x4c0>
mov    0x2888(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50c(%rbp)
mov    -0x4a8(%rbp),%edi
call   10d0 <gai_strerror@plt>
mov    -0x50c(%rbp),%edi
mov    %rax,%rdx
lea    0x8e8(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4ec(%rbp)
jmp    1a6c <open_irc_socket+0x7ac>
mov    -0x498(%rbp),%rax
mov    %rax,-0x4a0(%rbp)
cmpq   $0x0,-0x4a0(%rbp)
je     183f <open_irc_socket+0x57f>
mov    -0x4a0(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x4a0(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x4a0(%rbp),%rax
mov    0x10(%rax),%edx
call   11e0 <socket@plt>
mov    %eax,-0x4a4(%rbp)
cmp    $0xffffffff,%eax
jne    17df <open_irc_socket+0x51f>
lea    0x887(%rip),%rdi
call   1180 <perror@plt>
jmp    1828 <open_irc_socket+0x568>
mov    -0x4a4(%rbp),%edi
mov    -0x4a0(%rbp),%rax
mov    (%rax),%rsi
mov    -0x4a0(%rbp),%rax
mov    0xc(%rax),%edx
call   1190 <connect@plt>
cmp    $0xffffffff,%eax
jne    1823 <open_irc_socket+0x563>
mov    -0x4a4(%rbp),%edi
call   10f0 <close@plt>
lea    0x84a(%rip),%rdi
call   1180 <perror@plt>
jmp    1828 <open_irc_socket+0x568>
jmp    183f <open_irc_socket+0x57f>
mov    -0x4a0(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x4a0(%rbp)
jmp    178e <open_irc_socket+0x4ce>
cmpq   $0x0,-0x4a0(%rbp)
jne    187a <open_irc_socket+0x5ba>
mov    0x2774(%rip),%rax
mov    (%rax),%edi
lea    0x80e(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4ec(%rbp)
jmp    1a6c <open_irc_socket+0x7ac>
mov    -0x4a0(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x510(%rbp)
mov    -0x4a0(%rbp),%rax
mov    (%rax),%rdi
call   1060 <get_in_addr@plt>
mov    -0x510(%rbp),%edi
mov    -0x500(%rbp),%rdx
mov    %eax,%esi
mov    -0x508(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x500(%rbp),%rsi
lea    0x7ba(%rip),%rdi
call   10a0 <printf@plt>
mov    -0x498(%rbp),%rdi
call   11d0 <freeaddrinfo@plt>
lea    -0x460(%rbp),%rdi
mov    -0x4d8(%rbp),%rcx
mov    $0x200,%esi
lea    0x7a1(%rip),%rdx
mov    $0x0,%al
call   10c0 <snprintf@plt>
mov    -0x4a4(%rbp),%edi
lea    -0x460(%rbp),%rsi
call   11c0 <send_all@plt>
lea    -0x460(%rbp),%rdi
mov    -0x4d8(%rbp),%rcx
mov    -0x4e8(%rbp),%r8
mov    $0x200,%esi
lea    0x771(%rip),%rdx
mov    $0x0,%al
call   10c0 <snprintf@plt>
mov    -0x4a4(%rbp),%edi
lea    -0x460(%rbp),%rsi
call   11c0 <send_all@plt>
cmpq   $0x0,-0x4e0(%rbp)
je     1996 <open_irc_socket+0x6d6>
mov    -0x4e0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1996 <open_irc_socket+0x6d6>
lea    -0x460(%rbp),%rdi
mov    -0x4e0(%rbp),%rcx
mov    $0x200,%esi
lea    0x72f(%rip),%rdx
mov    $0x0,%al
call   10c0 <snprintf@plt>
mov    -0x4a4(%rbp),%edi
lea    -0x460(%rbp),%rsi
call   11c0 <send_all@plt>
lea    -0x460(%rbp),%rdi
mov    -0x4d0(%rbp),%rcx
mov    $0x200,%esi
lea    0x71c(%rip),%rdx
mov    $0x0,%al
call   10c0 <snprintf@plt>
mov    -0x4a4(%rbp),%edi
lea    -0x460(%rbp),%rsi
call   11c0 <send_all@plt>
mov    -0x4c0(%rbp),%rdi
call   11b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4c8(%rbp),%rdi
call   11b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4d0(%rbp),%rdi
call   11b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4d8(%rbp),%rdi
call   11b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4e0(%rbp),%rdi
call   11b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4e8(%rbp),%rdi
call   11b0 <strdup@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x248(%rbp),%rdi
call   1050 <free@plt>
mov    -0x4a4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4ec(%rbp)
mov    -0x4b0(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_irc_socket>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4b8,%rsp
mov    %r9,%r14
mov    %r8,-0xb0(%rbp)
mov    %rcx,-0xa8(%rbp)
mov    %rdx,-0xa0(%rbp)
mov    %rsi,-0x98(%rbp)
mov    %rdi,-0x90(%rbp)
mov    %rsp,%r12
mov    0x2ce4(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rax,-0x80(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
lea    0xce5(%rip),%rdi
call   1040 <getenv@plt>
lea    0xccb(%rip),%rdx
lea    -0x4e0(%rbp),%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %rax,%rcx
xor    %eax,%eax
call   10c0 <snprintf@plt>
lea    0xcbe(%rip),%rsi
mov    %rbx,%rdi
call   1170 <fopen@plt>
mov    $0xffffffff,%r13d
test   %rax,%rax
je     17e1 <open_irc_socket+0x521>
mov    %rax,%r15
mov    0x2c6a(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1160 <fseek@plt>
test   %rax,%rax
je     1394 <open_irc_socket+0xd4>
mov    %r15,%rdi
call   1080 <fclose@plt>
jmp    17e1 <open_irc_socket+0x521>
mov    %r14,-0x78(%rbp)
mov    %r15,%rdi
call   1130 <ftell@plt>
mov    %eax,%r14d
lea    0x1(%r14),%edi
call   1150 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    %r15,%rdi
call   10b0 <rewind@plt>
test   %r14d,%r14d
jle    13f4 <open_irc_socket+0x134>
xor    %ebx,%ebx
nop
mov    %r14d,%esi
sub    %ebx,%esi
mov    -0x50(%rbp),%rdi
mov    $0x1,%edx
mov    %r15,%rcx
call   1070 <fread@plt>
test   %eax,%eax
jle    13e3 <open_irc_socket+0x123>
add    %eax,%ebx
cmp    %ebx,%r14d
jg     13c0 <open_irc_socket+0x100>
jmp    13f4 <open_irc_socket+0x134>
mov    %r15,%rdi
call   1140 <feof@plt>
test   %rax,%rax
je     17ca <open_irc_socket+0x50a>
mov    %r12,-0x68(%rbp)
lea    0xc99(%rip),%rsi
lea    -0xb8(%rbp),%rdx
mov    -0x50(%rbp),%rdi
call   1100 <strtok_r@plt>
test   %rax,%rax
je     1534 <open_irc_socket+0x274>
mov    %rax,%r12
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
lea    0xc70(%rip),%rbx
lea    -0xb8(%rbp),%r14
xor    %eax,%eax
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %rax,-0x60(%rbp)
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    146d <open_irc_socket+0x1ad>
nop
mov    %r13,-0x48(%rbp)
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1100 <strtok_r@plt>
mov    %rax,%r12
test   %rax,%rax
je     1558 <open_irc_socket+0x298>
mov    %r12,%rdi
mov    $0x3d,%esi
call   1090 <strchr@plt>
test   %rax,%rax
je     1454 <open_irc_socket+0x194>
mov    %rax,%r13
movb   $0x0,(%rax)
add    $0x1,%r13
mov    %r12,%rdi
lea    0xb82(%rip),%rsi
call   1110 <strcmp@plt>
test   %rax,%rax
je     1450 <open_irc_socket+0x190>
mov    %r12,%rdi
lea    0xb77(%rip),%rsi
call   1110 <strcmp@plt>
test   %rax,%rax
je     1510 <open_irc_socket+0x250>
mov    %r12,%rdi
lea    0xb6c(%rip),%rsi
call   1110 <strcmp@plt>
test   %rax,%rax
je     1519 <open_irc_socket+0x259>
mov    %r12,%rdi
lea    0xb61(%rip),%rsi
call   1110 <strcmp@plt>
test   %rax,%rax
je     1522 <open_irc_socket+0x262>
mov    %r12,%rdi
lea    0xb56(%rip),%rsi
call   1110 <strcmp@plt>
test   %rax,%rax
je     152b <open_irc_socket+0x26b>
mov    %r12,%rdi
lea    0xb4b(%rip),%rsi
call   1110 <strcmp@plt>
test   %rax,%rax
mov    -0x30(%rbp),%rax
cmove  %r13,%rax
mov    %rax,-0x30(%rbp)
jmp    1454 <open_irc_socket+0x194>
mov    %r13,-0x40(%rbp)
jmp    1454 <open_irc_socket+0x194>
mov    %r13,-0x60(%rbp)
jmp    1454 <open_irc_socket+0x194>
mov    %r13,-0x38(%rbp)
jmp    1454 <open_irc_socket+0x194>
mov    %r13,-0x58(%rbp)
jmp    1454 <open_irc_socket+0x194>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %rax,-0x60(%rbp)
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
mov    %r15,%rdi
call   1080 <fclose@plt>
lea    -0xd8(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10e0 <memset@plt>
mov    0x2a5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd0(%rbp)
mov    0x2a34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
lea    -0x70(%rbp),%rcx
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %rbx,%rdx
call   11a0 <getaddrinfo@plt>
test   %eax,%eax
je     15d8 <open_irc_socket+0x318>
mov    0x2a15(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   10d0 <gai_strerror@plt>
lea    0xa88(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1120 <fprintf@plt>
mov    -0x68(%rbp),%r12
jmp    17db <open_irc_socket+0x51b>
mov    -0x70(%rbp),%rbx
test   %rbx,%rbx
mov    -0x68(%rbp),%r12
je     1637 <open_irc_socket+0x377>
lea    0xa70(%rip),%r14
lea    0xa70(%rip),%r15
mov    0x14(%rbx),%esi
mov    0x8(%rbx),%edi
mov    0x10(%rbx),%edx
call   11e0 <socket@plt>
mov    %r14,%rdi
cmp    $0xffffffff,%eax
je     1629 <open_irc_socket+0x369>
mov    %eax,%r13d
mov    (%rbx),%rsi
mov    0xc(%rbx),%edx
mov    %eax,%edi
call   1190 <connect@plt>
cmp    $0xffffffff,%eax
jne    1653 <open_irc_socket+0x393>
mov    %r13d,%edi
call   10f0 <close@plt>
mov    %r15,%rdi
call   1180 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    15f3 <open_irc_socket+0x333>
mov    0x298a(%rip),%rax
mov    (%rax),%edi
lea    0xa24(%rip),%rsi
xor    %eax,%eax
call   1120 <fprintf@plt>
jmp    17db <open_irc_socket+0x51b>
mov    0x8(%rbx),%r14d
mov    (%rbx),%rdi
call   1060 <get_in_addr@plt>
mov    %r14d,%edi
mov    %eax,%esi
mov    -0x88(%rbp),%rbx
mov    %rbx,%rdx
mov    -0x80(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xa00(%rip),%rdi
mov    %rbx,%rsi
call   10a0 <printf@plt>
mov    -0x70(%rbp),%rdi
call   11d0 <freeaddrinfo@plt>
lea    0x9fa(%rip),%rdx
lea    -0x2e0(%rbp),%r15
mov    %r15,%rdi
mov    $0x200,%esi
mov    -0x38(%rbp),%rbx
mov    %rbx,%rcx
xor    %eax,%eax
call   10c0 <snprintf@plt>
mov    %r13d,%edi
mov    %r15,%rsi
call   11c0 <send_all@plt>
lea    0x9d5(%rip),%rdx
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
mov    -0x30(%rbp),%r8
mov    %r8,-0x30(%rbp)
xor    %eax,%eax
call   10c0 <snprintf@plt>
mov    %r13d,%edi
mov    %r15,%rsi
call   11c0 <send_all@plt>
mov    -0x58(%rbp),%rbx
test   %rbx,%rbx
je     1723 <open_irc_socket+0x463>
cmpb   $0x0,(%rbx)
je     1723 <open_irc_socket+0x463>
lea    0x9ad(%rip),%rdx
lea    -0x2e0(%rbp),%r15
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   10c0 <snprintf@plt>
mov    %r13d,%edi
mov    %r15,%rsi
call   11c0 <send_all@plt>
lea    0x9a2(%rip),%rdx
lea    -0x2e0(%rbp),%r15
mov    %r15,%rdi
mov    $0x200,%esi
mov    -0x60(%rbp),%r14
mov    %r14,%rcx
xor    %eax,%eax
call   10c0 <snprintf@plt>
mov    %r13d,%edi
mov    %r15,%rsi
call   11c0 <send_all@plt>
mov    -0x48(%rbp),%rdi
call   11b0 <strdup@plt>
mov    -0x90(%rbp),%rcx
mov    %rax,(%rcx)
mov    -0x40(%rbp),%rdi
call   11b0 <strdup@plt>
mov    -0x98(%rbp),%rcx
mov    %rax,(%rcx)
mov    %r14,%rdi
call   11b0 <strdup@plt>
mov    -0xa0(%rbp),%rcx
mov    %rax,(%rcx)
mov    -0x38(%rbp),%rdi
call   11b0 <strdup@plt>
mov    -0xa8(%rbp),%rcx
mov    %rax,(%rcx)
mov    %rbx,%rdi
call   11b0 <strdup@plt>
mov    -0xb0(%rbp),%rcx
mov    %rax,(%rcx)
mov    -0x30(%rbp),%rdi
call   11b0 <strdup@plt>
mov    -0x78(%rbp),%rcx
mov    %rax,(%rcx)
mov    -0x50(%rbp),%rdi
call   1050 <free@plt>
jmp    17e1 <open_irc_socket+0x521>
mov    %r15,%rdi
call   1080 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1050 <free@plt>
mov    $0xffffffff,%r13d
mov    %r12,%rsp
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [14 x i8] c"%s/.konabotrc\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [9 x i8] c"irc_host\00"
@.str.5 = [9 x i8] c"irc_port\00"
@.str.6 = [9 x i8] c"irc_chan\00"
@.str.7 = [9 x i8] c"irc_nick\00"
@.str.8 = [9 x i8] c"irc_pass\00"
@.str.9 = [9 x i8] c"irc_name\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str.10 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.11 = [7 x i8] c"socket\00"
@.str.12 = [8 x i8] c"connect\00"
@.str.13 = [19 x i8] c"Failed to connect\0A\00"
@.str.14 = [18 x i8] c"Connecting to %s\0A\00"
@.str.15 = [10 x i8] c"NICK %s\0D\0A\00"
@.str.16 = [18 x i8] c"USER %s 0 * :%s\0D\0A\00"
@.str.17 = [32 x i8] c"PRIVMSG NickServ :IDENTIFY %s\0D\0A\00"
@.str.18 = [10 x i8] c"JOIN %s\0D\0A\00"
define i32 @open_irc_socket(i8** %0, i8** %1, i8** %2, i8** %3, i8** %4, i8** %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i8**
%13 = alloca i8**
%14 = alloca [512 x i8]
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca [512 x i8]
%20 = alloca i32*
%21 = alloca i32
%22 = alloca i32
%23 = alloca %struct.addrinfo
%24 = alloca %struct.addrinfo*
%25 = alloca %struct.addrinfo*
%26 = alloca i32
%27 = alloca i32
%28 = alloca i8*
%29 = alloca i64
%30 = alloca i8*
%31 = alloca i8*
%32 = alloca i8*
%33 = alloca i8*
%34 = alloca i8*
%35 = alloca i8*
%36 = alloca i32
%37 = alloca i32
store i8** %0, i8*** %8
store i8** %1, i8*** %9
store i8** %2, i8*** %10
store i8** %3, i8*** %11
store i8** %4, i8*** %12
store i8** %5, i8*** %13
%38 = load i32, i32* @INET6_ADDRSTRLEN
%39 = zext i32 %38 to i64
%40 = call i8* @llvm.stacksave()
store i8* %40, i8** %28
%41 = alloca i8, i64 %39
store i64 %39, i64* %29
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%43 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %42, i32 512, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %46, i32** %20
%47 = load i32*, i32** %20
%48 = icmp ne i32* %47, null
br i1 %48, label %50, label %49
49: ; preds = %6
store i32 -1, i32* %7
store i32 1, i32* %36
br label %282
50: ; preds = %6
%51 = load i32*, i32** %20
%52 = load i32, i32* @SEEK_END
%53 = call i64 @fseek(i32* %51, i32 0, i32 %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = load i32*, i32** %20
%57 = call i32 @fclose(i32* %56)
store i32 -1, i32* %7
store i32 1, i32* %36
br label %282
58: ; preds = %50
%59 = load i32*, i32** %20
%60 = call i32 @ftell(i32* %59)
store i32 %60, i32* %21
%61 = load i32, i32* %21
%62 = add nsw i32 %61, 1
%63 = call i8* @malloc(i32 %62)
store i8* %63, i8** %15
store i32 0, i32* %22
%64 = load i32*, i32** %20
%65 = call i32 @rewind(i32* %64)
br label %66
66: ; preds = %89, %58
%67 = load i32, i32* %22
%68 = load i32, i32* %21
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %93
70: ; preds = %66
%71 = load i8*, i8** %15
%72 = load i32, i32* %21
%73 = load i32, i32* %22
%74 = sub nsw i32 %72, %73
%75 = load i32*, i32** %20
%76 = call i32 @fread(i8* %71, i32 %74, i32 1, i32* %75)
store i32 %76, i32* %37
%77 = load i32, i32* %37
%78 = icmp sle i32 %77, 0
br i1 %78, label %79, label %89
79: ; preds = %70
%80 = load i32*, i32** %20
%81 = call i64 @feof(i32* %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %79
br label %93
84: ; preds = %79
%85 = load i32*, i32** %20
%86 = call i32 @fclose(i32* %85)
%87 = load i8*, i8** %15
%88 = call i32 @free(i8* %87)
store i32 -1, i32* %7
store i32 1, i32* %36
br label %282
89: ; preds = %70
%90 = load i32, i32* %37
%91 = load i32, i32* %22
%92 = add nsw i32 %91, %90
store i32 %92, i32* %22
br label %66
93: ; preds = %83, %66
store i8* null, i8** %30
store i8* null, i8** %31
store i8* null, i8** %32
store i8* null, i8** %33
store i8* null, i8** %34
store i8* null, i8** %35
%94 = load i8*, i8** %15
%95 = call i8* @strtok_r(i8* %94, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %16)
store i8* %95, i8** %17
br label %96
96: ; preds = %149, %93
%97 = load i8*, i8** %17
%98 = icmp ne i8* %97, null
br i1 %98, label %99, label %151
99: ; preds = %96
%100 = load i8*, i8** %17
%101 = call i8* @strchr(i8* %100, i8 signext 61)
store i8* %101, i8** %18
%102 = load i8*, i8** %18
%103 = icmp ne i8* %102, null
br i1 %103, label %104, label %149
104: ; preds = %99
%105 = load i8*, i8** %18
store i8 0, i8* %105
%106 = load i8*, i8** %18
%107 = getelementptr inbounds i8, i8* %106, i32 1
store i8* %107, i8** %18
%108 = load i8*, i8** %17
%109 = call i64 @strcmp(i8* %108, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %104
%112 = load i8*, i8** %18
store i8* %112, i8** %30
br label %148
113: ; preds = %104
%114 = load i8*, i8** %17
%115 = call i64 @strcmp(i8* %114, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%116 = icmp eq i64 %115, 0
br i1 %116, label %117, label %119
117: ; preds = %113
%118 = load i8*, i8** %18
store i8* %118, i8** %31
br label %147
119: ; preds = %113
%120 = load i8*, i8** %17
%121 = call i64 @strcmp(i8* %120, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%122 = icmp eq i64 %121, 0
br i1 %122, label %123, label %125
123: ; preds = %119
%124 = load i8*, i8** %18
store i8* %124, i8** %32
br label %146
125: ; preds = %119
%126 = load i8*, i8** %17
%127 = call i64 @strcmp(i8* %126, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%128 = icmp eq i64 %127, 0
br i1 %128, label %129, label %131
129: ; preds = %125
%130 = load i8*, i8** %18
store i8* %130, i8** %33
br label %145
131: ; preds = %125
%132 = load i8*, i8** %17
%133 = call i64 @strcmp(i8* %132, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%134 = icmp eq i64 %133, 0
br i1 %134, label %135, label %137
135: ; preds = %131
%136 = load i8*, i8** %18
store i8* %136, i8** %34
br label %144
137: ; preds = %131
%138 = load i8*, i8** %17
%139 = call i64 @strcmp(i8* %138, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%140 = icmp eq i64 %139, 0
br i1 %140, label %141, label %143
141: ; preds = %137
%142 = load i8*, i8** %18
store i8* %142, i8** %35
br label %143
143: ; preds = %141, %137
br label %144
144: ; preds = %143, %135
br label %145
145: ; preds = %144, %129
br label %146
146: ; preds = %145, %123
br label %147
147: ; preds = %146, %117
br label %148
148: ; preds = %147, %111
br label %149
149: ; preds = %148, %99
%150 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %16)
store i8* %150, i8** %17
br label %96
151: ; preds = %96
%152 = load i32*, i32** %20
%153 = call i32 @fclose(i32* %152)
%154 = call i32 @memset(%struct.addrinfo* %23, i32 0, i32 32)
%155 = load i32, i32* @AF_UNSPEC
%156 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i32 0, i32 1
store i32 %155, i32* %156
%157 = load i32, i32* @SOCK_STREAM
%158 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %23, i32 0, i32 4
store i32 %157, i32* %158
%159 = load i8*, i8** %30
%160 = load i8*, i8** %31
%161 = call i32 @getaddrinfo(i8* %159, i8* %160, %struct.addrinfo* %23, %struct.addrinfo** %24)
store i32 %161, i32* %27
%162 = icmp ne i32 %161, 0
br i1 %162, label %163, label %168
163: ; preds = %151
%164 = load i32, i32* @stderr
%165 = load i32, i32* %27
%166 = call i8* @gai_strerror(i32 %165)
%167 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i8* %166)
store i32 -1, i32* %7
store i32 1, i32* %36
br label %282
168: ; preds = %151
%169 = load %struct.addrinfo*, %struct.addrinfo** %24
store %struct.addrinfo* %169, %struct.addrinfo** %25
br label %170
170: ; preds = %202, %168
%171 = load %struct.addrinfo*, %struct.addrinfo** %25
%172 = icmp ne %struct.addrinfo* %171, null
br i1 %172, label %173, label %206
173: ; preds = %170
%174 = load %struct.addrinfo*, %struct.addrinfo** %25
%175 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %174, i32 0, i32 1
%176 = load i32, i32* %175
%177 = load %struct.addrinfo*, %struct.addrinfo** %25
%178 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %177, i32 0, i32 4
%179 = load i32, i32* %178
%180 = load %struct.addrinfo*, %struct.addrinfo** %25
%181 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %180, i32 0, i32 3
%182 = load i32, i32* %181
%183 = call i32 @socket(i32 %176, i32 %179, i32 %182)
store i32 %183, i32* %26
%184 = icmp eq i32 %183, -1
br i1 %184, label %185, label %187
185: ; preds = %173
%186 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %202
187: ; preds = %173
%188 = load i32, i32* %26
%189 = load %struct.addrinfo*, %struct.addrinfo** %25
%190 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %189, i32 0, i32 0
%191 = load i64, i64* %190
%192 = load %struct.addrinfo*, %struct.addrinfo** %25
%193 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %192, i32 0, i32 2
%194 = load i32, i32* %193
%195 = call i32 @connect(i32 %188, i64 %191, i32 %194)
%196 = icmp eq i32 %195, -1
br i1 %196, label %197, label %201
197: ; preds = %187
%198 = load i32, i32* %26
%199 = call i32 @close(i32 %198)
%200 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
br label %202
201: ; preds = %187
br label %206
202: ; preds = %197, %185
%203 = load %struct.addrinfo*, %struct.addrinfo** %25
%204 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %203, i32 0, i32 5
%205 = load %struct.addrinfo*, %struct.addrinfo** %204
store %struct.addrinfo* %205, %struct.addrinfo** %25
br label %170
206: ; preds = %201, %170
%207 = load %struct.addrinfo*, %struct.addrinfo** %25
%208 = icmp eq %struct.addrinfo* %207, null
br i1 %208, label %209, label %212
209: ; preds = %206
%210 = load i32, i32* @stderr
%211 = call i32 (i32, i8*, ...) @fprintf(i32 %210, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
store i32 -1, i32* %7
store i32 1, i32* %36
br label %282
212: ; preds = %206
%213 = load %struct.addrinfo*, %struct.addrinfo** %25
%214 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %213, i32 0, i32 1
%215 = load i32, i32* %214
%216 = load %struct.addrinfo*, %struct.addrinfo** %25
%217 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %216, i32 0, i32 0
%218 = load i64, i64* %217
%219 = inttoptr i64 %218 to %struct.sockaddr*
%220 = call i32 @get_in_addr(%struct.sockaddr* %219)
%221 = trunc i64 %39 to i32
%222 = call i32 @inet_ntop(i32 %215, i32 %220, i8* %41, i32 %221)
%223 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i8* %41)
%224 = load %struct.addrinfo*, %struct.addrinfo** %24
%225 = call i32 @freeaddrinfo(%struct.addrinfo* %224)
%226 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%227 = load i8*, i8** %33
%228 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %226, i32 512, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8* %227)
%229 = load i32, i32* %26
%230 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%231 = call i32 @send_all(i32 %229, i8* %230)
%232 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%233 = load i8*, i8** %33
%234 = load i8*, i8** %35
%235 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %232, i32 512, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0), i8* %233, i8* %234)
%236 = load i32, i32* %26
%237 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%238 = call i32 @send_all(i32 %236, i8* %237)
%239 = load i8*, i8** %34
%240 = icmp ne i8* %239, null
br i1 %240, label %241, label %254
241: ; preds = %212
%242 = load i8*, i8** %34
%243 = getelementptr inbounds i8, i8* %242, i64 0
%244 = load i8, i8* %243
%245 = sext i8 %244 to i32
%246 = icmp ne i32 %245, 0
br i1 %246, label %247, label %254
247: ; preds = %241
%248 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%249 = load i8*, i8** %34
%250 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %248, i32 512, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0), i8* %249)
%251 = load i32, i32* %26
%252 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%253 = call i32 @send_all(i32 %251, i8* %252)
br label %254
254: ; preds = %247, %241, %212
%255 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%256 = load i8*, i8** %32
%257 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %255, i32 512, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i8* %256)
%258 = load i32, i32* %26
%259 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%260 = call i32 @send_all(i32 %258, i8* %259)
%261 = load i8*, i8** %30
%262 = call i8* @strdup(i8* %261)
%263 = load i8**, i8*** %8
store i8* %262, i8** %263
%264 = load i8*, i8** %31
%265 = call i8* @strdup(i8* %264)
%266 = load i8**, i8*** %9
store i8* %265, i8** %266
%267 = load i8*, i8** %32
%268 = call i8* @strdup(i8* %267)
%269 = load i8**, i8*** %10
store i8* %268, i8** %269
%270 = load i8*, i8** %33
%271 = call i8* @strdup(i8* %270)
%272 = load i8**, i8*** %11
store i8* %271, i8** %272
%273 = load i8*, i8** %34
%274 = call i8* @strdup(i8* %273)
%275 = load i8**, i8*** %12
store i8* %274, i8** %275
%276 = load i8*, i8** %35
%277 = call i8* @strdup(i8* %276)
%278 = load i8**, i8*** %13
store i8* %277, i8** %278
%279 = load i8*, i8** %15
%280 = call i32 @free(i8* %279)
%281 = load i32, i32* %26
store i32 %281, i32* %7
store i32 1, i32* %36
br label %282
282: ; preds = %254, %209, %163, %84, %55, %49
%283 = load i8*, i8** %28
%284 = load i32, i32* %7
ret i32 %284
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [14 x i8] c"%s/.konabotrc\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [9 x i8] c"irc_host\00"
@.str.5 = [9 x i8] c"irc_port\00"
@.str.6 = [9 x i8] c"irc_chan\00"
@.str.7 = [9 x i8] c"irc_nick\00"
@.str.8 = [9 x i8] c"irc_pass\00"
@.str.9 = [9 x i8] c"irc_name\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str.10 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.11 = [7 x i8] c"socket\00"
@.str.12 = [8 x i8] c"connect\00"
@.str.13 = [19 x i8] c"Failed to connect\0A\00"
@.str.14 = [18 x i8] c"Connecting to %s\0A\00"
@.str.15 = [10 x i8] c"NICK %s\0D\0A\00"
@.str.16 = [18 x i8] c"USER %s 0 * :%s\0D\0A\00"
@.str.17 = [32 x i8] c"PRIVMSG NickServ :IDENTIFY %s\0D\0A\00"
@.str.18 = [10 x i8] c"JOIN %s\0D\0A\00"
define i32 @open_irc_socket(i8** nocapture writeonly %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3, i8** nocapture writeonly %4, i8** nocapture writeonly %5) {
%7 = alloca [512 x i8]
%8 = alloca i8*
%9 = alloca [512 x i8]
%10 = alloca %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%13 = bitcast i8** %8 to i8*
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%15 = bitcast %struct.addrinfo* %10 to i8*
%16 = bitcast %struct.addrinfo** %11 to i8*
%17 = load i32, i32* @INET6_ADDRSTRLEN
%18 = zext i32 %17 to i64
%19 = tail call i8* @llvm.stacksave()
%20 = alloca i8, i64 %18
%21 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %12, i32 512, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %175, label %25
25: ; preds = %6
%26 = load i32, i32* @SEEK_END
%27 = call i64 @fseek(i32* %23, i32 0, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 @fclose(i32* %23)
br label %175
31: ; preds = %25
%32 = call i32 @ftell(i32* %23)
%33 = add nsw i32 %32, 1
%34 = call i8* @malloc(i32 %33)
%35 = call i32 @rewind(i32* %23)
%36 = icmp sgt i32 %32, 0
br i1 %36, label %39, label %51
37: ; preds = %39
%38 = icmp sgt i32 %32, %44
br i1 %38, label %39, label %51
39: ; preds = %31, %37
%40 = phi i32 [ %44, %37 ], [ 0, %31 ]
%41 = sub nsw i32 %32, %40
%42 = call i32 @fread(i8* %34, i32 %41, i32 1, i32* %23)
%43 = icmp slt i32 %42, 1
%44 = add nsw i32 %42, %40
br i1 %43, label %45, label %37
45: ; preds = %39
%46 = call i64 @feof(i32* %23)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = call i32 @fclose(i32* %23)
%50 = call i32 @free(i8* %34)
br label %175
51: ; preds = %37, %31, %45
%52 = call i8* @strtok_r(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %8)
%53 = icmp eq i8* %52, null
br i1 %53, label %93, label %54
54: ; preds = %51, %84
%55 = phi i8* [ %90, %84 ], [ null, %51 ]
%56 = phi i8* [ %89, %84 ], [ null, %51 ]
%57 = phi i8* [ %88, %84 ], [ null, %51 ]
%58 = phi i8* [ %87, %84 ], [ null, %51 ]
%59 = phi i8* [ %86, %84 ], [ null, %51 ]
%60 = phi i8* [ %85, %84 ], [ null, %51 ]
%61 = phi i8* [ %91, %84 ], [ %52, %51 ]
%62 = call i8* @strchr(i8* %61, i8 signext 61)
%63 = icmp eq i8* %62, null
br i1 %63, label %84, label %64
64: ; preds = %54
store i8 0, i8* %62
%65 = getelementptr inbounds i8, i8* %62, i64 1
%66 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %84, label %68
68: ; preds = %64
%69 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %84, label %71
71: ; preds = %68
%72 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %84, label %74
74: ; preds = %71
%75 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %84, label %77
77: ; preds = %74
%78 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %84, label %80
80: ; preds = %77
%81 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%82 = icmp eq i64 %81, 0
%83 = select i1 %82, i8* %65, i8* %55
br label %84
84: ; preds = %80, %77, %74, %71, %68, %64, %54
%85 = phi i8* [ %60, %54 ], [ %65, %64 ], [ %60, %68 ], [ %60, %71 ], [ %60, %74 ], [ %60, %77 ], [ %60, %80 ]
%86 = phi i8* [ %59, %54 ], [ %59, %64 ], [ %65, %68 ], [ %59, %71 ], [ %59, %74 ], [ %59, %77 ], [ %59, %80 ]
%87 = phi i8* [ %58, %54 ], [ %58, %64 ], [ %58, %68 ], [ %65, %71 ], [ %58, %74 ], [ %58, %77 ], [ %58, %80 ]
%88 = phi i8* [ %57, %54 ], [ %57, %64 ], [ %57, %68 ], [ %57, %71 ], [ %65, %74 ], [ %57, %77 ], [ %57, %80 ]
%89 = phi i8* [ %56, %54 ], [ %56, %64 ], [ %56, %68 ], [ %56, %71 ], [ %56, %74 ], [ %65, %77 ], [ %56, %80 ]
%90 = phi i8* [ %55, %54 ], [ %55, %64 ], [ %55, %68 ], [ %55, %71 ], [ %55, %74 ], [ %55, %77 ], [ %83, %80 ]
%91 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %8)
%92 = icmp eq i8* %91, null
br i1 %92, label %93, label %54
93: ; preds = %84, %51
%94 = phi i8* [ null, %51 ], [ %85, %84 ]
%95 = phi i8* [ null, %51 ], [ %86, %84 ]
%96 = phi i8* [ null, %51 ], [ %87, %84 ]
%97 = phi i8* [ null, %51 ], [ %88, %84 ]
%98 = phi i8* [ null, %51 ], [ %89, %84 ]
%99 = phi i8* [ null, %51 ], [ %90, %84 ]
%100 = call i32 @fclose(i32* %23)
%101 = call i32 @memset(%struct.addrinfo* %10, i32 0, i32 32)
%102 = load i32, i32* @AF_UNSPEC
%103 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i64 0, i32 1
store i32 %102, i32* %103
%104 = load i32, i32* @SOCK_STREAM
%105 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i64 0, i32 4
store i32 %104, i32* %105
%106 = call i32 @getaddrinfo(i8* %94, i8* %95, %struct.addrinfo* %10, %struct.addrinfo** %11)
%107 = icmp eq i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %93
%109 = load %struct.addrinfo*, %struct.addrinfo** %11
%110 = icmp eq %struct.addrinfo* %109, null
br i1 %110, label %140, label %115
111: ; preds = %93
%112 = load i32, i32* @stderr
%113 = call i8* @gai_strerror(i32 %106)
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i8* %113)
br label %175
115: ; preds = %108, %134
%116 = phi %struct.addrinfo* [ %138, %134 ], [ %109, %108 ]
%117 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i64 0, i32 1
%118 = load i32, i32* %117
%119 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i64 0, i32 4
%120 = load i32, i32* %119
%121 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i64 0, i32 3
%122 = load i32, i32* %121
%123 = call i32 @socket(i32 %118, i32 %120, i32 %122)
%124 = icmp eq i32 %123, -1
br i1 %124, label %134, label %125
125: ; preds = %115
%126 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i64 0, i32 0
%127 = load i64, i64* %126
%128 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i64 0, i32 2
%129 = load i32, i32* %128
%130 = call i32 @connect(i32 %123, i64 %127, i32 %129)
%131 = icmp eq i32 %130, -1
br i1 %131, label %132, label %143
132: ; preds = %125
%133 = call i32 @close(i32 %123)
br label %134
134: ; preds = %115, %132
%135 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), %132 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), %115 ]
%136 = call i32 @perror(i8* %135)
%137 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i64 0, i32 5
%138 = load %struct.addrinfo*, %struct.addrinfo** %137
%139 = icmp eq %struct.addrinfo* %138, null
br i1 %139, label %140, label %115
140: ; preds = %134, %108
%141 = load i32, i32* @stderr
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
br label %175
143: ; preds = %125
%144 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i64 0, i32 1
%145 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i64 0, i32 0
%146 = load i32, i32* %144
%147 = load i64, i64* %145
%148 = inttoptr i64 %147 to %struct.sockaddr*
%149 = call i32 @get_in_addr(%struct.sockaddr* %148)
%150 = call i32 @inet_ntop(i32 %146, i32 %149, i8* %20, i32 %17)
%151 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i8* %20)
%152 = load %struct.addrinfo*, %struct.addrinfo** %11
%153 = call i32 @freeaddrinfo(%struct.addrinfo* %152)
%154 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 512, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8* %97)
%155 = call i32 @send_all(i32 %123, i8* %14)
%156 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 512, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0), i8* %97, i8* %99)
%157 = call i32 @send_all(i32 %123, i8* %14)
%158 = icmp eq i8* %98, null
br i1 %158, label %165, label %159
159: ; preds = %143
%160 = load i8, i8* %98
%161 = icmp eq i8 %160, 0
br i1 %161, label %165, label %162
162: ; preds = %159
%163 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 512, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0), i8* %98)
%164 = call i32 @send_all(i32 %123, i8* %14)
br label %165
165: ; preds = %162, %159, %143
%166 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 512, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i8* %96)
%167 = call i32 @send_all(i32 %123, i8* %14)
%168 = call i8* @strdup(i8* %94)
store i8* %168, i8** %0
%169 = call i8* @strdup(i8* %95)
store i8* %169, i8** %1
%170 = call i8* @strdup(i8* %96)
store i8* %170, i8** %2
%171 = call i8* @strdup(i8* %97)
store i8* %171, i8** %3
%172 = call i8* @strdup(i8* %98)
store i8* %172, i8** %4
%173 = call i8* @strdup(i8* %99)
store i8* %173, i8** %5
%174 = call i32 @free(i8* %34)
br label %175
175: ; preds = %48, %6, %165, %140, %111, %29
%176 = phi i32 [ -1, %29 ], [ -1, %111 ], [ -1, %140 ], [ %123, %165 ], [ -1, %6 ], [ -1, %48 ]
ret i32 %176
}