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

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ tio;
struct termios {
  int c_cflag;
};
typedef int /*<<< orphan*/ frames;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ bauds;

/* Variables and functions */
int /*<<< orphan*/ B1200;
int /*<<< orphan*/ B1800;
int /*<<< orphan*/ B19200;
int /*<<< orphan*/ B2400;
int /*<<< orphan*/ B300;
int /*<<< orphan*/ B38400;
int /*<<< orphan*/ B4800;
int /*<<< orphan*/ B600;
int /*<<< orphan*/ B9600;
int CLOCAL;
int CREAD;
int CS7;
int CS8;
int CSTOPB;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int O_NOCTTY;
int O_NONBLOCK;
int O_RDWR;
int PARENB;
int PARODD;
int /*<<< orphan*/ TCSANOW;
int atoi(char *);
char *bin(unsigned char);
int /*<<< orphan*/ bzero(struct termios *, int);
int /*<<< orphan*/ close(int);
int errno;
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, unsigned char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int tcsetattr(int, int /*<<< orphan*/, struct termios *);
int write(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  unsigned char buf;
  int i, n, fd, baud, flags;
  fd_set rd, wr;
  struct termios tio;
  struct baud {
    int code;
    int num;
  } bauds[] = {{B300, 300},   {B600, 600},     {B1200, 1200},
               {B1800, 1800}, {B2400, 2400},   {B4800, 4800},
               {B9600, 9600}, {B19200, 19200}, {B38400, 38400}};
  struct frame {
    char *str;
    int flags;
  } frames[] = {{"7N1", CS7},
                {"7N2", CS7 | CSTOPB},
                {"7O1", CS7 | PARENB | PARODD},
                {"7O2", CS7 | PARENB | PARODD | CSTOPB},
                {"7E1", CS7 | PARENB},
                {"7E2", CS7 | PARENB | CSTOPB},
                {"8N1", CS8},
                {"8O1", CS8 | PARENB | PARODD},
                {"8E1", CS8 | PARENB}};
  if (argc < 4) {
    printf("Usage:   %s <device> <baud> <frame>\n"
           "Example: %s /dev/ttyS0 9600 8N1\n",
           argv[0], argv[0]);
    return 0;
  }
  baud = atoi(argv[2]);
  n = sizeof(bauds) / sizeof(bauds[0]);
  for (i = 0; i < n; i++) {
    if (baud == bauds[i].num)
      break;
  }
  if (i < n)
    baud = bauds[i].code;
  else {
    printf("Unknown baudrate %d\n", baud);
    return -1;
  }
  n = sizeof(frames) / sizeof(frames[0]);
  for (i = 0; i < n; i++) {
    if (!strncmp(argv[3], frames[i].str, 3))
      break;
  }
  if (i < n)
    flags = frames[i].flags;
  else {
    printf("Unknown frame format %s\n", argv[2]);
    return -1;
  }
  if ((fd = open(argv[1], O_RDWR | O_NOCTTY | O_NONBLOCK)) == -1) {
    perror("open");
    return -1;
  }
  bzero(&tio, sizeof(tio));
  tio.c_cflag = baud | flags | CLOCAL | CREAD;
  if (tcsetattr(fd, TCSANOW, &tio) == -1) {
    perror("tcsetattr");
    close(fd);
    return -1;
  }
  printf("using %s with baud 0x%X and flags 0%o\n", argv[1], baud, flags);
  do {
    FD_ZERO(&rd);
    FD_ZERO(&wr);
    FD_SET(0, &rd);
    FD_SET(fd, &rd);
    FD_SET(fd, &wr);
    n = select(fd + 1, &rd, &wr, NULL, NULL);
    if (n == 0)
      continue;
    if (n == -1)
      break;
    if (FD_ISSET(fd, &rd)) {
      if ((n = read(fd, &buf, sizeof(buf))) == -1) {
        perror("fd read");
        continue;
      }
      printf("0x%X\tb%s\t%c\n", buf, bin(buf),
             (buf >= 32 && buf < 128) ? buf : '.');
      if (buf == 'q')
        break;
    }
    if (FD_ISSET(0, &rd)) {
      if ((n = read(0, &buf, sizeof(buf))) == -1) {
        perror("stdin read");
        continue;
      }
      switch (buf) {
      case '.':
        buf = 1;
        break;
      case ';':
        buf = 0xD;
        break;
      }
      if ((n = write(fd, &buf, sizeof(buf))) == -1) {
        perror("fd write");
        continue;
      }
    }
  } while (buf != 'q');
  printf("error: %d\n", errno);
  if (n == -1)
    perror("read");
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
movl   $0x12c,-0x7c(%rbp)
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
movl   $0x258,-0x74(%rbp)
mov    0x2d2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
movl   $0x4b0,-0x6c(%rbp)
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
movl   $0x708,-0x64(%rbp)
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
movl   $0x960,-0x5c(%rbp)
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
movl   $0x12c0,-0x54(%rbp)
mov    0x2d26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
movl   $0x2580,-0x4c(%rbp)
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
movl   $0x4b00,-0x44(%rbp)
mov    0x2c90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
movl   $0x9600,-0x3c(%rbp)
lea    0xd45(%rip),%rax
mov    %rax,-0x110(%rbp)
mov    0x2c7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x108(%rbp)
lea    0xd2c(%rip),%rax
mov    %rax,-0x100(%rbp)
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
mov    0x2c61(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0xf8(%rbp)
lea    0xd0a(%rip),%rax
mov    %rax,-0xf0(%rbp)
mov    0x2c3c(%rip),%rax
mov    (%rax),%eax
mov    0x2cbb(%rip),%rcx
or     (%rcx),%eax
mov    0x2c9a(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0xe8(%rbp)
lea    0xcdf(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    0x2c0d(%rip),%rax
mov    (%rax),%eax
mov    0x2c8c(%rip),%rcx
or     (%rcx),%eax
mov    0x2c6b(%rip),%rcx
or     (%rcx),%eax
mov    0x2bfa(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0xd8(%rbp)
lea    0xcab(%rip),%rax
mov    %rax,-0xd0(%rbp)
mov    0x2bd5(%rip),%rax
mov    (%rax),%eax
mov    0x2c54(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0xc8(%rbp)
lea    0xc89(%rip),%rax
mov    %rax,-0xc0(%rbp)
mov    0x2baf(%rip),%rax
mov    (%rax),%eax
mov    0x2c2e(%rip),%rcx
or     (%rcx),%eax
mov    0x2ba5(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0xb8(%rbp)
lea    0xc5e(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0x2bc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa8(%rbp)
lea    0xc45(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0x2bab(%rip),%rax
mov    (%rax),%eax
mov    0x2be2(%rip),%rcx
or     (%rcx),%eax
mov    0x2bc1(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x98(%rbp)
lea    0xc1a(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0x2b7c(%rip),%rax
mov    (%rax),%eax
mov    0x2bb3(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x88(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1457 <main+0x267>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xbe0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    189d <main+0x6ad>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x24(%rbp)
movl   $0x9,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    14aa <main+0x2ba>
mov    -0x24(%rbp),%eax
movslq -0x18(%rbp),%rcx
cmp    -0x7c(%rbp,%rcx,8),%eax
jne    1497 <main+0x2a7>
jmp    14aa <main+0x2ba>
jmp    149c <main+0x2ac>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1475 <main+0x285>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    14c6 <main+0x2d6>
movslq -0x18(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%eax
mov    %eax,-0x24(%rbp)
jmp    14e3 <main+0x2f3>
mov    -0x24(%rbp),%esi
lea    0xb99(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    189d <main+0x6ad>
movl   $0x9,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1545 <main+0x355>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
movslq -0x18(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1532 <main+0x342>
jmp    1545 <main+0x355>
jmp    1537 <main+0x347>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    14f1 <main+0x301>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    156e <main+0x37e>
movslq -0x18(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    %eax,-0x28(%rbp)
jmp    1590 <main+0x3a0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xb01(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    189d <main+0x6ad>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2a41(%rip),%rax
mov    (%rax),%esi
mov    0x29d0(%rip),%rax
or     (%rax),%esi
mov    0x2a27(%rip),%rax
or     (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    15dc <main+0x3ec>
lea    0xacc(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    189d <main+0x6ad>
lea    -0x38(%rbp),%rdi
mov    $0x4,%esi
call   10f0 <bzero@plt>
mov    -0x24(%rbp),%eax
or     -0x28(%rbp),%eax
mov    0x2949(%rip),%rcx
or     (%rcx),%eax
mov    0x2998(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
mov    0x29b9(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   10c0 <tcsetattr@plt>
cmp    $0xffffffff,%eax
jne    1643 <main+0x453>
lea    0xa72(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    189d <main+0x6ad>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xa4e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x2c(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
lea    -0x30(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
xor    %edi,%edi
lea    -0x2c(%rbp),%rsi
call   1110 <FD_SET@plt>
mov    -0x20(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1110 <FD_SET@plt>
mov    -0x20(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1110 <FD_SET@plt>
mov    -0x20(%rbp),%edi
add    $0x1,%edi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   10b0 <select@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    16c1 <main+0x4d1>
jmp    1854 <main+0x664>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    16d0 <main+0x4e0>
jmp    1861 <main+0x671>
mov    -0x20(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     17a1 <main+0x5b1>
mov    -0x20(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    1714 <main+0x524>
lea    0x9c3(%rip),%rdi
call   10e0 <perror@plt>
jmp    1854 <main+0x664>
movzbl -0x11(%rbp),%eax
mov    %eax,-0x11c(%rbp)
movzbl -0x11(%rbp),%edi
call   1060 <bin@plt>
mov    %rax,-0x118(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jl     1759 <main+0x569>
movzbl -0x11(%rbp),%eax
cmp    $0x80,%eax
jge    1759 <main+0x569>
movzbl -0x11(%rbp),%eax
mov    %eax,-0x120(%rbp)
jmp    1769 <main+0x579>
mov    $0x2e,%eax
mov    %eax,-0x120(%rbp)
jmp    1769 <main+0x579>
mov    -0x118(%rbp),%rdx
mov    -0x11c(%rbp),%esi
mov    -0x120(%rbp),%ecx
lea    0x952(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movzbl -0x11(%rbp),%eax
cmp    $0x71,%eax
jne    179c <main+0x5ac>
jmp    1861 <main+0x671>
jmp    17a1 <main+0x5b1>
xor    %edi,%edi
lea    -0x2c(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     184f <main+0x65f>
xor    %edi,%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    17e3 <main+0x5f3>
lea    0x909(%rip),%rdi
call   10e0 <perror@plt>
jmp    1854 <main+0x664>
movzbl -0x11(%rbp),%eax
mov    %eax,-0x124(%rbp)
sub    $0x2e,%eax
je     180f <main+0x61f>
jmp    17fb <main+0x60b>
mov    -0x124(%rbp),%eax
sub    $0x3b,%eax
je     1818 <main+0x628>
jmp    181c <main+0x62c>
movb   $0x1,-0x11(%rbp)
jmp    181c <main+0x62c>
movb   $0xd,-0x11(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    184a <main+0x65a>
lea    0x8ad(%rip),%rdi
call   10e0 <perror@plt>
jmp    1854 <main+0x664>
jmp    184f <main+0x65f>
jmp    1854 <main+0x664>
movzbl -0x11(%rbp),%eax
cmp    $0x71,%eax
jne    165f <main+0x46f>
mov    0x2700(%rip),%rax
mov    (%rax),%esi
lea    0x885(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    188e <main+0x69e>
lea    0x847(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
mov    %rsi,%r15
mov    0x2da5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
movl   $0x12c,0x14(%rsp)
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
movl   $0x258,0x1c(%rsp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
movl   $0x4b0,0x24(%rsp)
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
movl   $0x708,0x2c(%rsp)
mov    0x2d21(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
movl   $0x960,0x34(%rsp)
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
movl   $0x12c0,0x3c(%rsp)
mov    0x2d2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
movl   $0x2580,0x44(%rsp)
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x48(%rsp)
movl   $0x4b00,0x4c(%rsp)
mov    0x2c95(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rsp)
movl   $0x9600,0x54(%rsp)
lea    0xd48(%rip),%rax
mov    %rax,0x60(%rsp)
mov    0x2c84(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,0x68(%rsp)
lea    0xd33(%rip),%rcx
mov    %rcx,0x70(%rsp)
mov    0x2c73(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%edx
or     %ebp,%edx
mov    %edx,0x78(%rsp)
lea    0xd1a(%rip),%rdx
mov    %rdx,0x80(%rsp)
mov    0x2cd3(%rip),%rdx
mov    (%rdx),%edx
or     %edx,%ebp
mov    0x2cb0(%rip),%rsi
mov    (%rsi),%esi
mov    %ebp,%eax
or     %esi,%eax
mov    %eax,0x88(%rsp)
lea    0xcf0(%rip),%rbx
mov    %rbx,0x90(%rsp)
or     %ecx,%eax
mov    %eax,0x98(%rsp)
lea    0xcdc(%rip),%rax
mov    %rax,0xa0(%rsp)
mov    %ebp,0xa8(%rsp)
lea    0xcca(%rip),%rax
mov    %rax,0xb0(%rsp)
or     %ecx,%ebp
mov    %ebp,0xb8(%rsp)
lea    0xcb6(%rip),%rax
mov    %rax,0xc0(%rsp)
mov    0x2c1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc8(%rsp)
lea    0xc9b(%rip),%rcx
mov    %rcx,0xd0(%rsp)
or     %edx,%eax
or     %eax,%esi
mov    %esi,0xd8(%rsp)
lea    0xc85(%rip),%rcx
mov    %rcx,0xe0(%rsp)
mov    %eax,0xe8(%rsp)
cmp    $0x3,%edi
jg     13ca <main+0x1ea>
mov    (%r15),%rdx
lea    0xc6b(%rip),%rdi
xor    %ebx,%ebx
mov    %rdx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    186f <main+0x68f>
mov    0x10(%r15),%rdi
call   10f0 <atoi@plt>
cmp    $0x95f,%eax
jle    1401 <main+0x221>
cmp    $0x257f,%eax
jle    1421 <main+0x241>
cmp    $0x2580,%eax
je     1453 <main+0x273>
cmp    $0x4b00,%eax
je     145a <main+0x27a>
cmp    $0x9600,%eax
jne    15a0 <main+0x3c0>
mov    $0x8,%eax
jmp    1471 <main+0x291>
cmp    $0x4af,%eax
jg     143a <main+0x25a>
cmp    $0x12c,%eax
je     1461 <main+0x281>
cmp    $0x258,%eax
jne    15a0 <main+0x3c0>
mov    $0x1,%eax
jmp    1471 <main+0x291>
cmp    $0x960,%eax
je     1465 <main+0x285>
cmp    $0x12c0,%eax
jne    15a0 <main+0x3c0>
mov    $0x5,%eax
jmp    1471 <main+0x291>
cmp    $0x4b0,%eax
je     146c <main+0x28c>
cmp    $0x708,%eax
jne    15a0 <main+0x3c0>
mov    $0x3,%eax
jmp    1471 <main+0x291>
mov    $0x6,%eax
jmp    1471 <main+0x291>
mov    $0x7,%eax
jmp    1471 <main+0x291>
xor    %eax,%eax
jmp    1471 <main+0x291>
mov    $0x4,%eax
jmp    1471 <main+0x291>
mov    $0x2,%eax
mov    0x10(%rsp,%rax,8),%ebp
mov    0x18(%r15),%rdi
lea    0xb80(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     158e <main+0x3ae>
mov    0x18(%r15),%rdi
lea    0xb67(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1592 <main+0x3b2>
mov    0x18(%r15),%rdi
lea    0xb4e(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1599 <main+0x3b9>
mov    0x18(%r15),%rdi
lea    0xb35(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     15ba <main+0x3da>
mov    0x18(%r15),%rdi
lea    0xb1c(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     15c1 <main+0x3e1>
mov    0x18(%r15),%rdi
lea    0xb03(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     15c8 <main+0x3e8>
mov    0x18(%r15),%rdi
lea    0xaea(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     15cf <main+0x3ef>
mov    0x18(%r15),%rdi
lea    0xad1(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     15d6 <main+0x3f6>
mov    0x18(%r15),%rdi
lea    0xabc(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     15dd <main+0x3fd>
mov    0x10(%r15),%rsi
lea    0xb01(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%ebx
jmp    186f <main+0x68f>
xor    %eax,%eax
jmp    15e2 <main+0x402>
mov    $0x1,%eax
jmp    15e2 <main+0x402>
mov    $0x2,%eax
jmp    15e2 <main+0x402>
lea    0xac2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%ebx
jmp    186f <main+0x68f>
mov    $0x3,%eax
jmp    15e2 <main+0x402>
mov    $0x4,%eax
jmp    15e2 <main+0x402>
mov    $0x5,%eax
jmp    15e2 <main+0x402>
mov    $0x6,%eax
jmp    15e2 <main+0x402>
mov    $0x7,%eax
jmp    15e2 <main+0x402>
mov    $0x8,%eax
shl    $0x4,%rax
mov    0x68(%rsp,%rax,1),%ebx
mov    0x29ef(%rip),%rax
mov    0x2980(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x8(%r15),%rdi
mov    0x29d1(%rip),%rax
or     (%rax),%esi
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     1814 <main+0x634>
mov    %eax,%r14d
mov    %ebx,%eax
or     %ebp,%eax
mov    0x291b(%rip),%rcx
or     (%rcx),%eax
mov    0x296a(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x8(%rsp)
mov    0x298d(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r14d,%edi
call   10c0 <tcsetattr@plt>
cmp    $0xffffffff,%eax
je     1827 <main+0x647>
mov    0x8(%r15),%rsi
lea    0xa48(%rip),%rdi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%ebx
add    $0x1,%ebx
lea    0x5c(%rsp),%r15
lea    0x58(%rsp),%r12
lea    0x7(%rsp),%rbp
jmp    16b3 <main+0x4d3>
movb   $0xd,0x7(%rsp)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,%r13d
lea    0xa4e(%rip),%rdi
cmp    $0xffffffff,%eax
je     17cc <main+0x5ec>
cmpb   $0x71,0x7(%rsp)
je     17dc <main+0x5fc>
mov    %r15,%rdi
call   10a0 <FD_ZERO@plt>
mov    %r12,%rdi
call   10a0 <FD_ZERO@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1100 <FD_SET@plt>
mov    %r14d,%edi
mov    %r15,%rsi
call   1100 <FD_SET@plt>
mov    %r14d,%edi
mov    %r12,%rsi
call   1100 <FD_SET@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10b0 <select@plt>
mov    %eax,%r13d
test   %eax,%eax
je     16a8 <main+0x4c8>
cmp    $0xffffffff,%r13d
je     1842 <main+0x662>
mov    %r14d,%edi
mov    %r15,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     177f <main+0x59f>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
lea    0x9a0(%rip),%rdi
cmp    $0xffffffff,%eax
je     17cc <main+0x5ec>
mov    %eax,%r13d
mov    %r14d,%ebp
mov    %r12,%r14
movzbl 0x7(%rsp),%r12d
mov    %r12d,%edi
call   1060 <bin@plt>
cmp    $0x20,%r12b
mov    $0x2e,%ecx
cmovge %r12d,%ecx
lea    0x974(%rip),%rdi
mov    %r12d,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x71,%r12b
mov    %r14,%r12
mov    %ebp,%r14d
lea    0x7(%rsp),%rbp
je     17fb <main+0x61b>
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     16a8 <main+0x4c8>
xor    %edi,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
lea    0x93a(%rip),%rdi
cmp    $0xffffffff,%eax
je     17cc <main+0x5ec>
movzbl 0x7(%rsp),%eax
cmp    $0x3b,%al
je     1680 <main+0x4a0>
cmp    $0x2e,%al
jne    1685 <main+0x4a5>
movb   $0x1,0x7(%rsp)
jmp    1685 <main+0x4a5>
call   10e0 <perror@plt>
mov    $0xffffffff,%r13d
jmp    16a8 <main+0x4c8>
mov    0x2785(%rip),%rax
mov    (%rax),%esi
lea    0x90a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0xffffffff,%r13d
jne    1865 <main+0x685>
jmp    1859 <main+0x679>
mov    0x2766(%rip),%rax
mov    (%rax),%esi
lea    0x8eb(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1865 <main+0x685>
lea    0x87c(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%ebx
jmp    186f <main+0x68f>
lea    0x86e(%rip),%rdi
call   10e0 <perror@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    $0xffffffff,%ebx
jmp    186f <main+0x68f>
mov    0x271f(%rip),%rax
mov    (%rax),%esi
lea    0x8a4(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x870(%rip),%rdi
call   10e0 <perror@plt>
mov    %r14d,%edi
call   1080 <close@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
%struct.baud = type { i32, i32 }
%struct.frame = type { i8*, i32 }
@B300 = global i32 0
@B600 = global i32 0
@B1200 = global i32 0
@B1800 = global i32 0
@B2400 = global i32 0
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@.str = [4 x i8] c"7N1\00"
@CS7 = global i32 0
@.str.1 = [4 x i8] c"7N2\00"
@CSTOPB = global i32 0
@.str.2 = [4 x i8] c"7O1\00"
@PARENB = global i32 0
@PARODD = global i32 0
@.str.3 = [4 x i8] c"7O2\00"
@.str.4 = [4 x i8] c"7E1\00"
@.str.5 = [4 x i8] c"7E2\00"
@.str.6 = [4 x i8] c"8N1\00"
@CS8 = global i32 0
@.str.7 = [4 x i8] c"8O1\00"
@.str.8 = [4 x i8] c"8E1\00"
@.str.9 = [69 x i8] c"Usage: %s <device> <baud> <frame>\0AExample: %s /dev/ttyS0 9600 8N1\0A\00"
@.str.10 = [21 x i8] c"Unknown baudrate %d\0A\00"
@.str.11 = [25 x i8] c"Unknown frame format %s\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@.str.12 = [5 x i8] c"open\00"
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
@.str.13 = [10 x i8] c"tcsetattr\00"
@.str.14 = [39 x i8] c"using %s with baud 0x%X and flags 0%o\0A\00"
@.str.15 = [8 x i8] c"fd read\00"
@.str.16 = [13 x i8] c"0x%X\09b%s\09%c\0A\00"
@.str.17 = [11 x i8] c"stdin read\00"
@.str.18 = [9 x i8] c"fd write\00"
@.str.19 = [11 x i8] c"error: %d\0A\00"
@errno = global i32 0
@.str.20 = [5 x i8] c"read\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.termios
%15 = alloca [9 x %struct.baud]
%16 = alloca [9 x %struct.frame]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %15, i64 0, i64 0
%18 = getelementptr inbounds %struct.baud, %struct.baud* %17, i32 0, i32 0
%19 = load i32, i32* @B300
store i32 %19, i32* %18
%20 = getelementptr inbounds %struct.baud, %struct.baud* %17, i32 0, i32 1
store i32 300, i32* %20
%21 = getelementptr inbounds %struct.baud, %struct.baud* %17, i64 1
%22 = getelementptr inbounds %struct.baud, %struct.baud* %21, i32 0, i32 0
%23 = load i32, i32* @B600
store i32 %23, i32* %22
%24 = getelementptr inbounds %struct.baud, %struct.baud* %21, i32 0, i32 1
store i32 600, i32* %24
%25 = getelementptr inbounds %struct.baud, %struct.baud* %21, i64 1
%26 = getelementptr inbounds %struct.baud, %struct.baud* %25, i32 0, i32 0
%27 = load i32, i32* @B1200
store i32 %27, i32* %26
%28 = getelementptr inbounds %struct.baud, %struct.baud* %25, i32 0, i32 1
store i32 1200, i32* %28
%29 = getelementptr inbounds %struct.baud, %struct.baud* %25, i64 1
%30 = getelementptr inbounds %struct.baud, %struct.baud* %29, i32 0, i32 0
%31 = load i32, i32* @B1800
store i32 %31, i32* %30
%32 = getelementptr inbounds %struct.baud, %struct.baud* %29, i32 0, i32 1
store i32 1800, i32* %32
%33 = getelementptr inbounds %struct.baud, %struct.baud* %29, i64 1
%34 = getelementptr inbounds %struct.baud, %struct.baud* %33, i32 0, i32 0
%35 = load i32, i32* @B2400
store i32 %35, i32* %34
%36 = getelementptr inbounds %struct.baud, %struct.baud* %33, i32 0, i32 1
store i32 2400, i32* %36
%37 = getelementptr inbounds %struct.baud, %struct.baud* %33, i64 1
%38 = getelementptr inbounds %struct.baud, %struct.baud* %37, i32 0, i32 0
%39 = load i32, i32* @B4800
store i32 %39, i32* %38
%40 = getelementptr inbounds %struct.baud, %struct.baud* %37, i32 0, i32 1
store i32 4800, i32* %40
%41 = getelementptr inbounds %struct.baud, %struct.baud* %37, i64 1
%42 = getelementptr inbounds %struct.baud, %struct.baud* %41, i32 0, i32 0
%43 = load i32, i32* @B9600
store i32 %43, i32* %42
%44 = getelementptr inbounds %struct.baud, %struct.baud* %41, i32 0, i32 1
store i32 9600, i32* %44
%45 = getelementptr inbounds %struct.baud, %struct.baud* %41, i64 1
%46 = getelementptr inbounds %struct.baud, %struct.baud* %45, i32 0, i32 0
%47 = load i32, i32* @B19200
store i32 %47, i32* %46
%48 = getelementptr inbounds %struct.baud, %struct.baud* %45, i32 0, i32 1
store i32 19200, i32* %48
%49 = getelementptr inbounds %struct.baud, %struct.baud* %45, i64 1
%50 = getelementptr inbounds %struct.baud, %struct.baud* %49, i32 0, i32 0
%51 = load i32, i32* @B38400
store i32 %51, i32* %50
%52 = getelementptr inbounds %struct.baud, %struct.baud* %49, i32 0, i32 1
store i32 38400, i32* %52
%53 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %16, i64 0, i64 0
%54 = getelementptr inbounds %struct.frame, %struct.frame* %53, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %54
%55 = getelementptr inbounds %struct.frame, %struct.frame* %53, i32 0, i32 1
%56 = load i32, i32* @CS7
store i32 %56, i32* %55
%57 = getelementptr inbounds %struct.frame, %struct.frame* %53, i64 1
%58 = getelementptr inbounds %struct.frame, %struct.frame* %57, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %58
%59 = getelementptr inbounds %struct.frame, %struct.frame* %57, i32 0, i32 1
%60 = load i32, i32* @CS7
%61 = load i32, i32* @CSTOPB
%62 = or i32 %60, %61
store i32 %62, i32* %59
%63 = getelementptr inbounds %struct.frame, %struct.frame* %57, i64 1
%64 = getelementptr inbounds %struct.frame, %struct.frame* %63, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %64
%65 = getelementptr inbounds %struct.frame, %struct.frame* %63, i32 0, i32 1
%66 = load i32, i32* @CS7
%67 = load i32, i32* @PARENB
%68 = or i32 %66, %67
%69 = load i32, i32* @PARODD
%70 = or i32 %68, %69
store i32 %70, i32* %65
%71 = getelementptr inbounds %struct.frame, %struct.frame* %63, i64 1
%72 = getelementptr inbounds %struct.frame, %struct.frame* %71, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %72
%73 = getelementptr inbounds %struct.frame, %struct.frame* %71, i32 0, i32 1
%74 = load i32, i32* @CS7
%75 = load i32, i32* @PARENB
%76 = or i32 %74, %75
%77 = load i32, i32* @PARODD
%78 = or i32 %76, %77
%79 = load i32, i32* @CSTOPB
%80 = or i32 %78, %79
store i32 %80, i32* %73
%81 = getelementptr inbounds %struct.frame, %struct.frame* %71, i64 1
%82 = getelementptr inbounds %struct.frame, %struct.frame* %81, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %82
%83 = getelementptr inbounds %struct.frame, %struct.frame* %81, i32 0, i32 1
%84 = load i32, i32* @CS7
%85 = load i32, i32* @PARENB
%86 = or i32 %84, %85
store i32 %86, i32* %83
%87 = getelementptr inbounds %struct.frame, %struct.frame* %81, i64 1
%88 = getelementptr inbounds %struct.frame, %struct.frame* %87, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %88
%89 = getelementptr inbounds %struct.frame, %struct.frame* %87, i32 0, i32 1
%90 = load i32, i32* @CS7
%91 = load i32, i32* @PARENB
%92 = or i32 %90, %91
%93 = load i32, i32* @CSTOPB
%94 = or i32 %92, %93
store i32 %94, i32* %89
%95 = getelementptr inbounds %struct.frame, %struct.frame* %87, i64 1
%96 = getelementptr inbounds %struct.frame, %struct.frame* %95, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %96
%97 = getelementptr inbounds %struct.frame, %struct.frame* %95, i32 0, i32 1
%98 = load i32, i32* @CS8
store i32 %98, i32* %97
%99 = getelementptr inbounds %struct.frame, %struct.frame* %95, i64 1
%100 = getelementptr inbounds %struct.frame, %struct.frame* %99, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %100
%101 = getelementptr inbounds %struct.frame, %struct.frame* %99, i32 0, i32 1
%102 = load i32, i32* @CS8
%103 = load i32, i32* @PARENB
%104 = or i32 %102, %103
%105 = load i32, i32* @PARODD
%106 = or i32 %104, %105
store i32 %106, i32* %101
%107 = getelementptr inbounds %struct.frame, %struct.frame* %99, i64 1
%108 = getelementptr inbounds %struct.frame, %struct.frame* %107, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8** %108
%109 = getelementptr inbounds %struct.frame, %struct.frame* %107, i32 0, i32 1
%110 = load i32, i32* @CS8
%111 = load i32, i32* @PARENB
%112 = or i32 %110, %111
store i32 %112, i32* %109
%113 = load i32, i32* %4
%114 = icmp slt i32 %113, 4
br i1 %114, label %115, label %123
115: ; preds = %2
%116 = load i8**, i8*** %5
%117 = getelementptr inbounds i8*, i8** %116, i64 0
%118 = load i8*, i8** %117
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 0
%121 = load i8*, i8** %120
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.9, i64 0, i64 0), i8* %118, i8* %121)
store i32 0, i32* %3
br label %319
123: ; preds = %2
%124 = load i8**, i8*** %5
%125 = getelementptr inbounds i8*, i8** %124, i64 2
%126 = load i8*, i8** %125
%127 = call i32 @atoi(i8* %126)
store i32 %127, i32* %10
store i32 9, i32* %8
store i32 0, i32* %7
br label %128
128: ; preds = %142, %123
%129 = load i32, i32* %7
%130 = load i32, i32* %8
%131 = icmp slt i32 %129, %130
br i1 %131, label %132, label %145
132: ; preds = %128
%133 = load i32, i32* %10
%134 = load i32, i32* %7
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %15, i64 0, i64 %135
%137 = getelementptr inbounds %struct.baud, %struct.baud* %136, i32 0, i32 1
%138 = load i32, i32* %137
%139 = icmp eq i32 %133, %138
br i1 %139, label %140, label %141
140: ; preds = %132
br label %145
141: ; preds = %132
br label %142
142: ; preds = %141
%143 = load i32, i32* %7
%144 = add nsw i32 %143, 1
store i32 %144, i32* %7
br label %128
145: ; preds = %140, %128
%146 = load i32, i32* %7
%147 = load i32, i32* %8
%148 = icmp slt i32 %146, %147
br i1 %148, label %149, label %155
149: ; preds = %145
%150 = load i32, i32* %7
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %15, i64 0, i64 %151
%153 = getelementptr inbounds %struct.baud, %struct.baud* %152, i32 0, i32 0
%154 = load i32, i32* %153
store i32 %154, i32* %10
br label %158
155: ; preds = %145
%156 = load i32, i32* %10
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %156)
store i32 -1, i32* %3
br label %319
158: ; preds = %149
store i32 9, i32* %8
store i32 0, i32* %7
br label %159
159: ; preds = %176, %158
%160 = load i32, i32* %7
%161 = load i32, i32* %8
%162 = icmp slt i32 %160, %161
br i1 %162, label %163, label %179
163: ; preds = %159
%164 = load i8**, i8*** %5
%165 = getelementptr inbounds i8*, i8** %164, i64 3
%166 = load i8*, i8** %165
%167 = load i32, i32* %7
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %16, i64 0, i64 %168
%170 = getelementptr inbounds %struct.frame, %struct.frame* %169, i32 0, i32 0
%171 = load i8*, i8** %170
%172 = call i32 @strncmp(i8* %166, i8* %171, i32 3)
%173 = icmp ne i32 %172, 0
br i1 %173, label %175, label %174
174: ; preds = %163
br label %179
175: ; preds = %163
br label %176
176: ; preds = %175
%177 = load i32, i32* %7
%178 = add nsw i32 %177, 1
store i32 %178, i32* %7
br label %159
179: ; preds = %174, %159
%180 = load i32, i32* %7
%181 = load i32, i32* %8
%182 = icmp slt i32 %180, %181
br i1 %182, label %183, label %189
183: ; preds = %179
%184 = load i32, i32* %7
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %16, i64 0, i64 %185
%187 = getelementptr inbounds %struct.frame, %struct.frame* %186, i32 0, i32 1
%188 = load i32, i32* %187
store i32 %188, i32* %11
br label %194
189: ; preds = %179
%190 = load i8**, i8*** %5
%191 = getelementptr inbounds i8*, i8** %190, i64 2
%192 = load i8*, i8** %191
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %192)
store i32 -1, i32* %3
br label %319
194: ; preds = %183
%195 = load i8**, i8*** %5
%196 = getelementptr inbounds i8*, i8** %195, i64 1
%197 = load i8*, i8** %196
%198 = load i32, i32* @O_RDWR
%199 = load i32, i32* @O_NOCTTY
%200 = or i32 %198, %199
%201 = load i32, i32* @O_NONBLOCK
%202 = or i32 %200, %201
%203 = call i32 @open(i8* %197, i32 %202)
store i32 %203, i32* %9
%204 = icmp eq i32 %203, -1
br i1 %204, label %205, label %207
205: ; preds = %194
%206 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %3
br label %319
207: ; preds = %194
%208 = call i32 @bzero(%struct.termios* %14, i32 4)
%209 = load i32, i32* %10
%210 = load i32, i32* %11
%211 = or i32 %209, %210
%212 = load i32, i32* @CLOCAL
%213 = or i32 %211, %212
%214 = load i32, i32* @CREAD
%215 = or i32 %213, %214
%216 = getelementptr inbounds %struct.termios, %struct.termios* %14, i32 0, i32 0
store i32 %215, i32* %216
%217 = load i32, i32* %9
%218 = load i32, i32* @TCSANOW
%219 = call i32 @tcsetattr(i32 %217, i32 %218, %struct.termios* %14)
%220 = icmp eq i32 %219, -1
br i1 %220, label %221, label %225
221: ; preds = %207
%222 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0))
%223 = load i32, i32* %9
%224 = call i32 @close(i32 %223)
store i32 -1, i32* %3
br label %319
225: ; preds = %207
%226 = load i8**, i8*** %5
%227 = getelementptr inbounds i8*, i8** %226, i64 1
%228 = load i8*, i8** %227
%229 = load i32, i32* %10
%230 = load i32, i32* %11
%231 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i8* %228, i32 %229, i32 %230)
br label %232
232: ; preds = %305, %225
%233 = call i32 @FD_ZERO(i32* %12)
%234 = call i32 @FD_ZERO(i32* %13)
%235 = call i32 @FD_SET(i32 0, i32* %12)
%236 = load i32, i32* %9
%237 = call i32 @FD_SET(i32 %236, i32* %12)
%238 = load i32, i32* %9
%239 = call i32 @FD_SET(i32 %238, i32* %13)
%240 = load i32, i32* %9
%241 = add nsw i32 %240, 1
%242 = call i32 @select(i32 %241, i32* %12, i32* %13, i32* null, i32* null)
store i32 %242, i32* %8
%243 = load i32, i32* %8
%244 = icmp eq i32 %243, 0
br i1 %244, label %245, label %246
245: ; preds = %232
br label %305
246: ; preds = %232
%247 = load i32, i32* %8
%248 = icmp eq i32 %247, -1
br i1 %248, label %249, label %250
249: ; preds = %246
br label %309
250: ; preds = %246
%251 = load i32, i32* %9
%252 = call i64 @FD_ISSET(i32 %251, i32* %12)
%253 = icmp ne i64 %252, 0
br i1 %253, label %254, label %284
254: ; preds = %250
%255 = load i32, i32* %9
%256 = call i32 @read(i32 %255, i8* %6, i32 1)
store i32 %256, i32* %8
%257 = icmp eq i32 %256, -1
br i1 %257, label %258, label %260
258: ; preds = %254
%259 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0))
br label %305
260: ; preds = %254
%261 = load i8, i8* %6
%262 = zext i8 %261 to i32
%263 = load i8, i8* %6
%264 = call i8* @bin(i8 zeroext %263)
%265 = load i8, i8* %6
%266 = zext i8 %265 to i32
%267 = icmp sge i32 %266, 32
br i1 %267, label %268, label %275
268: ; preds = %260
%269 = load i8, i8* %6
%270 = zext i8 %269 to i32
%271 = icmp slt i32 %270, 128
br i1 %271, label %272, label %275
272: ; preds = %268
%273 = load i8, i8* %6
%274 = zext i8 %273 to i32
br label %276
275: ; preds = %268, %260
br label %276
276: ; preds = %275, %272
%277 = phi i32 [ %274, %272 ], [ 46, %275 ]
%278 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i32 %262, i8* %264, i32 %277)
%279 = load i8, i8* %6
%280 = zext i8 %279 to i32
%281 = icmp eq i32 %280, 113
br i1 %281, label %282, label %283
282: ; preds = %276
br label %309
283: ; preds = %276
br label %284
284: ; preds = %283, %250
%285 = call i64 @FD_ISSET(i32 0, i32* %12)
%286 = icmp ne i64 %285, 0
br i1 %286, label %287, label %304
287: ; preds = %284
%288 = call i32 @read(i32 0, i8* %6, i32 1)
store i32 %288, i32* %8
%289 = icmp eq i32 %288, -1
br i1 %289, label %290, label %292
290: ; preds = %287
%291 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0))
br label %305
292: ; preds = %287
%293 = load i8, i8* %6
%294 = zext i8 %293 to i32
switch i32 %294, label %297 [
i32 46, label %295
i32 59, label %296
]
295: ; preds = %292
store i8 1, i8* %6
br label %297
296: ; preds = %292
store i8 13, i8* %6
br label %297
297: ; preds = %292, %296, %295
%298 = load i32, i32* %9
%299 = call i32 @write(i32 %298, i8* %6, i32 1)
store i32 %299, i32* %8
%300 = icmp eq i32 %299, -1
br i1 %300, label %301, label %303
301: ; preds = %297
%302 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0))
br label %305
303: ; preds = %297
br label %304
304: ; preds = %303, %284
br label %305
305: ; preds = %304, %301, %290, %258, %245
%306 = load i8, i8* %6
%307 = zext i8 %306 to i32
%308 = icmp ne i32 %307, 113
br i1 %308, label %232, label %309
309: ; preds = %305, %282, %249
%310 = load i32, i32* @errno
%311 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i64 0, i64 0), i32 %310)
%312 = load i32, i32* %8
%313 = icmp eq i32 %312, -1
br i1 %313, label %314, label %316
314: ; preds = %309
%315 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0))
br label %316
316: ; preds = %314, %309
%317 = load i32, i32* %9
%318 = call i32 @close(i32 %317)
store i32 0, i32* %3
br label %319
319: ; preds = %316, %221, %205, %189, %155, %115
%320 = load i32, i32* %3
ret i32 %320
}

LLVM IR (-O2):
%struct.termios = type { i32 }
%struct.baud = type { i32, i32 }
%struct.frame = type { i8*, i32 }
@B300 = global i32 0
@B600 = global i32 0
@B1200 = global i32 0
@B1800 = global i32 0
@B2400 = global i32 0
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@.str = [4 x i8] c"7N1\00"
@CS7 = global i32 0
@.str.1 = [4 x i8] c"7N2\00"
@CSTOPB = global i32 0
@.str.2 = [4 x i8] c"7O1\00"
@PARENB = global i32 0
@PARODD = global i32 0
@.str.3 = [4 x i8] c"7O2\00"
@.str.4 = [4 x i8] c"7E1\00"
@.str.5 = [4 x i8] c"7E2\00"
@.str.6 = [4 x i8] c"8N1\00"
@CS8 = global i32 0
@.str.7 = [4 x i8] c"8O1\00"
@.str.8 = [4 x i8] c"8E1\00"
@.str.9 = [69 x i8] c"Usage: %s <device> <baud> <frame>\0AExample: %s /dev/ttyS0 9600 8N1\0A\00"
@.str.10 = [21 x i8] c"Unknown baudrate %d\0A\00"
@.str.11 = [25 x i8] c"Unknown frame format %s\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@.str.12 = [5 x i8] c"open\00"
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
@.str.13 = [10 x i8] c"tcsetattr\00"
@.str.14 = [39 x i8] c"using %s with baud 0x%X and flags 0%o\0A\00"
@.str.15 = [8 x i8] c"fd read\00"
@.str.16 = [13 x i8] c"0x%X\09b%s\09%c\0A\00"
@.str.17 = [11 x i8] c"stdin read\00"
@.str.18 = [9 x i8] c"fd write\00"
@.str.19 = [11 x i8] c"error: %d\0A\00"
@errno = global i32 0
@.str.20 = [5 x i8] c"read\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.termios
%7 = alloca [9 x %struct.baud]
%8 = alloca [9 x %struct.frame]
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast %struct.termios* %6 to i8*
%12 = bitcast [9 x %struct.baud]* %7 to i8*
%13 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 0, i32 0
%14 = load i32, i32* @B300
store i32 %14, i32* %13
%15 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 0, i32 1
store i32 300, i32* %15
%16 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 1, i32 0
%17 = load i32, i32* @B600
store i32 %17, i32* %16
%18 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 1, i32 1
store i32 600, i32* %18
%19 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 2, i32 0
%20 = load i32, i32* @B1200
store i32 %20, i32* %19
%21 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 2, i32 1
store i32 1200, i32* %21
%22 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 3, i32 0
%23 = load i32, i32* @B1800
store i32 %23, i32* %22
%24 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 3, i32 1
store i32 1800, i32* %24
%25 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 4, i32 0
%26 = load i32, i32* @B2400
store i32 %26, i32* %25
%27 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 4, i32 1
store i32 2400, i32* %27
%28 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 5, i32 0
%29 = load i32, i32* @B4800
store i32 %29, i32* %28
%30 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 5, i32 1
store i32 4800, i32* %30
%31 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 6, i32 0
%32 = load i32, i32* @B9600
store i32 %32, i32* %31
%33 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 6, i32 1
store i32 9600, i32* %33
%34 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 7, i32 0
%35 = load i32, i32* @B19200
store i32 %35, i32* %34
%36 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 7, i32 1
store i32 19200, i32* %36
%37 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 8, i32 0
%38 = load i32, i32* @B38400
store i32 %38, i32* %37
%39 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 8, i32 1
store i32 38400, i32* %39
%40 = bitcast [9 x %struct.frame]* %8 to i8*
%41 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %41
%42 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 0, i32 1
%43 = load i32, i32* @CS7
store i32 %43, i32* %42
%44 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %44
%45 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 1, i32 1
%46 = load i32, i32* @CSTOPB
%47 = or i32 %46, %43
store i32 %47, i32* %45
%48 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %48
%49 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 2, i32 1
%50 = load i32, i32* @PARENB
%51 = or i32 %50, %43
%52 = load i32, i32* @PARODD
%53 = or i32 %51, %52
store i32 %53, i32* %49
%54 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 3, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %54
%55 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 3, i32 1
%56 = or i32 %53, %46
store i32 %56, i32* %55
%57 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 4, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %57
%58 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 4, i32 1
store i32 %51, i32* %58
%59 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 5, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %59
%60 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 5, i32 1
%61 = or i32 %51, %46
store i32 %61, i32* %60
%62 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 6, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %62
%63 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 6, i32 1
%64 = load i32, i32* @CS8
store i32 %64, i32* %63
%65 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 7, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %65
%66 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 7, i32 1
%67 = or i32 %64, %50
%68 = or i32 %67, %52
store i32 %68, i32* %66
%69 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 8, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8** %69
%70 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 8, i32 1
store i32 %67, i32* %70
%71 = icmp slt i32 %0, 4
br i1 %71, label %72, label %75
72: ; preds = %2
%73 = load i8*, i8** %1
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.9, i64 0, i64 0), i8* %73, i8* %73)
br label %221
75: ; preds = %2
%76 = getelementptr inbounds i8*, i8** %1, i64 2
%77 = load i8*, i8** %76
%78 = tail call i32 @atoi(i8* %77)
switch i32 %78, label %79 [
i32 300, label %89
i32 600, label %81
i32 1200, label %82
i32 1800, label %83
i32 2400, label %84
i32 4800, label %85
i32 9600, label %86
i32 19200, label %87
i32 38400, label %88
]
79: ; preds = %75
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %78)
br label %221
81: ; preds = %75
br label %89
82: ; preds = %75
br label %89
83: ; preds = %75
br label %89
84: ; preds = %75
br label %89
85: ; preds = %75
br label %89
86: ; preds = %75
br label %89
87: ; preds = %75
br label %89
88: ; preds = %75
br label %89
89: ; preds = %75, %88, %87, %86, %85, %84, %83, %82, %81
%90 = phi i64 [ 0, %75 ], [ 1, %81 ], [ 2, %82 ], [ 3, %83 ], [ 4, %84 ], [ 5, %85 ], [ 6, %86 ], [ 7, %87 ], [ 8, %88 ]
%91 = getelementptr inbounds [9 x %struct.baud], [9 x %struct.baud]* %7, i64 0, i64 %90, i32 0
%92 = load i32, i32* %91
%93 = getelementptr inbounds i8*, i8** %1, i64 3
%94 = load i8*, i8** %93
%95 = tail call i32 @strncmp(i8* %94, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%96 = icmp eq i32 %95, 0
br i1 %96, label %132, label %97
97: ; preds = %89
%98 = load i8*, i8** %93
%99 = tail call i32 @strncmp(i8* %98, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%100 = icmp eq i32 %99, 0
br i1 %100, label %132, label %101
101: ; preds = %97
%102 = load i8*, i8** %93
%103 = tail call i32 @strncmp(i8* %102, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%104 = icmp eq i32 %103, 0
br i1 %104, label %132, label %105
105: ; preds = %101
%106 = load i8*, i8** %93
%107 = tail call i32 @strncmp(i8* %106, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%108 = icmp eq i32 %107, 0
br i1 %108, label %132, label %109
109: ; preds = %105
%110 = load i8*, i8** %93
%111 = tail call i32 @strncmp(i8* %110, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%112 = icmp eq i32 %111, 0
br i1 %112, label %132, label %113
113: ; preds = %109
%114 = load i8*, i8** %93
%115 = tail call i32 @strncmp(i8* %114, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%116 = icmp eq i32 %115, 0
br i1 %116, label %132, label %117
117: ; preds = %113
%118 = load i8*, i8** %93
%119 = tail call i32 @strncmp(i8* %118, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%120 = icmp eq i32 %119, 0
br i1 %120, label %132, label %121
121: ; preds = %117
%122 = load i8*, i8** %93
%123 = tail call i32 @strncmp(i8* %122, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%124 = icmp eq i32 %123, 0
br i1 %124, label %132, label %125
125: ; preds = %121
%126 = load i8*, i8** %93
%127 = tail call i32 @strncmp(i8* %126, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 3)
%128 = icmp eq i32 %127, 0
br i1 %128, label %132, label %129
129: ; preds = %125
%130 = load i8*, i8** %76
%131 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %130)
br label %221
132: ; preds = %125, %121, %117, %113, %109, %105, %101, %97, %89
%133 = phi i64 [ 0, %89 ], [ 1, %97 ], [ 2, %101 ], [ 3, %105 ], [ 4, %109 ], [ 5, %113 ], [ 6, %117 ], [ 7, %121 ], [ 8, %125 ]
%134 = getelementptr inbounds [9 x %struct.frame], [9 x %struct.frame]* %8, i64 0, i64 %133, i32 1
%135 = load i32, i32* %134
%136 = getelementptr inbounds i8*, i8** %1, i64 1
%137 = load i8*, i8** %136
%138 = load i32, i32* @O_RDWR
%139 = load i32, i32* @O_NOCTTY
%140 = or i32 %139, %138
%141 = load i32, i32* @O_NONBLOCK
%142 = or i32 %140, %141
%143 = tail call i32 @open(i8* %137, i32 %142)
%144 = icmp eq i32 %143, -1
br i1 %144, label %145, label %147
145: ; preds = %132
%146 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %221
147: ; preds = %132
%148 = or i32 %135, %92
%149 = load i32, i32* @CLOCAL
%150 = or i32 %148, %149
%151 = load i32, i32* @CREAD
%152 = or i32 %150, %151
%153 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 0
store i32 %152, i32* %153
%154 = load i32, i32* @TCSANOW
%155 = call i32 @tcsetattr(i32 %143, i32 %154, %struct.termios* %6)
%156 = icmp eq i32 %155, -1
br i1 %156, label %157, label %160
157: ; preds = %147
%158 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0))
%159 = call i32 @close(i32 %143)
br label %221
160: ; preds = %147
%161 = load i8*, i8** %136
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i8* %161, i32 %92, i32 %135)
%163 = add nuw nsw i32 %143, 1
br label %164
164: ; preds = %209, %160
%165 = call i32 @FD_ZERO(i32* %4)
%166 = call i32 @FD_ZERO(i32* %5)
%167 = call i32 @FD_SET(i32 0, i32* %4)
%168 = call i32 @FD_SET(i32 %143, i32* %4)
%169 = call i32 @FD_SET(i32 %143, i32* %5)
%170 = call i32 @select(i32 %163, i32* %4, i32* %5, i32* null, i32* null)
switch i32 %170, label %174 [
i32 0, label %209
i32 -1, label %171
]
171: ; preds = %164
%172 = load i32, i32* @errno
%173 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i64 0, i64 0), i32 %172)
br label %217
174: ; preds = %164
%175 = call i64 @FD_ISSET(i32 %143, i32* %4)
%176 = icmp eq i64 %175, 0
br i1 %176, label %192, label %177
177: ; preds = %174
%178 = call i32 @read(i32 %143, i8* %3, i32 1)
%179 = icmp eq i32 %178, -1
br i1 %179, label %206, label %180
180: ; preds = %177
%181 = load i8, i8* %3
%182 = zext i8 %181 to i32
%183 = call i8* @bin(i8 zeroext %181)
%184 = icmp sgt i8 %181, 31
%185 = select i1 %184, i8 %181, i8 46
%186 = zext i8 %185 to i32
%187 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i32 %182, i8* %183, i32 %186)
%188 = icmp eq i8 %181, 113
br i1 %188, label %189, label %192
189: ; preds = %180
%190 = load i32, i32* @errno
%191 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i64 0, i64 0), i32 %190)
br label %219
192: ; preds = %180, %174
%193 = phi i32 [ %178, %180 ], [ %170, %174 ]
%194 = call i64 @FD_ISSET(i32 0, i32* %4)
%195 = icmp eq i64 %194, 0
br i1 %195, label %209, label %196
196: ; preds = %192
%197 = call i32 @read(i32 0, i8* %3, i32 1)
%198 = icmp eq i32 %197, -1
br i1 %198, label %206, label %199
199: ; preds = %196
%200 = load i8, i8* %3
switch i8 %200, label %203 [
i8 46, label %201
i8 59, label %202
]
201: ; preds = %199
store i8 1, i8* %3
br label %203
202: ; preds = %199
store i8 13, i8* %3
br label %203
203: ; preds = %199, %202, %201
%204 = call i32 @write(i32 %143, i8* %3, i32 1)
%205 = icmp eq i32 %204, -1
br i1 %205, label %206, label %209
206: ; preds = %203, %196, %177
%207 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), %177 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0), %196 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0), %203 ]
%208 = call i32 @perror(i8* %207)
br label %209
209: ; preds = %206, %164, %192, %203
%210 = phi i32 [ %170, %164 ], [ %204, %203 ], [ %193, %192 ], [ -1, %206 ]
%211 = load i8, i8* %3
%212 = icmp eq i8 %211, 113
br i1 %212, label %213, label %164
213: ; preds = %209
%214 = load i32, i32* @errno
%215 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i64 0, i64 0), i32 %214)
%216 = icmp eq i32 %210, -1
br i1 %216, label %217, label %219
217: ; preds = %171, %213
%218 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0))
br label %219
219: ; preds = %189, %217, %213
%220 = call i32 @close(i32 %143)
br label %221
221: ; preds = %219, %157, %145, %129, %79, %72
%222 = phi i32 [ 0, %72 ], [ -1, %145 ], [ -1, %157 ], [ 0, %219 ], [ -1, %129 ], [ -1, %79 ]
ret i32 %222
}