#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 katcl_parse {
  int dummy;
};
struct katcl_line {
  int dummy;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
#define EAGAIN 129
#define EINTR 128
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int STDOUT_FILENO;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ append_parse_katcl(struct katcl_line *,
                                      struct katcl_parse *);
int atoi(char *);
int /*<<< orphan*/ close(int);
struct katcl_line *create_katcl(int);
int /*<<< orphan*/ destroy_katcl(struct katcl_line *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error_katcl(struct katcl_line *);
int fileno_katcl(struct katcl_line *);
scalar_t__ flushing_katcl(struct katcl_line *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ have_katcl(struct katcl_line *);
int /*<<< orphan*/ log_message_katcl(struct katcl_line *, int, char *, char *,
                                     ...);
int net_listen(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int read_katcl(struct katcl_line *);
struct katcl_parse *ready_katcl(struct katcl_line *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int start_serial(char *, int);
int /*<<< orphan*/ stderr;
char strerror(int /*<<< orphan*/);
int /*<<< orphan*/ sync_message_katcl(struct katcl_line *, int, char *, char *,
                                      ...);
int /*<<< orphan*/ usage(char *, struct katcl_line *);
int write_katcl(struct katcl_line *);
int main(int argc, char **argv) {
  char *net, *serial, *label;
  int i, j, c, lfd, run, fd, mfd, result, count, speed;
  struct katcl_line *sk, *nk, *k;
  struct katcl_parse *p;
  fd_set fsr, fsw;
  label = "katcp-serial-gateway";
  k = create_katcl(STDOUT_FILENO);
  if (k == NULL) {
    fprintf(stderr, "%s: unable to create katcp message logic\n", label);
    return 4;
  }
  sk = NULL;
  nk = NULL;
  speed = 0;
  serial = NULL;
  net = NULL;
  count = 0;
  i = j = 1;
  while (i < argc) {
    if (argv[i][0] == '-') {
      c = argv[i][j];
      switch (c) {
      case 'h':
        usage(label, k);
        return 0;
      case 'b':
      case 's':
        j++;
        if (argv[i][j] == '\0') {
          j = 0;
          i++;
        }
        if (i >= argc) {
          sync_message_katcl(k, 4, label, "argument needs a parameter");
          return 2;
        }
        switch (c) {
        case 'p':
          net = argv[i] + j;
          break;
        case 'b':
          speed = atoi(argv[i] + j);
          if (speed < 0) {
            sync_message_katcl(k, 4, label, "speed %s unreasonable",
                               argv[i] + j);
            return 2;
          }
          break;
        case 's':
          serial = argv[i] + j;
          break;
        }
      case '-':
        j++;
        break;
      case '\0':
        j = 1;
        i++;
        break;
      default:
        sync_message_katcl(k, 4, label, "unknown option -%c", c);
        return 2;
      }
    } else {
      if (serial == NULL) {
        serial = argv[i];
      } else if (net == NULL) {
        net = argv[i];
      } else if (speed == 0) {
        speed = atoi(argv[i]);
      } else {
        sync_message_katcl(k, 4, label, "excess argument %s", argv[i]);
        return 2;
      }
      i++;
    }
  }
  if (speed <= 0) {
    speed = 9600;
  }
  if (serial == NULL) {
    sync_message_katcl(k, 4, label, "need a serial port to relay");
    usage(label, k);
    return 2;
  }
  fd = start_serial(serial, speed);
  if (fd < 0) {
    sync_message_katcl(k, 4, label, "unable to open serial device %s: %s",
                       serial, strerror(errno));
    return 3;
  }
  sk = create_katcl(fd);
  if (sk == NULL) {
    sync_message_katcl(k, 4, label,
                       "unable to run katcp wrapper on serial file descriptor");
    return 4;
  }
  lfd = net_listen(net, 0, 0);
  if (lfd < 0) {
    sync_message_katcl(k, 4, label, "unknown option -%c", argv[i][j]);
    return 3;
  }
  for (run = 1; run;) {
    mfd = 0;
    FD_ZERO(&fsr);
    FD_ZERO(&fsw);
    if (k) {
      if (flushing_katcl(k)) {
        fd = fileno_katcl(k);
        FD_SET(fd, &fsw);
        mfd = fd;
      }
    }
    if (nk) {
      fd = fileno_katcl(nk);
      if (flushing_katcl(nk)) {
        FD_SET(fd, &fsw);
      }
      FD_SET(fd, &fsr);
      if (mfd < fd) {
        mfd = fd;
      }
    } else {
      FD_SET(lfd, &fsr);
      if (mfd < lfd) {
        mfd = lfd;
      }
    }
    if (sk) {
      fd = fileno_katcl(sk);
      if (flushing_katcl(sk)) {
        FD_SET(fd, &fsw);
      }
      FD_SET(fd, &fsr);
      if (mfd < fd) {
        mfd = fd;
      }
    }
    result = select(mfd + 1, &fsr, &fsw, NULL, NULL);
    switch (result) {
    case -1:
      switch (errno) {
      case EAGAIN:
      case EINTR:
        continue;
      default:
        sync_message_katcl(k, 4, label, "select failed: %s", strerror(errno));
        return 4;
      }
      break;
    }
    if (k) {
      fd = fileno_katcl(k);
      if (FD_ISSET(fd, &fsw)) {
        write_katcl(k);
      }
    }
    if (nk) {
      fd = fileno_katcl(nk);
      if (FD_ISSET(fd, &fsw)) {
        result = write_katcl(nk);
        if (result < 0) {
          log_message_katcl(k, 4, label,
                            "unable to write to network client: %s",
                            strerror(error_katcl(nk)));
          destroy_katcl(nk, 1);
          nk = NULL;
          continue;
        }
      }
      if (FD_ISSET(fd, &fsr)) {
        result = read_katcl(nk);
        if (result) {
          if (result < 0) {
            log_message_katcl(k, 4, label, "network read failed: %s",
                              strerror(error_katcl(nk)));
          } else {
            log_message_katcl(k, 3, label, "network disconnected");
          }
          destroy_katcl(nk, 1);
          nk = NULL;
          continue;
        }
        while (have_katcl(nk) > 0) {
          p = ready_katcl(nk);
          if (p) {
            append_parse_katcl(sk, p);
          }
        }
      }
    } else {
      fd = accept(lfd, NULL, NULL);
      if (fd < 0) {
        log_message_katcl(k, 4, label, "network accept failed: %s",
                          strerror(error_katcl(nk)));
      }
      nk = create_katcl(fd);
      if (nk == NULL) {
        log_message_katcl(k, 4, label,
                          "unable to encapsulate network file descriptor");
        close(fd);
      }
      if (count > 0) {
        log_message_katcl(nk, 3, label,
                          "discarded %u messages while no client was connected",
                          count);
        count = 0;
      }
      log_message_katcl(nk, 1, label, "connected to %s at speed %d", serial,
                        speed);
    }
    if (sk) {
      fd = fileno_katcl(sk);
      if (FD_ISSET(fd, &fsw)) {
        result = write_katcl(sk);
        if (result < 0) {
          log_message_katcl(k, 4, label,
                            "unable to write to serial port %s: %s", serial,
                            strerror(error_katcl(sk)));
          destroy_katcl(sk, 1);
          sk = NULL;
          run = 0;
          continue;
        }
      }
      if (FD_ISSET(fd, &fsr)) {
        result = read_katcl(sk);
        if (result) {
          if (result < 0) {
            log_message_katcl(k, 4, label, "serial read from %s failed: %s",
                              serial, strerror(error_katcl(sk)));
          } else {
            log_message_katcl(k, 3, label, "serial port hung up");
          }
          destroy_katcl(sk, 1);
          sk = NULL;
          run = 0;
        }
        while (have_katcl(sk) > 0) {
          p = ready_katcl(sk);
          if (p) {
            if (nk) {
              append_parse_katcl(nk, p);
            } else {
              count++;
            }
          }
        }
        continue;
      }
    }
  }
  if (nk) {
    destroy_katcl(nk, 1);
    nk = NULL;
  }
  if (sk) {
    destroy_katcl(sk, 1);
    sk = NULL;
  }
  if (lfd >= 0) {
    close(lfd);
  }
  while (write_katcl(k) == 0)
    ;
  destroy_katcl(k, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xd60(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
call   1120 <create_katcl@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    12e6 <main+0x66>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xd40(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0x4,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movl   $0x0,-0x50(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x1,-0x30(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1609 <main+0x389>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    155b <main+0x2db>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x7c(%rbp)
test   %eax,%eax
je     1516 <main+0x296>
jmp    1370 <main+0xf0>
mov    -0x7c(%rbp),%eax
sub    $0x2d,%eax
je     1508 <main+0x288>
jmp    1381 <main+0x101>
mov    -0x7c(%rbp),%eax
sub    $0x62,%eax
je     13cd <main+0x14d>
jmp    1392 <main+0x112>
mov    -0x7c(%rbp),%eax
sub    $0x68,%eax
je     13b4 <main+0x134>
jmp    13a3 <main+0x123>
mov    -0x7c(%rbp),%eax
sub    $0x73,%eax
je     13cd <main+0x14d>
jmp    152b <main+0x2ab>
mov    -0x28(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1130 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1403 <main+0x183>
movl   $0x0,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1436 <main+0x1b6>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x4,%esi
lea    0xc1c(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
movl   $0x2,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
mov    -0x34(%rbp),%eax
mov    %eax,-0x80(%rbp)
sub    $0x62,%eax
je     1488 <main+0x208>
jmp    144a <main+0x1ca>
mov    -0x80(%rbp),%eax
sub    $0x70,%eax
je     146c <main+0x1ec>
jmp    145b <main+0x1db>
mov    -0x80(%rbp),%eax
sub    $0x73,%eax
je     14ec <main+0x26c>
jmp    1503 <main+0x283>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1503 <main+0x283>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x30(%rbp),%rax
add    %rax,%rdi
call   1160 <atoi@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jge    14e7 <main+0x267>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%r8
movslq -0x30(%rbp),%rax
add    %rax,%r8
mov    $0x4,%esi
lea    0xb86(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
movl   $0x2,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
jmp    1503 <main+0x283>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1508 <main+0x288>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1556 <main+0x2d6>
movl   $0x1,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1556 <main+0x2d6>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x34(%rbp),%r8d
mov    $0x4,%esi
lea    0xb2d(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
movl   $0x2,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
jmp    1604 <main+0x384>
cmpq   $0x0,-0x20(%rbp)
jne    157b <main+0x2fb>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
jmp    15fb <main+0x37b>
cmpq   $0x0,-0x18(%rbp)
jne    159b <main+0x31b>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
jmp    15f6 <main+0x376>
cmpl   $0x0,-0x50(%rbp)
jne    15be <main+0x33e>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1160 <atoi@plt>
mov    %eax,-0x50(%rbp)
jmp    15f1 <main+0x371>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%r8
mov    $0x4,%esi
lea    0xaa5(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
movl   $0x2,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
jmp    15f6 <main+0x376>
jmp    15fb <main+0x37b>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1322 <main+0xa2>
cmpl   $0x0,-0x50(%rbp)
jg     161a <main+0x39a>
movl   $0x2580,-0x50(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1659 <main+0x3d9>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x4,%esi
lea    0xa5d(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
mov    -0x28(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1130 <usage@plt>
movl   $0x2,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
mov    -0x20(%rbp),%rdi
mov    -0x50(%rbp),%esi
call   1110 <start_serial@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    16d9 <main+0x459>
mov    -0x68(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    0x2936(%rip),%rax
mov    (%rax),%edi
call   1180 <strerror@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    -0x88(%rbp),%r8
movsbl %al,%r9d
mov    $0x4,%esi
lea    0x9ec(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
movl   $0x3,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
mov    -0x40(%rbp),%edi
call   1120 <create_katcl@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1717 <main+0x497>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x4,%esi
lea    0x9d2(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
movl   $0x4,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
mov    -0x18(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   11a0 <net_listen@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    176d <main+0x4ed>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%r8d
mov    $0x4,%esi
lea    0x916(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
movl   $0x3,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
movl   $0x1,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1e3b <main+0xbbb>
movl   $0x0,-0x44(%rbp)
lea    -0x74(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
lea    -0x78(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
cmpq   $0x0,-0x68(%rbp)
je     17d8 <main+0x558>
mov    -0x68(%rbp),%rdi
call   1030 <flushing_katcl@plt>
cmp    $0x0,%rax
je     17d3 <main+0x553>
mov    -0x68(%rbp),%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x78(%rbp),%rsi
call   1190 <FD_SET@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    17d8 <main+0x558>
cmpq   $0x0,-0x60(%rbp)
je     1831 <main+0x5b1>
mov    -0x60(%rbp),%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,-0x40(%rbp)
mov    -0x60(%rbp),%rdi
call   1030 <flushing_katcl@plt>
cmp    $0x0,%rax
je     180e <main+0x58e>
mov    -0x40(%rbp),%edi
lea    -0x78(%rbp),%rsi
call   1190 <FD_SET@plt>
mov    -0x40(%rbp),%edi
lea    -0x74(%rbp),%rsi
call   1190 <FD_SET@plt>
mov    -0x44(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    182c <main+0x5ac>
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1854 <main+0x5d4>
mov    -0x38(%rbp),%edi
lea    -0x74(%rbp),%rsi
call   1190 <FD_SET@plt>
mov    -0x44(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    184f <main+0x5cf>
mov    -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1854 <main+0x5d4>
cmpq   $0x0,-0x58(%rbp)
je     18ad <main+0x62d>
mov    -0x58(%rbp),%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,-0x40(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <flushing_katcl@plt>
cmp    $0x0,%rax
je     188a <main+0x60a>
mov    -0x40(%rbp),%edi
lea    -0x78(%rbp),%rsi
call   1190 <FD_SET@plt>
mov    -0x40(%rbp),%edi
lea    -0x74(%rbp),%rsi
call   1190 <FD_SET@plt>
mov    -0x44(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    18a8 <main+0x628>
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    18ad <main+0x62d>
mov    -0x44(%rbp),%edi
add    $0x1,%edi
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x74(%rbp),%rsi
lea    -0x78(%rbp),%rdx
mov    %r8,%rcx
call   10f0 <select@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
sub    $0xffffffff,%eax
jne    1950 <main+0x6d0>
jmp    18dc <main+0x65c>
mov    0x26ed(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
sub    $0x1,%eax
ja     18fb <main+0x67b>
jmp    18f6 <main+0x676>
jmp    1774 <main+0x4f4>
mov    -0x68(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    0x26b8(%rip),%rax
mov    (%rax),%edi
call   1180 <strerror@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
movsbl %al,%r8d
mov    $0x4,%esi
lea    0x7cf(%rip),%rcx
mov    $0x0,%al
call   1050 <sync_message_katcl@plt>
movl   $0x4,-0x4(%rbp)
jmp    1ebd <main+0xc3d>
cmpq   $0x0,-0x68(%rbp)
je     198b <main+0x70b>
mov    -0x68(%rbp),%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x78(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1986 <main+0x706>
mov    -0x68(%rbp),%rdi
call   1040 <write_katcl@plt>
jmp    198b <main+0x70b>
cmpq   $0x0,-0x60(%rbp)
je     1b41 <main+0x8c1>
mov    -0x60(%rbp),%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x78(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1a39 <main+0x7b9>
mov    -0x60(%rbp),%rdi
call   1040 <write_katcl@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jge    1a34 <main+0x7b4>
mov    -0x68(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x60(%rbp),%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rdx
movsbl %al,%r8d
mov    $0x4,%esi
lea    0x70c(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
mov    -0x60(%rbp),%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
movq   $0x0,-0x60(%rbp)
jmp    1774 <main+0x4f4>
jmp    1a39 <main+0x7b9>
mov    -0x40(%rbp),%edi
lea    -0x74(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1b3c <main+0x8bc>
mov    -0x60(%rbp),%rdi
call   1070 <read_katcl@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     1af5 <main+0x875>
cmpl   $0x0,-0x48(%rbp)
jge    1abf <main+0x83f>
mov    -0x68(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x60(%rbp),%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
mov    -0xc8(%rbp),%rdi
mov    -0xc0(%rbp),%rdx
movsbl %al,%r8d
mov    $0x4,%esi
lea    0x691(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
jmp    1ada <main+0x85a>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x3,%esi
lea    0x689(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
mov    -0x60(%rbp),%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
movq   $0x0,-0x60(%rbp)
jmp    1774 <main+0x4f4>
jmp    1afa <main+0x87a>
mov    -0x60(%rbp),%rdi
call   1170 <have_katcl@plt>
cmp    $0x0,%rax
jle    1b37 <main+0x8b7>
mov    -0x60(%rbp),%rdi
call   1080 <ready_katcl@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     1b32 <main+0x8b2>
mov    -0x58(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   1090 <append_parse_katcl@plt>
jmp    1afa <main+0x87a>
jmp    1b3c <main+0x8bc>
jmp    1c35 <main+0x9b5>
mov    -0x38(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1150 <accept@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    1ba8 <main+0x928>
mov    -0x68(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x60(%rbp),%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xd0(%rbp),%rdx
movsbl %al,%r8d
mov    $0x4,%esi
lea    0x5d0(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
mov    -0x40(%rbp),%edi
call   1120 <create_katcl@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1be2 <main+0x962>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x4,%esi
lea    0x5b8(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
cmpl   $0x0,-0x4c(%rbp)
jle    1c12 <main+0x992>
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x4c(%rbp),%r8d
mov    $0x3,%esi
lea    0x5b5(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%r8
mov    -0x50(%rbp),%r9d
mov    $0x1,%esi
lea    0x5bf(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
cmpq   $0x0,-0x58(%rbp)
je     1e36 <main+0xbb6>
mov    -0x58(%rbp),%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x78(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1cfc <main+0xa7c>
mov    -0x58(%rbp),%rdi
call   1040 <write_katcl@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jge    1cf7 <main+0xa77>
mov    -0x68(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x58(%rbp),%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
mov    -0xf0(%rbp),%rdi
mov    -0xe8(%rbp),%rdx
mov    -0xe0(%rbp),%r8
movsbl %al,%r9d
mov    $0x4,%esi
lea    0x53b(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
mov    -0x58(%rbp),%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    1774 <main+0x4f4>
jmp    1cfc <main+0xa7c>
mov    -0x40(%rbp),%edi
lea    -0x74(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1e31 <main+0xbb1>
mov    -0x58(%rbp),%rdi
call   1070 <read_katcl@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     1dcc <main+0xb4c>
cmpl   $0x0,-0x48(%rbp)
jge    1d94 <main+0xb14>
mov    -0x68(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x58(%rbp),%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
mov    -0x108(%rbp),%rdi
mov    -0x100(%rbp),%rdx
mov    -0xf8(%rbp),%r8
movsbl %al,%r9d
mov    $0x4,%esi
lea    0x4a7(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
jmp    1daf <main+0xb2f>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x3,%esi
lea    0x4a6(%rip),%rcx
mov    $0x0,%al
call   10c0 <log_message_katcl@plt>
mov    -0x58(%rbp),%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    1dd1 <main+0xb51>
mov    -0x58(%rbp),%rdi
call   1170 <have_katcl@plt>
cmp    $0x0,%rax
jle    1e2c <main+0xbac>
mov    -0x58(%rbp),%rdi
call   1080 <ready_katcl@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     1e27 <main+0xba7>
cmpq   $0x0,-0x60(%rbp)
je     1e19 <main+0xb99>
mov    -0x60(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   1090 <append_parse_katcl@plt>
jmp    1e22 <main+0xba2>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1e27 <main+0xba7>
jmp    1dd1 <main+0xb51>
jmp    1774 <main+0x4f4>
jmp    1e36 <main+0xbb6>
jmp    1774 <main+0x4f4>
cmpq   $0x0,-0x60(%rbp)
je     1e5c <main+0xbdc>
mov    -0x60(%rbp),%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
movq   $0x0,-0x60(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1e7d <main+0xbfd>
mov    -0x58(%rbp),%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
movq   $0x0,-0x58(%rbp)
cmpl   $0x0,-0x38(%rbp)
jl     1e8f <main+0xc0f>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
jmp    1e94 <main+0xc14>
mov    -0x68(%rbp),%rdi
call   1040 <write_katcl@plt>
cmp    $0x0,%eax
jne    1eab <main+0xc2b>
jmp    1e94 <main+0xc14>
mov    -0x68(%rbp),%rdi
xor    %esi,%esi
call   10d0 <destroy_katcl@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,0x18(%rsp)
mov    %edi,%r15d
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   1120 <create_katcl@plt>
test   %rax,%rax
je     140c <main+0x18c>
mov    %rax,0x10(%rsp)
mov    $0x1,%r14d
cmp    $0x2,%r15d
jl     1432 <main+0x1b2>
xor    %eax,%eax
xor    %edi,%edi
xor    %r13d,%r13d
mov    $0x1,%r12d
mov    0x18(%rsp),%rsi
jmp    12e6 <main+0x66>
mov    %rbx,%r13
add    $0x1,%r12d
cmp    %r15d,%r12d
jge    1444 <main+0x1c4>
movslq %r12d,%rcx
mov    (%rsi,%rcx,8),%rbx
cmpb   $0x2d,(%rbx)
jne    1370 <main+0xf0>
movslq %r14d,%rcx
movsbl (%rbx,%rcx,1),%r8d
cmp    $0x61,%r8d
jle    13a0 <main+0x120>
cmp    $0x62,%r8d
je     1314 <main+0x94>
cmp    $0x73,%r8d
jne    1b5a <main+0x8da>
lea    0x1(%rcx),%r14
xor    %edx,%edx
cmpb   $0x0,0x1(%rbx,%rcx,1)
sete   %dl
mov    $0x0,%ecx
cmove  %ecx,%r14d
add    %edx,%r12d
cmp    %r15d,%r12d
jge    1a91 <main+0x811>
cmp    $0x62,%r8d
je     13ca <main+0x14a>
cmp    $0x73,%r8d
je     13f3 <main+0x173>
mov    %r13,%rbp
cmp    $0x70,%r8d
jne    1400 <main+0x180>
movslq %r12d,%rcx
movslq %r14d,%rdi
add    (%rsi,%rcx,8),%rdi
jmp    1400 <main+0x180>
nopw   0x0(%rax,%rax,1)
test   %r13,%r13
je     12d6 <main+0x56>
test   %rdi,%rdi
je     13c2 <main+0x142>
test   %eax,%eax
jne    1b3d <main+0x8bd>
mov    %rdi,%rbp
mov    %rbx,%rdi
call   1160 <atoi@plt>
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
jmp    12d9 <main+0x59>
xchg   %ax,%ax
test   %r8d,%r8d
je     13b3 <main+0x133>
mov    %r13,%rbp
cmp    $0x2d,%r8d
je     1400 <main+0x180>
jmp    1b75 <main+0x8f5>
add    $0x1,%r12d
mov    $0x1,%r14d
jmp    12dd <main+0x5d>
mov    %rbx,%rdi
jmp    12d9 <main+0x59>
mov    %r13,%rbp
movslq %r12d,%rax
movslq %r14d,%r13
add    (%rsi,%rax,8),%r13
mov    %rdi,%rbx
mov    %r13,%rdi
call   1160 <atoi@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
test   %eax,%eax
jns    1400 <main+0x180>
jmp    1b96 <main+0x916>
movslq %r12d,%rcx
movslq %r14d,%rbp
add    (%rsi,%rcx,8),%rbp
nopl   (%rax)
add    $0x1,%r14d
mov    %rbp,%r13
jmp    12dd <main+0x5d>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
lea    0xbf9(%rip),%rsi
lea    0xbdd(%rip),%rdx
call   10b0 <fprintf@plt>
mov    $0x4,%ebx
jmp    1bbd <main+0x93d>
xor    %edi,%edi
xor    %r13d,%r13d
mov    $0x1,%r12d
mov    $0x2580,%eax
jmp    1448 <main+0x1c8>
test   %eax,%eax
jle    143d <main+0x1bd>
test   %r13,%r13
je     19b8 <main+0x738>
mov    %rdi,%rbx
mov    %r13,%rdi
mov    %eax,0x30(%rsp)
mov    %eax,%esi
call   1110 <start_serial@plt>
test   %eax,%eax
js     19ed <main+0x76d>
mov    %eax,%edi
call   1120 <create_katcl@plt>
test   %rax,%rax
je     1a2b <main+0x7ab>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   11a0 <net_listen@plt>
mov    %eax,0x24(%rsp)
test   %eax,%eax
js     1a54 <main+0x7d4>
mov    %r13,0x28(%rsp)
mov    $0x1,%ebp
lea    0x34(%rsp),%r12
lea    0x4(%rsp),%rbx
movl   $0x0,0x18(%rsp)
xor    %r15d,%r15d
mov    0x10(%rsp),%r14
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
je     1ab5 <main+0x835>
mov    %r12,%rdi
call   10e0 <FD_ZERO@plt>
mov    %rbx,%rdi
call   10e0 <FD_ZERO@plt>
mov    %r14,%rdi
call   1030 <flushing_katcl@plt>
test   %rax,%rax
je     1500 <main+0x280>
mov    %rbx,%rbp
mov    %r14,%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %rbp,%rsi
call   1190 <FD_SET@plt>
jmp    1502 <main+0x282>
xchg   %ax,%ax
xor    %ebx,%ebx
mov    0x24(%rsp),%ebp
test   %r15,%r15
je     152e <main+0x2ae>
mov    %r15,%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <flushing_katcl@plt>
test   %rax,%rax
je     152e <main+0x2ae>
mov    %ebp,%edi
lea    0x4(%rsp),%rsi
call   1190 <FD_SET@plt>
mov    %ebp,%edi
mov    %r12,%r13
mov    %r12,%rsi
call   1190 <FD_SET@plt>
cmp    %ebp,%ebx
cmovl  %ebp,%ebx
mov    0x8(%rsp),%r12
test   %r12,%r12
je     1590 <main+0x310>
mov    %r12,%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1030 <flushing_katcl@plt>
test   %rax,%rax
je     156d <main+0x2ed>
mov    %ebp,%edi
lea    0x4(%rsp),%rsi
call   1190 <FD_SET@plt>
mov    %ebp,%edi
mov    %r13,%r12
mov    %r13,%rsi
call   1190 <FD_SET@plt>
cmp    %ebp,%ebx
cmovl  %ebp,%ebx
jmp    1593 <main+0x313>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%r12
add    $0x1,%ebx
mov    %ebx,%edi
mov    %r12,%rsi
lea    0x4(%rsp),%rbx
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10f0 <select@plt>
cmp    $0xffffffff,%eax
jne    15d5 <main+0x355>
mov    0x2a17(%rip),%rax
mov    (%rax),%edi
mov    %edi,%eax
and    $0xfffffffe,%eax
mov    $0x1,%ebp
cmp    $0x80,%eax
je     14c0 <main+0x240>
jmp    1b0d <main+0x88d>
mov    %r14,%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     15f4 <main+0x374>
mov    %r14,%rdi
call   1040 <write_katcl@plt>
test   %r15,%r15
je     16e2 <main+0x462>
mov    %r15,%rdi
call   1100 <fileno_katcl@plt>
mov    %eax,%ebx
mov    %eax,%edi
lea    0x4(%rsp),%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1624 <main+0x3a4>
mov    %r15,%rdi
call   1040 <write_katcl@plt>
test   %eax,%eax
js     1693 <main+0x413>
mov    %ebx,%edi
mov    %r12,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     17b6 <main+0x536>
mov    %r15,%rdi
call   1070 <read_katcl@plt>
test   %eax,%eax
je     17bd <main+0x53d>
js     1668 <main+0x3e8>
mov    %r14,%rdi
mov    $0x3,%esi
lea    0x9a8(%rip),%rdx
lea    0xafd(%rip),%rcx
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
jmp    16c3 <main+0x443>
mov    %r15,%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
movsbl %al,%r8d
mov    %r14,%rdi
mov    $0x4,%esi
lea    0x976(%rip),%rdx
lea    0xab3(%rip),%rcx
jmp    16bc <main+0x43c>
mov    %r15,%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
movsbl %al,%r8d
mov    %r14,%rdi
mov    $0x4,%esi
lea    0x94b(%rip),%rdx
lea    0xa62(%rip),%rcx
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
lea    0x4(%rsp),%rbx
mov    $0x1,%ebp
mov    %r15,%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
xor    %r15d,%r15d
jmp    14c0 <main+0x240>
mov    0x24(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1150 <accept@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1724 <main+0x4a4>
xor    %edi,%edi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
movsbl %al,%r8d
mov    %r14,%rdi
mov    $0x4,%esi
lea    0x8ea(%rip),%rdx
lea    0xa54(%rip),%rcx
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
mov    %ebx,%edi
call   1120 <create_katcl@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1757 <main+0x4d7>
mov    %r14,%rdi
mov    $0x4,%esi
lea    0x8be(%rip),%rdx
lea    0xa42(%rip),%rcx
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
mov    %ebx,%edi
call   10a0 <close@plt>
cmpl   $0x0,0x18(%rsp)
jle    1788 <main+0x508>
mov    %r15,%rdi
mov    $0x3,%esi
lea    0x893(%rip),%rdx
lea    0xa45(%rip),%rcx
mov    0x18(%rsp),%r8d
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
movl   $0x0,0x18(%rsp)
lea    0x4(%rsp),%rbx
mov    %r15,%rdi
mov    $0x1,%esi
lea    0x864(%rip),%rdx
lea    0xa4a(%rip),%rcx
mov    0x28(%rsp),%r8
mov    0x30(%rsp),%r9d
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
jmp    17d3 <main+0x553>
lea    0x4(%rsp),%rbx
jmp    17d3 <main+0x553>
mov    %r15,%rdi
call   1170 <have_katcl@plt>
test   %rax,%rax
lea    0x4(%rsp),%rbx
jg     187b <main+0x5fb>
mov    $0x1,%ebp
cmpq   $0x0,0x8(%rsp)
je     14c0 <main+0x240>
mov    0x8(%rsp),%rdi
mov    %rdi,0x8(%rsp)
call   1100 <fileno_katcl@plt>
mov    %rbx,%rsi
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1816 <main+0x596>
mov    0x8(%rsp),%rdi
call   1040 <write_katcl@plt>
test   %eax,%eax
js     1897 <main+0x617>
mov    %ebx,%edi
mov    %r12,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
lea    0x4(%rsp),%rbx
je     14c0 <main+0x240>
mov    0x8(%rsp),%rdi
call   1070 <read_katcl@plt>
test   %eax,%eax
je     18f1 <main+0x671>
js     18f8 <main+0x678>
mov    0x10(%rsp),%rdi
mov    $0x3,%esi
lea    0x7a9(%rip),%rdx
lea    0x9f0(%rip),%rcx
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
jmp    1931 <main+0x6b1>
mov    %r15,%rdi
call   1170 <have_katcl@plt>
test   %rax,%rax
jle    17d3 <main+0x553>
mov    %r15,%rdi
call   1080 <ready_katcl@plt>
test   %rax,%rax
je     186a <main+0x5ea>
mov    0x8(%rsp),%rdi
mov    %rax,%rsi
call   1090 <append_parse_katcl@plt>
jmp    186a <main+0x5ea>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
movsbl %al,%r9d
xor    %ebp,%ebp
mov    %r14,%rdi
mov    $0x4,%esi
lea    0x740(%rip),%rdx
lea    0x942(%rip),%rcx
mov    0x28(%rsp),%r8
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x4(%rsp),%rbx
jmp    14c0 <main+0x240>
mov    $0x1,%ebp
jmp    1949 <main+0x6c9>
mov    0x8(%rsp),%rdi
call   1140 <error_katcl@plt>
mov    %eax,%edi
call   1180 <strerror@plt>
movsbl %al,%r9d
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
lea    0x6e2(%rip),%rdx
lea    0x90a(%rip),%rcx
mov    0x28(%rsp),%r8
xor    %eax,%eax
call   10c0 <log_message_katcl@plt>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
xor    %ebp,%ebp
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rdi
call   1170 <have_katcl@plt>
test   %rax,%rax
mov    0x10(%rsp),%r14
mov    %r13,%r12
lea    0x4(%rsp),%rbx
jle    14c0 <main+0x240>
mov    0x8(%rsp),%rbx
jmp    1987 <main+0x707>
addl   $0x1,0x18(%rsp)
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1170 <have_katcl@plt>
test   %rax,%rax
jle    19a6 <main+0x726>
mov    %rbx,%rdi
call   1080 <ready_katcl@plt>
test   %rax,%rax
je     1975 <main+0x6f5>
test   %r15,%r15
je     1970 <main+0x6f0>
mov    %r15,%rdi
mov    %rax,%rsi
call   1090 <append_parse_katcl@plt>
jmp    1975 <main+0x6f5>
mov    0x10(%rsp),%r14
mov    %r13,%r12
lea    0x4(%rsp),%rbx
jmp    14c0 <main+0x240>
lea    0x641(%rip),%rbx
lea    0x6d0(%rip),%rcx
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sync_message_katcl@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1130 <usage@plt>
jmp    1bb8 <main+0x938>
mov    0x25dc(%rip),%rax
mov    (%rax),%edi
call   1180 <strerror@plt>
movsbl %al,%r9d
lea    0x5fa(%rip),%rdx
lea    0x6a5(%rip),%rcx
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    %r13,%r8
xor    %eax,%eax
call   1050 <sync_message_katcl@plt>
mov    $0x3,%ebx
jmp    1bbd <main+0x93d>
lea    0x5ce(%rip),%rdx
lea    0x69d(%rip),%rcx
mov    $0x4,%ebx
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <sync_message_katcl@plt>
jmp    1bbd <main+0x93d>
movslq %r12d,%rax
mov    0x18(%rsp),%rcx
mov    (%rcx,%rax,8),%rax
movslq %r14d,%rcx
movsbl (%rax,%rcx,1),%r8d
lea    0x591(%rip),%rdx
lea    0x5fa(%rip),%rcx
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <sync_message_katcl@plt>
mov    $0x3,%ebx
jmp    1bbd <main+0x93d>
lea    0x568(%rip),%rdx
lea    0x5a0(%rip),%rcx
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <sync_message_katcl@plt>
jmp    1bb8 <main+0x938>
test   %r15,%r15
je     1ac7 <main+0x847>
mov    %r15,%rdi
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1adb <main+0x85b>
mov    $0x1,%esi
call   10d0 <destroy_katcl@plt>
mov    0x24(%rsp),%edi
call   10a0 <close@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <write_katcl@plt>
test   %eax,%eax
je     1af0 <main+0x870>
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   10d0 <destroy_katcl@plt>
jmp    1bbd <main+0x93d>
call   1180 <strerror@plt>
movsbl %al,%r8d
lea    0x4e3(%rip),%rdx
lea    0x5e8(%rip),%rcx
mov    $0x4,%ebx
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <sync_message_katcl@plt>
jmp    1bbd <main+0x93d>
lea    0x4bc(%rip),%rdx
lea    0x538(%rip),%rcx
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    %rbx,%r8
jmp    1bb1 <main+0x931>
cmp    $0x68,%r8d
jne    1b75 <main+0x8f5>
lea    0x499(%rip),%rdi
mov    0x10(%rsp),%rsi
call   1130 <usage@plt>
xor    %ebx,%ebx
jmp    1bbd <main+0x93d>
lea    0x484(%rip),%rdx
lea    0x4ed(%rip),%rcx
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <sync_message_katcl@plt>
jmp    1bb8 <main+0x938>
lea    0x463(%rip),%rdx
lea    0x4b6(%rip),%rcx
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    %r13,%r8
xor    %eax,%eax
call   1050 <sync_message_katcl@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
@.str = [21 x i8] c"katcp-serial-gateway\00"
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str.1 = [42 x i8] c"%s: unable to create katcp message logic\0A\00"
@.str.2 = [27 x i8] c"argument needs a parameter\00"
@.str.3 = [22 x i8] c"speed %s unreasonable\00"
@.str.4 = [19 x i8] c"unknown option -%c\00"
@.str.5 = [19 x i8] c"excess argument %s\00"
@.str.6 = [28 x i8] c"need a serial port to relay\00"
@.str.7 = [36 x i8] c"unable to open serial device %s: %s\00"
@errno = global i32 0
@.str.8 = [54 x i8] c"unable to run katcp wrapper on serial file descriptor\00"
@.str.9 = [18 x i8] c"select failed: %s\00"
@.str.10 = [38 x i8] c"unable to write to network client: %s\00"
@.str.11 = [24 x i8] c"network read failed: %s\00"
@.str.12 = [21 x i8] c"network disconnected\00"
@.str.13 = [26 x i8] c"network accept failed: %s\00"
@.str.14 = [46 x i8] c"unable to encapsulate network file descriptor\00"
@.str.15 = [52 x i8] c"discarded %u messages while no client was connected\00"
@.str.16 = [28 x i8] c"connected to %s at speed %d\00"
@.str.17 = [38 x i8] c"unable to write to serial port %s: %s\00"
@.str.18 = [31 x i8] c"serial read from %s failed: %s\00"
@.str.19 = [20 x i8] c"serial port hung up\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca %struct.katcl_line*
%20 = alloca %struct.katcl_line*
%21 = alloca %struct.katcl_line*
%22 = alloca %struct.katcl_parse*
%23 = alloca i32
%24 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %8
%25 = load i32, i32* @STDOUT_FILENO
%26 = call %struct.katcl_line* @create_katcl(i32 %25)
store %struct.katcl_line* %26, %struct.katcl_line** %21
%27 = load %struct.katcl_line*, %struct.katcl_line** %21
%28 = icmp eq %struct.katcl_line* %27, null
br i1 %28, label %29, label %33
29: ; preds = %2
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %8
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store i32 4, i32* %3
br label %558
33: ; preds = %2
store %struct.katcl_line* null, %struct.katcl_line** %19
store %struct.katcl_line* null, %struct.katcl_line** %20
store i32 0, i32* %18
store i8* null, i8** %7
store i8* null, i8** %6
store i32 0, i32* %17
store i32 1, i32* %10
store i32 1, i32* %9
br label %34
34: ; preds = %189, %33
%35 = load i32, i32* %9
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %190
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = getelementptr inbounds i8, i8* %43, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 45
br i1 %47, label %48, label %147
48: ; preds = %38
%49 = load i8**, i8*** %5
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
store i32 %58, i32* %11
%59 = load i32, i32* %11
switch i32 %59, label %141 [
i32 104, label %60
i32 98, label %64
i32 115, label %64
i32 45, label %135
i32 0, label %138
]
60: ; preds = %48
%61 = load i8*, i8** %8
%62 = load %struct.katcl_line*, %struct.katcl_line** %21
%63 = call i32 @usage(i8* %61, %struct.katcl_line* %62)
store i32 0, i32* %3
br label %558
64: ; preds = %48, %48
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
%67 = load i8**, i8*** %5
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %67, i64 %69
%71 = load i8*, i8** %70
%72 = load i32, i32* %10
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %64
store i32 0, i32* %10
%79 = load i32, i32* %9
%80 = add nsw i32 %79, 1
store i32 %80, i32* %9
br label %81
81: ; preds = %78, %64
%82 = load i32, i32* %9
%83 = load i32, i32* %4
%84 = icmp sge i32 %82, %83
br i1 %84, label %85, label %89
85: ; preds = %81
%86 = load %struct.katcl_line*, %struct.katcl_line** %21
%87 = load i8*, i8** %8
%88 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %86, i32 4, i8* %87, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %558
89: ; preds = %81
%90 = load i32, i32* %11
switch i32 %90, label %134 [
i32 112, label %91
i32 98, label %100
i32 115, label %125
]
91: ; preds = %89
%92 = load i8**, i8*** %5
%93 = load i32, i32* %9
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8*, i8** %92, i64 %94
%96 = load i8*, i8** %95
%97 = load i32, i32* %10
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %96, i64 %98
store i8* %99, i8** %6
br label %134
100: ; preds = %89
%101 = load i8**, i8*** %5
%102 = load i32, i32* %9
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i8*, i8** %101, i64 %103
%105 = load i8*, i8** %104
%106 = load i32, i32* %10
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %105, i64 %107
%109 = call i32 @atoi(i8* %108)
store i32 %109, i32* %18
%110 = load i32, i32* %18
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %124
112: ; preds = %100
%113 = load %struct.katcl_line*, %struct.katcl_line** %21
%114 = load i8*, i8** %8
%115 = load i8**, i8*** %5
%116 = load i32, i32* %9
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8*, i8** %115, i64 %117
%119 = load i8*, i8** %118
%120 = load i32, i32* %10
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i8, i8* %119, i64 %121
%123 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %113, i32 4, i8* %114, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %122)
store i32 2, i32* %3
br label %558
124: ; preds = %100
br label %134
125: ; preds = %89
%126 = load i8**, i8*** %5
%127 = load i32, i32* %9
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i8*, i8** %126, i64 %128
%130 = load i8*, i8** %129
%131 = load i32, i32* %10
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %130, i64 %132
store i8* %133, i8** %7
br label %134
134: ; preds = %89, %125, %124, %91
br label %135
135: ; preds = %48, %134
%136 = load i32, i32* %10
%137 = add nsw i32 %136, 1
store i32 %137, i32* %10
br label %146
138: ; preds = %48
store i32 1, i32* %10
%139 = load i32, i32* %9
%140 = add nsw i32 %139, 1
store i32 %140, i32* %9
br label %146
141: ; preds = %48
%142 = load %struct.katcl_line*, %struct.katcl_line** %21
%143 = load i8*, i8** %8
%144 = load i32, i32* %11
%145 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %142, i32 4, i8* %143, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %144)
store i32 2, i32* %3
br label %558
146: ; preds = %138, %135
br label %189
147: ; preds = %38
%148 = load i8*, i8** %7
%149 = icmp eq i8* %148, null
br i1 %149, label %150, label %156
150: ; preds = %147
%151 = load i8**, i8*** %5
%152 = load i32, i32* %9
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i8*, i8** %151, i64 %153
%155 = load i8*, i8** %154
store i8* %155, i8** %7
br label %186
156: ; preds = %147
%157 = load i8*, i8** %6
%158 = icmp eq i8* %157, null
br i1 %158, label %159, label %165
159: ; preds = %156
%160 = load i8**, i8*** %5
%161 = load i32, i32* %9
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8*, i8** %160, i64 %162
%164 = load i8*, i8** %163
store i8* %164, i8** %6
br label %185
165: ; preds = %156
%166 = load i32, i32* %18
%167 = icmp eq i32 %166, 0
br i1 %167, label %168, label %175
168: ; preds = %165
%169 = load i8**, i8*** %5
%170 = load i32, i32* %9
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i8*, i8** %169, i64 %171
%173 = load i8*, i8** %172
%174 = call i32 @atoi(i8* %173)
store i32 %174, i32* %18
br label %184
175: ; preds = %165
%176 = load %struct.katcl_line*, %struct.katcl_line** %21
%177 = load i8*, i8** %8
%178 = load i8**, i8*** %5
%179 = load i32, i32* %9
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i8*, i8** %178, i64 %180
%182 = load i8*, i8** %181
%183 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %176, i32 4, i8* %177, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %182)
store i32 2, i32* %3
br label %558
184: ; preds = %168
br label %185
185: ; preds = %184, %159
br label %186
186: ; preds = %185, %150
%187 = load i32, i32* %9
%188 = add nsw i32 %187, 1
store i32 %188, i32* %9
br label %189
189: ; preds = %186, %146
br label %34
190: ; preds = %34
%191 = load i32, i32* %18
%192 = icmp sle i32 %191, 0
br i1 %192, label %193, label %194
193: ; preds = %190
store i32 9600, i32* %18
br label %194
194: ; preds = %193, %190
%195 = load i8*, i8** %7
%196 = icmp eq i8* %195, null
br i1 %196, label %197, label %204
197: ; preds = %194
%198 = load %struct.katcl_line*, %struct.katcl_line** %21
%199 = load i8*, i8** %8
%200 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %198, i32 4, i8* %199, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%201 = load i8*, i8** %8
%202 = load %struct.katcl_line*, %struct.katcl_line** %21
%203 = call i32 @usage(i8* %201, %struct.katcl_line* %202)
store i32 2, i32* %3
br label %558
204: ; preds = %194
%205 = load i8*, i8** %7
%206 = load i32, i32* %18
%207 = call i32 @start_serial(i8* %205, i32 %206)
store i32 %207, i32* %14
%208 = load i32, i32* %14
%209 = icmp slt i32 %208, 0
br i1 %209, label %210, label %218
210: ; preds = %204
%211 = load %struct.katcl_line*, %struct.katcl_line** %21
%212 = load i8*, i8** %8
%213 = load i8*, i8** %7
%214 = load i32, i32* @errno
%215 = call signext i8 @strerror(i32 %214)
%216 = sext i8 %215 to i32
%217 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %211, i32 4, i8* %212, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), i8* %213, i32 %216)
store i32 3, i32* %3
br label %558
218: ; preds = %204
%219 = load i32, i32* %14
%220 = call %struct.katcl_line* @create_katcl(i32 %219)
store %struct.katcl_line* %220, %struct.katcl_line** %19
%221 = load %struct.katcl_line*, %struct.katcl_line** %19
%222 = icmp eq %struct.katcl_line* %221, null
br i1 %222, label %223, label %227
223: ; preds = %218
%224 = load %struct.katcl_line*, %struct.katcl_line** %21
%225 = load i8*, i8** %8
%226 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %224, i32 4, i8* %225, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
store i32 4, i32* %3
br label %558
227: ; preds = %218
%228 = load i8*, i8** %6
%229 = call i32 @net_listen(i8* %228, i32 0, i32 0)
store i32 %229, i32* %12
%230 = load i32, i32* %12
%231 = icmp slt i32 %230, 0
br i1 %231, label %232, label %246
232: ; preds = %227
%233 = load %struct.katcl_line*, %struct.katcl_line** %21
%234 = load i8*, i8** %8
%235 = load i8**, i8*** %5
%236 = load i32, i32* %9
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds i8*, i8** %235, i64 %237
%239 = load i8*, i8** %238
%240 = load i32, i32* %10
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds i8, i8* %239, i64 %241
%243 = load i8, i8* %242
%244 = sext i8 %243 to i32
%245 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %233, i32 4, i8* %234, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %244)
store i32 3, i32* %3
br label %558
246: ; preds = %227
store i32 1, i32* %13
br label %247
247: ; preds = %530, %528, %466, %394, %359, %324, %246
%248 = load i32, i32* %13
%249 = icmp ne i32 %248, 0
br i1 %249, label %250, label %531
250: ; preds = %247
store i32 0, i32* %15
%251 = call i32 @FD_ZERO(i32* %23)
%252 = call i32 @FD_ZERO(i32* %24)
%253 = load %struct.katcl_line*, %struct.katcl_line** %21
%254 = icmp ne %struct.katcl_line* %253, null
br i1 %254, label %255, label %266
255: ; preds = %250
%256 = load %struct.katcl_line*, %struct.katcl_line** %21
%257 = call i64 @flushing_katcl(%struct.katcl_line* %256)
%258 = icmp ne i64 %257, 0
br i1 %258, label %259, label %265
259: ; preds = %255
%260 = load %struct.katcl_line*, %struct.katcl_line** %21
%261 = call i32 @fileno_katcl(%struct.katcl_line* %260)
store i32 %261, i32* %14
%262 = load i32, i32* %14
%263 = call i32 @FD_SET(i32 %262, i32* %24)
%264 = load i32, i32* %14
store i32 %264, i32* %15
br label %265
265: ; preds = %259, %255
br label %266
266: ; preds = %265, %250
%267 = load %struct.katcl_line*, %struct.katcl_line** %20
%268 = icmp ne %struct.katcl_line* %267, null
br i1 %268, label %269, label %287
269: ; preds = %266
%270 = load %struct.katcl_line*, %struct.katcl_line** %20
%271 = call i32 @fileno_katcl(%struct.katcl_line* %270)
store i32 %271, i32* %14
%272 = load %struct.katcl_line*, %struct.katcl_line** %20
%273 = call i64 @flushing_katcl(%struct.katcl_line* %272)
%274 = icmp ne i64 %273, 0
br i1 %274, label %275, label %278
275: ; preds = %269
%276 = load i32, i32* %14
%277 = call i32 @FD_SET(i32 %276, i32* %24)
br label %278
278: ; preds = %275, %269
%279 = load i32, i32* %14
%280 = call i32 @FD_SET(i32 %279, i32* %23)
%281 = load i32, i32* %15
%282 = load i32, i32* %14
%283 = icmp slt i32 %281, %282
br i1 %283, label %284, label %286
284: ; preds = %278
%285 = load i32, i32* %14
store i32 %285, i32* %15
br label %286
286: ; preds = %284, %278
br label %296
287: ; preds = %266
%288 = load i32, i32* %12
%289 = call i32 @FD_SET(i32 %288, i32* %23)
%290 = load i32, i32* %15
%291 = load i32, i32* %12
%292 = icmp slt i32 %290, %291
br i1 %292, label %293, label %295
293: ; preds = %287
%294 = load i32, i32* %12
store i32 %294, i32* %15
br label %295
295: ; preds = %293, %287
br label %296
296: ; preds = %295, %286
%297 = load %struct.katcl_line*, %struct.katcl_line** %19
%298 = icmp ne %struct.katcl_line* %297, null
br i1 %298, label %299, label %317
299: ; preds = %296
%300 = load %struct.katcl_line*, %struct.katcl_line** %19
%301 = call i32 @fileno_katcl(%struct.katcl_line* %300)
store i32 %301, i32* %14
%302 = load %struct.katcl_line*, %struct.katcl_line** %19
%303 = call i64 @flushing_katcl(%struct.katcl_line* %302)
%304 = icmp ne i64 %303, 0
br i1 %304, label %305, label %308
305: ; preds = %299
%306 = load i32, i32* %14
%307 = call i32 @FD_SET(i32 %306, i32* %24)
br label %308
308: ; preds = %305, %299
%309 = load i32, i32* %14
%310 = call i32 @FD_SET(i32 %309, i32* %23)
%311 = load i32, i32* %15
%312 = load i32, i32* %14
%313 = icmp slt i32 %311, %312
br i1 %313, label %314, label %316
314: ; preds = %308
%315 = load i32, i32* %14
store i32 %315, i32* %15
br label %316
316: ; preds = %314, %308
br label %317
317: ; preds = %316, %296
%318 = load i32, i32* %15
%319 = add nsw i32 %318, 1
%320 = call i32 @select(i32 %319, i32* %23, i32* %24, i32* null, i32* null)
store i32 %320, i32* %16
%321 = load i32, i32* %16
switch i32 %321, label %332 [
i32 -1, label %322
]
322: ; preds = %317
%323 = load i32, i32* @errno
switch i32 %323, label %325 [
i32 129, label %324
i32 128, label %324
]
324: ; preds = %322, %322
br label %247
325: ; preds = %322
%326 = load %struct.katcl_line*, %struct.katcl_line** %21
%327 = load i8*, i8** %8
%328 = load i32, i32* @errno
%329 = call signext i8 @strerror(i32 %328)
%330 = sext i8 %329 to i32
%331 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %326, i32 4, i8* %327, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %330)
store i32 4, i32* %3
br label %558
332: ; preds = %317
%333 = load %struct.katcl_line*, %struct.katcl_line** %21
%334 = icmp ne %struct.katcl_line* %333, null
br i1 %334, label %335, label %345
335: ; preds = %332
%336 = load %struct.katcl_line*, %struct.katcl_line** %21
%337 = call i32 @fileno_katcl(%struct.katcl_line* %336)
store i32 %337, i32* %14
%338 = load i32, i32* %14
%339 = call i64 @FD_ISSET(i32 %338, i32* %24)
%340 = icmp ne i64 %339, 0
br i1 %340, label %341, label %344
341: ; preds = %335
%342 = load %struct.katcl_line*, %struct.katcl_line** %21
%343 = call i32 @write_katcl(%struct.katcl_line* %342)
br label %344
344: ; preds = %341, %335
br label %345
345: ; preds = %344, %332
%346 = load %struct.katcl_line*, %struct.katcl_line** %20
%347 = icmp ne %struct.katcl_line* %346, null
br i1 %347, label %348, label %414
348: ; preds = %345
%349 = load %struct.katcl_line*, %struct.katcl_line** %20
%350 = call i32 @fileno_katcl(%struct.katcl_line* %349)
store i32 %350, i32* %14
%351 = load i32, i32* %14
%352 = call i64 @FD_ISSET(i32 %351, i32* %24)
%353 = icmp ne i64 %352, 0
br i1 %353, label %354, label %370
354: ; preds = %348
%355 = load %struct.katcl_line*, %struct.katcl_line** %20
%356 = call i32 @write_katcl(%struct.katcl_line* %355)
store i32 %356, i32* %16
%357 = load i32, i32* %16
%358 = icmp slt i32 %357, 0
br i1 %358, label %359, label %369
359: ; preds = %354
%360 = load %struct.katcl_line*, %struct.katcl_line** %21
%361 = load i8*, i8** %8
%362 = load %struct.katcl_line*, %struct.katcl_line** %20
%363 = call i32 @error_katcl(%struct.katcl_line* %362)
%364 = call signext i8 @strerror(i32 %363)
%365 = sext i8 %364 to i32
%366 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %360, i32 4, i8* %361, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i32 %365)
%367 = load %struct.katcl_line*, %struct.katcl_line** %20
%368 = call i32 @destroy_katcl(%struct.katcl_line* %367, i32 1)
store %struct.katcl_line* null, %struct.katcl_line** %20
br label %247
369: ; preds = %354
br label %370
370: ; preds = %369, %348
%371 = load i32, i32* %14
%372 = call i64 @FD_ISSET(i32 %371, i32* %23)
%373 = icmp ne i64 %372, 0
br i1 %373, label %374, label %413
374: ; preds = %370
%375 = load %struct.katcl_line*, %struct.katcl_line** %20
%376 = call i32 @read_katcl(%struct.katcl_line* %375)
store i32 %376, i32* %16
%377 = load i32, i32* %16
%378 = icmp ne i32 %377, 0
br i1 %378, label %379, label %397
379: ; preds = %374
%380 = load i32, i32* %16
%381 = icmp slt i32 %380, 0
br i1 %381, label %382, label %390
382: ; preds = %379
%383 = load %struct.katcl_line*, %struct.katcl_line** %21
%384 = load i8*, i8** %8
%385 = load %struct.katcl_line*, %struct.katcl_line** %20
%386 = call i32 @error_katcl(%struct.katcl_line* %385)
%387 = call signext i8 @strerror(i32 %386)
%388 = sext i8 %387 to i32
%389 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %383, i32 4, i8* %384, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 %388)
br label %394
390: ; preds = %379
%391 = load %struct.katcl_line*, %struct.katcl_line** %21
%392 = load i8*, i8** %8
%393 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %391, i32 3, i8* %392, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
br label %394
394: ; preds = %390, %382
%395 = load %struct.katcl_line*, %struct.katcl_line** %20
%396 = call i32 @destroy_katcl(%struct.katcl_line* %395, i32 1)
store %struct.katcl_line* null, %struct.katcl_line** %20
br label %247
397: ; preds = %374
br label %398
398: ; preds = %411, %397
%399 = load %struct.katcl_line*, %struct.katcl_line** %20
%400 = call i64 @have_katcl(%struct.katcl_line* %399)
%401 = icmp sgt i64 %400, 0
br i1 %401, label %402, label %412
402: ; preds = %398
%403 = load %struct.katcl_line*, %struct.katcl_line** %20
%404 = call %struct.katcl_parse* @ready_katcl(%struct.katcl_line* %403)
store %struct.katcl_parse* %404, %struct.katcl_parse** %22
%405 = load %struct.katcl_parse*, %struct.katcl_parse** %22
%406 = icmp ne %struct.katcl_parse* %405, null
br i1 %406, label %407, label %411
407: ; preds = %402
%408 = load %struct.katcl_line*, %struct.katcl_line** %19
%409 = load %struct.katcl_parse*, %struct.katcl_parse** %22
%410 = call i32 @append_parse_katcl(%struct.katcl_line* %408, %struct.katcl_parse* %409)
br label %411
411: ; preds = %407, %402
br label %398
412: ; preds = %398
br label %413
413: ; preds = %412, %370
br label %452
414: ; preds = %345
%415 = load i32, i32* %12
%416 = call i32 @accept(i32 %415, i32* null, i32* null)
store i32 %416, i32* %14
%417 = load i32, i32* %14
%418 = icmp slt i32 %417, 0
br i1 %418, label %419, label %427
419: ; preds = %414
%420 = load %struct.katcl_line*, %struct.katcl_line** %21
%421 = load i8*, i8** %8
%422 = load %struct.katcl_line*, %struct.katcl_line** %20
%423 = call i32 @error_katcl(%struct.katcl_line* %422)
%424 = call signext i8 @strerror(i32 %423)
%425 = sext i8 %424 to i32
%426 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %420, i32 4, i8* %421, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i32 %425)
br label %427
427: ; preds = %419, %414
%428 = load i32, i32* %14
%429 = call %struct.katcl_line* @create_katcl(i32 %428)
store %struct.katcl_line* %429, %struct.katcl_line** %20
%430 = load %struct.katcl_line*, %struct.katcl_line** %20
%431 = icmp eq %struct.katcl_line* %430, null
br i1 %431, label %432, label %438
432: ; preds = %427
%433 = load %struct.katcl_line*, %struct.katcl_line** %21
%434 = load i8*, i8** %8
%435 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %433, i32 4, i8* %434, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%436 = load i32, i32* %14
%437 = call i32 @close(i32 %436)
br label %438
438: ; preds = %432, %427
%439 = load i32, i32* %17
%440 = icmp sgt i32 %439, 0
br i1 %440, label %441, label %446
441: ; preds = %438
%442 = load %struct.katcl_line*, %struct.katcl_line** %20
%443 = load i8*, i8** %8
%444 = load i32, i32* %17
%445 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %442, i32 3, i8* %443, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.15, i64 0, i64 0), i32 %444)
store i32 0, i32* %17
br label %446
446: ; preds = %441, %438
%447 = load %struct.katcl_line*, %struct.katcl_line** %20
%448 = load i8*, i8** %8
%449 = load i8*, i8** %7
%450 = load i32, i32* %18
%451 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %447, i32 1, i8* %448, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* %449, i32 %450)
br label %452
452: ; preds = %446, %413
%453 = load %struct.katcl_line*, %struct.katcl_line** %19
%454 = icmp ne %struct.katcl_line* %453, null
br i1 %454, label %455, label %530
455: ; preds = %452
%456 = load %struct.katcl_line*, %struct.katcl_line** %19
%457 = call i32 @fileno_katcl(%struct.katcl_line* %456)
store i32 %457, i32* %14
%458 = load i32, i32* %14
%459 = call i64 @FD_ISSET(i32 %458, i32* %24)
%460 = icmp ne i64 %459, 0
br i1 %460, label %461, label %478
461: ; preds = %455
%462 = load %struct.katcl_line*, %struct.katcl_line** %19
%463 = call i32 @write_katcl(%struct.katcl_line* %462)
store i32 %463, i32* %16
%464 = load i32, i32* %16
%465 = icmp slt i32 %464, 0
br i1 %465, label %466, label %477
466: ; preds = %461
%467 = load %struct.katcl_line*, %struct.katcl_line** %21
%468 = load i8*, i8** %8
%469 = load i8*, i8** %7
%470 = load %struct.katcl_line*, %struct.katcl_line** %19
%471 = call i32 @error_katcl(%struct.katcl_line* %470)
%472 = call signext i8 @strerror(i32 %471)
%473 = sext i8 %472 to i32
%474 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %467, i32 4, i8* %468, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.17, i64 0, i64 0), i8* %469, i32 %473)
%475 = load %struct.katcl_line*, %struct.katcl_line** %19
%476 = call i32 @destroy_katcl(%struct.katcl_line* %475, i32 1)
store %struct.katcl_line* null, %struct.katcl_line** %19
store i32 0, i32* %13
br label %247
477: ; preds = %461
br label %478
478: ; preds = %477, %455
%479 = load i32, i32* %14
%480 = call i64 @FD_ISSET(i32 %479, i32* %23)
%481 = icmp ne i64 %480, 0
br i1 %481, label %482, label %529
482: ; preds = %478
%483 = load %struct.katcl_line*, %struct.katcl_line** %19
%484 = call i32 @read_katcl(%struct.katcl_line* %483)
store i32 %484, i32* %16
%485 = load i32, i32* %16
%486 = icmp ne i32 %485, 0
br i1 %486, label %487, label %506
487: ; preds = %482
%488 = load i32, i32* %16
%489 = icmp slt i32 %488, 0
br i1 %489, label %490, label %499
490: ; preds = %487
%491 = load %struct.katcl_line*, %struct.katcl_line** %21
%492 = load i8*, i8** %8
%493 = load i8*, i8** %7
%494 = load %struct.katcl_line*, %struct.katcl_line** %19
%495 = call i32 @error_katcl(%struct.katcl_line* %494)
%496 = call signext i8 @strerror(i32 %495)
%497 = sext i8 %496 to i32
%498 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %491, i32 4, i8* %492, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.18, i64 0, i64 0), i8* %493, i32 %497)
br label %503
499: ; preds = %487
%500 = load %struct.katcl_line*, %struct.katcl_line** %21
%501 = load i8*, i8** %8
%502 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %500, i32 3, i8* %501, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.19, i64 0, i64 0))
br label %503
503: ; preds = %499, %490
%504 = load %struct.katcl_line*, %struct.katcl_line** %19
%505 = call i32 @destroy_katcl(%struct.katcl_line* %504, i32 1)
store %struct.katcl_line* null, %struct.katcl_line** %19
store i32 0, i32* %13
br label %506
506: ; preds = %503, %482
br label %507
507: ; preds = %527, %506
%508 = load %struct.katcl_line*, %struct.katcl_line** %19
%509 = call i64 @have_katcl(%struct.katcl_line* %508)
%510 = icmp sgt i64 %509, 0
br i1 %510, label %511, label %528
511: ; preds = %507
%512 = load %struct.katcl_line*, %struct.katcl_line** %19
%513 = call %struct.katcl_parse* @ready_katcl(%struct.katcl_line* %512)
store %struct.katcl_parse* %513, %struct.katcl_parse** %22
%514 = load %struct.katcl_parse*, %struct.katcl_parse** %22
%515 = icmp ne %struct.katcl_parse* %514, null
br i1 %515, label %516, label %527
516: ; preds = %511
%517 = load %struct.katcl_line*, %struct.katcl_line** %20
%518 = icmp ne %struct.katcl_line* %517, null
br i1 %518, label %519, label %523
519: ; preds = %516
%520 = load %struct.katcl_line*, %struct.katcl_line** %20
%521 = load %struct.katcl_parse*, %struct.katcl_parse** %22
%522 = call i32 @append_parse_katcl(%struct.katcl_line* %520, %struct.katcl_parse* %521)
br label %526
523: ; preds = %516
%524 = load i32, i32* %17
%525 = add nsw i32 %524, 1
store i32 %525, i32* %17
br label %526
526: ; preds = %523, %519
br label %527
527: ; preds = %526, %511
br label %507
528: ; preds = %507
br label %247
529: ; preds = %478
br label %530
530: ; preds = %529, %452
br label %247
531: ; preds = %247
%532 = load %struct.katcl_line*, %struct.katcl_line** %20
%533 = icmp ne %struct.katcl_line* %532, null
br i1 %533, label %534, label %537
534: ; preds = %531
%535 = load %struct.katcl_line*, %struct.katcl_line** %20
%536 = call i32 @destroy_katcl(%struct.katcl_line* %535, i32 1)
store %struct.katcl_line* null, %struct.katcl_line** %20
br label %537
537: ; preds = %534, %531
%538 = load %struct.katcl_line*, %struct.katcl_line** %19
%539 = icmp ne %struct.katcl_line* %538, null
br i1 %539, label %540, label %543
540: ; preds = %537
%541 = load %struct.katcl_line*, %struct.katcl_line** %19
%542 = call i32 @destroy_katcl(%struct.katcl_line* %541, i32 1)
store %struct.katcl_line* null, %struct.katcl_line** %19
br label %543
543: ; preds = %540, %537
%544 = load i32, i32* %12
%545 = icmp sge i32 %544, 0
br i1 %545, label %546, label %549
546: ; preds = %543
%547 = load i32, i32* %12
%548 = call i32 @close(i32 %547)
br label %549
549: ; preds = %546, %543
br label %550
550: ; preds = %554, %549
%551 = load %struct.katcl_line*, %struct.katcl_line** %21
%552 = call i32 @write_katcl(%struct.katcl_line* %551)
%553 = icmp eq i32 %552, 0
br i1 %553, label %554, label %555
554: ; preds = %550
br label %550
555: ; preds = %550
%556 = load %struct.katcl_line*, %struct.katcl_line** %21
%557 = call i32 @destroy_katcl(%struct.katcl_line* %556, i32 0)
store i32 0, i32* %3
br label %558
558: ; preds = %555, %325, %232, %223, %210, %197, %175, %141, %112, %85, %60, %29
%559 = load i32, i32* %3
ret i32 %559
}

LLVM IR (-O2):
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
@.str = [21 x i8] c"katcp-serial-gateway\00"
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str.1 = [42 x i8] c"%s: unable to create katcp message logic\0A\00"
@.str.2 = [27 x i8] c"argument needs a parameter\00"
@.str.3 = [22 x i8] c"speed %s unreasonable\00"
@.str.4 = [19 x i8] c"unknown option -%c\00"
@.str.5 = [19 x i8] c"excess argument %s\00"
@.str.6 = [28 x i8] c"need a serial port to relay\00"
@.str.7 = [36 x i8] c"unable to open serial device %s: %s\00"
@errno = global i32 0
@.str.8 = [54 x i8] c"unable to run katcp wrapper on serial file descriptor\00"
@.str.9 = [18 x i8] c"select failed: %s\00"
@.str.10 = [38 x i8] c"unable to write to network client: %s\00"
@.str.11 = [24 x i8] c"network read failed: %s\00"
@.str.12 = [21 x i8] c"network disconnected\00"
@.str.13 = [26 x i8] c"network accept failed: %s\00"
@.str.14 = [46 x i8] c"unable to encapsulate network file descriptor\00"
@.str.15 = [52 x i8] c"discarded %u messages while no client was connected\00"
@.str.16 = [28 x i8] c"connected to %s at speed %d\00"
@.str.17 = [38 x i8] c"unable to write to serial port %s: %s\00"
@.str.18 = [31 x i8] c"serial read from %s failed: %s\00"
@.str.19 = [20 x i8] c"serial port hung up\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* @STDOUT_FILENO
%8 = tail call %struct.katcl_line* @create_katcl(i32 %7)
%9 = icmp eq %struct.katcl_line* %8, null
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = icmp sgt i32 %0, 1
br i1 %11, label %15, label %104
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %344
15: ; preds = %10, %95
%16 = phi i32 [ %100, %95 ], [ 0, %10 ]
%17 = phi i8* [ %99, %95 ], [ null, %10 ]
%18 = phi i8* [ %98, %95 ], [ null, %10 ]
%19 = phi i32 [ %97, %95 ], [ 1, %10 ]
%20 = phi i32 [ %96, %95 ], [ 1, %10 ]
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 45
br i1 %25, label %26, label %80
26: ; preds = %15
%27 = sext i32 %19 to i64
%28 = getelementptr inbounds i8, i8* %23, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
switch i32 %30, label %77 [
i32 104, label %31
i32 98, label %33
i32 115, label %33
i32 45, label %68
i32 0, label %75
]
31: ; preds = %26
%32 = tail call i32 @usage(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), %struct.katcl_line* %8)
br label %344
33: ; preds = %26, %26
%34 = add nsw i32 %19, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %23, i64 %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 0
%39 = zext i1 %38 to i32
%40 = add nsw i32 %20, %39
%41 = select i1 %38, i32 0, i32 %34
%42 = icmp slt i32 %40, %0
br i1 %42, label %45, label %43
43: ; preds = %33
%44 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %344
45: ; preds = %33
switch i32 %30, label %68 [
i32 112, label %46
i32 98, label %52
i32 115, label %62
]
46: ; preds = %45
%47 = sext i32 %40 to i64
%48 = getelementptr inbounds i8*, i8** %1, i64 %47
%49 = load i8*, i8** %48
%50 = sext i32 %41 to i64
%51 = getelementptr inbounds i8, i8* %49, i64 %50
br label %68
52: ; preds = %45
%53 = sext i32 %40 to i64
%54 = getelementptr inbounds i8*, i8** %1, i64 %53
%55 = load i8*, i8** %54
%56 = sext i32 %41 to i64
%57 = getelementptr inbounds i8, i8* %55, i64 %56
%58 = tail call i32 @atoi(i8* %57)
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %68
60: ; preds = %52
%61 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %57)
br label %344
62: ; preds = %45
%63 = sext i32 %40 to i64
%64 = getelementptr inbounds i8*, i8** %1, i64 %63
%65 = load i8*, i8** %64
%66 = sext i32 %41 to i64
%67 = getelementptr inbounds i8, i8* %65, i64 %66
br label %68
68: ; preds = %46, %62, %45, %52, %26
%69 = phi i32 [ %20, %26 ], [ %40, %45 ], [ %40, %62 ], [ %40, %52 ], [ %40, %46 ]
%70 = phi i32 [ %19, %26 ], [ %41, %45 ], [ %41, %62 ], [ %41, %52 ], [ %41, %46 ]
%71 = phi i8* [ %18, %26 ], [ %18, %45 ], [ %67, %62 ], [ %18, %52 ], [ %18, %46 ]
%72 = phi i8* [ %17, %26 ], [ %17, %45 ], [ %17, %62 ], [ %17, %52 ], [ %51, %46 ]
%73 = phi i32 [ %16, %26 ], [ %16, %45 ], [ %16, %62 ], [ %58, %52 ], [ %16, %46 ]
%74 = add nsw i32 %70, 1
br label %95
75: ; preds = %26
%76 = add nsw i32 %20, 1
br label %95
77: ; preds = %26
%78 = sext i8 %29 to i32
%79 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %78)
br label %344
80: ; preds = %15
%81 = icmp eq i8* %18, null
br i1 %81, label %90, label %82
82: ; preds = %80
%83 = icmp eq i8* %17, null
br i1 %83, label %90, label %84
84: ; preds = %82
%85 = icmp eq i32 %16, 0
br i1 %85, label %86, label %88
86: ; preds = %84
%87 = tail call i32 @atoi(i8* %23)
br label %90
88: ; preds = %84
%89 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %23)
br label %344
90: ; preds = %82, %80, %86
%91 = phi i8* [ %18, %86 ], [ %23, %80 ], [ %18, %82 ]
%92 = phi i8* [ %17, %86 ], [ %17, %80 ], [ %23, %82 ]
%93 = phi i32 [ %87, %86 ], [ %16, %80 ], [ %16, %82 ]
%94 = add nsw i32 %20, 1
br label %95
95: ; preds = %68, %75, %90
%96 = phi i32 [ %76, %75 ], [ %69, %68 ], [ %94, %90 ]
%97 = phi i32 [ 1, %75 ], [ %74, %68 ], [ %19, %90 ]
%98 = phi i8* [ %18, %75 ], [ %71, %68 ], [ %91, %90 ]
%99 = phi i8* [ %17, %75 ], [ %72, %68 ], [ %92, %90 ]
%100 = phi i32 [ %16, %75 ], [ %73, %68 ], [ %93, %90 ]
%101 = icmp slt i32 %96, %0
br i1 %101, label %15, label %102
102: ; preds = %95
%103 = icmp slt i32 %100, 1
br i1 %103, label %104, label %109
104: ; preds = %10, %102
%105 = phi i8* [ %99, %102 ], [ null, %10 ]
%106 = phi i8* [ %98, %102 ], [ null, %10 ]
%107 = phi i32 [ %97, %102 ], [ 1, %10 ]
%108 = phi i32 [ %96, %102 ], [ 1, %10 ]
br label %109
109: ; preds = %102, %104
%110 = phi i8* [ %105, %104 ], [ %99, %102 ]
%111 = phi i8* [ %106, %104 ], [ %98, %102 ]
%112 = phi i32 [ %107, %104 ], [ %97, %102 ]
%113 = phi i32 [ %108, %104 ], [ %96, %102 ]
%114 = phi i32 [ 9600, %104 ], [ %100, %102 ]
%115 = icmp eq i8* %111, null
br i1 %115, label %116, label %119
116: ; preds = %109
%117 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%118 = tail call i32 @usage(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), %struct.katcl_line* %8)
br label %344
119: ; preds = %109
%120 = tail call i32 @start_serial(i8* %111, i32 %114)
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %127
122: ; preds = %119
%123 = load i32, i32* @errno
%124 = tail call signext i8 @strerror(i32 %123)
%125 = sext i8 %124 to i32
%126 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), i8* %111, i32 %125)
br label %344
127: ; preds = %119
%128 = tail call %struct.katcl_line* @create_katcl(i32 %120)
%129 = icmp eq %struct.katcl_line* %128, null
br i1 %129, label %130, label %132
130: ; preds = %127
%131 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
br label %344
132: ; preds = %127
%133 = tail call i32 @net_listen(i8* %110, i32 0, i32 0)
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %144
135: ; preds = %132
%136 = sext i32 %113 to i64
%137 = getelementptr inbounds i8*, i8** %1, i64 %136
%138 = load i8*, i8** %137
%139 = sext i32 %112 to i64
%140 = getelementptr inbounds i8, i8* %138, i64 %139
%141 = load i8, i8* %140
%142 = sext i8 %141 to i32
%143 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %142)
br label %344
144: ; preds = %132, %312
%145 = phi i32 [ %313, %312 ], [ 1, %132 ]
%146 = phi i32 [ %314, %312 ], [ 0, %132 ]
%147 = phi %struct.katcl_line* [ %315, %312 ], [ %128, %132 ]
%148 = phi %struct.katcl_line* [ %275, %312 ], [ null, %132 ]
%149 = icmp eq %struct.katcl_line* %147, null
br label %150
150: ; preds = %292, %144
%151 = phi i32 [ %145, %144 ], [ 1, %292 ]
%152 = phi i32 [ %146, %144 ], [ %274, %292 ]
%153 = phi %struct.katcl_line* [ %148, %144 ], [ %275, %292 ]
br label %154
154: ; preds = %224, %150
%155 = phi i32 [ %151, %150 ], [ 1, %224 ]
%156 = phi %struct.katcl_line* [ %153, %150 ], [ null, %224 ]
%157 = icmp eq %struct.katcl_line* %156, null
br label %158
158: ; preds = %154, %197
%159 = phi i32 [ 1, %197 ], [ %155, %154 ]
%160 = icmp eq i32 %159, 0
br i1 %160, label %331, label %161
161: ; preds = %158
%162 = call i32 @FD_ZERO(i32* %3)
%163 = call i32 @FD_ZERO(i32* %4)
%164 = call i64 @flushing_katcl(%struct.katcl_line* %8)
%165 = icmp eq i64 %164, 0
br i1 %165, label %169, label %166
166: ; preds = %161
%167 = call i32 @fileno_katcl(%struct.katcl_line* %8)
%168 = call i32 @FD_SET(i32 %167, i32* %4)
br label %169
169: ; preds = %161, %166
%170 = phi i32 [ %167, %166 ], [ 0, %161 ]
br i1 %157, label %177, label %171
171: ; preds = %169
%172 = call i32 @fileno_katcl(%struct.katcl_line* %156)
%173 = call i64 @flushing_katcl(%struct.katcl_line* %156)
%174 = icmp eq i64 %173, 0
br i1 %174, label %177, label %175
175: ; preds = %171
%176 = call i32 @FD_SET(i32 %172, i32* %4)
br label %177
177: ; preds = %169, %171, %175
%178 = phi i32 [ %172, %175 ], [ %172, %171 ], [ %133, %169 ]
%179 = call i32 @FD_SET(i32 %178, i32* %3)
%180 = icmp slt i32 %170, %178
%181 = select i1 %180, i32 %178, i32 %170
br i1 %149, label %192, label %182
182: ; preds = %177
%183 = call i32 @fileno_katcl(%struct.katcl_line* %147)
%184 = call i64 @flushing_katcl(%struct.katcl_line* %147)
%185 = icmp eq i64 %184, 0
br i1 %185, label %188, label %186
186: ; preds = %182
%187 = call i32 @FD_SET(i32 %183, i32* %4)
br label %188
188: ; preds = %186, %182
%189 = call i32 @FD_SET(i32 %183, i32* %3)
%190 = icmp slt i32 %181, %183
%191 = select i1 %190, i32 %183, i32 %181
br label %192
192: ; preds = %188, %177
%193 = phi i32 [ %181, %177 ], [ %191, %188 ]
%194 = add nsw i32 %193, 1
%195 = call i32 @select(i32 %194, i32* %3, i32* %4, i32* null, i32* null)
%196 = icmp eq i32 %195, -1
br i1 %196, label %197, label %205
197: ; preds = %192
%198 = load i32, i32* @errno
%199 = and i32 %198, -2
%200 = icmp eq i32 %199, 128
br i1 %200, label %158, label %201
201: ; preds = %197
%202 = call signext i8 @strerror(i32 %198)
%203 = sext i8 %202 to i32
%204 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %203)
br label %344
205: ; preds = %192
%206 = call i32 @fileno_katcl(%struct.katcl_line* %8)
%207 = call i64 @FD_ISSET(i32 %206, i32* %4)
%208 = icmp eq i64 %207, 0
br i1 %208, label %211, label %209
209: ; preds = %205
%210 = call i32 @write_katcl(%struct.katcl_line* %8)
br label %211
211: ; preds = %205, %209
br i1 %157, label %252, label %212
212: ; preds = %211
%213 = call i32 @fileno_katcl(%struct.katcl_line* %156)
%214 = call i64 @FD_ISSET(i32 %213, i32* %4)
%215 = icmp eq i64 %214, 0
br i1 %215, label %226, label %216
216: ; preds = %212
%217 = call i32 @write_katcl(%struct.katcl_line* %156)
%218 = icmp slt i32 %217, 0
br i1 %218, label %219, label %226
219: ; preds = %216
%220 = call i32 @error_katcl(%struct.katcl_line* %156)
%221 = call signext i8 @strerror(i32 %220)
%222 = sext i8 %221 to i32
%223 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i32 %222)
br label %224
224: ; preds = %237, %242, %219
%225 = call i32 @destroy_katcl(%struct.katcl_line* %156, i32 1)
br label %154
226: ; preds = %216, %212
%227 = call i64 @FD_ISSET(i32 %213, i32* %3)
%228 = icmp eq i64 %227, 0
br i1 %228, label %273, label %229
229: ; preds = %226
%230 = call i32 @read_katcl(%struct.katcl_line* %156)
%231 = icmp eq i32 %230, 0
br i1 %231, label %232, label %235
232: ; preds = %229
%233 = call i64 @have_katcl(%struct.katcl_line* %156)
%234 = icmp sgt i64 %233, 0
br i1 %234, label %244, label %273
235: ; preds = %229
%236 = icmp slt i32 %230, 0
br i1 %236, label %237, label %242
237: ; preds = %235
%238 = call i32 @error_katcl(%struct.katcl_line* %156)
%239 = call signext i8 @strerror(i32 %238)
%240 = sext i8 %239 to i32
%241 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 %240)
br label %224
242: ; preds = %235
%243 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %8, i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
br label %224
244: ; preds = %232, %249
%245 = call %struct.katcl_parse* @ready_katcl(%struct.katcl_line* %156)
%246 = icmp eq %struct.katcl_parse* %245, null
br i1 %246, label %249, label %247
247: ; preds = %244
%248 = call i32 @append_parse_katcl(%struct.katcl_line* %147, %struct.katcl_parse* %245)
br label %249
249: ; preds = %247, %244
%250 = call i64 @have_katcl(%struct.katcl_line* %156)
%251 = icmp sgt i64 %250, 0
br i1 %251, label %244, label %273
252: ; preds = %211
%253 = call i32 @accept(i32 %133, i32* null, i32* null)
%254 = icmp slt i32 %253, 0
br i1 %254, label %255, label %260
255: ; preds = %252
%256 = call i32 @error_katcl(%struct.katcl_line* null)
%257 = call signext i8 @strerror(i32 %256)
%258 = sext i8 %257 to i32
%259 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i32 %258)
br label %260
260: ; preds = %255, %252
%261 = call %struct.katcl_line* @create_katcl(i32 %253)
%262 = icmp eq %struct.katcl_line* %261, null
br i1 %262, label %263, label %266
263: ; preds = %260
%264 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%265 = call i32 @close(i32 %253)
br label %266
266: ; preds = %263, %260
%267 = icmp sgt i32 %152, 0
br i1 %267, label %268, label %270
268: ; preds = %266
%269 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %261, i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.15, i64 0, i64 0), i32 %152)
br label %270
270: ; preds = %268, %266
%271 = phi i32 [ 0, %268 ], [ %152, %266 ]
%272 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %261, i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* %111, i32 %114)
br label %273
273: ; preds = %226, %249, %232, %270
%274 = phi i32 [ %271, %270 ], [ %152, %232 ], [ %152, %249 ], [ %152, %226 ]
%275 = phi %struct.katcl_line* [ %261, %270 ], [ %156, %232 ], [ %156, %249 ], [ %156, %226 ]
br i1 %149, label %292, label %276
276: ; preds = %273
%277 = call i32 @fileno_katcl(%struct.katcl_line* %147)
%278 = call i64 @FD_ISSET(i32 %277, i32* %4)
%279 = icmp eq i64 %278, 0
br i1 %279, label %289, label %280
280: ; preds = %276
%281 = call i32 @write_katcl(%struct.katcl_line* %147)
%282 = icmp slt i32 %281, 0
br i1 %282, label %283, label %289
283: ; preds = %280
%284 = call i32 @error_katcl(%struct.katcl_line* %147)
%285 = call signext i8 @strerror(i32 %284)
%286 = sext i8 %285 to i32
%287 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.17, i64 0, i64 0), i8* %111, i32 %286)
%288 = call i32 @destroy_katcl(%struct.katcl_line* %147, i32 1)
br label %312
289: ; preds = %280, %276
%290 = call i64 @FD_ISSET(i32 %277, i32* %3)
%291 = icmp eq i64 %290, 0
br i1 %291, label %292, label %293
292: ; preds = %289, %273
br label %150
293: ; preds = %289
%294 = call i32 @read_katcl(%struct.katcl_line* %147)
%295 = icmp eq i32 %294, 0
br i1 %295, label %307, label %296
296: ; preds = %293
%297 = icmp slt i32 %294, 0
br i1 %297, label %298, label %303
298: ; preds = %296
%299 = call i32 @error_katcl(%struct.katcl_line* %147)
%300 = call signext i8 @strerror(i32 %299)
%301 = sext i8 %300 to i32
%302 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %8, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.18, i64 0, i64 0), i8* %111, i32 %301)
br label %305
303: ; preds = %296
%304 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %8, i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.19, i64 0, i64 0))
br label %305
305: ; preds = %303, %298
%306 = call i32 @destroy_katcl(%struct.katcl_line* %147, i32 1)
br label %307
307: ; preds = %305, %293
%308 = phi i32 [ 0, %305 ], [ 1, %293 ]
%309 = phi %struct.katcl_line* [ null, %305 ], [ %147, %293 ]
%310 = call i64 @have_katcl(%struct.katcl_line* %309)
%311 = icmp sgt i64 %310, 0
br i1 %311, label %316, label %312
312: ; preds = %327, %307, %283
%313 = phi i32 [ 0, %283 ], [ %308, %307 ], [ %308, %327 ]
%314 = phi i32 [ %274, %283 ], [ %274, %307 ], [ %328, %327 ]
%315 = phi %struct.katcl_line* [ null, %283 ], [ %309, %307 ], [ %309, %327 ]
br label %144
316: ; preds = %307
%317 = icmp eq %struct.katcl_line* %275, null
br label %318
318: ; preds = %316, %327
%319 = phi i32 [ %274, %316 ], [ %328, %327 ]
%320 = call %struct.katcl_parse* @ready_katcl(%struct.katcl_line* %309)
%321 = icmp eq %struct.katcl_parse* %320, null
br i1 %321, label %327, label %322
322: ; preds = %318
br i1 %317, label %325, label %323
323: ; preds = %322
%324 = call i32 @append_parse_katcl(%struct.katcl_line* %275, %struct.katcl_parse* %320)
br label %327
325: ; preds = %322
%326 = add nsw i32 %319, 1
br label %327
327: ; preds = %323, %325, %318
%328 = phi i32 [ %319, %323 ], [ %326, %325 ], [ %319, %318 ]
%329 = call i64 @have_katcl(%struct.katcl_line* %309)
%330 = icmp sgt i64 %329, 0
br i1 %330, label %318, label %312
331: ; preds = %158
br i1 %157, label %334, label %332
332: ; preds = %331
%333 = call i32 @destroy_katcl(%struct.katcl_line* %156, i32 1)
br label %334
334: ; preds = %332, %331
br i1 %149, label %337, label %335
335: ; preds = %334
%336 = call i32 @destroy_katcl(%struct.katcl_line* %147, i32 1)
br label %337
337: ; preds = %334, %335
%338 = call i32 @close(i32 %133)
br label %339
339: ; preds = %339, %337
%340 = call i32 @write_katcl(%struct.katcl_line* %8)
%341 = icmp eq i32 %340, 0
br i1 %341, label %339, label %342
342: ; preds = %339
%343 = call i32 @destroy_katcl(%struct.katcl_line* %8, i32 0)
br label %344
344: ; preds = %342, %201, %135, %130, %122, %116, %88, %77, %60, %43, %31, %12
%345 = phi i32 [ 4, %12 ], [ 2, %77 ], [ 2, %43 ], [ 2, %60 ], [ 0, %31 ], [ 2, %88 ], [ 2, %116 ], [ 3, %122 ], [ 4, %130 ], [ 3, %135 ], [ 4, %201 ], [ 0, %342 ]
ret i32 %345
}