#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_2__ {
  void *s_addr;
};
struct sockaddr_in {
  void *sin_port;
  TYPE_1__ sin_addr;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ ret_saddr;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
void *AF_INET;
scalar_t__ EINTR;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ _string_analyze(char *, int);
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
struct sockaddr *getip(char *);
void *htonl(int /*<<< orphan*/);
void *htons(int);
int /*<<< orphan*/ itoa(int);
scalar_t__ listen(int, int);
int /*<<< orphan*/ log_write(char *, char *, char *, ...);
char *malloc(int);
int read(int, char *, int);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int sendto(int, char *, scalar_t__, int /*<<< orphan*/, struct sockaddr *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ sleep(int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
char *strerror(scalar_t__);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, scalar_t__);
int /*<<< orphan*/ strncpy(char *, char *, int);
int connectToServer(void) {
  int STREAM_socket, STREAM_socket2;
  int ret;
  struct sockaddr_in saddr2, saddr3, ret_saddr;
  struct sockaddr saddr;
  char *buffer = malloc(1024);
  socklen_t socket_len;
  fd_set rfds;
  struct timeval time_out;
  struct sockaddr *serverInfo = getip("e-car.dyndns.org");
  int optval = 1;
  char *read_buff = malloc(4096);
  if (serverInfo == NULL) {
    log_write("Communication Process",
              "Could not resolve server's domain name.", NULL);
    return EXIT_FAILURE;
  }
  if ((STREAM_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    log_write("Communication Process",
              "Could not resolve server's domain name.", NULL);
    return EXIT_FAILURE;
  }
  if ((STREAM_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    log_write("Communication Process", strerror(errno), NULL);
    exit(EXIT_FAILURE);
  }
  log_write("Communication Process",
            "DGRAM socket created for transmission successfully.", NULL);
  if (setsockopt(STREAM_socket, SOL_SOCKET, SO_REUSEADDR, &optval,
                 sizeof optval) < 0)
    log_write("Communication Process", "Couldn't set socket to re-use address.",
              NULL);
  else
    log_write("Communication Process",
              "Socket set to re-use address successfully.", NULL);
  strncpy(buffer, "#3c4r1d3n74ndr3d1rm3@", 1024);
  strncat(buffer, "TestID", 1024 - strlen(buffer));
  while (1) {
    while (1) {
      log_write("Communication Process",
                "Attempting to send identification pattern to server", NULL);
      if ((ret = sendto(STREAM_socket, buffer, strlen(buffer), 0, serverInfo,
                        sizeof(struct sockaddr))) < 0)
        log_write("Communication Process", strerror(errno), NULL);
      else
        break;
    }
    log_write("Communication Process", "Identification pattern sent to server.",
              NULL);
    if ((STREAM_socket2 = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
      log_write("Communication Process", strerror(errno), NULL);
      exit(EXIT_FAILURE);
    }
    log_write("Communication Process",
              "DGRAM socket created for receiving successfully.", NULL);
    if (setsockopt(STREAM_socket2, SOL_SOCKET, SO_REUSEADDR, &optval,
                   sizeof optval) < 0)
      log_write("Communication Process",
                "Couldn't set socket to re-use address.", NULL);
    else
      log_write("Communication Process",
                "Socket set to re-use address successfully.", NULL);
    saddr2.sin_family = AF_INET;
    saddr2.sin_port = htons(6543);
    saddr2.sin_addr.s_addr = htonl(INADDR_ANY);
    if (bind(STREAM_socket2, (struct sockaddr *)&saddr2,
             sizeof(struct sockaddr)) < 0) {
      log_write("Communication Process", strerror(errno), NULL);
      exit(EXIT_FAILURE);
    }
    log_write("Communication Process", "Socket bound.", NULL);
    socket_len = sizeof(ret_saddr);
    FD_ZERO(&rfds);
    FD_SET(STREAM_socket2, &rfds);
    time_out.tv_sec = 15;
    time_out.tv_usec = 0;
    log_write("Communication Process", "Waiting for server to reply.", NULL);
    ret = select(STREAM_socket2 + 1, &rfds, NULL, NULL, &time_out);
    if (ret < 0) {
      log_write("Communication Process", strerror(errno), NULL);
      continue;
    } else if (!ret) {
      log_write("Communication Process",
                "No answer received from server within ", itoa(15), " seconds.",
                NULL);
      log_write("Communication Process", "Retrying...", NULL);
      continue;
    }
    if ((ret = recvfrom(STREAM_socket2, buffer, 1024, 0,
                        (struct sockaddr *)&ret_saddr, &socket_len)) < 0)
      log_write("Communication Process", strerror(errno), NULL);
    else
      break;
  }
  buffer[ret] = '\0';
  log_write("Communication Process", "Server replied:\'", buffer, "\'.", NULL);
  close(STREAM_socket2);
  if ((STREAM_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    log_write("Communication Process", strerror(errno), NULL);
    exit(EXIT_FAILURE);
  }
  log_write("Communication Process", "STREAM socket created successfully.",
            NULL);
  if (setsockopt(STREAM_socket, SOL_SOCKET, SO_REUSEADDR, &optval,
                 sizeof optval) < 0)
    log_write("Communication Process", "Couldn't set socket to re-use address.",
              NULL);
  else
    log_write("Communication Process",
              "Socket set to re-use address successfully.", NULL);
  saddr3.sin_family = AF_INET;
  saddr3.sin_addr.s_addr = htonl(INADDR_ANY);
  saddr3.sin_port = htons(atoi(buffer));
  while (bind(STREAM_socket, (struct sockaddr *)&saddr3,
              sizeof(struct sockaddr)) < 0) {
    log_write("Communication Process", strerror(errno), NULL);
    sleep(1);
  }
  log_write("Communication Process", "STREAM socket bound successfully.", NULL);
  while (listen(STREAM_socket, 1) < 0) {
    log_write("Communication Process", strerror(errno), NULL);
    sleep(1);
  }
  log_write(
      "Communication Process",
      "Listening to the given port and waiting for the incoming connection.",
      NULL);
  socket_len = sizeof(ret_saddr);
  if ((STREAM_socket2 = accept(STREAM_socket, (struct sockaddr *)&ret_saddr,
                               &socket_len)) < 0) {
    log_write("Communication Process", strerror(errno), NULL);
    sleep(1);
  }
  log_write("Communication Process", strerror(errno), NULL);
  log_write("Communication Process",
            "Connection accepted. Starting reading loop.", NULL);
  free(buffer);
  while (1) {
    if ((ret = read(STREAM_socket2, read_buff, 4096)) < 0) {
      if (errno != EINTR) {
        log_write("Communication Process", strerror(errno), NULL);
        continue;
      } else
        continue;
    }
    read_buff[ret] = '\0';
    log_write("Communication Process", "Received data: '", read_buff, "'.",
              NULL);
    _string_analyze(read_buff, ret);
  }
  log_write("Communication Process",
            "Program flow got out of the reading loop.", NULL);
  close(STREAM_socket);
  close(STREAM_socket2);
  STREAM_socket = 0;
  free(read_buff);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<connectToServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    $0x400,%edi
call   1110 <malloc@plt>
mov    %rax,-0x68(%rbp)
lea    0xd30(%rip),%rdi
call   1080 <getip@plt>
mov    %rax,-0x88(%rbp)
movl   $0x1,-0x8c(%rbp)
mov    $0x1000,%edi
call   1110 <malloc@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x88(%rbp)
jne    132f <connectToServer+0x7f>
lea    0xd05(%rip),%rdi
lea    0xd14(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x2c8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1b63 <connectToServer+0x8b3>
mov    0x2caa(%rip),%rax
mov    (%rax),%rdi
mov    0x2c90(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    137f <connectToServer+0xcf>
lea    0xcb5(%rip),%rdi
lea    0xcc4(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1b63 <connectToServer+0x8b3>
mov    0x2c5a(%rip),%rax
mov    (%rax),%rdi
mov    0x2c40(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    13d7 <connectToServer+0x127>
mov    0x2c0c(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0xc53(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x2be0(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
lea    0xc33(%rip),%rdi
lea    0xc6a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0x8(%rbp),%edi
mov    0x2bee(%rip),%rax
mov    (%rax),%esi
mov    0x2b9d(%rip),%rax
mov    (%rax),%edx
lea    -0x8c(%rbp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmp    $0x0,%rax
jge    143f <connectToServer+0x18f>
lea    0xbe9(%rip),%rdi
lea    0xc54(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
jmp    1458 <connectToServer+0x1a8>
lea    0xbcb(%rip),%rdi
lea    0xc5d(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0x68(%rbp),%rdi
lea    0xc72(%rip),%rsi
mov    $0x400,%edx
call   1040 <strncpy@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xa0(%rbp),%rdi
mov    $0x400,%edx
sub    %rax,%rdx
lea    0xc54(%rip),%rsi
call   10b0 <strncat@plt>
jmp    14a1 <connectToServer+0x1f1>
lea    0xb69(%rip),%rdi
lea    0xc43(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rsi
mov    %rax,%rdx
mov    -0x88(%rbp),%r8
xor    %ecx,%ecx
mov    $0x4,%r9d
call   10a0 <sendto@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1530 <connectToServer+0x280>
mov    0x2aaa(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0xaf1(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
jmp    1535 <connectToServer+0x285>
jmp    153a <connectToServer+0x28a>
jmp    14a1 <connectToServer+0x1f1>
lea    0xad0(%rip),%rdi
lea    0xbde(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x2a86(%rip),%rax
mov    (%rax),%rdi
mov    0x2a6c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    15ab <connectToServer+0x2fb>
mov    0x2a38(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0xa7f(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x2a0c(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
lea    0xa5f(%rip),%rdi
lea    0xb94(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0xc(%rbp),%edi
mov    0x2a1a(%rip),%rax
mov    (%rax),%esi
mov    0x29c9(%rip),%rax
mov    (%rax),%edx
lea    -0x8c(%rbp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmp    $0x0,%rax
jge    1613 <connectToServer+0x363>
lea    0xa15(%rip),%rdi
lea    0xa80(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
jmp    162c <connectToServer+0x37c>
lea    0x9f7(%rip),%rdi
lea    0xa89(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x29ad(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    $0x198f,%edi
call   1070 <htons@plt>
mov    %rax,-0x28(%rbp)
mov    0x2989(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x4,%edx
call   1140 <bind@plt>
cmp    $0x0,%rax
jge    16a7 <connectToServer+0x3f7>
mov    0x293c(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x983(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x2910(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
lea    0x963(%rip),%rdi
lea    0xac9(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
movl   $0x18,-0x6c(%rbp)
lea    -0x70(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
mov    -0xc(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   11b0 <FD_SET@plt>
movl   $0xf,-0x80(%rbp)
movq   $0x0,-0x78(%rbp)
lea    0x91f(%rip),%rdi
lea    0xa93(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
lea    -0x70(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x80(%rbp),%r8
mov    %rcx,%rdx
call   10f0 <select@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1754 <connectToServer+0x4a4>
mov    0x2886(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x8cd(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
jmp    149c <connectToServer+0x1ec>
cmpl   $0x0,-0x10(%rbp)
jne    17aa <connectToServer+0x4fa>
mov    $0xf,%edi
call   1190 <itoa@plt>
movslq %eax,%rdx
lea    0x89f(%rip),%rdi
lea    0xa30(%rip),%rsi
lea    0xa50(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1170 <log_write@plt>
lea    0x87e(%rip),%rdi
lea    0xa40(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
jmp    149c <connectToServer+0x1ec>
jmp    17af <connectToServer+0x4ff>
mov    -0xc(%rbp),%edi
mov    -0x68(%rbp),%rsi
lea    -0x58(%rbp),%r8
mov    $0x400,%edx
xor    %ecx,%ecx
lea    -0x6c(%rbp),%r9
call   1130 <recvfrom@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    17ff <connectToServer+0x54f>
mov    0x27db(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x822(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
jmp    1804 <connectToServer+0x554>
jmp    1809 <connectToServer+0x559>
jmp    149c <connectToServer+0x1ec>
mov    -0x68(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x68(%rbp),%rdx
lea    0x7f1(%rip),%rdi
lea    0x9bf(%rip),%rsi
lea    0x9c9(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0xc(%rbp),%edi
call   10c0 <close@plt>
mov    0x2797(%rip),%rax
mov    (%rax),%rdi
mov    0x276d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    189a <connectToServer+0x5ea>
mov    0x2749(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x790(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x271d(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
lea    0x770(%rip),%rdi
lea    0x952(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0x8(%rbp),%edi
mov    0x272b(%rip),%rax
mov    (%rax),%esi
mov    0x26da(%rip),%rax
mov    (%rax),%edx
lea    -0x8c(%rbp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmp    $0x0,%rax
jge    1902 <connectToServer+0x652>
lea    0x726(%rip),%rdi
lea    0x791(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
jmp    191b <connectToServer+0x66b>
lea    0x708(%rip),%rdi
lea    0x79a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    0x26be(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x26a8(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %rax,-0x38(%rbp)
mov    -0x68(%rbp),%rdi
call   1160 <atoi@plt>
mov    %eax,%edi
call   1070 <htons@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   1140 <bind@plt>
cmp    $0x0,%rax
jge    199d <connectToServer+0x6ed>
mov    0x2647(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x68e(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    $0x1,%edi
call   11c0 <sleep@plt>
jmp    194f <connectToServer+0x69f>
lea    0x66d(%rip),%rdi
lea    0x873(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1120 <listen@plt>
cmp    $0x0,%rax
jge    1a00 <connectToServer+0x750>
mov    0x25e4(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x62b(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    $0x1,%edi
call   11c0 <sleep@plt>
jmp    19b6 <connectToServer+0x706>
lea    0x60a(%rip),%rdi
lea    0x832(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
movl   $0x18,-0x6c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x58(%rbp),%rsi
lea    -0x6c(%rbp),%rdx
call   1150 <accept@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1a6a <connectToServer+0x7ba>
mov    0x2575(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x5bc(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    $0x1,%edi
call   11c0 <sleep@plt>
mov    0x2547(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x58e(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
lea    0x57c(%rip),%rdi
lea    0x7e9(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%edi
mov    -0x98(%rbp),%rsi
mov    $0x1000,%edx
call   10d0 <read@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1b18 <connectToServer+0x868>
mov    0x24e1(%rip),%rax
mov    (%rax),%rax
mov    0x24c7(%rip),%rcx
cmp    (%rcx),%rax
je     1b13 <connectToServer+0x863>
mov    0x24c7(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x50e(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <log_write@plt>
jmp    1ab0 <connectToServer+0x800>
jmp    1ab0 <connectToServer+0x800>
mov    -0x98(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x98(%rbp),%rdx
lea    0x4dc(%rip),%rdi
lea    0x775(%rip),%rsi
lea    0x6b4(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1170 <log_write@plt>
mov    -0x98(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1100 <_string_analyze@plt>
jmp    1ab0 <connectToServer+0x800>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connectToServer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    $0x400,%edi
call   1110 <malloc@plt>
mov    %rax,%r14
lea    0xd2e(%rip),%rdi
call   1080 <getip@plt>
mov    %rax,%r12
movl   $0x1,0x8(%rsp)
mov    $0x1000,%edi
call   1110 <malloc@plt>
test   %r12,%r12
je     1657 <connectToServer+0x3a7>
mov    %rax,%r13
mov    0x2ce1(%rip),%rbx
mov    (%rbx),%rdi
mov    0x2cc7(%rip),%rbp
mov    0x0(%rbp),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
test   %eax,%eax
js     1657 <connectToServer+0x3a7>
mov    (%rbx),%rdi
mov    0x0(%rbp),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
test   %eax,%eax
js     1959 <connectToServer+0x6a9>
mov    %eax,%ebx
lea    0xcd8(%rip),%r15
lea    0xd0f(%rip),%rsi
mov    %r15,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
mov    0x2c44(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebx,0x18(%rsp)
mov    %ebx,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %rax,%rax
lea    0xd05(%rip),%rax
lea    0xd25(%rip),%rsi
cmovs  %rax,%rsi
mov    %r15,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
lea    0xd39(%rip),%rsi
mov    %r14,%rdi
mov    $0x400,%edx
call   1040 <strncpy@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    $0x400,%edx
sub    %rax,%rdx
lea    0xd2b(%rip),%rsi
mov    %r14,0x10(%rsp)
mov    %r14,%rdi
call   10b0 <strncat@plt>
lea    0xd1e(%rip),%r14
mov    %r12,%rbx
jmp    142d <connectToServer+0x17d>
nopl   0x0(%rax)
mov    %ebx,%edi
mov    0x10(%rsp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
lea    0x60(%rsp),%r8
lea    0xc(%rsp),%r9
call   1130 <recvfrom@plt>
test   %eax,%eax
jns    1686 <connectToServer+0x3d6>
mov    0x2bac(%rip),%rbx
mov    (%rbx),%rdi
call   11a0 <strerror@plt>
mov    %rax,%rsi
mov    %r15,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %r14,%rbx
lea    0xcc5(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %r15,%r12
mov    0x10(%rsp),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    0x18(%rsp),%ebp
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    $0x4,%r9d
call   10a0 <sendto@plt>
test   %eax,%eax
mov    %rbx,%r14
mov    0x2b44(%rip),%rbx
jns    14ce <connectToServer+0x21e>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%rdi
call   11a0 <strerror@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %r12,%rdi
lea    0xc51(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x4,%r9d
call   10a0 <sendto@plt>
test   %eax,%eax
js     1480 <connectToServer+0x1d0>
mov    %r12,%rdi
lea    0xc4e(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    0x2af8(%rip),%rbp
mov    0x0(%rbp),%rdi
mov    0x2add(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
test   %eax,%eax
js     1959 <connectToServer+0x6a9>
mov    %eax,%ebx
mov    %r12,%r15
mov    %r12,%rdi
lea    0xc3a(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    0x2ac5(%rip),%rax
mov    (%rax),%esi
mov    0x2a74(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %rax,%rax
lea    0xb60(%rip),%rsi
lea    0xb32(%rip),%rax
cmovs  %rax,%rsi
mov    %r12,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %rbp,%r12
mov    0x0(%rbp),%rax
mov    %rax,0x58(%rsp)
mov    $0x198f,%edi
call   1070 <htons@plt>
mov    %rax,0x48(%rsp)
mov    0x2a55(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %rax,0x50(%rsp)
mov    %ebx,%edi
lea    0x48(%rsp),%rsi
mov    $0x4,%edx
call   1140 <bind@plt>
test   %rax,%rax
js     1959 <connectToServer+0x6a9>
mov    %r15,%rdi
lea    0xbcb(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
movl   $0x18,0xc(%rsp)
lea    0x1c(%rsp),%rbp
mov    %rbp,%rdi
call   10e0 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
call   11b0 <FD_SET@plt>
movl   $0xf,0x38(%rsp)
movq   $0x0,0x40(%rsp)
mov    %r15,%rdi
lea    0xb96(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %ebx,%edi
add    $0x1,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0x38(%rsp),%r8
call   10f0 <select@plt>
test   %eax,%eax
js     1405 <connectToServer+0x155>
jne    13e0 <connectToServer+0x130>
mov    $0xf,%edi
call   1190 <itoa@plt>
movslq %eax,%rdx
mov    %r15,%rdi
lea    0xb6f(%rip),%rsi
lea    0xb8f(%rip),%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1170 <log_write@plt>
lea    0xb88(%rip),%rsi
jmp    1417 <connectToServer+0x167>
lea    0x9b3(%rip),%rdi
lea    0x9c2(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    0x293b(%rip),%rax
mov    (%rax),%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%eax
mov    0x10(%rsp),%r14
movb   $0x0,(%r14,%rax,1)
lea    0x978(%rip),%rdi
lea    0xb46(%rip),%rsi
lea    0xb50(%rip),%rcx
mov    %r14,%rdx
xor    %r8d,%r8d
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %ebx,%edi
call   10c0 <close@plt>
mov    %r12,%r15
mov    (%r12),%rdi
mov    0x28f7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
test   %eax,%eax
js     1959 <connectToServer+0x6a9>
mov    %eax,%ebp
lea    0x92e(%rip),%rbx
lea    0xb10(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    0x28eb(%rip),%rax
mov    (%rax),%esi
mov    0x289a(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %rax,%rax
lea    0x986(%rip),%rsi
lea    0x958(%rip),%rax
cmovs  %rax,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    (%r15),%rax
mov    %rax,0x30(%rsp)
mov    0x288e(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %rax,0x28(%rsp)
mov    %r14,%rdi
call   1160 <atoi@plt>
mov    %eax,%edi
call   1070 <htons@plt>
mov    %rax,0x20(%rsp)
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1140 <bind@plt>
test   %rax,%rax
mov    0x2833(%rip),%rbx
jns    17d5 <connectToServer+0x525>
lea    0x883(%rip),%r15
lea    0x20(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%rdi
call   11a0 <strerror@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    $0x1,%edi
call   11c0 <sleep@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x4,%edx
call   1140 <bind@plt>
test   %rax,%rax
js     17a0 <connectToServer+0x4f0>
lea    0x835(%rip),%rdi
lea    0xa3b(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   1120 <listen@plt>
test   %rax,%rax
jns    1842 <connectToServer+0x592>
lea    0x80d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%rdi
call   11a0 <strerror@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    $0x1,%edi
call   11c0 <sleep@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   1120 <listen@plt>
test   %rax,%rax
js     1810 <connectToServer+0x560>
lea    0x7c8(%rip),%rdi
lea    0x9f0(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
movl   $0x18,0xc(%rsp)
lea    0x60(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,%edi
call   1150 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    189d <connectToServer+0x5ed>
mov    (%rbx),%rdi
call   11a0 <strerror@plt>
lea    0x78a(%rip),%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    $0x1,%edi
call   11c0 <sleep@plt>
mov    (%rbx),%rdi
call   11a0 <strerror@plt>
lea    0x765(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
lea    0x9c3(%rip),%rsi
mov    %r15,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0x9d4(%rip),%r14
lea    0x913(%rip),%r12
jmp    191a <connectToServer+0x66a>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%ebx
mov    %eax,%eax
movb   $0x0,0x0(%r13,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1170 <log_write@plt>
mov    %r13,%rdi
mov    %ebx,%esi
call   1100 <_string_analyze@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x1000,%edx
call   10d0 <read@plt>
test   %eax,%eax
jns    18f0 <connectToServer+0x640>
mov    0x2684(%rip),%rax
mov    (%rax),%rdi
mov    0x266a(%rip),%rax
cmp    (%rax),%rdi
je     191a <connectToServer+0x66a>
call   11a0 <strerror@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
jmp    191a <connectToServer+0x66a>
mov    0x2658(%rip),%rax
mov    (%rax),%rdi
call   11a0 <strerror@plt>
lea    0x6a2(%rip),%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1170 <log_write@plt>
mov    0x262e(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
%struct.timeval = type { i32, i64 }
@.str = [17 x i8] c"e-car.dyndns.org\00"
@.str.1 = [22 x i8] c"Communication Process\00"
@.str.2 = [40 x i8] c"Could not resolve server's domain name.\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@errno = global i64 0
@.str.3 = [52 x i8] c"DGRAM socket created for transmission successfully.\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.4 = [39 x i8] c"Couldn't set socket to re-use address.\00"
@.str.5 = [43 x i8] c"Socket set to re-use address successfully.\00"
@.str.6 = [22 x i8] c"c4r1d3n74ndr3d1rm3@\00"
@.str.7 = [7 x i8] c"TestID\00"
@.str.8 = [52 x i8] c"Attempting to send identification pattern to server\00"
@.str.9 = [39 x i8] c"Identification pattern sent to server.\00"
@.str.10 = [49 x i8] c"DGRAM socket created for receiving successfully.\00"
@INADDR_ANY = global i32 0
@.str.11 = [14 x i8] c"Socket bound.\00"
@.str.12 = [29 x i8] c"Waiting for server to reply.\00"
@.str.13 = [39 x i8] c"No answer received from server within \00"
@.str.14 = [10 x i8] c" seconds.\00"
@.str.15 = [12 x i8] c"Retrying...\00"
@.str.16 = [17 x i8] c"Server replied:'\00"
@.str.17 = [3 x i8] c"'.\00"
@SOCK_STREAM = global i32 0
@.str.18 = [36 x i8] c"STREAM socket created successfully.\00"
@.str.19 = [34 x i8] c"STREAM socket bound successfully.\00"
@.str.20 = [69 x i8] c"Listening to the given port and waiting for the incoming connection.\00"
@.str.21 = [44 x i8] c"Connection accepted. Starting reading loop.\00"
@EINTR = global i64 0
@.str.22 = [17 x i8] c"Received data: '\00"
@EXIT_SUCCESS = global i32 0
define i32 @connectToServer() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = alloca %struct.sockaddr
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.timeval
%13 = alloca %struct.sockaddr*
%14 = alloca i32
%15 = alloca i8*
%16 = call i8* @malloc(i32 1024)
store i8* %16, i8** %9
%17 = call %struct.sockaddr* @getip(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store %struct.sockaddr* %17, %struct.sockaddr** %13
store i32 1, i32* %14
%18 = call i8* @malloc(i32 4096)
store i8* %18, i8** %15
%19 = load %struct.sockaddr*, %struct.sockaddr** %13
%20 = icmp eq %struct.sockaddr* %19, null
br i1 %20, label %21, label %24
21: ; preds = %0
%22 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* null)
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %1
br label %263
24: ; preds = %0
%25 = load i8*, i8** @AF_INET
%26 = load i32, i32* @SOCK_DGRAM
%27 = call i32 @socket(i8* %25, i32 %26, i32 0)
store i32 %27, i32* %2
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* null)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %1
br label %263
32: ; preds = %24
%33 = load i8*, i8** @AF_INET
%34 = load i32, i32* @SOCK_DGRAM
%35 = call i32 @socket(i8* %33, i32 %34, i32 0)
store i32 %35, i32* %2
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %32
%38 = load i64, i64* @errno
%39 = call i8* @strerror(i64 %38)
%40 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %39, i8* null)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %32
%44 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* null)
%45 = load i32, i32* %2
%46 = load i32, i32* @SOL_SOCKET
%47 = load i32, i32* @SO_REUSEADDR
%48 = call i64 @setsockopt(i32 %45, i32 %46, i32 %47, i32* %14, i32 4)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %43
%51 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* null)
br label %54
52: ; preds = %43
%53 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* null)
br label %54
54: ; preds = %52, %50
%55 = load i8*, i8** %9
%56 = call i32 @strncpy(i8* %55, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 1024)
%57 = load i8*, i8** %9
%58 = load i8*, i8** %9
%59 = call i64 @strlen(i8* %58)
%60 = sub nsw i64 1024, %59
%61 = call i32 @strncat(i8* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i64 %60)
br label %62
62: ; preds = %54, %133, %140, %158
br label %63
63: ; preds = %62, %77
%64 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i8* null)
%65 = load i32, i32* %2
%66 = load i8*, i8** %9
%67 = load i8*, i8** %9
%68 = call i64 @strlen(i8* %67)
%69 = load %struct.sockaddr*, %struct.sockaddr** %13
%70 = call i32 @sendto(i32 %65, i8* %66, i64 %68, i32 0, %struct.sockaddr* %69, i32 4)
store i32 %70, i32* %4
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %63
%73 = load i64, i64* @errno
%74 = call i8* @strerror(i64 %73)
%75 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %74, i8* null)
br label %77
76: ; preds = %63
br label %78
77: ; preds = %72
br label %63
78: ; preds = %76
%79 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i8* null)
%80 = load i8*, i8** @AF_INET
%81 = load i32, i32* @SOCK_DGRAM
%82 = call i32 @socket(i8* %80, i32 %81, i32 0)
store i32 %82, i32* %3
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %90
84: ; preds = %78
%85 = load i64, i64* @errno
%86 = call i8* @strerror(i64 %85)
%87 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %86, i8* null)
%88 = load i32, i32* @EXIT_FAILURE
%89 = call i32 @exit(i32 %88)
unreachable
90: ; preds = %78
%91 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i8* null)
%92 = load i32, i32* %3
%93 = load i32, i32* @SOL_SOCKET
%94 = load i32, i32* @SO_REUSEADDR
%95 = call i64 @setsockopt(i32 %92, i32 %93, i32 %94, i32* %14, i32 4)
%96 = icmp slt i64 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %90
%98 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* null)
br label %101
99: ; preds = %90
%100 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* null)
br label %101
101: ; preds = %99, %97
%102 = load i8*, i8** @AF_INET
%103 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i8* %102, i8** %103
%104 = call i8* @htons(i32 6543)
%105 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
store i8* %104, i8** %105
%106 = load i32, i32* @INADDR_ANY
%107 = call i8* @htonl(i32 %106)
%108 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%109 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %108, i32 0, i32 0
store i8* %107, i8** %109
%110 = load i32, i32* %3
%111 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%112 = call i64 @bind(i32 %110, %struct.sockaddr* %111, i32 4)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %120
114: ; preds = %101
%115 = load i64, i64* @errno
%116 = call i8* @strerror(i64 %115)
%117 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %116, i8* null)
%118 = load i32, i32* @EXIT_FAILURE
%119 = call i32 @exit(i32 %118)
unreachable
120: ; preds = %101
%121 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* null)
store i32 24, i32* %10
%122 = call i32 @FD_ZERO(i32* %11)
%123 = load i32, i32* %3
%124 = call i32 @FD_SET(i32 %123, i32* %11)
%125 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
store i32 15, i32* %125
%126 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
store i64 0, i64* %126
%127 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i8* null)
%128 = load i32, i32* %3
%129 = add nsw i32 %128, 1
%130 = call i32 @select(i32 %129, i32* %11, i32* null, i32* null, %struct.timeval* %12)
store i32 %130, i32* %4
%131 = load i32, i32* %4
%132 = icmp slt i32 %131, 0
br i1 %132, label %133, label %137
133: ; preds = %120
%134 = load i64, i64* @errno
%135 = call i8* @strerror(i64 %134)
%136 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %135, i8* null)
br label %62
137: ; preds = %120
%138 = load i32, i32* %4
%139 = icmp ne i32 %138, 0
br i1 %139, label %146, label %140
140: ; preds = %137
%141 = call i32 @itoa(i32 15)
%142 = sext i32 %141 to i64
%143 = inttoptr i64 %142 to i8*
%144 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i8* %143, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* null)
%145 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* null)
br label %62
146: ; preds = %137
br label %147
147: ; preds = %146
%148 = load i32, i32* %3
%149 = load i8*, i8** %9
%150 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%151 = call i32 @recvfrom(i32 %148, i8* %149, i32 1024, i32 0, %struct.sockaddr* %150, i32* %10)
store i32 %151, i32* %4
%152 = icmp slt i32 %151, 0
br i1 %152, label %153, label %157
153: ; preds = %147
%154 = load i64, i64* @errno
%155 = call i8* @strerror(i64 %154)
%156 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %155, i8* null)
br label %158
157: ; preds = %147
br label %159
158: ; preds = %153
br label %62
159: ; preds = %157
%160 = load i8*, i8** %9
%161 = load i32, i32* %4
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8, i8* %160, i64 %162
store i8 0, i8* %163
%164 = load i8*, i8** %9
%165 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i8* %164, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i8* null)
%166 = load i32, i32* %3
%167 = call i32 @close(i32 %166)
%168 = load i8*, i8** @AF_INET
%169 = load i32, i32* @SOCK_STREAM
%170 = call i32 @socket(i8* %168, i32 %169, i32 0)
store i32 %170, i32* %2
%171 = icmp slt i32 %170, 0
br i1 %171, label %172, label %178
172: ; preds = %159
%173 = load i64, i64* @errno
%174 = call i8* @strerror(i64 %173)
%175 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %174, i8* null)
%176 = load i32, i32* @EXIT_FAILURE
%177 = call i32 @exit(i32 %176)
unreachable
178: ; preds = %159
%179 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i8* null)
%180 = load i32, i32* %2
%181 = load i32, i32* @SOL_SOCKET
%182 = load i32, i32* @SO_REUSEADDR
%183 = call i64 @setsockopt(i32 %180, i32 %181, i32 %182, i32* %14, i32 4)
%184 = icmp slt i64 %183, 0
br i1 %184, label %185, label %187
185: ; preds = %178
%186 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* null)
br label %189
187: ; preds = %178
%188 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* null)
br label %189
189: ; preds = %187, %185
%190 = load i8*, i8** @AF_INET
%191 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i8* %190, i8** %191
%192 = load i32, i32* @INADDR_ANY
%193 = call i8* @htonl(i32 %192)
%194 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%195 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %194, i32 0, i32 0
store i8* %193, i8** %195
%196 = load i8*, i8** %9
%197 = call i32 @atoi(i8* %196)
%198 = call i8* @htons(i32 %197)
%199 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i8* %198, i8** %199
br label %200
200: ; preds = %205, %189
%201 = load i32, i32* %2
%202 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%203 = call i64 @bind(i32 %201, %struct.sockaddr* %202, i32 4)
%204 = icmp slt i64 %203, 0
br i1 %204, label %205, label %210
205: ; preds = %200
%206 = load i64, i64* @errno
%207 = call i8* @strerror(i64 %206)
%208 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %207, i8* null)
%209 = call i32 @sleep(i32 1)
br label %200
210: ; preds = %200
%211 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0), i8* null)
br label %212
212: ; preds = %216, %210
%213 = load i32, i32* %2
%214 = call i64 @listen(i32 %213, i32 1)
%215 = icmp slt i64 %214, 0
br i1 %215, label %216, label %221
216: ; preds = %212
%217 = load i64, i64* @errno
%218 = call i8* @strerror(i64 %217)
%219 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %218, i8* null)
%220 = call i32 @sleep(i32 1)
br label %212
221: ; preds = %212
%222 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.20, i64 0, i64 0), i8* null)
store i32 24, i32* %10
%223 = load i32, i32* %2
%224 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%225 = call i32 @accept(i32 %223, %struct.sockaddr* %224, i32* %10)
store i32 %225, i32* %3
%226 = icmp slt i32 %225, 0
br i1 %226, label %227, label %232
227: ; preds = %221
%228 = load i64, i64* @errno
%229 = call i8* @strerror(i64 %228)
%230 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %229, i8* null)
%231 = call i32 @sleep(i32 1)
br label %232
232: ; preds = %227, %221
%233 = load i64, i64* @errno
%234 = call i8* @strerror(i64 %233)
%235 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %234, i8* null)
%236 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.21, i64 0, i64 0), i8* null)
%237 = load i8*, i8** %9
%238 = call i32 @free(i8* %237)
br label %239
239: ; preds = %232, %248, %252, %253
%240 = load i32, i32* %3
%241 = load i8*, i8** %15
%242 = call i32 @read(i32 %240, i8* %241, i32 4096)
store i32 %242, i32* %4
%243 = icmp slt i32 %242, 0
br i1 %243, label %244, label %253
244: ; preds = %239
%245 = load i64, i64* @errno
%246 = load i64, i64* @EINTR
%247 = icmp ne i64 %245, %246
br i1 %247, label %248, label %252
248: ; preds = %244
%249 = load i64, i64* @errno
%250 = call i8* @strerror(i64 %249)
%251 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %250, i8* null)
br label %239
252: ; preds = %244
br label %239
253: ; preds = %239
%254 = load i8*, i8** %15
%255 = load i32, i32* %4
%256 = sext i32 %255 to i64
%257 = getelementptr inbounds i8, i8* %254, i64 %256
store i8 0, i8* %257
%258 = load i8*, i8** %15
%259 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.22, i64 0, i64 0), i8* %258, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i8* null)
%260 = load i8*, i8** %15
%261 = load i32, i32* %4
%262 = call i32 @_string_analyze(i8* %260, i32 %261)
br label %239
263: ; preds = %29, %21
%264 = load i32, i32* %1
ret i32 %264
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [17 x i8] c"e-car.dyndns.org\00"
@.str.1 = [22 x i8] c"Communication Process\00"
@.str.2 = [40 x i8] c"Could not resolve server's domain name.\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@errno = global i64 0
@.str.3 = [52 x i8] c"DGRAM socket created for transmission successfully.\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.4 = [39 x i8] c"Couldn't set socket to re-use address.\00"
@.str.5 = [43 x i8] c"Socket set to re-use address successfully.\00"
@.str.6 = [22 x i8] c"c4r1d3n74ndr3d1rm3@\00"
@.str.7 = [7 x i8] c"TestID\00"
@.str.8 = [52 x i8] c"Attempting to send identification pattern to server\00"
@.str.9 = [39 x i8] c"Identification pattern sent to server.\00"
@.str.10 = [49 x i8] c"DGRAM socket created for receiving successfully.\00"
@INADDR_ANY = global i32 0
@.str.11 = [14 x i8] c"Socket bound.\00"
@.str.12 = [29 x i8] c"Waiting for server to reply.\00"
@.str.13 = [39 x i8] c"No answer received from server within \00"
@.str.14 = [10 x i8] c" seconds.\00"
@.str.15 = [12 x i8] c"Retrying...\00"
@.str.16 = [17 x i8] c"Server replied:'\00"
@.str.17 = [3 x i8] c"'.\00"
@SOCK_STREAM = global i32 0
@.str.18 = [36 x i8] c"STREAM socket created successfully.\00"
@.str.19 = [34 x i8] c"STREAM socket bound successfully.\00"
@.str.20 = [69 x i8] c"Listening to the given port and waiting for the incoming connection.\00"
@.str.21 = [44 x i8] c"Connection accepted. Starting reading loop.\00"
@EINTR = global i64 0
@.str.22 = [17 x i8] c"Received data: '\00"
@EXIT_SUCCESS = global i32 0
define i32 @connectToServer() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.timeval
%7 = alloca i32
%8 = bitcast %struct.sockaddr_in* %1 to i8*
%9 = bitcast %struct.sockaddr_in* %2 to i8*
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast %struct.timeval* %6 to i8*
%15 = tail call %struct.sockaddr* @getip(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%16 = bitcast i32* %7 to i8*
store i32 1, i32* %7
%17 = tail call dereferenceable_or_null(4096) i8* @malloc(i32 4096)
%18 = icmp eq %struct.sockaddr* %15, null
br i1 %18, label %209, label %19
19: ; preds = %0
%20 = load i8*, i8** @AF_INET
%21 = load i32, i32* @SOCK_DGRAM
%22 = tail call i32 @socket(i8* %20, i32 %21, i32 0)
%23 = icmp slt i32 %22, 0
br i1 %23, label %209, label %24
24: ; preds = %19
%25 = load i8*, i8** @AF_INET
%26 = load i32, i32* @SOCK_DGRAM
%27 = tail call i32 @socket(i8* %25, i32 %26, i32 0)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %24
%30 = load i64, i64* @errno
%31 = tail call i8* @strerror(i64 %30)
%32 = tail call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* null)
%33 = load i32, i32* @EXIT_FAILURE
%34 = tail call i32 @exit(i32 %33)
unreachable
35: ; preds = %24
%36 = tail call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* null)
%37 = load i32, i32* @SOL_SOCKET
%38 = load i32, i32* @SO_REUSEADDR
%39 = call i64 @setsockopt(i32 %27, i32 %37, i32 %38, i32* %7, i32 4)
%40 = icmp slt i64 %39, 0
%41 = select i1 %40, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0)
%42 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %41, i8* null)
%43 = call i32 @strncpy(i8* %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 1024)
%44 = call i64 @strlen(i8* dereferenceable(1) %11)
%45 = sub nsw i64 1024, %44
%46 = call i32 @strncat(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i64 %45)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
%50 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%51 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%53 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
br label %54
54: ; preds = %110, %35
%55 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i8* null)
%56 = call i64 @strlen(i8* dereferenceable(1) %11)
%57 = call i32 @sendto(i32 %27, i8* %11, i64 %56, i32 0, %struct.sockaddr* %15, i32 4)
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %67
59: ; preds = %54, %59
%60 = load i64, i64* @errno
%61 = call i8* @strerror(i64 %60)
%62 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %61, i8* null)
%63 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i8* null)
%64 = call i64 @strlen(i8* dereferenceable(1) %11)
%65 = call i32 @sendto(i32 %27, i8* %11, i64 %64, i32 0, %struct.sockaddr* %15, i32 4)
%66 = icmp slt i32 %65, 0
br i1 %66, label %59, label %67
67: ; preds = %59, %54
%68 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i8* null)
%69 = load i8*, i8** @AF_INET
%70 = load i32, i32* @SOCK_DGRAM
%71 = call i32 @socket(i8* %69, i32 %70, i32 0)
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %67
%74 = load i64, i64* @errno
%75 = call i8* @strerror(i64 %74)
%76 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %75, i8* null)
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 @exit(i32 %77)
unreachable
79: ; preds = %67
%80 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i8* null)
%81 = load i32, i32* @SOL_SOCKET
%82 = load i32, i32* @SO_REUSEADDR
%83 = call i64 @setsockopt(i32 %71, i32 %81, i32 %82, i32* %7, i32 4)
%84 = icmp slt i64 %83, 0
%85 = select i1 %84, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0)
%86 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %85, i8* null)
%87 = load i8*, i8** @AF_INET
store i8* %87, i8** %47
%88 = call i8* @htons(i32 6543)
store i8* %88, i8** %48
%89 = load i32, i32* @INADDR_ANY
%90 = call i8* @htonl(i32 %89)
store i8* %90, i8** %49
%91 = call i64 @bind(i32 %71, %struct.sockaddr* %50, i32 4)
%92 = icmp slt i64 %91, 0
br i1 %92, label %93, label %99
93: ; preds = %79
%94 = load i64, i64* @errno
%95 = call i8* @strerror(i64 %94)
%96 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %95, i8* null)
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %79
%100 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* null)
store i32 24, i32* %4
%101 = call i32 @FD_ZERO(i32* %5)
%102 = call i32 @FD_SET(i32 %71, i32* %5)
store i32 15, i32* %51
store i64 0, i64* %52
%103 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i8* null)
%104 = add nuw nsw i32 %71, 1
%105 = call i32 @select(i32 %104, i32* %5, i32* null, i32* null, %struct.timeval* %6)
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %113
107: ; preds = %99
%108 = load i64, i64* @errno
%109 = call i8* @strerror(i64 %108)
br label %110
110: ; preds = %107, %115, %123
%111 = phi i8* [ %109, %107 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), %115 ], [ %125, %123 ]
%112 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %111, i8* null)
br label %54
113: ; preds = %99
%114 = icmp eq i32 %105, 0
br i1 %114, label %115, label %120
115: ; preds = %113
%116 = call i32 @itoa(i32 15)
%117 = sext i32 %116 to i64
%118 = inttoptr i64 %117 to i8*
%119 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i8* %118, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* null)
br label %110
120: ; preds = %113
%121 = call i32 @recvfrom(i32 %71, i8* %11, i32 1024, i32 0, %struct.sockaddr* %53, i32* %4)
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %126
123: ; preds = %120
%124 = load i64, i64* @errno
%125 = call i8* @strerror(i64 %124)
br label %110
126: ; preds = %120
%127 = zext i32 %121 to i64
%128 = getelementptr inbounds i8, i8* %11, i64 %127
store i8 0, i8* %128
%129 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i8* null)
%130 = call i32 @close(i32 %71)
%131 = load i8*, i8** @AF_INET
%132 = load i32, i32* @SOCK_STREAM
%133 = call i32 @socket(i8* %131, i32 %132, i32 0)
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %141
135: ; preds = %126
%136 = load i64, i64* @errno
%137 = call i8* @strerror(i64 %136)
%138 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %137, i8* null)
%139 = load i32, i32* @EXIT_FAILURE
%140 = call i32 @exit(i32 %139)
unreachable
141: ; preds = %126
%142 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i8* null)
%143 = load i32, i32* @SOL_SOCKET
%144 = load i32, i32* @SO_REUSEADDR
%145 = call i64 @setsockopt(i32 %133, i32 %143, i32 %144, i32* %7, i32 4)
%146 = icmp slt i64 %145, 0
%147 = select i1 %146, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0)
%148 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %147, i8* null)
%149 = load i8*, i8** @AF_INET
%150 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i8* %149, i8** %150
%151 = load i32, i32* @INADDR_ANY
%152 = call i8* @htonl(i32 %151)
%153 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
store i8* %152, i8** %153
%154 = call i32 @atoi(i8* %11)
%155 = call i8* @htons(i32 %154)
%156 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
store i8* %155, i8** %156
%157 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%158 = call i64 @bind(i32 %133, %struct.sockaddr* %157, i32 4)
%159 = icmp slt i64 %158, 0
br i1 %159, label %160, label %167
160: ; preds = %141, %160
%161 = load i64, i64* @errno
%162 = call i8* @strerror(i64 %161)
%163 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %162, i8* null)
%164 = call i32 @sleep(i32 1)
%165 = call i64 @bind(i32 %133, %struct.sockaddr* %157, i32 4)
%166 = icmp slt i64 %165, 0
br i1 %166, label %160, label %167
167: ; preds = %160, %141
%168 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0), i8* null)
%169 = call i64 @listen(i32 %133, i32 1)
%170 = icmp slt i64 %169, 0
br i1 %170, label %171, label %178
171: ; preds = %167, %171
%172 = load i64, i64* @errno
%173 = call i8* @strerror(i64 %172)
%174 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %173, i8* null)
%175 = call i32 @sleep(i32 1)
%176 = call i64 @listen(i32 %133, i32 1)
%177 = icmp slt i64 %176, 0
br i1 %177, label %171, label %178
178: ; preds = %171, %167
%179 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.20, i64 0, i64 0), i8* null)
store i32 24, i32* %4
%180 = call i32 @accept(i32 %133, %struct.sockaddr* %53, i32* %4)
%181 = icmp slt i32 %180, 0
br i1 %181, label %182, label %187
182: ; preds = %178
%183 = load i64, i64* @errno
%184 = call i8* @strerror(i64 %183)
%185 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %184, i8* null)
%186 = call i32 @sleep(i32 1)
br label %187
187: ; preds = %182, %178
%188 = load i64, i64* @errno
%189 = call i8* @strerror(i64 %188)
%190 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %189, i8* null)
%191 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.21, i64 0, i64 0), i8* null)
%192 = call i32 @free(i8* %11)
br label %193
193: ; preds = %203, %187
%194 = call i32 @read(i32 %180, i8* %17, i32 4096)
%195 = icmp slt i32 %194, 0
br i1 %195, label %196, label %204
196: ; preds = %193
%197 = load i64, i64* @errno
%198 = load i64, i64* @EINTR
%199 = icmp eq i64 %197, %198
br i1 %199, label %203, label %200
200: ; preds = %196
%201 = call i8* @strerror(i64 %197)
%202 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %201, i8* null)
br label %203
203: ; preds = %200, %204, %196
br label %193
204: ; preds = %193
%205 = zext i32 %194 to i64
%206 = getelementptr inbounds i8, i8* %17, i64 %205
store i8 0, i8* %206
%207 = call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.22, i64 0, i64 0), i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i8* null)
%208 = call i32 @_string_analyze(i8* %17, i32 %194)
br label %203
209: ; preds = %19, %0
%210 = tail call i32 (i8*, i8*, i8*, ...) @log_write(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* null)
%211 = load i32, i32* @EXIT_FAILURE
ret i32 %211
}