#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 in_addr {
  int dummy;
};
struct sockaddr_in {
  scalar_t__ sin_family;
  scalar_t__ sin_port;
  struct in_addr sin_addr;
};
struct sockaddr {
  int dummy;
};
struct servent {
  int s_port;
};
struct iovec {
  unsigned char *iov_base;
  int iov_len;
};
struct hostent {
  scalar_t__ h_addrtype;
  int h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ sin;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
scalar_t__ AF_INET;
int EOF;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ drain(unsigned char *, int);
int /*<<< orphan*/ fill(unsigned char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *const);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
struct hostent *gethostbyname(char const *const);
int getopt(int, char **, char *);
struct servent *getservbyname(char const *const, char *);
void *htons(int);
char *optarg;
int optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, size_t, size_t);
int read(int, unsigned char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ shutdown(int, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
double strtod(char *, char **);
int strtoul(char const *const, char **, int /*<<< orphan*/);
int writev(int, struct iovec *, int);
int main(int argc, char *argv[]) {
  int sock;
  unsigned char buffer[8192];
  size_t buffer_pos;
  int opt;
  char *end;
  double max_time = 0.0;
  size_t max_bytes = (size_t)-1;
  size_t bytes_written = 0, bytes_read = 0;
  struct sockaddr_in sin;
  sin.sin_family = AF_INET;
  sin.sin_port = htons(7);
  while (EOF != (opt = getopt(argc, argv, "s:t:")))
    switch (opt) {
    case 's':
      max_bytes = strtoul(optarg, &end, 0);
      if ('\0' == *optarg || '\0' != *end || 0 == max_bytes) {
        fprintf(stderr, "%s: invalid length\n", optarg);
        return 2;
      }
      break;
    case 't':
      max_time = strtod(optarg, &end);
      if ('\0' == *optarg || '\0' != *end || max_time <= 0.0) {
        fprintf(stderr, "%s: invalid timeout\n", optarg);
        return 2;
      }
      break;
    case '?':
    usage:
      fputs("TCP loopback test utility version 1, copyright 2001 Dan Egnor.\n"
            "\n"
            "usage: looptest [flags] host [port]\n"
            "flags: -s bytes         Maximum amount of data to send\n"
            "       -t seconds       Maximum time in seconds to run\n"
            "\n"
            "Connects to TCP <host> and <port> (default 7), transmits a "
            "continuous stream\n"
            "of data, expects to receive the same data in return, verifies "
            "consistency\n"
            "and measures throughput.  Will run forever if not limited or "
            "stopped.\n",
            stderr);
      return 2;
    }
  if (argc - optind == 2) {
    const char *const name = argv[optind + 1];
    struct servent *const service = getservbyname(name, "tcp");
    if (NULL != service)
      sin.sin_port = htons(service->s_port);
    else {
      sin.sin_port = htons(strtoul(name, &end, 0));
      if ('\0' == *name || '\0' != *end || 0 == sin.sin_port) {
        fprintf(stderr, "%s: invalid port\n", name);
        return 1;
      }
    }
    --argc;
  }
  if (argc - optind != 1)
    goto usage;
  else {
    const char *const name = argv[optind];
    struct hostent *const host = gethostbyname(name);
    if (NULL == host) {
      fprintf(stderr, "%s: invalid host\n", name);
      return 1;
    }
    if (sin.sin_family != host->h_addrtype ||
        sizeof(sin.sin_addr) != host->h_length) {
      fprintf(stderr, "%s: wrong address type\n", name);
      return 1;
    }
    sin.sin_addr = *(struct in_addr *)host->h_addr;
    --argc;
  }
  sock = socket(PF_INET, SOCK_STREAM, 0);
  if (sock < 0) {
    perror("socket");
    return 1;
  }
  if (connect(sock, (struct sockaddr *)&sin, sizeof(sin))) {
    perror("connect");
    return 1;
  }
  fill(buffer, sizeof(buffer));
  buffer_pos = 0;
  for (;;) {
    int r;
    fd_set rfd, wfd;
    FD_ZERO(&rfd);
    FD_SET(sock, &rfd);
    FD_ZERO(&wfd);
    if (0 != max_bytes)
      FD_SET(sock, &wfd);
    r = select(1 + sock, &rfd, &wfd, NULL, NULL);
    if (r < 0) {
      perror("select");
      return 1;
    }
    if (FD_ISSET(sock, &rfd)) {
      unsigned char buffer[8192];
      r = read(sock, buffer, sizeof(buffer));
      if (r < 0)
        perror("read");
      if (0 != max_bytes && 0 == r)
        fputs("read: connection closed\n", stderr);
      if (r <= 0)
        break;
      bytes_read += r;
      if (!drain(buffer, r))
        break;
    }
    if (FD_ISSET(sock, &wfd)) {
      struct iovec iov[2];
      iov[0].iov_base = &buffer[buffer_pos];
      iov[0].iov_len = sizeof(buffer) - buffer_pos;
      if (max_bytes != (size_t)-1 && iov[0].iov_len > max_bytes) {
        iov[0].iov_len = max_bytes;
        iov[1].iov_len = 0;
      } else {
        iov[1].iov_base = &buffer[0];
        iov[1].iov_len = buffer_pos;
        if (max_bytes != (size_t)-1 &&
            iov[1].iov_len > max_bytes - iov[0].iov_len)
          iov[1].iov_len = max_bytes - iov[0].iov_len;
      }
      r = writev(sock, iov, 2);
      if (r < 0) {
        perror("write");
        max_bytes = 0;
      } else {
        if (max_bytes != (size_t)-1)
          max_bytes -= r;
        bytes_written += r;
        if (r > iov[0].iov_len) {
          buffer_pos = r - iov[0].iov_len;
          fill(iov[0].iov_base, iov[0].iov_len);
          fill(iov[1].iov_base, buffer_pos);
        } else {
          fill(iov[0].iov_base, r);
          buffer_pos += r;
        }
      }
      if (0 == max_bytes && shutdown(sock, 1))
        perror("shutdown");
    }
  }
  printf("read: %d; written: %d\n", bytes_read, bytes_written);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2040(%rbp)
ff
movq   $0xffffffffffffffff,-0x2048(%rbp)
ff ff ff ff
movq   $0x0,-0x2050(%rbp)
movq   $0x0,-0x2058(%rbp)
mov    0x2d44(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x2070(%rbp)
mov    $0x7,%edi
call   1070 <htons@plt>
mov    %rax,-0x2068(%rbp)
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40c4(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd2c(%rip),%rdx
call   1120 <getopt@plt>
mov    %eax,%ecx
mov    -0x40c4(%rbp),%eax
mov    %ecx,-0x202c(%rbp)
cmp    %ecx,%eax
je     1471 <main+0x221>
mov    -0x202c(%rbp),%eax
mov    %eax,-0x40c8(%rbp)
sub    $0x3f,%eax
je     1446 <main+0x1f6>
jmp    1309 <main+0xb9>
mov    -0x40c8(%rbp),%eax
sub    $0x73,%eax
je     1331 <main+0xe1>
jmp    131d <main+0xcd>
mov    -0x40c8(%rbp),%eax
sub    $0x74,%eax
je     13bc <main+0x16c>
jmp    146c <main+0x21c>
mov    0x2cc0(%rip),%rax
mov    (%rax),%rdi
lea    -0x2038(%rbp),%rsi
xor    %edx,%edx
call   1130 <strtoul@plt>
cltq
mov    %rax,-0x2048(%rbp)
mov    0x2c9f(%rip),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     138c <main+0x13c>
mov    -0x2038(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    138c <main+0x13c>
xor    %eax,%eax
cmp    -0x2048(%rbp),%rax
jne    13b7 <main+0x167>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
mov    0x2c5c(%rip),%rax
mov    (%rax),%rdx
lea    0xc5f(%rip),%rsi
call   10e0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1a91 <main+0x841>
jmp    146c <main+0x21c>
mov    0x2c35(%rip),%rax
mov    (%rax),%rdi
lea    -0x2038(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x2040(%rbp)
ff
mov    0x2c17(%rip),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1416 <main+0x1c6>
mov    -0x2038(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1416 <main+0x1c6>
xorps  %xmm0,%xmm0
ucomisd -0x2040(%rbp),%xmm0
ff
jb     1441 <main+0x1f1>
mov    0x2ba3(%rip),%rax
mov    (%rax),%edi
mov    0x2bd2(%rip),%rax
mov    (%rax),%rdx
lea    0xbe9(%rip),%rsi
call   10e0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1a91 <main+0x841>
jmp    146c <main+0x21c>
jmp    144b <main+0x1fb>
mov    0x2b6e(%rip),%rax
mov    (%rax),%esi
lea    0xbd3(%rip),%rdi
call   1090 <fputs@plt>
movl   $0x2,-0x4(%rbp)
jmp    1a91 <main+0x841>
jmp    12b7 <main+0x67>
mov    -0x8(%rbp),%eax
mov    0x2b55(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
jne    1577 <main+0x327>
mov    -0x10(%rbp),%rax
mov    0x2b3f(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x2078(%rbp)
mov    -0x2078(%rbp),%rdi
lea    0xd2d(%rip),%rsi
call   10a0 <getservbyname@plt>
mov    %rax,-0x2080(%rbp)
xor    %eax,%eax
cmp    -0x2080(%rbp),%rax
je     14e7 <main+0x297>
mov    -0x2080(%rbp),%rax
mov    (%rax),%edi
call   1070 <htons@plt>
mov    %rax,-0x2068(%rbp)
jmp    156e <main+0x31e>
mov    -0x2078(%rbp),%rdi
lea    -0x2038(%rbp),%rsi
xor    %edx,%edx
call   1130 <strtoul@plt>
mov    %eax,%edi
call   1070 <htons@plt>
mov    %rax,-0x2068(%rbp)
mov    -0x2078(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1541 <main+0x2f1>
mov    -0x2038(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1541 <main+0x2f1>
xor    %eax,%eax
cmp    -0x2068(%rbp),%rax
jne    1569 <main+0x319>
mov    0x2a78(%rip),%rax
mov    (%rax),%edi
mov    -0x2078(%rbp),%rdx
lea    0xc8b(%rip),%rsi
call   10e0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a91 <main+0x841>
jmp    156e <main+0x31e>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2a4f(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x1,%eax
je     1591 <main+0x341>
jmp    144b <main+0x1fb>
mov    -0x10(%rbp),%rax
mov    0x2a34(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x2088(%rbp)
mov    -0x2088(%rbp),%rdi
call   10d0 <gethostbyname@plt>
mov    %rax,-0x2090(%rbp)
xor    %eax,%eax
cmp    -0x2090(%rbp),%rax
jne    15f4 <main+0x3a4>
mov    0x29ed(%rip),%rax
mov    (%rax),%edi
mov    -0x2088(%rbp),%rdx
lea    0xc12(%rip),%rsi
call   10e0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a91 <main+0x841>
mov    -0x2070(%rbp),%rax
mov    -0x2090(%rbp),%rcx
cmp    (%rcx),%rax
jne    1624 <main+0x3d4>
mov    -0x2090(%rbp),%rax
movslq 0x8(%rax),%rcx
mov    $0x4,%eax
cmp    %rcx,%rax
je     164c <main+0x3fc>
mov    0x2995(%rip),%rax
mov    (%rax),%edi
mov    -0x2088(%rbp),%rdx
lea    0xbcc(%rip),%rsi
call   10e0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a91 <main+0x841>
mov    -0x2090(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x2060(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    0x2941(%rip),%rax
mov    (%rax),%edi
mov    0x2940(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    16a6 <main+0x456>
lea    0xb8a(%rip),%rdi
call   1110 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a91 <main+0x841>
mov    -0x14(%rbp),%edi
lea    -0x2070(%rbp),%rsi
mov    $0x18,%edx
call   1150 <connect@plt>
cmp    $0x0,%rax
je     16dc <main+0x48c>
lea    0xb5b(%rip),%rdi
call   1110 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a91 <main+0x841>
lea    -0x2020(%rbp),%rdi
mov    $0x2000,%esi
call   10c0 <fill@plt>
movq   $0x0,-0x2028(%rbp)
lea    -0x2098(%rbp),%rdi
call   10f0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x2098(%rbp),%rsi
call   1160 <FD_SET@plt>
lea    -0x209c(%rbp),%rdi
call   10f0 <FD_ZERO@plt>
xor    %eax,%eax
cmp    -0x2048(%rbp),%rax
je     173d <main+0x4ed>
mov    -0x14(%rbp),%edi
lea    -0x209c(%rbp),%rsi
call   1160 <FD_SET@plt>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x2098(%rbp),%rsi
lea    -0x209c(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1100 <select@plt>
mov    %eax,-0x2094(%rbp)
cmpl   $0x0,-0x2094(%rbp)
jge    1789 <main+0x539>
lea    0xab6(%rip),%rdi
call   1110 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a91 <main+0x841>
mov    -0x14(%rbp),%edi
lea    -0x2098(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1853 <main+0x603>
mov    -0x14(%rbp),%edi
lea    -0x40a0(%rbp),%rsi
mov    $0x2000,%edx
call   10b0 <read@plt>
mov    %eax,-0x2094(%rbp)
cmpl   $0x0,-0x2094(%rbp)
jge    17d5 <main+0x585>
lea    0xa65(%rip),%rdi
call   1110 <perror@plt>
xor    %eax,%eax
cmp    -0x2048(%rbp),%rax
je     1807 <main+0x5b7>
xor    %eax,%eax
cmp    -0x2094(%rbp),%eax
jne    1807 <main+0x5b7>
mov    0x27c7(%rip),%rax
mov    (%rax),%esi
lea    0xa38(%rip),%rdi
call   1090 <fputs@plt>
cmpl   $0x0,-0x2094(%rbp)
jg     1819 <main+0x5c9>
jmp    1a70 <main+0x820>
movslq -0x2094(%rbp),%rax
add    -0x2058(%rbp),%rax
mov    %rax,-0x2058(%rbp)
lea    -0x40a0(%rbp),%rdi
mov    -0x2094(%rbp),%esi
call   1140 <drain@plt>
cmp    $0x0,%eax
jne    184e <main+0x5fe>
jmp    1a70 <main+0x820>
jmp    1853 <main+0x603>
mov    -0x14(%rbp),%edi
lea    -0x209c(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1a6b <main+0x81b>
lea    -0x2020(%rbp),%rax
add    -0x2028(%rbp),%rax
mov    %rax,-0x40c0(%rbp)
mov    $0x2000,%eax
sub    -0x2028(%rbp),%rax
mov    %eax,-0x40b8(%rbp)
cmpq   $0xffffffffffffffff,-0x2048(%rbp)
ff
je     18d1 <main+0x681>
movslq -0x40b8(%rbp),%rax
cmp    -0x2048(%rbp),%rax
jbe    18d1 <main+0x681>
mov    -0x2048(%rbp),%rax
mov    %eax,-0x40b8(%rbp)
movl   $0x0,-0x40a8(%rbp)
jmp    1937 <main+0x6e7>
lea    -0x2020(%rbp),%rax
mov    %rax,-0x40b0(%rbp)
mov    -0x2028(%rbp),%rax
mov    %eax,-0x40a8(%rbp)
cmpq   $0xffffffffffffffff,-0x2048(%rbp)
ff
je     1932 <main+0x6e2>
movslq -0x40a8(%rbp),%rax
mov    -0x2048(%rbp),%rcx
movslq -0x40b8(%rbp),%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
jbe    1932 <main+0x6e2>
mov    -0x2048(%rbp),%rax
movslq -0x40b8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x40a8(%rbp)
jmp    1937 <main+0x6e7>
mov    -0x14(%rbp),%edi
lea    -0x40c0(%rbp),%rsi
mov    $0x2,%edx
call   1030 <writev@plt>
mov    %eax,-0x2094(%rbp)
cmpl   $0x0,-0x2094(%rbp)
jge    197a <main+0x72a>
lea    0x8ee(%rip),%rdi
call   1110 <perror@plt>
movq   $0x0,-0x2048(%rbp)
jmp    1a34 <main+0x7e4>
cmpq   $0xffffffffffffffff,-0x2048(%rbp)
ff
je     19a0 <main+0x750>
movslq -0x2094(%rbp),%rcx
mov    -0x2048(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x2048(%rbp)
movslq -0x2094(%rbp),%rax
add    -0x2050(%rbp),%rax
mov    %rax,-0x2050(%rbp)
mov    -0x2094(%rbp),%eax
cmp    -0x40b8(%rbp),%eax
jle    1a08 <main+0x7b8>
mov    -0x2094(%rbp),%eax
sub    -0x40b8(%rbp),%eax
cltq
mov    %rax,-0x2028(%rbp)
mov    -0x40c0(%rbp),%rdi
mov    -0x40b8(%rbp),%esi
call   10c0 <fill@plt>
mov    -0x40b0(%rbp),%rdi
mov    -0x2028(%rbp),%rax
mov    %eax,%esi
call   10c0 <fill@plt>
jmp    1a2f <main+0x7df>
mov    -0x40c0(%rbp),%rdi
mov    -0x2094(%rbp),%esi
call   10c0 <fill@plt>
movslq -0x2094(%rbp),%rax
add    -0x2028(%rbp),%rax
mov    %rax,-0x2028(%rbp)
jmp    1a34 <main+0x7e4>
xor    %eax,%eax
cmp    -0x2048(%rbp),%rax
jne    1a66 <main+0x816>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1060 <shutdown@plt>
cmp    $0x0,%rax
je     1a66 <main+0x816>
lea    0x7f8(%rip),%rdi
call   1110 <perror@plt>
jmp    1a6b <main+0x81b>
jmp    16f8 <main+0x4a8>
mov    -0x2058(%rbp),%rsi
mov    -0x2050(%rbp),%rdx
lea    0x7dd(%rip),%rdi
call   1080 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4048,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2d73(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    $0x7,%edi
call   1070 <htons@plt>
mov    %rax,0x28(%rsp)
mov    0x2d4d(%rip),%r13
mov    0x0(%r13),%ebx
lea    0xd72(%rip),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
call   1120 <getopt@plt>
movq   $0xffffffffffffffff,(%rsp)
ff
cmp    %eax,%ebx
jne    13a8 <main+0x158>
mov    0x2d19(%rip),%r15
mov    (%r15),%eax
mov    %ebp,%ecx
sub    %eax,%ecx
cmp    $0x2,%ecx
jne    12f4 <main+0xa4>
cltq
mov    0x8(%r14,%rax,8),%rbx
lea    0xf16(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <getservbyname@plt>
test   %rax,%rax
je     14a2 <main+0x252>
mov    (%rax),%edi
call   1070 <htons@plt>
mov    %rax,0x28(%rsp)
add    $0xffffffff,%ebp
mov    (%r15),%eax
sub    %eax,%ebp
cmp    $0x1,%ebp
jne    146e <main+0x21e>
cltq
mov    (%r14,%rax,8),%rbx
mov    %rbx,%rdi
call   10d0 <gethostbyname@plt>
test   %rax,%rax
je     1515 <main+0x2c5>
mov    0x20(%rsp),%rcx
cmp    (%rax),%rcx
jne    148d <main+0x23d>
cmpl   $0x4,0x8(%rax)
jne    148d <main+0x23d>
mov    0x10(%rax),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
mov    0x2c70(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
test   %eax,%eax
js     1765 <main+0x515>
mov    %eax,%r14d
lea    0x20(%rsp),%rsi
mov    %eax,%edi
mov    $0x18,%edx
call   1150 <connect@plt>
test   %rax,%rax
jne    176e <main+0x51e>
lea    0x2040(%rsp),%rdi
mov    $0x2000,%esi
call   10c0 <fill@plt>
mov    %r14d,%eax
add    $0x1,%eax
mov    %eax,0x1c(%rsp)
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    (%rsp),%rbx
jmp    1553 <main+0x303>
movq   $0xffffffffffffffff,(%rsp)
ff
mov    0x2c41(%rip),%r12
lea    0xc4a(%rip),%r15
jmp    13e2 <main+0x192>
cmp    $0x3f,%eax
je     146e <main+0x21e>
mov    0x0(%r13),%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1120 <getopt@plt>
cmp    %eax,%ebx
je     12b0 <main+0x60>
cmp    $0x73,%eax
je     1430 <main+0x1e0>
cmp    $0x74,%eax
jne    13c0 <main+0x170>
mov    (%r12),%rdi
lea    0x10(%rsp),%rsi
call   1040 <strtod@plt>
mov    (%r12),%rdx
cmpb   $0x0,(%rdx)
je     14e7 <main+0x297>
mov    0x10(%rsp),%rax
cmpb   $0x0,(%rax)
jne    14e7 <main+0x297>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jb     13c9 <main+0x179>
jmp    14e7 <main+0x297>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12),%rdi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1130 <strtoul@plt>
mov    (%r12),%rdx
cmpb   $0x0,(%rdx)
je     14f9 <main+0x2a9>
mov    0x10(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    14f9 <main+0x2a9>
test   %eax,%eax
je     14f9 <main+0x2a9>
cltq
mov    %rax,(%rsp)
jmp    13c9 <main+0x179>
mov    0x2b4b(%rip),%rax
mov    (%rax),%esi
lea    0xbb8(%rip),%rdi
call   1090 <fputs@plt>
mov    $0x2,%eax
jmp    1532 <main+0x2e2>
mov    0x2b2c(%rip),%rax
mov    (%rax),%edi
lea    0xd72(%rip),%rsi
jmp    1525 <main+0x2d5>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1130 <strtoul@plt>
mov    %eax,%edi
call   1070 <htons@plt>
mov    %rax,0x28(%rsp)
cmpb   $0x0,(%rbx)
je     14d5 <main+0x285>
mov    0x10(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    14d5 <main+0x285>
test   %rax,%rax
jne    12ee <main+0x9e>
mov    0x2ae4(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
jmp    1525 <main+0x2d5>
mov    0x2ad2(%rip),%rax
mov    (%rax),%edi
lea    0xb2a(%rip),%rsi
jmp    1509 <main+0x2b9>
mov    0x2ac0(%rip),%rax
mov    (%rax),%edi
lea    0xb04(%rip),%rsi
call   10e0 <fprintf@plt>
mov    $0x2,%eax
jmp    1532 <main+0x2e2>
mov    0x2aa4(%rip),%rax
mov    (%rax),%edi
lea    0xcd8(%rip),%rsi
mov    %rbx,%rdx
call   10e0 <fprintf@plt>
mov    $0x1,%eax
add    $0x4048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x6,%r13d
test   %r13d,%r13d
jne    172f <main+0x4df>
lea    0x3c(%rsp),%rbp
mov    %rbp,%rdi
call   10f0 <FD_ZERO@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1160 <FD_SET@plt>
lea    0x38(%rsp),%r13
mov    %r13,%rdi
call   10f0 <FD_ZERO@plt>
test   %rbx,%rbx
je     1588 <main+0x338>
mov    %r14d,%edi
mov    %r13,%rsi
call   1160 <FD_SET@plt>
mov    0x1c(%rsp),%edi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1100 <select@plt>
test   %eax,%eax
js     1777 <main+0x527>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     15fc <main+0x3ac>
mov    %r14d,%edi
lea    0x40(%rsp),%rsi
mov    $0x2000,%edx
call   10b0 <read@plt>
test   %eax,%eax
js     1788 <main+0x538>
test   %rbx,%rbx
je     15db <main+0x38b>
test   %eax,%eax
je     1737 <main+0x4e7>
test   %eax,%eax
je     174c <main+0x4fc>
mov    %eax,%ecx
add    %rcx,%r12
lea    0x40(%rsp),%rdi
mov    %eax,%esi
call   1140 <drain@plt>
test   %eax,%eax
je     1544 <main+0x2f4>
mov    %r14d,%edi
mov    %r13,%rsi
call   1050 <FD_ISSET@plt>
xor    %r13d,%r13d
test   %rax,%rax
je     154a <main+0x2fa>
mov    %r12,(%rsp)
mov    %r15,%r12
mov    0x8(%rsp),%rcx
lea    (%rsp,%rcx,1),%rax
add    $0x2040,%rax
mov    %rax,0x40(%rsp)
mov    $0x2000,%eax
sub    %ecx,%eax
mov    %eax,0x48(%rsp)
cltq
cmp    $0xffffffffffffffff,%rbx
je     164e <main+0x3fe>
cmp    %rax,%rbx
jae    164e <main+0x3fe>
mov    %ebx,0x48(%rsp)
xor    %ecx,%ecx
jmp    167a <main+0x42a>
lea    0x2040(%rsp),%rcx
mov    %rcx,0x50(%rsp)
mov    0x8(%rsp),%rcx
mov    %ecx,0x58(%rsp)
cmp    $0xffffffffffffffff,%rbx
je     167e <main+0x42e>
movslq 0x8(%rsp),%rdx
mov    %rbx,%rcx
sub    %rax,%rcx
cmp    %rcx,%rdx
jbe    167e <main+0x42e>
mov    %ecx,0x58(%rsp)
mov    %r14d,%edi
lea    0x40(%rsp),%rsi
mov    $0x2,%edx
call   1030 <writev@plt>
test   %eax,%eax
js     170c <main+0x4bc>
mov    %eax,%r15d
mov    %rbx,%rcx
sub    %r15,%rbx
cmp    $0xffffffffffffffff,%rcx
cmove  %rcx,%rbx
mov    0x48(%rsp),%esi
mov    %eax,%ecx
sub    %esi,%ecx
jle    16cf <main+0x47f>
movslq %ecx,%rbp
mov    0x40(%rsp),%rdi
call   10c0 <fill@plt>
mov    0x50(%rsp),%rdi
mov    %rbp,0x8(%rsp)
mov    %ebp,%esi
call   10c0 <fill@plt>
jmp    16e0 <main+0x490>
mov    0x40(%rsp),%rdi
mov    %eax,%esi
call   10c0 <fill@plt>
add    %r15,0x8(%rsp)
add    %r15,%r12
mov    %r12,%r15
test   %rbx,%rbx
mov    (%rsp),%r12
jne    154a <main+0x2fa>
mov    %r14d,%edi
mov    $0x1,%esi
call   1060 <shutdown@plt>
test   %rax,%rax
jne    1721 <main+0x4d1>
xor    %ebx,%ebx
jmp    154a <main+0x2fa>
lea    0xb48(%rip),%rdi
call   1110 <perror@plt>
mov    %r12,%r15
mov    (%rsp),%r12
jmp    16f3 <main+0x4a3>
lea    0xb39(%rip),%rdi
call   1110 <perror@plt>
jmp    1705 <main+0x4b5>
cmp    $0x6,%r13d
je     174c <main+0x4fc>
jmp    175e <main+0x50e>
mov    0x2882(%rip),%rax
mov    (%rax),%esi
lea    0xafb(%rip),%rdi
call   1090 <fputs@plt>
lea    0xb17(%rip),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1080 <printf@plt>
xor    %eax,%eax
jmp    1532 <main+0x2e2>
lea    0xabb(%rip),%rdi
jmp    177e <main+0x52e>
lea    0xab9(%rip),%rdi
jmp    177e <main+0x52e>
lea    0xab8(%rip),%rdi
call   1110 <perror@plt>
jmp    152d <main+0x2dd>
lea    0xaae(%rip),%rdi
call   1110 <perror@plt>
jmp    174c <main+0x4fc>

LLVM IR (-O0):
%struct.sockaddr_in = type { i64, i64, %struct.in_addr }
%struct.in_addr = type { i32 }
%struct.servent = type { i32 }
%struct.hostent = type { i64, i32, i64 }
%struct.iovec = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i64 0
@EOF = global i32 0
@.str = [5 x i8] c"s:t:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [20 x i8] c"%s: invalid length\0A\00"
@.str.2 = [21 x i8] c"%s: invalid timeout\0A\00"
@.str.3 = [433 x i8] c"TCP loopback test utility version 1, copyright 2001 Dan Egnor.\0A\0Ausage: looptest [flags] host [port]\0Aflags: -s bytes Maximum amount of data to send\0A -t seconds Maximum time in seconds to run\0A\0AConnects to TCP <host> and <port> (default 7), transmits a continuous stream\0Aof data, expects to receive the same data in return, verifies consistency\0Aand measures throughput. Will run forever if not limited or stopped.\0A\00"
@optind = global i32 0
@.str.4 = [4 x i8] c"tcp\00"
@.str.5 = [18 x i8] c"%s: invalid port\0A\00"
@.str.6 = [18 x i8] c"%s: invalid host\0A\00"
@.str.7 = [24 x i8] c"%s: wrong address type\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.8 = [7 x i8] c"socket\00"
@.str.9 = [8 x i8] c"connect\00"
@.str.10 = [7 x i8] c"select\00"
@.str.11 = [5 x i8] c"read\00"
@.str.12 = [25 x i8] c"read: connection closed\0A\00"
@.str.13 = [6 x i8] c"write\00"
@.str.14 = [9 x i8] c"shutdown\00"
@.str.15 = [23 x i8] c"read: %d; written: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [8192 x i8]
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca double
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca %struct.sockaddr_in
%16 = alloca i8*
%17 = alloca %struct.servent*
%18 = alloca i8*
%19 = alloca %struct.hostent*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca [8192 x i8]
%24 = alloca [2 x %struct.iovec]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %11
store i64 -1, i64* %12
store i64 0, i64* %13
store i64 0, i64* %14
%25 = load i64, i64* @AF_INET
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
store i64 %25, i64* %26
%27 = call i8* @htons(i32 7)
%28 = ptrtoint i8* %27 to i64
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
store i64 %28, i64* %29
br label %30
30: ; preds = %83, %2
%31 = load i32, i32* @EOF
%32 = load i32, i32* %4
%33 = load i8**, i8*** %5
%34 = call i32 @getopt(i32 %32, i8** %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %34, i32* %9
%35 = icmp ne i32 %31, %34
br i1 %35, label %36, label %84
36: ; preds = %30
%37 = load i32, i32* %9
switch i32 %37, label %83 [
i32 115, label %38
i32 116, label %59
i32 63, label %79
]
38: ; preds = %36
%39 = load i8*, i8** @optarg
%40 = call i32 @strtoul(i8* %39, i8** %10, i32 0)
%41 = sext i32 %40 to i64
store i64 %41, i64* %12
%42 = load i8*, i8** @optarg
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 0, %44
br i1 %45, label %54, label %46
46: ; preds = %38
%47 = load i8*, i8** %10
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 0, %49
br i1 %50, label %54, label %51
51: ; preds = %46
%52 = load i64, i64* %12
%53 = icmp eq i64 0, %52
br i1 %53, label %54, label %58
54: ; preds = %51, %46, %38
%55 = load i32, i32* @stderr
%56 = load i8*, i8** @optarg
%57 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %56)
store i32 2, i32* %3
br label %388
58: ; preds = %51
br label %83
59: ; preds = %36
%60 = load i8*, i8** @optarg
%61 = call double @strtod(i8* %60, i8** %10)
store double %61, double* %11
%62 = load i8*, i8** @optarg
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 0, %64
br i1 %65, label %74, label %66
66: ; preds = %59
%67 = load i8*, i8** %10
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 0, %69
br i1 %70, label %74, label %71
71: ; preds = %66
%72 = load double, double* %11
%73 = fcmp ole double %72, 0.000000e+00
br i1 %73, label %74, label %78
74: ; preds = %71, %66, %59
%75 = load i32, i32* @stderr
%76 = load i8*, i8** @optarg
%77 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %76)
store i32 2, i32* %3
br label %388
78: ; preds = %71
br label %83
79: ; preds = %36
br label %80
80: ; preds = %139, %79
%81 = load i32, i32* @stderr
%82 = call i32 @fputs(i8* getelementptr inbounds ([433 x i8], [433 x i8]* @.str.3, i64 0, i64 0), i32 %81)
store i32 2, i32* %3
br label %388
83: ; preds = %36, %78, %58
br label %30
84: ; preds = %30
%85 = load i32, i32* %4
%86 = load i32, i32* @optind
%87 = sub nsw i32 %85, %86
%88 = icmp eq i32 %87, 2
br i1 %88, label %89, label %134
89: ; preds = %84
%90 = load i8**, i8*** %5
%91 = load i32, i32* @optind
%92 = add nsw i32 %91, 1
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8*, i8** %90, i64 %93
%95 = load i8*, i8** %94
store i8* %95, i8** %16
%96 = load i8*, i8** %16
%97 = call %struct.servent* @getservbyname(i8* %96, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store %struct.servent* %97, %struct.servent** %17
%98 = load %struct.servent*, %struct.servent** %17
%99 = icmp ne %struct.servent* null, %98
br i1 %99, label %100, label %107
100: ; preds = %89
%101 = load %struct.servent*, %struct.servent** %17
%102 = getelementptr inbounds %struct.servent, %struct.servent* %101, i32 0, i32 0
%103 = load i32, i32* %102
%104 = call i8* @htons(i32 %103)
%105 = ptrtoint i8* %104 to i64
%106 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
store i64 %105, i64* %106
br label %131
107: ; preds = %89
%108 = load i8*, i8** %16
%109 = call i32 @strtoul(i8* %108, i8** %10, i32 0)
%110 = call i8* @htons(i32 %109)
%111 = ptrtoint i8* %110 to i64
%112 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
store i64 %111, i64* %112
%113 = load i8*, i8** %16
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = icmp eq i32 0, %115
br i1 %116, label %126, label %117
117: ; preds = %107
%118 = load i8*, i8** %10
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = icmp ne i32 0, %120
br i1 %121, label %126, label %122
122: ; preds = %117
%123 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
%124 = load i64, i64* %123
%125 = icmp eq i64 0, %124
br i1 %125, label %126, label %130
126: ; preds = %122, %117, %107
%127 = load i32, i32* @stderr
%128 = load i8*, i8** %16
%129 = call i32 @fprintf(i32 %127, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %128)
store i32 1, i32* %3
br label %388
130: ; preds = %122
br label %131
131: ; preds = %130, %100
%132 = load i32, i32* %4
%133 = add nsw i32 %132, -1
store i32 %133, i32* %4
br label %134
134: ; preds = %131, %84
%135 = load i32, i32* %4
%136 = load i32, i32* @optind
%137 = sub nsw i32 %135, %136
%138 = icmp ne i32 %137, 1
br i1 %138, label %139, label %140
139: ; preds = %134
br label %80
140: ; preds = %134
%141 = load i8**, i8*** %5
%142 = load i32, i32* @optind
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds i8*, i8** %141, i64 %143
%145 = load i8*, i8** %144
store i8* %145, i8** %18
%146 = load i8*, i8** %18
%147 = call %struct.hostent* @gethostbyname(i8* %146)
store %struct.hostent* %147, %struct.hostent** %19
%148 = load %struct.hostent*, %struct.hostent** %19
%149 = icmp eq %struct.hostent* null, %148
br i1 %149, label %150, label %154
150: ; preds = %140
%151 = load i32, i32* @stderr
%152 = load i8*, i8** %18
%153 = call i32 @fprintf(i32 %151, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %152)
store i32 1, i32* %3
br label %388
154: ; preds = %140
%155 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%156 = load i64, i64* %155
%157 = load %struct.hostent*, %struct.hostent** %19
%158 = getelementptr inbounds %struct.hostent, %struct.hostent* %157, i32 0, i32 0
%159 = load i64, i64* %158
%160 = icmp ne i64 %156, %159
br i1 %160, label %167, label %161
161: ; preds = %154
%162 = load %struct.hostent*, %struct.hostent** %19
%163 = getelementptr inbounds %struct.hostent, %struct.hostent* %162, i32 0, i32 1
%164 = load i32, i32* %163
%165 = sext i32 %164 to i64
%166 = icmp ne i64 4, %165
br i1 %166, label %167, label %171
167: ; preds = %161, %154
%168 = load i32, i32* @stderr
%169 = load i8*, i8** %18
%170 = call i32 @fprintf(i32 %168, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %169)
store i32 1, i32* %3
br label %388
171: ; preds = %161
%172 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 2
%173 = load %struct.hostent*, %struct.hostent** %19
%174 = getelementptr inbounds %struct.hostent, %struct.hostent* %173, i32 0, i32 2
%175 = load i64, i64* %174
%176 = inttoptr i64 %175 to %struct.in_addr*
%177 = bitcast %struct.in_addr* %172 to i8*
%178 = bitcast %struct.in_addr* %176 to i8*
%179 = load i32, i32* %4
%180 = add nsw i32 %179, -1
store i32 %180, i32* %4
br label %181
181: ; preds = %171
%182 = load i32, i32* @PF_INET
%183 = load i32, i32* @SOCK_STREAM
%184 = call i32 @socket(i32 %182, i32 %183, i32 0)
store i32 %184, i32* %6
%185 = load i32, i32* %6
%186 = icmp slt i32 %185, 0
br i1 %186, label %187, label %189
187: ; preds = %181
%188 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %388
189: ; preds = %181
%190 = load i32, i32* %6
%191 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%192 = call i64 @connect(i32 %190, %struct.sockaddr* %191, i32 24)
%193 = icmp ne i64 %192, 0
br i1 %193, label %194, label %196
194: ; preds = %189
%195 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %388
196: ; preds = %189
%197 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%198 = call i32 @fill(i8* %197, i32 8192)
store i64 0, i64* %8
br label %199
199: ; preds = %383, %196
%200 = call i32 @FD_ZERO(i32* %21)
%201 = load i32, i32* %6
%202 = call i32 @FD_SET(i32 %201, i32* %21)
%203 = call i32 @FD_ZERO(i32* %22)
%204 = load i64, i64* %12
%205 = icmp ne i64 0, %204
br i1 %205, label %206, label %209
206: ; preds = %199
%207 = load i32, i32* %6
%208 = call i32 @FD_SET(i32 %207, i32* %22)
br label %209
209: ; preds = %206, %199
%210 = load i32, i32* %6
%211 = add nsw i32 1, %210
%212 = call i32 @select(i32 %211, i32* %21, i32* %22, i32* null, i32* null)
store i32 %212, i32* %20
%213 = load i32, i32* %20
%214 = icmp slt i32 %213, 0
br i1 %214, label %215, label %217
215: ; preds = %209
%216 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %388
217: ; preds = %209
%218 = load i32, i32* %6
%219 = call i64 @FD_ISSET(i32 %218, i32* %21)
%220 = icmp ne i64 %219, 0
br i1 %220, label %221, label %253
221: ; preds = %217
%222 = load i32, i32* %6
%223 = getelementptr inbounds [8192 x i8], [8192 x i8]* %23, i64 0, i64 0
%224 = call i32 @read(i32 %222, i8* %223, i32 8192)
store i32 %224, i32* %20
%225 = load i32, i32* %20
%226 = icmp slt i32 %225, 0
br i1 %226, label %227, label %229
227: ; preds = %221
%228 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %229
229: ; preds = %227, %221
%230 = load i64, i64* %12
%231 = icmp ne i64 0, %230
br i1 %231, label %232, label %238
232: ; preds = %229
%233 = load i32, i32* %20
%234 = icmp eq i32 0, %233
br i1 %234, label %235, label %238
235: ; preds = %232
%236 = load i32, i32* @stderr
%237 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i32 %236)
br label %238
238: ; preds = %235, %232, %229
%239 = load i32, i32* %20
%240 = icmp sle i32 %239, 0
br i1 %240, label %241, label %242
241: ; preds = %238
br label %384
242: ; preds = %238
%243 = load i32, i32* %20
%244 = sext i32 %243 to i64
%245 = load i64, i64* %14
%246 = add i64 %245, %244
store i64 %246, i64* %14
%247 = getelementptr inbounds [8192 x i8], [8192 x i8]* %23, i64 0, i64 0
%248 = load i32, i32* %20
%249 = call i32 @drain(i8* %247, i32 %248)
%250 = icmp ne i32 %249, 0
br i1 %250, label %252, label %251
251: ; preds = %242
br label %384
252: ; preds = %242
br label %253
253: ; preds = %252, %217
%254 = load i32, i32* %6
%255 = call i64 @FD_ISSET(i32 %254, i32* %22)
%256 = icmp ne i64 %255, 0
br i1 %256, label %257, label %383
257: ; preds = %253
%258 = load i64, i64* %8
%259 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 %258
%260 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%261 = getelementptr inbounds %struct.iovec, %struct.iovec* %260, i32 0, i32 0
store i8* %259, i8** %261
%262 = load i64, i64* %8
%263 = sub i64 8192, %262
%264 = trunc i64 %263 to i32
%265 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%266 = getelementptr inbounds %struct.iovec, %struct.iovec* %265, i32 0, i32 1
store i32 %264, i32* %266
%267 = load i64, i64* %12
%268 = icmp ne i64 %267, -1
br i1 %268, label %269, label %283
269: ; preds = %257
%270 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%271 = getelementptr inbounds %struct.iovec, %struct.iovec* %270, i32 0, i32 1
%272 = load i32, i32* %271
%273 = sext i32 %272 to i64
%274 = load i64, i64* %12
%275 = icmp ugt i64 %273, %274
br i1 %275, label %276, label %283
276: ; preds = %269
%277 = load i64, i64* %12
%278 = trunc i64 %277 to i32
%279 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%280 = getelementptr inbounds %struct.iovec, %struct.iovec* %279, i32 0, i32 1
store i32 %278, i32* %280
%281 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 1
%282 = getelementptr inbounds %struct.iovec, %struct.iovec* %281, i32 0, i32 1
store i32 0, i32* %282
br label %316
283: ; preds = %269, %257
%284 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%285 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 1
%286 = getelementptr inbounds %struct.iovec, %struct.iovec* %285, i32 0, i32 0
store i8* %284, i8** %286
%287 = load i64, i64* %8
%288 = trunc i64 %287 to i32
%289 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 1
%290 = getelementptr inbounds %struct.iovec, %struct.iovec* %289, i32 0, i32 1
store i32 %288, i32* %290
%291 = load i64, i64* %12
%292 = icmp ne i64 %291, -1
br i1 %292, label %293, label %315
293: ; preds = %283
%294 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 1
%295 = getelementptr inbounds %struct.iovec, %struct.iovec* %294, i32 0, i32 1
%296 = load i32, i32* %295
%297 = sext i32 %296 to i64
%298 = load i64, i64* %12
%299 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%300 = getelementptr inbounds %struct.iovec, %struct.iovec* %299, i32 0, i32 1
%301 = load i32, i32* %300
%302 = sext i32 %301 to i64
%303 = sub i64 %298, %302
%304 = icmp ugt i64 %297, %303
br i1 %304, label %305, label %315
305: ; preds = %293
%306 = load i64, i64* %12
%307 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%308 = getelementptr inbounds %struct.iovec, %struct.iovec* %307, i32 0, i32 1
%309 = load i32, i32* %308
%310 = sext i32 %309 to i64
%311 = sub i64 %306, %310
%312 = trunc i64 %311 to i32
%313 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 1
%314 = getelementptr inbounds %struct.iovec, %struct.iovec* %313, i32 0, i32 1
store i32 %312, i32* %314
br label %315
315: ; preds = %305, %293, %283
br label %316
316: ; preds = %315, %276
%317 = load i32, i32* %6
%318 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%319 = call i32 @writev(i32 %317, %struct.iovec* %318, i32 2)
store i32 %319, i32* %20
%320 = load i32, i32* %20
%321 = icmp slt i32 %320, 0
br i1 %321, label %322, label %324
322: ; preds = %316
%323 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
store i64 0, i64* %12
br label %373
324: ; preds = %316
%325 = load i64, i64* %12
%326 = icmp ne i64 %325, -1
br i1 %326, label %327, label %332
327: ; preds = %324
%328 = load i32, i32* %20
%329 = sext i32 %328 to i64
%330 = load i64, i64* %12
%331 = sub i64 %330, %329
store i64 %331, i64* %12
br label %332
332: ; preds = %327, %324
%333 = load i32, i32* %20
%334 = sext i32 %333 to i64
%335 = load i64, i64* %13
%336 = add i64 %335, %334
store i64 %336, i64* %13
%337 = load i32, i32* %20
%338 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%339 = getelementptr inbounds %struct.iovec, %struct.iovec* %338, i32 0, i32 1
%340 = load i32, i32* %339
%341 = icmp sgt i32 %337, %340
br i1 %341, label %342, label %362
342: ; preds = %332
%343 = load i32, i32* %20
%344 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%345 = getelementptr inbounds %struct.iovec, %struct.iovec* %344, i32 0, i32 1
%346 = load i32, i32* %345
%347 = sub nsw i32 %343, %346
%348 = sext i32 %347 to i64
store i64 %348, i64* %8
%349 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%350 = getelementptr inbounds %struct.iovec, %struct.iovec* %349, i32 0, i32 0
%351 = load i8*, i8** %350
%352 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%353 = getelementptr inbounds %struct.iovec, %struct.iovec* %352, i32 0, i32 1
%354 = load i32, i32* %353
%355 = call i32 @fill(i8* %351, i32 %354)
%356 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 1
%357 = getelementptr inbounds %struct.iovec, %struct.iovec* %356, i32 0, i32 0
%358 = load i8*, i8** %357
%359 = load i64, i64* %8
%360 = trunc i64 %359 to i32
%361 = call i32 @fill(i8* %358, i32 %360)
br label %372
362: ; preds = %332
%363 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %24, i64 0, i64 0
%364 = getelementptr inbounds %struct.iovec, %struct.iovec* %363, i32 0, i32 0
%365 = load i8*, i8** %364
%366 = load i32, i32* %20
%367 = call i32 @fill(i8* %365, i32 %366)
%368 = load i32, i32* %20
%369 = sext i32 %368 to i64
%370 = load i64, i64* %8
%371 = add i64 %370, %369
store i64 %371, i64* %8
br label %372
372: ; preds = %362, %342
br label %373
373: ; preds = %372, %322
%374 = load i64, i64* %12
%375 = icmp eq i64 0, %374
br i1 %375, label %376, label %382
376: ; preds = %373
%377 = load i32, i32* %6
%378 = call i64 @shutdown(i32 %377, i32 1)
%379 = icmp ne i64 %378, 0
br i1 %379, label %380, label %382
380: ; preds = %376
%381 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
br label %382
382: ; preds = %380, %376, %373
br label %383
383: ; preds = %382, %253
br label %199
384: ; preds = %251, %241
%385 = load i64, i64* %14
%386 = load i64, i64* %13
%387 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i64 %385, i64 %386)
store i32 0, i32* %3
br label %388
388: ; preds = %384, %215, %194, %187, %167, %150, %126, %80, %74, %54
%389 = load i32, i32* %3
ret i32 %389
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i64, i64, %struct.in_addr }
%struct.in_addr = type { i32 }
%struct.iovec = type { i8*, i32 }
%struct.servent = type { i32 }
%struct.hostent = type { i64, i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i64 0
@EOF = global i32 0
@.str = [5 x i8] c"s:t:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [20 x i8] c"%s: invalid length\0A\00"
@.str.2 = [21 x i8] c"%s: invalid timeout\0A\00"
@.str.3 = [433 x i8] c"TCP loopback test utility version 1, copyright 2001 Dan Egnor.\0A\0Ausage: looptest [flags] host [port]\0Aflags: -s bytes Maximum amount of data to send\0A -t seconds Maximum time in seconds to run\0A\0AConnects to TCP <host> and <port> (default 7), transmits a continuous stream\0Aof data, expects to receive the same data in return, verifies consistency\0Aand measures throughput. Will run forever if not limited or stopped.\0A\00"
@optind = global i32 0
@.str.4 = [4 x i8] c"tcp\00"
@.str.5 = [18 x i8] c"%s: invalid port\0A\00"
@.str.6 = [18 x i8] c"%s: invalid host\0A\00"
@.str.7 = [24 x i8] c"%s: wrong address type\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.8 = [7 x i8] c"socket\00"
@.str.9 = [8 x i8] c"connect\00"
@.str.10 = [7 x i8] c"select\00"
@.str.11 = [5 x i8] c"read\00"
@.str.12 = [25 x i8] c"read: connection closed\0A\00"
@.str.13 = [6 x i8] c"write\00"
@.str.14 = [9 x i8] c"shutdown\00"
@.str.15 = [23 x i8] c"read: %d; written: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [8192 x i8]
%4 = alloca i8*
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca i32
%8 = alloca [8192 x i8]
%9 = alloca [2 x %struct.iovec]
%10 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%11 = bitcast i8** %4 to i8*
%12 = bitcast %struct.sockaddr_in* %5 to i8*
%13 = load i64, i64* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i64 %13, i64* %14
%15 = tail call i8* @htons(i32 7)
%16 = ptrtoint i8* %15 to i64
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i64 %16, i64* %17
%18 = load i32, i32* @EOF
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i32 %18, %19
br i1 %20, label %63, label %21
21: ; preds = %2, %58
%22 = phi i32 [ %61, %58 ], [ %19, %2 ]
%23 = phi i64 [ %59, %58 ], [ -1, %2 ]
switch i32 %22, label %58 [
i32 115, label %24
i32 116, label %40
i32 63, label %55
]
24: ; preds = %21
%25 = load i8*, i8** @optarg
%26 = call i32 @strtoul(i8* %25, i8** %4, i32 0)
%27 = load i8*, i8** @optarg
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %37, label %30
30: ; preds = %24
%31 = sext i32 %26 to i64
%32 = load i8*, i8** %4
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
%35 = icmp eq i32 %26, 0
%36 = select i1 %34, i1 true, i1 %35
br i1 %36, label %37, label %58
37: ; preds = %30, %24
%38 = load i32, i32* @stderr
%39 = tail call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %263
40: ; preds = %21
%41 = load i8*, i8** @optarg
%42 = call double @strtod(i8* %41, i8** %4)
%43 = load i8*, i8** @optarg
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 0
br i1 %45, label %52, label %46
46: ; preds = %40
%47 = load i8*, i8** %4
%48 = load i8, i8* %47
%49 = icmp ne i8 %48, 0
%50 = fcmp ole double %42, 0.000000e+00
%51 = select i1 %49, i1 true, i1 %50
br i1 %51, label %52, label %58
52: ; preds = %46, %40
%53 = load i32, i32* @stderr
%54 = tail call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %263
55: ; preds = %21, %98
%56 = load i32, i32* @stderr
%57 = tail call i32 @fputs(i8* getelementptr inbounds ([433 x i8], [433 x i8]* @.str.3, i64 0, i64 0), i32 %56)
br label %263
58: ; preds = %46, %30, %21
%59 = phi i64 [ %23, %21 ], [ %23, %46 ], [ %31, %30 ]
%60 = load i32, i32* @EOF
%61 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%62 = icmp eq i32 %60, %61
br i1 %62, label %63, label %21
63: ; preds = %58, %2
%64 = phi i64 [ -1, %2 ], [ %59, %58 ]
%65 = load i32, i32* @optind
%66 = sub nsw i32 %0, %65
%67 = icmp eq i32 %66, 2
br i1 %67, label %68, label %98
68: ; preds = %63
%69 = add nsw i32 %65, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %1, i64 %70
%72 = load i8*, i8** %71
%73 = tail call %struct.servent* @getservbyname(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%74 = icmp eq %struct.servent* %73, null
br i1 %74, label %80, label %75
75: ; preds = %68
%76 = getelementptr inbounds %struct.servent, %struct.servent* %73, i64 0, i32 0
%77 = load i32, i32* %76
%78 = tail call i8* @htons(i32 %77)
%79 = ptrtoint i8* %78 to i64
store i64 %79, i64* %17
br label %92
80: ; preds = %68
%81 = call i32 @strtoul(i8* %72, i8** %4, i32 0)
%82 = tail call i8* @htons(i32 %81)
%83 = ptrtoint i8* %82 to i64
store i64 %83, i64* %17
%84 = load i8, i8* %72
%85 = icmp eq i8 %84, 0
br i1 %85, label %95, label %86
86: ; preds = %80
%87 = load i8*, i8** %4
%88 = load i8, i8* %87
%89 = icmp ne i8 %88, 0
%90 = icmp eq i8* %82, null
%91 = select i1 %89, i1 true, i1 %90
br i1 %91, label %95, label %92
92: ; preds = %75, %86
%93 = add nsw i32 %0, -1
%94 = load i32, i32* @optind
br label %98
95: ; preds = %80, %86
%96 = load i32, i32* @stderr
%97 = tail call i32 @fprintf(i32 %96, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %72)
br label %263
98: ; preds = %92, %63
%99 = phi i32 [ %65, %63 ], [ %94, %92 ]
%100 = phi i32 [ %0, %63 ], [ %93, %92 ]
%101 = sub nsw i32 %100, %99
%102 = icmp eq i32 %101, 1
br i1 %102, label %103, label %55
103: ; preds = %98
%104 = sext i32 %99 to i64
%105 = getelementptr inbounds i8*, i8** %1, i64 %104
%106 = load i8*, i8** %105
%107 = tail call %struct.hostent* @gethostbyname(i8* %106)
%108 = icmp eq %struct.hostent* %107, null
br i1 %108, label %109, label %112
109: ; preds = %103
%110 = load i32, i32* @stderr
%111 = tail call i32 @fprintf(i32 %110, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %106)
br label %263
112: ; preds = %103
%113 = load i64, i64* %14
%114 = getelementptr inbounds %struct.hostent, %struct.hostent* %107, i64 0, i32 0
%115 = load i64, i64* %114
%116 = icmp eq i64 %113, %115
br i1 %116, label %117, label %121
117: ; preds = %112
%118 = getelementptr inbounds %struct.hostent, %struct.hostent* %107, i64 0, i32 1
%119 = load i32, i32* %118
%120 = icmp eq i32 %119, 4
br i1 %120, label %124, label %121
121: ; preds = %117, %112
%122 = load i32, i32* @stderr
%123 = tail call i32 @fprintf(i32 %122, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %106)
br label %263
124: ; preds = %117
%125 = getelementptr inbounds %struct.hostent, %struct.hostent* %107, i64 0, i32 2
%126 = load i64, i64* %125
%127 = inttoptr i64 %126 to i32*
%128 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2, i32 0
%129 = load i32, i32* %127
store i32 %129, i32* %128
%130 = load i32, i32* @PF_INET
%131 = load i32, i32* @SOCK_STREAM
%132 = tail call i32 @socket(i32 %130, i32 %131, i32 0)
%133 = icmp slt i32 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %124
%135 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %263
136: ; preds = %124
%137 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%138 = call i64 @connect(i32 %132, %struct.sockaddr* %137, i32 24)
%139 = icmp eq i64 %138, 0
br i1 %139, label %142, label %140
140: ; preds = %136
%141 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %263
142: ; preds = %136
%143 = call i32 @fill(i8* %10, i32 8192)
%144 = bitcast i32* %6 to i8*
%145 = bitcast i32* %7 to i8*
%146 = add nuw nsw i32 %132, 1
%147 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%148 = bitcast [2 x %struct.iovec]* %9 to i8*
%149 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %9, i64 0, i64 0
%150 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %9, i64 0, i64 0, i32 0
%151 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %9, i64 0, i64 0, i32 1
%152 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %9, i64 0, i64 1, i32 0
%153 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %9, i64 0, i64 1, i32 1
br label %154
154: ; preds = %253, %142
%155 = phi i64 [ %64, %142 ], [ %254, %253 ]
%156 = phi i64 [ 0, %142 ], [ %255, %253 ]
%157 = phi i64 [ 0, %142 ], [ %256, %253 ]
%158 = phi i64 [ 0, %142 ], [ %258, %253 ]
%159 = call i32 @FD_ZERO(i32* %6)
%160 = call i32 @FD_SET(i32 %132, i32* %6)
%161 = call i32 @FD_ZERO(i32* %7)
%162 = icmp ne i64 %155, 0
br i1 %162, label %163, label %165
163: ; preds = %154
%164 = call i32 @FD_SET(i32 %132, i32* %7)
br label %165
165: ; preds = %163, %154
%166 = call i32 @select(i32 %146, i32* %6, i32* %7, i32* null, i32* null)
%167 = icmp slt i32 %166, 0
br i1 %167, label %168, label %170
168: ; preds = %165
%169 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %263
170: ; preds = %165
%171 = call i64 @FD_ISSET(i32 %132, i32* %6)
%172 = icmp eq i64 %171, 0
br i1 %172, label %191, label %173
173: ; preds = %170
%174 = call i32 @read(i32 %132, i8* %147, i32 8192)
%175 = icmp slt i32 %174, 0
br i1 %175, label %176, label %178
176: ; preds = %173
%177 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %185
178: ; preds = %173
%179 = icmp eq i32 %174, 0
%180 = and i1 %162, %179
br i1 %180, label %181, label %184
181: ; preds = %178
%182 = load i32, i32* @stderr
%183 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i32 %182)
br label %185
184: ; preds = %178
br i1 %179, label %185, label %186
185: ; preds = %184, %181, %176
br label %259
186: ; preds = %184
%187 = zext i32 %174 to i64
%188 = add i64 %157, %187
%189 = call i32 @drain(i8* %147, i32 %174)
%190 = icmp eq i32 %189, 0
br i1 %190, label %253, label %191
191: ; preds = %186, %170
%192 = phi i64 [ %188, %186 ], [ %157, %170 ]
%193 = call i64 @FD_ISSET(i32 %132, i32* %7)
%194 = icmp eq i64 %193, 0
br i1 %194, label %253, label %195
195: ; preds = %191
%196 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %158
store i8* %196, i8** %150
%197 = trunc i64 %158 to i32
%198 = sub i32 8192, %197
store i32 %198, i32* %151
%199 = icmp eq i64 %155, -1
%200 = xor i1 %199, true
%201 = sext i32 %198 to i64
%202 = icmp ult i64 %155, %201
%203 = select i1 %200, i1 %202, i1 false
br i1 %203, label %204, label %206
204: ; preds = %195
%205 = trunc i64 %155 to i32
store i32 %205, i32* %151
br label %214
206: ; preds = %195
store i8* %10, i8** %152
store i32 %197, i32* %153
br i1 %199, label %216, label %207
207: ; preds = %206
%208 = shl i64 %158, 32
%209 = ashr exact i64 %208, 32
%210 = sub i64 %155, %201
%211 = icmp ugt i64 %209, %210
br i1 %211, label %212, label %216
212: ; preds = %207
%213 = trunc i64 %210 to i32
br label %214
214: ; preds = %204, %212
%215 = phi i32 [ %213, %212 ], [ 0, %204 ]
store i32 %215, i32* %153
br label %216
216: ; preds = %214, %206, %207
%217 = call i32 @writev(i32 %132, %struct.iovec* %149, i32 2)
%218 = icmp slt i32 %217, 0
br i1 %218, label %219, label %221
219: ; preds = %216
%220 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
br label %242
221: ; preds = %216
%222 = zext i32 %217 to i64
%223 = sub i64 %155, %222
%224 = select i1 %199, i64 -1, i64 %223
%225 = add i64 %156, %222
%226 = load i32, i32* %151
%227 = icmp sgt i32 %217, %226
br i1 %227, label %228, label %235
228: ; preds = %221
%229 = sub nsw i32 %217, %226
%230 = sext i32 %229 to i64
%231 = load i8*, i8** %150
%232 = call i32 @fill(i8* %231, i32 %226)
%233 = load i8*, i8** %152
%234 = call i32 @fill(i8* %233, i32 %229)
br label %239
235: ; preds = %221
%236 = load i8*, i8** %150
%237 = call i32 @fill(i8* %236, i32 %217)
%238 = add i64 %158, %222
br label %239
239: ; preds = %228, %235
%240 = phi i64 [ %230, %228 ], [ %238, %235 ]
%241 = icmp eq i64 %224, 0
br i1 %241, label %242, label %249
242: ; preds = %219, %239
%243 = phi i64 [ %158, %219 ], [ %240, %239 ]
%244 = phi i64 [ %156, %219 ], [ %225, %239 ]
%245 = call i64 @shutdown(i32 %132, i32 1)
%246 = icmp eq i64 %245, 0
br i1 %246, label %249, label %247
247: ; preds = %242
%248 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
br label %249
249: ; preds = %247, %242, %239
%250 = phi i64 [ %243, %247 ], [ %243, %242 ], [ %240, %239 ]
%251 = phi i64 [ %244, %247 ], [ %244, %242 ], [ %225, %239 ]
%252 = phi i64 [ 0, %247 ], [ 0, %242 ], [ %224, %239 ]
br label %253
253: ; preds = %191, %249, %186
%254 = phi i64 [ %155, %186 ], [ %252, %249 ], [ %155, %191 ]
%255 = phi i64 [ %156, %186 ], [ %251, %249 ], [ %156, %191 ]
%256 = phi i64 [ %188, %186 ], [ %192, %249 ], [ %192, %191 ]
%257 = phi i32 [ 6, %186 ], [ 0, %249 ], [ 0, %191 ]
%258 = phi i64 [ %158, %186 ], [ %250, %249 ], [ %158, %191 ]
switch i32 %257, label %263 [
i32 0, label %154
i32 6, label %259
]
259: ; preds = %253, %185
%260 = phi i64 [ %157, %185 ], [ %256, %253 ]
%261 = phi i64 [ %156, %185 ], [ %255, %253 ]
%262 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i64 %260, i64 %261)
br label %263
263: ; preds = %253, %109, %121, %168, %95, %259, %140, %134, %55, %52, %37
%264 = phi i32 [ 2, %55 ], [ 2, %52 ], [ 2, %37 ], [ 1, %134 ], [ 1, %140 ], [ 0, %259 ], [ 1, %95 ], [ 1, %168 ], [ 1, %121 ], [ 1, %109 ], [ 0, %253 ]
ret i32 %264
}