#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 termios {
  int c_cflag;
  int c_lflag;
  int c_iflag;
  int c_oflag;
  int *c_cc;
};
struct pollfd {
  int fd;
  int /*<<< orphan*/ events;
};
typedef int /*<<< orphan*/ speed_t;
typedef int /*<<< orphan*/ key;
typedef int /*<<< orphan*/ data;
typedef int /*<<< orphan*/ baudrate;

/* Variables and functions */
int /*<<< orphan*/ B115200;
int /*<<< orphan*/ B19200;
int /*<<< orphan*/ B230400;
int /*<<< orphan*/ B38400;
int /*<<< orphan*/ B57600;
int /*<<< orphan*/ B9600;
int CLOCAL;
int CREAD;
int CS8;
int CSIZE;
int CSTOPB;
scalar_t__ EAGAIN;
int ECHO;
int ECHOE;
scalar_t__ EINVAL;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int ICANON;
int ICRNL;
int INLCR;
int ISIG;
int IXANY;
int IXOFF;
int IXON;
int OCRNL;
scalar_t__ ONLCR;
int OPOST;
int O_CLOEXEC;
int O_NOCTTY;
int O_NONBLOCK;
int O_RDWR;
int PARENB;
int /*<<< orphan*/ POLLIN;
int /*<<< orphan*/ TCSANOW;
size_t VEOF;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int fcntl(int /*<<< orphan*/, int /*<<< orphan*/, ...);
int open(char const *, int);
int /*<<< orphan*/ perror(char *);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
scalar_t__ strcmp(char const *, char const *);
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, const char *argv[]) {
  int fd;
  char key[255];
  char data[255];
  size_t bi;
  struct termios old_stdin_tconf;
  struct termios saved_options;
  struct termios options;
  struct pollfd fds;
  struct {
    speed_t speed;
    const char *name;
  } baudrate[] = {{B9600, "9600"},   {B19200, "19200"},   {B38400, "38400"},
                  {B57600, "57600"}, {B115200, "115200"}, {B230400, "230400"}};
  if (argc != 4 || strcmp(argv[3], "8N1")) {
  USAGE:
    printf("Usage: %s /dev/ttyXXX <baudrate> 8N1\n", argv[0]);
    exit(1);
  }
  fd = open(argv[1], O_RDWR | O_NOCTTY | O_NONBLOCK | O_CLOEXEC);
  if (fd == -1) {
    perror("open");
    exit(1);
  }
  if (tcgetattr(0, &old_stdin_tconf)) {
    perror("tcgetattr");
    exit(1);
  }
  if (tcgetattr(fd, &saved_options)) {
    perror("tcgetattr");
    exit(1);
  }
  for (bi = 0; bi < sizeof(baudrate) / sizeof(baudrate[0]); ++bi) {
    if (strcmp(baudrate[bi].name, argv[2]) == 0)
      break;
  }
  if (bi == sizeof(baudrate) / sizeof(baudrate[0])) {
    errno = EINVAL;
    perror("Unsupported baudrate");
    printf("Supported baudrates:");
    for (bi = 0; bi < sizeof(baudrate) / sizeof(baudrate[0]); ++bi) {
      printf(" %s", baudrate[bi].name);
    }
    printf("\n");
    exit(1);
  }
  options = saved_options;
  options.c_cflag |= (CLOCAL | CREAD);
  options.c_lflag &= ~(ICANON | ECHO | ECHOE);
  options.c_iflag &= ~(IXON | IXOFF | IXANY);
  options.c_iflag &= ~(ICRNL);
  options.c_oflag &= ~(OPOST | OCRNL);
  cfsetispeed(&options, baudrate[bi].speed);
  cfsetospeed(&options, baudrate[bi].speed);
  if (0 == strcmp(argv[3], "8N1")) {
    options.c_cflag |= (CLOCAL | CREAD);
    options.c_cflag &= ~PARENB;
    options.c_cflag &= ~CSTOPB;
    options.c_cflag &= ~CSIZE;
    options.c_cflag |= CS8;
  } else {
    errno = EINVAL;
    perror("Unsupported format");
    goto USAGE;
  }
  if (tcsetattr(fd, TCSANOW, &options)) {
    perror("tcsetattr");
    exit(1);
  }
  {
    struct termios tconf = old_stdin_tconf;
    int fl = fcntl(0, F_GETFL);
    fcntl(0, F_SETFL, (fl != -1 ? fl : 0) | O_NONBLOCK);
    tconf.c_iflag &= (unsigned)~(IXON | ICRNL | INLCR);
    tconf.c_oflag &= (unsigned)~(OCRNL);
    tconf.c_oflag |= (unsigned)(ONLCR);
    tconf.c_lflag &= (unsigned)~(ICANON | ECHO | ISIG);
    tconf.c_cc[VMIN] = 1;
    tconf.c_cc[VTIME] = 0;
    tcsetattr(0, TCSANOW, &tconf);
  }
  printf("Press <CTRL>-D to end program\n");
  fds.fd = fd;
  fds.events = POLLIN;
  for (;;) {
    if (1 == poll(&fds, 1, 100)) {
      int bytes = read(fd, data, sizeof(data));
      if (bytes == -1) {
        if (errno == EAGAIN)
          continue;
        perror("read");
        goto DONE;
      }
      write(1, data, bytes);
    }
    int nrkeys = read(0, key, sizeof(key));
    if (nrkeys > 0) {
      if (key[nrkeys - 1] == old_stdin_tconf.c_cc[VEOF]) {
        write(fd, key, nrkeys - 1);
        break;
      } else {
        write(fd, key, nrkeys);
      }
    }
  }
DONE:
  tcsetattr(0, TCSANOW, &old_stdin_tconf);
  tcsetattr(fd, TCSANOW, &saved_options);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x310,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2e0(%rbp)
lea    0xdf1(%rip),%rax
mov    %rax,-0x2d8(%rbp)
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2d0(%rbp)
lea    0xdd9(%rip),%rax
mov    %rax,-0x2c8(%rbp)
mov    0x2c76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c0(%rbp)
lea    0xdc2(%rip),%rax
mov    %rax,-0x2b8(%rbp)
mov    0x2cf1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2b0(%rbp)
lea    0xdab(%rip),%rax
mov    %rax,-0x2a8(%rbp)
mov    0x2c94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2a0(%rbp)
lea    0xd94(%rip),%rax
mov    %rax,-0x298(%rbp)
mov    0x2c47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x290(%rbp)
lea    0xd7e(%rip),%rax
mov    %rax,-0x288(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    22cf <main+0xef>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd65(%rip),%rsi
call   2090 <strcmp@plt>
cmp    $0x0,%rax
je     22f3 <main+0x113>
jmp    22d4 <main+0xf4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   2060 <printf@plt>
mov    $0x1,%edi
call   2100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2cd6(%rip),%rax
mov    (%rax),%esi
mov    0x2c25(%rip),%rax
or     (%rax),%esi
mov    0x2ca4(%rip),%rax
or     (%rax),%esi
mov    0x2bc3(%rip),%rax
or     (%rax),%esi
call   20d0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    2347 <main+0x167>
lea    0xd17(%rip),%rdi
call   20f0 <perror@plt>
mov    $0x1,%edi
call   2100 <exit@plt>
xor    %edi,%edi
lea    -0x240(%rbp),%rsi
call   20b0 <tcgetattr@plt>
cmp    $0x0,%rax
je     2375 <main+0x195>
lea    0xcee(%rip),%rdi
call   20f0 <perror@plt>
mov    $0x1,%edi
call   2100 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x258(%rbp),%rsi
call   20b0 <tcgetattr@plt>
cmp    $0x0,%rax
je     23a4 <main+0x1c4>
lea    0xcbf(%rip),%rdi
call   20f0 <perror@plt>
mov    $0x1,%edi
call   2100 <exit@plt>
movq   $0x0,-0x228(%rbp)
cmpq   $0x6,-0x228(%rbp)
06
jae    240e <main+0x22e>
mov    -0x228(%rbp),%rcx
lea    -0x2e0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   2090 <strcmp@plt>
cmp    $0x0,%rax
jne    23f2 <main+0x212>
jmp    240e <main+0x22e>
jmp    23f7 <main+0x217>
mov    -0x228(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x228(%rbp)
jmp    23af <main+0x1cf>
cmpq   $0x6,-0x228(%rbp)
06
jne    24b9 <main+0x2d9>
mov    0x2aed(%rip),%rax
mov    (%rax),%rcx
mov    0x2af3(%rip),%rax
mov    %rcx,(%rax)
lea    0xc27(%rip),%rdi
call   20f0 <perror@plt>
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   2060 <printf@plt>
movq   $0x0,-0x228(%rbp)
cmpq   $0x6,-0x228(%rbp)
06
jae    24a1 <main+0x2c1>
mov    -0x228(%rbp),%rcx
lea    -0x2e0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
lea    0xc05(%rip),%rdi
mov    $0x0,%al
call   2060 <printf@plt>
mov    -0x228(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x228(%rbp)
jmp    2455 <main+0x275>
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   2060 <printf@plt>
mov    $0x1,%edi
call   2100 <exit@plt>
mov    -0x258(%rbp),%rax
mov    %rax,-0x270(%rbp)
mov    -0x250(%rbp),%rax
mov    %rax,-0x268(%rbp)
mov    -0x248(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    0x29d6(%rip),%rax
mov    (%rax),%eax
mov    0x2a75(%rip),%rcx
or     (%rcx),%eax
or     -0x270(%rbp),%eax
mov    %eax,-0x270(%rbp)
mov    0x29e8(%rip),%rax
mov    (%rax),%eax
mov    0x2a7f(%rip),%rcx
or     (%rcx),%eax
mov    0x2a6e(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x26c(%rbp),%eax
mov    %eax,-0x26c(%rbp)
mov    0x2a76(%rip),%rax
mov    (%rax),%eax
mov    0x2a85(%rip),%rcx
or     (%rcx),%eax
mov    0x29f4(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x268(%rbp),%eax
mov    %eax,-0x268(%rbp)
mov    0x2a74(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x268(%rbp),%eax
mov    %eax,-0x268(%rbp)
mov    0x2a3c(%rip),%rax
mov    (%rax),%eax
mov    0x2a73(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x264(%rbp),%eax
mov    %eax,-0x264(%rbp)
mov    -0x228(%rbp),%rcx
lea    -0x2e0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%esi
lea    -0x270(%rbp),%rdi
call   20e0 <cfsetispeed@plt>
mov    -0x228(%rbp),%rcx
lea    -0x2e0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%esi
lea    -0x270(%rbp),%rdi
call   2050 <cfsetospeed@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xa42(%rip),%rsi
call   2090 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    2676 <main+0x496>
mov    0x28c3(%rip),%rax
mov    (%rax),%eax
mov    0x2962(%rip),%rcx
or     (%rcx),%eax
or     -0x270(%rbp),%eax
mov    %eax,-0x270(%rbp)
mov    0x2985(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x270(%rbp),%eax
mov    %eax,-0x270(%rbp)
mov    0x289d(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x270(%rbp),%eax
mov    %eax,-0x270(%rbp)
mov    0x2905(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x270(%rbp),%eax
mov    %eax,-0x270(%rbp)
mov    0x28fd(%rip),%rax
mov    (%rax),%eax
or     -0x270(%rbp),%eax
mov    %eax,-0x270(%rbp)
jmp    269b <main+0x4bb>
mov    0x2893(%rip),%rax
mov    (%rax),%rcx
mov    0x2899(%rip),%rax
mov    %rcx,(%rax)
lea    0x9fb(%rip),%rdi
call   20f0 <perror@plt>
jmp    22d4 <main+0xf4>
mov    -0x14(%rbp),%edi
mov    0x28f3(%rip),%rax
mov    (%rax),%esi
lea    -0x270(%rbp),%rdx
call   20c0 <tcsetattr@plt>
cmp    $0x0,%rax
je     26d3 <main+0x4f3>
lea    0x9db(%rip),%rdi
call   20f0 <perror@plt>
mov    $0x1,%edi
call   2100 <exit@plt>
mov    -0x240(%rbp),%rax
mov    %rax,-0x2f8(%rbp)
mov    -0x238(%rbp),%rax
mov    %rax,-0x2f0(%rbp)
mov    -0x230(%rbp),%rax
mov    %rax,-0x2e8(%rbp)
mov    0x2814(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
mov    $0x0,%al
call   2030 <fcntl@plt>
mov    %eax,-0x2fc(%rbp)
mov    0x280c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x308(%rbp)
cmpl   $0xffffffff,-0x2fc(%rbp)
je     2742 <main+0x562>
mov    -0x2fc(%rbp),%eax
mov    %eax,-0x30c(%rbp)
jmp    274f <main+0x56f>
xor    %eax,%eax
mov    %eax,-0x30c(%rbp)
jmp    274f <main+0x56f>
mov    -0x308(%rbp),%esi
mov    -0x30c(%rbp),%edx
mov    0x2856(%rip),%rax
or     (%rax),%edx
xor    %edi,%edi
mov    $0x0,%al
call   2030 <fcntl@plt>
mov    0x2834(%rip),%rax
mov    (%rax),%eax
mov    0x2853(%rip),%rcx
or     (%rcx),%eax
mov    0x2842(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x2f0(%rbp),%eax
mov    %eax,-0x2f0(%rbp)
mov    0x2852(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x2ec(%rbp),%eax
mov    %eax,-0x2ec(%rbp)
mov    0x274a(%rip),%rax
mov    (%rax),%rax
or     -0x2ec(%rbp),%eax
mov    %eax,-0x2ec(%rbp)
mov    0x2724(%rip),%rax
mov    (%rax),%eax
mov    0x27bb(%rip),%rcx
or     (%rcx),%eax
mov    0x27a2(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x2f4(%rbp),%eax
mov    %eax,-0x2f4(%rbp)
mov    -0x2e8(%rbp),%rax
mov    0x275b(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x2e8(%rbp),%rax
mov    0x26e3(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2772(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x2f8(%rbp),%rdx
call   20c0 <tcsetattr@plt>
lea    0x86c(%rip),%rdi
mov    $0x0,%al
call   2060 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x278(%rbp)
mov    0x271c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x274(%rbp)
lea    -0x278(%rbp),%rdi
mov    $0x1,%esi
mov    $0x64,%edx
call   20a0 <poll@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    28ef <main+0x70f>
mov    -0x14(%rbp),%edi
lea    -0x220(%rbp),%rsi
mov    $0xff,%edx
call   2080 <read@plt>
mov    %eax,-0x300(%rbp)
cmpl   $0xffffffff,-0x300(%rbp)
jne    28d8 <main+0x6f8>
mov    0x2671(%rip),%rax
mov    (%rax),%rax
mov    0x260f(%rip),%rcx
cmp    (%rcx),%rax
jne    28c7 <main+0x6e7>
jmp    285c <main+0x67c>
lea    0x7fa(%rip),%rdi
call   20f0 <perror@plt>
jmp    2983 <main+0x7a3>
lea    -0x220(%rbp),%rsi
mov    -0x300(%rbp),%edx
mov    $0x1,%edi
call   2040 <write@plt>
lea    -0x120(%rbp),%rsi
xor    %edi,%edi
mov    $0xff,%edx
call   2080 <read@plt>
mov    %eax,-0x304(%rbp)
cmpl   $0x0,-0x304(%rbp)
jle    2979 <main+0x799>
mov    -0x304(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x120(%rbp,%rax,1),%eax
ff
mov    -0x230(%rbp),%rcx
mov    0x2582(%rip),%rdx
mov    (%rdx),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    295f <main+0x77f>
mov    -0x14(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x304(%rbp),%edx
sub    $0x1,%edx
call   2040 <write@plt>
jmp    297e <main+0x79e>
mov    -0x14(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x304(%rbp),%edx
call   2040 <write@plt>
jmp    2979 <main+0x799>
jmp    285c <main+0x67c>
jmp    2983 <main+0x7a3>
mov    0x260e(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x240(%rbp),%rdx
call   20c0 <tcsetattr@plt>
mov    -0x14(%rbp),%edi
mov    0x25f4(%rip),%rax
mov    (%rax),%esi
lea    -0x258(%rbp),%rdx
call   20c0 <tcsetattr@plt>
mov    -0x14(%rbp),%edi
call   2070 <close@plt>
xor    %eax,%eax
add    $0x310,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2b8,%rsp
mov    %rsi,%r14
mov    0x2d5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rsp)
lea    0xdd8(%rip),%rax
mov    %rax,0x58(%rsp)
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x60(%rsp)
lea    0xdc4(%rip),%rax
mov    %rax,0x68(%rsp)
mov    0x2c63(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x70(%rsp)
lea    0xdb1(%rip),%rax
mov    %rax,0x78(%rsp)
mov    0x2ce2(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x80(%rsp)
lea    0xd9b(%rip),%rax
mov    %rax,0x88(%rsp)
mov    0x2c83(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x90(%rsp)
lea    0xd82(%rip),%rax
mov    %rax,0x98(%rsp)
mov    0x2c34(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xa0(%rsp)
lea    0xd6a(%rip),%rax
mov    %rax,0xa8(%rsp)
cmp    $0x4,%edi
jne    27f6 <main+0x5f6>
mov    0x18(%r14),%rdi
lea    0xd55(%rip),%rsi
call   20b0 <strcmp@plt>
test   %rax,%rax
jne    27f6 <main+0x5f6>
mov    0x2cf3(%rip),%rax
mov    0x2c44(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2cc1(%rip),%rax
or     (%rax),%esi
mov    0x8(%r14),%rdi
mov    0x2bdc(%rip),%rax
or     (%rax),%esi
call   20f0 <open@plt>
cmp    $0xffffffff,%eax
je     282b <main+0x62b>
mov    %eax,%r15d
lea    0x20(%rsp),%rsi
xor    %edi,%edi
call   20d0 <tcgetattr@plt>
test   %rax,%rax
jne    2822 <main+0x622>
lea    0x38(%rsp),%rsi
mov    %r15d,%edi
call   20d0 <tcgetattr@plt>
test   %rax,%rax
jne    2822 <main+0x622>
mov    0x10(%r14),%rsi
lea    0xcb3(%rip),%rdi
call   20b0 <strcmp@plt>
test   %rax,%rax
je     248c <main+0x28c>
mov    0x10(%r14),%rsi
lea    0xc9f(%rip),%rdi
call   20b0 <strcmp@plt>
test   %rax,%rax
je     2490 <main+0x290>
mov    0x10(%r14),%rsi
lea    0xc8c(%rip),%rdi
call   20b0 <strcmp@plt>
test   %rax,%rax
je     2497 <main+0x297>
mov    0x10(%r14),%rsi
lea    0xc79(%rip),%rdi
call   20b0 <strcmp@plt>
test   %rax,%rax
je     249e <main+0x29e>
mov    0x10(%r14),%rsi
lea    0xc66(%rip),%rdi
call   20b0 <strcmp@plt>
test   %rax,%rax
je     24a5 <main+0x2a5>
mov    0x10(%r14),%rsi
lea    0xc54(%rip),%rdi
call   20b0 <strcmp@plt>
mov    $0x5,%ecx
test   %rax,%rax
je     24aa <main+0x2aa>
mov    0x2b2c(%rip),%rax
mov    (%rax),%rax
mov    0x2b32(%rip),%rcx
mov    %rax,(%rcx)
lea    0xc66(%rip),%rdi
call   2110 <perror@plt>
lea    0xc6f(%rip),%rdi
xor    %eax,%eax
call   2080 <printf@plt>
lea    0xc76(%rip),%rbx
lea    0xbe7(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   2080 <printf@plt>
lea    0xbdb(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   2080 <printf@plt>
lea    0xbd0(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   2080 <printf@plt>
lea    0xbc5(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   2080 <printf@plt>
lea    0xbba(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   2080 <printf@plt>
lea    0xbb0(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   2080 <printf@plt>
mov    $0xa,%edi
call   2030 <putchar@plt>
mov    $0x1,%edi
call   2120 <exit@plt>
xor    %ecx,%ecx
jmp    24aa <main+0x2aa>
mov    $0x1,%ecx
jmp    24aa <main+0x2aa>
mov    $0x2,%ecx
jmp    24aa <main+0x2aa>
mov    $0x3,%ecx
jmp    24aa <main+0x2aa>
mov    $0x4,%ecx
movups 0x38(%rsp),%xmm0
movaps %xmm0,(%rsp)
mov    0x48(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0x29fc(%rip),%r12
mov    0x2a9d(%rip),%r13
mov    0x0(%r13),%eax
or     (%r12),%eax
or     %eax,(%rsp)
mov    0x2a13(%rip),%rdx
mov    0x2aac(%rip),%rax
mov    (%rax),%eax
or     (%rdx),%eax
mov    0x2a99(%rip),%rdx
or     (%rdx),%eax
not    %eax
and    %eax,0x4(%rsp)
mov    0x2aaa(%rip),%rdx
mov    0x2abb(%rip),%rax
mov    (%rax),%eax
or     (%rdx),%eax
mov    0x2a28(%rip),%rdx
or     (%rdx),%eax
mov    0x2ab7(%rip),%rdx
or     (%rdx),%eax
not    %eax
and    %eax,0x8(%rsp)
mov    0x2a88(%rip),%rax
mov    0x2ac1(%rip),%rdx
mov    (%rdx),%edx
or     (%rax),%edx
not    %edx
and    %edx,0xc(%rsp)
shl    $0x4,%rcx
mov    0x50(%rsp,%rcx,1),%ebx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
call   2100 <cfsetispeed@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   2070 <cfsetospeed@plt>
mov    0x18(%r14),%rdi
lea    0xac2(%rip),%rsi
call   20b0 <strcmp@plt>
test   %rax,%rax
jne    27d6 <main+0x5d6>
mov    0x0(%r13),%eax
or     (%r12),%eax
or     (%rsp),%eax
mov    0x2a1d(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2944(%rip),%rdx
or     (%rdx),%ecx
mov    0x29bb(%rip),%rdx
or     (%rdx),%ecx
not    %ecx
and    %eax,%ecx
mov    0x29be(%rip),%rax
or     (%rax),%ecx
mov    %ecx,(%rsp)
mov    0x29ea(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rsp,%rdx
mov    %r15d,%edi
call   20e0 <tcsetattr@plt>
test   %rax,%rax
jne    2834 <main+0x634>
mov    0x30(%rsp),%rax
mov    %rax,0xc0(%rsp)
movups 0x20(%rsp),%xmm0
movaps %xmm0,0xb0(%rsp)
mov    0x2932(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
xor    %edi,%edi
xor    %eax,%eax
call   2050 <fcntl@plt>
mov    0x292e(%rip),%rcx
mov    (%rcx),%esi
cmp    $0xffffffff,%eax
cmove  %ebx,%eax
mov    0x29af(%rip),%rcx
or     (%rcx),%eax
xor    %edi,%edi
mov    %eax,%edx
xor    %eax,%eax
call   2050 <fcntl@plt>
mov    0x29b3(%rip),%rax
mov    (%rax),%eax
mov    0x2982(%rip),%rcx
or     (%rcx),%eax
mov    0x2999(%rip),%rcx
or     (%rcx),%eax
not    %eax
and    %eax,0xb8(%rsp)
mov    0x29af(%rip),%rax
mov    (%rax),%eax
not    %eax
and    0xbc(%rsp),%eax
mov    0x28ad(%rip),%rcx
or     (%rcx),%eax
mov    0x2934(%rip),%rcx
mov    (%rcx),%ecx
mov    0x288b(%rip),%rdx
or     (%rdx),%ecx
mov    %eax,0xbc(%rsp)
mov    0x290b(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0xb4(%rsp)
mov    0xc0(%rsp),%rax
mov    0x28c9(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2858(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x0(%rbp),%esi
lea    0xb0(%rsp),%rbx
xor    %edi,%edi
mov    %rbx,%rdx
call   20e0 <tcsetattr@plt>
lea    0x9e8(%rip),%rdi
call   2040 <puts@plt>
mov    %r15d,0x18(%rsp)
mov    0x2899(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
lea    0x18(%rsp),%rbp
lea    0x1b0(%rsp),%r14
mov    0x27d7(%rip),%r13
mov    0x27c0(%rip),%r12
jmp    2710 <main+0x510>
mov    0x281f(%rip),%rax
mov    (%rax),%rax
cmp    0x0(%r13),%rax
jne    2811 <main+0x611>
xchg   %ax,%ax
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x64,%edx
call   20c0 <poll@plt>
cmp    $0x1,%eax
jne    274b <main+0x54b>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0xff,%edx
call   20a0 <read@plt>
cmp    $0xffffffff,%eax
je     26fa <main+0x4fa>
mov    $0x1,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   2060 <write@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
call   20a0 <read@plt>
test   %eax,%eax
jle    2710 <main+0x510>
lea    -0x1(%rax),%edx
movsbl 0xb0(%rsp,%rdx,1),%ecx
mov    0x30(%rsp),%rsi
mov    (%r12),%rdi
cmp    %ecx,(%rsi,%rdi,4)
je     2786 <main+0x586>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   2060 <write@plt>
jmp    2710 <main+0x510>
lea    0xb0(%rsp),%rsi
mov    %r15d,%edi
call   2060 <write@plt>
mov    0x27fb(%rip),%rbx
mov    (%rbx),%esi
lea    0x20(%rsp),%rdx
xor    %edi,%edi
call   20e0 <tcsetattr@plt>
mov    (%rbx),%esi
lea    0x38(%rsp),%rdx
mov    %r15d,%edi
call   20e0 <tcsetattr@plt>
mov    %r15d,%edi
call   2090 <close@plt>
xor    %eax,%eax
add    $0x2b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2733(%rip),%rax
mov    (%rax),%rax
mov    0x2739(%rip),%rcx
mov    %rax,(%rcx)
lea    0x89b(%rip),%rdi
call   2110 <perror@plt>
mov    (%r14),%rsi
lea    0x829(%rip),%rdi
xor    %eax,%eax
call   2080 <printf@plt>
mov    $0x1,%edi
call   2120 <exit@plt>
lea    0x891(%rip),%rdi
call   2110 <perror@plt>
jmp    2796 <main+0x596>
lea    0x82b(%rip),%rdi
jmp    283b <main+0x63b>
lea    0x81d(%rip),%rdi
jmp    283b <main+0x63b>
lea    0x864(%rip),%rdi
call   2110 <perror@plt>
mov    $0x1,%edi
call   2120 <exit@plt>

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i32, i32* }
%struct.pollfd = type { i32, i32 }
%struct.anon = type { i32, i8* }
@B9600 = global i32 0
@.str = [5 x i8] c"9600\00"
@B19200 = global i32 0
@.str.1 = [6 x i8] c"19200\00"
@B38400 = global i32 0
@.str.2 = [6 x i8] c"38400\00"
@B57600 = global i32 0
@.str.3 = [6 x i8] c"57600\00"
@B115200 = global i32 0
@.str.4 = [7 x i8] c"115200\00"
@B230400 = global i32 0
@.str.5 = [7 x i8] c"230400\00"
@.str.6 = [4 x i8] c"8N1\00"
@.str.7 = [38 x i8] c"Usage: %s /dev/ttyXXX <baudrate> 8N1\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@O_CLOEXEC = global i32 0
@.str.8 = [5 x i8] c"open\00"
@.str.9 = [10 x i8] c"tcgetattr\00"
@EINVAL = global i64 0
@errno = global i64 0
@.str.10 = [21 x i8] c"Unsupported baudrate\00"
@.str.11 = [21 x i8] c"Supported baudrates:\00"
@.str.12 = [4 x i8] c" %s\00"
@.str.13 = [2 x i8] c"\0A\00"
@CLOCAL = global i32 0
@CREAD = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@ICRNL = global i32 0
@OPOST = global i32 0
@OCRNL = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@.str.14 = [19 x i8] c"Unsupported format\00"
@TCSANOW = global i32 0
@.str.15 = [10 x i8] c"tcsetattr\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@INLCR = global i32 0
@ONLCR = global i64 0
@ISIG = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@.str.16 = [31 x i8] c"Press <CTRL>-D to end program\0A\00"
@POLLIN = global i32 0
@EAGAIN = global i64 0
@.str.17 = [5 x i8] c"read\00"
@VEOF = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [255 x i8]
%8 = alloca [255 x i8]
%9 = alloca i64
%10 = alloca %struct.termios
%11 = alloca %struct.termios
%12 = alloca %struct.termios
%13 = alloca %struct.pollfd
%14 = alloca [6 x %struct.anon]
%15 = alloca %struct.termios
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %14, i64 0, i64 0
%20 = getelementptr inbounds %struct.anon, %struct.anon* %19, i32 0, i32 0
%21 = load i32, i32* @B9600
store i32 %21, i32* %20
%22 = getelementptr inbounds %struct.anon, %struct.anon* %19, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %22
%23 = getelementptr inbounds %struct.anon, %struct.anon* %19, i64 1
%24 = getelementptr inbounds %struct.anon, %struct.anon* %23, i32 0, i32 0
%25 = load i32, i32* @B19200
store i32 %25, i32* %24
%26 = getelementptr inbounds %struct.anon, %struct.anon* %23, i32 0, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %26
%27 = getelementptr inbounds %struct.anon, %struct.anon* %23, i64 1
%28 = getelementptr inbounds %struct.anon, %struct.anon* %27, i32 0, i32 0
%29 = load i32, i32* @B38400
store i32 %29, i32* %28
%30 = getelementptr inbounds %struct.anon, %struct.anon* %27, i32 0, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %30
%31 = getelementptr inbounds %struct.anon, %struct.anon* %27, i64 1
%32 = getelementptr inbounds %struct.anon, %struct.anon* %31, i32 0, i32 0
%33 = load i32, i32* @B57600
store i32 %33, i32* %32
%34 = getelementptr inbounds %struct.anon, %struct.anon* %31, i32 0, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %34
%35 = getelementptr inbounds %struct.anon, %struct.anon* %31, i64 1
%36 = getelementptr inbounds %struct.anon, %struct.anon* %35, i32 0, i32 0
%37 = load i32, i32* @B115200
store i32 %37, i32* %36
%38 = getelementptr inbounds %struct.anon, %struct.anon* %35, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %38
%39 = getelementptr inbounds %struct.anon, %struct.anon* %35, i64 1
%40 = getelementptr inbounds %struct.anon, %struct.anon* %39, i32 0, i32 0
%41 = load i32, i32* @B230400
store i32 %41, i32* %40
%42 = getelementptr inbounds %struct.anon, %struct.anon* %39, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8** %42
%43 = load i32, i32* %4
%44 = icmp ne i32 %43, 4
br i1 %44, label %51, label %45
45: ; preds = %2
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %45, %2
br label %52
52: ; preds = %209, %51
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %45
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = load i32, i32* @O_RDWR
%63 = load i32, i32* @O_NOCTTY
%64 = or i32 %62, %63
%65 = load i32, i32* @O_NONBLOCK
%66 = or i32 %64, %65
%67 = load i32, i32* @O_CLOEXEC
%68 = or i32 %66, %67
%69 = call i32 @open(i8* %61, i32 %68)
store i32 %69, i32* %6
%70 = load i32, i32* %6
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %75
72: ; preds = %58
%73 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %58
%76 = call i64 @tcgetattr(i32 0, %struct.termios* %10)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %75
%82 = load i32, i32* %6
%83 = call i64 @tcgetattr(i32 %82, %struct.termios* %11)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %81
%86 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %81
store i64 0, i64* %9
br label %89
89: ; preds = %104, %88
%90 = load i64, i64* %9
%91 = icmp ult i64 %90, 6
br i1 %91, label %92, label %107
92: ; preds = %89
%93 = load i64, i64* %9
%94 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %14, i64 0, i64 %93
%95 = getelementptr inbounds %struct.anon, %struct.anon* %94, i32 0, i32 1
%96 = load i8*, i8** %95
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 2
%99 = load i8*, i8** %98
%100 = call i64 @strcmp(i8* %96, i8* %99)
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %103
102: ; preds = %92
br label %107
103: ; preds = %92
br label %104
104: ; preds = %103
%105 = load i64, i64* %9
%106 = add i64 %105, 1
store i64 %106, i64* %9
br label %89
107: ; preds = %102, %89
%108 = load i64, i64* %9
%109 = icmp eq i64 %108, 6
br i1 %109, label %110, label %129
110: ; preds = %107
%111 = load i64, i64* @EINVAL
store i64 %111, i64* @errno
%112 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
store i64 0, i64* %9
br label %114
114: ; preds = %123, %110
%115 = load i64, i64* %9
%116 = icmp ult i64 %115, 6
br i1 %116, label %117, label %126
117: ; preds = %114
%118 = load i64, i64* %9
%119 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %14, i64 0, i64 %118
%120 = getelementptr inbounds %struct.anon, %struct.anon* %119, i32 0, i32 1
%121 = load i8*, i8** %120
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %121)
br label %123
123: ; preds = %117
%124 = load i64, i64* %9
%125 = add i64 %124, 1
store i64 %125, i64* %9
br label %114
126: ; preds = %114
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %107
%130 = bitcast %struct.termios* %12 to i8*
%131 = bitcast %struct.termios* %11 to i8*
%132 = load i32, i32* @CLOCAL
%133 = load i32, i32* @CREAD
%134 = or i32 %132, %133
%135 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%136 = load i32, i32* %135
%137 = or i32 %136, %134
store i32 %137, i32* %135
%138 = load i32, i32* @ICANON
%139 = load i32, i32* @ECHO
%140 = or i32 %138, %139
%141 = load i32, i32* @ECHOE
%142 = or i32 %140, %141
%143 = xor i32 %142, -1
%144 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 1
%145 = load i32, i32* %144
%146 = and i32 %145, %143
store i32 %146, i32* %144
%147 = load i32, i32* @IXON
%148 = load i32, i32* @IXOFF
%149 = or i32 %147, %148
%150 = load i32, i32* @IXANY
%151 = or i32 %149, %150
%152 = xor i32 %151, -1
%153 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 2
%154 = load i32, i32* %153
%155 = and i32 %154, %152
store i32 %155, i32* %153
%156 = load i32, i32* @ICRNL
%157 = xor i32 %156, -1
%158 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 2
%159 = load i32, i32* %158
%160 = and i32 %159, %157
store i32 %160, i32* %158
%161 = load i32, i32* @OPOST
%162 = load i32, i32* @OCRNL
%163 = or i32 %161, %162
%164 = xor i32 %163, -1
%165 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 3
%166 = load i32, i32* %165
%167 = and i32 %166, %164
store i32 %167, i32* %165
%168 = load i64, i64* %9
%169 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %14, i64 0, i64 %168
%170 = getelementptr inbounds %struct.anon, %struct.anon* %169, i32 0, i32 0
%171 = load i32, i32* %170
%172 = call i32 @cfsetispeed(%struct.termios* %12, i32 %171)
%173 = load i64, i64* %9
%174 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %14, i64 0, i64 %173
%175 = getelementptr inbounds %struct.anon, %struct.anon* %174, i32 0, i32 0
%176 = load i32, i32* %175
%177 = call i32 @cfsetospeed(%struct.termios* %12, i32 %176)
%178 = load i8**, i8*** %5
%179 = getelementptr inbounds i8*, i8** %178, i64 3
%180 = load i8*, i8** %179
%181 = call i64 @strcmp(i8* %180, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%182 = icmp eq i64 0, %181
br i1 %182, label %183, label %209
183: ; preds = %129
%184 = load i32, i32* @CLOCAL
%185 = load i32, i32* @CREAD
%186 = or i32 %184, %185
%187 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%188 = load i32, i32* %187
%189 = or i32 %188, %186
store i32 %189, i32* %187
%190 = load i32, i32* @PARENB
%191 = xor i32 %190, -1
%192 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%193 = load i32, i32* %192
%194 = and i32 %193, %191
store i32 %194, i32* %192
%195 = load i32, i32* @CSTOPB
%196 = xor i32 %195, -1
%197 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%198 = load i32, i32* %197
%199 = and i32 %198, %196
store i32 %199, i32* %197
%200 = load i32, i32* @CSIZE
%201 = xor i32 %200, -1
%202 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%203 = load i32, i32* %202
%204 = and i32 %203, %201
store i32 %204, i32* %202
%205 = load i32, i32* @CS8
%206 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%207 = load i32, i32* %206
%208 = or i32 %207, %205
store i32 %208, i32* %206
br label %212
209: ; preds = %129
%210 = load i64, i64* @EINVAL
store i64 %210, i64* @errno
%211 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0))
br label %52
212: ; preds = %183
%213 = load i32, i32* %6
%214 = load i32, i32* @TCSANOW
%215 = call i64 @tcsetattr(i32 %213, i32 %214, %struct.termios* %12)
%216 = icmp ne i64 %215, 0
br i1 %216, label %217, label %220
217: ; preds = %212
%218 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%219 = call i32 @exit(i32 1)
unreachable
220: ; preds = %212
%221 = bitcast %struct.termios* %15 to i8*
%222 = bitcast %struct.termios* %10 to i8*
%223 = load i32, i32* @F_GETFL
%224 = call i32 (i32, i32, ...) @fcntl(i32 0, i32 %223)
store i32 %224, i32* %16
%225 = load i32, i32* @F_SETFL
%226 = load i32, i32* %16
%227 = icmp ne i32 %226, -1
br i1 %227, label %228, label %230
228: ; preds = %220
%229 = load i32, i32* %16
br label %231
230: ; preds = %220
br label %231
231: ; preds = %230, %228
%232 = phi i32 [ %229, %228 ], [ 0, %230 ]
%233 = load i32, i32* @O_NONBLOCK
%234 = or i32 %232, %233
%235 = call i32 (i32, i32, ...) @fcntl(i32 0, i32 %225, i32 %234)
%236 = load i32, i32* @IXON
%237 = load i32, i32* @ICRNL
%238 = or i32 %236, %237
%239 = load i32, i32* @INLCR
%240 = or i32 %238, %239
%241 = xor i32 %240, -1
%242 = getelementptr inbounds %struct.termios, %struct.termios* %15, i32 0, i32 2
%243 = load i32, i32* %242
%244 = and i32 %243, %241
store i32 %244, i32* %242
%245 = load i32, i32* @OCRNL
%246 = xor i32 %245, -1
%247 = getelementptr inbounds %struct.termios, %struct.termios* %15, i32 0, i32 3
%248 = load i32, i32* %247
%249 = and i32 %248, %246
store i32 %249, i32* %247
%250 = load i64, i64* @ONLCR
%251 = trunc i64 %250 to i32
%252 = getelementptr inbounds %struct.termios, %struct.termios* %15, i32 0, i32 3
%253 = load i32, i32* %252
%254 = or i32 %253, %251
store i32 %254, i32* %252
%255 = load i32, i32* @ICANON
%256 = load i32, i32* @ECHO
%257 = or i32 %255, %256
%258 = load i32, i32* @ISIG
%259 = or i32 %257, %258
%260 = xor i32 %259, -1
%261 = getelementptr inbounds %struct.termios, %struct.termios* %15, i32 0, i32 1
%262 = load i32, i32* %261
%263 = and i32 %262, %260
store i32 %263, i32* %261
%264 = getelementptr inbounds %struct.termios, %struct.termios* %15, i32 0, i32 4
%265 = load i32*, i32** %264
%266 = load i64, i64* @VMIN
%267 = getelementptr inbounds i32, i32* %265, i64 %266
store i32 1, i32* %267
%268 = getelementptr inbounds %struct.termios, %struct.termios* %15, i32 0, i32 4
%269 = load i32*, i32** %268
%270 = load i64, i64* @VTIME
%271 = getelementptr inbounds i32, i32* %269, i64 %270
store i32 0, i32* %271
%272 = load i32, i32* @TCSANOW
%273 = call i64 @tcsetattr(i32 0, i32 %272, %struct.termios* %15)
%274 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.16, i64 0, i64 0))
%275 = load i32, i32* %6
%276 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i32 0, i32 0
store i32 %275, i32* %276
%277 = load i32, i32* @POLLIN
%278 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i32 0, i32 1
store i32 %277, i32* %278
br label %279
279: ; preds = %329, %292, %231
%280 = call i32 @poll(%struct.pollfd* %13, i32 1, i32 100)
%281 = icmp eq i32 1, %280
br i1 %281, label %282, label %299
282: ; preds = %279
%283 = load i32, i32* %6
%284 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%285 = call i32 @read(i32 %283, i8* %284, i32 255)
store i32 %285, i32* %17
%286 = load i32, i32* %17
%287 = icmp eq i32 %286, -1
br i1 %287, label %288, label %295
288: ; preds = %282
%289 = load i64, i64* @errno
%290 = load i64, i64* @EAGAIN
%291 = icmp eq i64 %289, %290
br i1 %291, label %292, label %293
292: ; preds = %288
br label %279
293: ; preds = %288
%294 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0))
br label %331
295: ; preds = %282
%296 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%297 = load i32, i32* %17
%298 = call i32 @write(i32 1, i8* %296, i32 %297)
br label %299
299: ; preds = %295, %279
%300 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%301 = call i32 @read(i32 0, i8* %300, i32 255)
store i32 %301, i32* %18
%302 = load i32, i32* %18
%303 = icmp sgt i32 %302, 0
br i1 %303, label %304, label %329
304: ; preds = %299
%305 = load i32, i32* %18
%306 = sub nsw i32 %305, 1
%307 = sext i32 %306 to i64
%308 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %307
%309 = load i8, i8* %308
%310 = sext i8 %309 to i32
%311 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 4
%312 = load i32*, i32** %311
%313 = load i64, i64* @VEOF
%314 = getelementptr inbounds i32, i32* %312, i64 %313
%315 = load i32, i32* %314
%316 = icmp eq i32 %310, %315
br i1 %316, label %317, label %323
317: ; preds = %304
%318 = load i32, i32* %6
%319 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%320 = load i32, i32* %18
%321 = sub nsw i32 %320, 1
%322 = call i32 @write(i32 %318, i8* %319, i32 %321)
br label %330
323: ; preds = %304
%324 = load i32, i32* %6
%325 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%326 = load i32, i32* %18
%327 = call i32 @write(i32 %324, i8* %325, i32 %326)
br label %328
328: ; preds = %323
br label %329
329: ; preds = %328, %299
br label %279
330: ; preds = %317
br label %331
331: ; preds = %330, %293
%332 = load i32, i32* @TCSANOW
%333 = call i64 @tcsetattr(i32 0, i32 %332, %struct.termios* %10)
%334 = load i32, i32* %6
%335 = load i32, i32* @TCSANOW
%336 = call i64 @tcsetattr(i32 %334, i32 %335, %struct.termios* %11)
%337 = load i32, i32* %6
%338 = call i32 @close(i32 %337)
ret i32 0
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32, i32* }
%struct.pollfd = type { i32, i32 }
%struct.anon = type { i32, i8* }
@B9600 = global i32 0
@.str = [5 x i8] c"9600\00"
@B19200 = global i32 0
@.str.1 = [6 x i8] c"19200\00"
@B38400 = global i32 0
@.str.2 = [6 x i8] c"38400\00"
@B57600 = global i32 0
@.str.3 = [6 x i8] c"57600\00"
@B115200 = global i32 0
@.str.4 = [7 x i8] c"115200\00"
@B230400 = global i32 0
@.str.5 = [7 x i8] c"230400\00"
@.str.6 = [4 x i8] c"8N1\00"
@.str.7 = [38 x i8] c"Usage: %s /dev/ttyXXX <baudrate> 8N1\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@O_CLOEXEC = global i32 0
@.str.8 = [5 x i8] c"open\00"
@.str.9 = [10 x i8] c"tcgetattr\00"
@EINVAL = global i64 0
@errno = global i64 0
@.str.10 = [21 x i8] c"Unsupported baudrate\00"
@.str.11 = [21 x i8] c"Supported baudrates:\00"
@.str.12 = [4 x i8] c" %s\00"
@CLOCAL = global i32 0
@CREAD = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@ICRNL = global i32 0
@OPOST = global i32 0
@OCRNL = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@.str.14 = [19 x i8] c"Unsupported format\00"
@TCSANOW = global i32 0
@.str.15 = [10 x i8] c"tcsetattr\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@INLCR = global i32 0
@ONLCR = global i64 0
@ISIG = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@POLLIN = global i32 0
@EAGAIN = global i64 0
@.str.17 = [5 x i8] c"read\00"
@VEOF = global i64 0
@str = [30 x i8] c"Press <CTRL>-D to end program\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca %struct.termios
%6 = alloca %struct.termios
%7 = alloca %struct.termios
%8 = alloca %struct.pollfd
%9 = alloca [6 x %struct.anon]
%10 = alloca %struct.termios
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%13 = bitcast %struct.termios* %5 to i8*
%14 = bitcast %struct.termios* %6 to i8*
%15 = bitcast %struct.termios* %7 to i8*
%16 = bitcast %struct.pollfd* %8 to i8*
%17 = bitcast [6 x %struct.anon]* %9 to i8*
%18 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 0, i32 0
%19 = load i32, i32* @B9600
store i32 %19, i32* %18
%20 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 1, i32 0
%22 = load i32, i32* @B19200
store i32 %22, i32* %21
%23 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 1, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 2, i32 0
%25 = load i32, i32* @B38400
store i32 %25, i32* %24
%26 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 2, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %26
%27 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 3, i32 0
%28 = load i32, i32* @B57600
store i32 %28, i32* %27
%29 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 3, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 4, i32 0
%31 = load i32, i32* @B115200
store i32 %31, i32* %30
%32 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 4, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %32
%33 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 5, i32 0
%34 = load i32, i32* @B230400
store i32 %34, i32* %33
%35 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 5, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8** %35
%36 = icmp eq i32 %0, 4
br i1 %36, label %37, label %42
37: ; preds = %2
%38 = getelementptr inbounds i8*, i8** %1, i64 3
%39 = load i8*, i8** %38
%40 = tail call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %2, %37, %170
%43 = load i8*, i8** %1
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %37
%47 = getelementptr inbounds i8*, i8** %1, i64 1
%48 = load i8*, i8** %47
%49 = load i32, i32* @O_RDWR
%50 = load i32, i32* @O_NOCTTY
%51 = or i32 %50, %49
%52 = load i32, i32* @O_NONBLOCK
%53 = or i32 %51, %52
%54 = load i32, i32* @O_CLOEXEC
%55 = or i32 %53, %54
%56 = tail call i32 @open(i8* %48, i32 %55)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %61
58: ; preds = %46
%59 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%60 = tail call i32 @exit(i32 1)
unreachable
61: ; preds = %46
%62 = call i64 @tcgetattr(i32 0, %struct.termios* %5)
%63 = icmp eq i64 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %61
%65 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %61
%68 = call i64 @tcgetattr(i32 %56, %struct.termios* %6)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %67
%71 = getelementptr inbounds i8*, i8** %1, i64 2
%72 = load i8*, i8** %71
%73 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %110, label %78
75: ; preds = %67
%76 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %70
%79 = load i8*, i8** %71
%80 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %79)
%81 = icmp eq i64 %80, 0
br i1 %81, label %110, label %82
82: ; preds = %78
%83 = load i8*, i8** %71
%84 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %83)
%85 = icmp eq i64 %84, 0
br i1 %85, label %110, label %86
86: ; preds = %82
%87 = load i8*, i8** %71
%88 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %87)
%89 = icmp eq i64 %88, 0
br i1 %89, label %110, label %90
90: ; preds = %86
%91 = load i8*, i8** %71
%92 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %91)
%93 = icmp eq i64 %92, 0
br i1 %93, label %110, label %94
94: ; preds = %90
%95 = load i8*, i8** %71
%96 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %95)
%97 = icmp eq i64 %96, 0
br i1 %97, label %110, label %98
98: ; preds = %94
%99 = load i64, i64* @EINVAL
store i64 %99, i64* @errno
%100 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%108 = call i32 @putchar(i32 10)
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %70, %78, %82, %86, %90, %94
%111 = phi i64 [ 0, %70 ], [ 1, %78 ], [ 2, %82 ], [ 3, %86 ], [ 4, %90 ], [ 5, %94 ]
%112 = load i32, i32* @CLOCAL
%113 = load i32, i32* @CREAD
%114 = or i32 %113, %112
%115 = getelementptr inbounds %struct.termios, %struct.termios* %7, i64 0, i32 0
%116 = load i32, i32* %115
%117 = or i32 %114, %116
store i32 %117, i32* %115
%118 = load i32, i32* @ICANON
%119 = load i32, i32* @ECHO
%120 = or i32 %119, %118
%121 = load i32, i32* @ECHOE
%122 = or i32 %120, %121
%123 = xor i32 %122, -1
%124 = getelementptr inbounds %struct.termios, %struct.termios* %7, i64 0, i32 1
%125 = load i32, i32* %124
%126 = and i32 %125, %123
store i32 %126, i32* %124
%127 = load i32, i32* @IXON
%128 = load i32, i32* @IXOFF
%129 = or i32 %128, %127
%130 = load i32, i32* @IXANY
%131 = or i32 %129, %130
%132 = getelementptr inbounds %struct.termios, %struct.termios* %7, i64 0, i32 2
%133 = load i32, i32* %132
%134 = load i32, i32* @ICRNL
%135 = or i32 %131, %134
%136 = xor i32 %135, -1
%137 = and i32 %133, %136
store i32 %137, i32* %132
%138 = load i32, i32* @OPOST
%139 = load i32, i32* @OCRNL
%140 = or i32 %139, %138
%141 = xor i32 %140, -1
%142 = getelementptr inbounds %struct.termios, %struct.termios* %7, i64 0, i32 3
%143 = load i32, i32* %142
%144 = and i32 %143, %141
store i32 %144, i32* %142
%145 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* %9, i64 0, i64 %111, i32 0
%146 = load i32, i32* %145
%147 = call i32 @cfsetispeed(%struct.termios* %7, i32 %146)
%148 = call i32 @cfsetospeed(%struct.termios* %7, i32 %146)
%149 = load i8*, i8** %38
%150 = call i64 @strcmp(i8* %149, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%151 = icmp eq i64 %150, 0
br i1 %151, label %152, label %170
152: ; preds = %110
%153 = load i32, i32* @CLOCAL
%154 = load i32, i32* @CREAD
%155 = or i32 %154, %153
%156 = load i32, i32* %115
%157 = or i32 %155, %156
%158 = load i32, i32* @PARENB
%159 = load i32, i32* @CSTOPB
%160 = or i32 %158, %159
%161 = load i32, i32* @CSIZE
%162 = or i32 %160, %161
%163 = xor i32 %162, -1
%164 = and i32 %157, %163
%165 = load i32, i32* @CS8
%166 = or i32 %165, %164
store i32 %166, i32* %115
%167 = load i32, i32* @TCSANOW
%168 = call i64 @tcsetattr(i32 %56, i32 %167, %struct.termios* %7)
%169 = icmp eq i64 %168, 0
br i1 %169, label %176, label %173
170: ; preds = %110
%171 = load i64, i64* @EINVAL
store i64 %171, i64* @errno
%172 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0))
br label %42
173: ; preds = %152
%174 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%175 = call i32 @exit(i32 1)
unreachable
176: ; preds = %152
%177 = bitcast %struct.termios* %10 to i8*
%178 = load i32, i32* @F_GETFL
%179 = call i32 (i32, i32, ...) @fcntl(i32 0, i32 %178)
%180 = load i32, i32* @F_SETFL
%181 = icmp eq i32 %179, -1
%182 = select i1 %181, i32 0, i32 %179
%183 = load i32, i32* @O_NONBLOCK
%184 = or i32 %182, %183
%185 = call i32 (i32, i32, ...) @fcntl(i32 0, i32 %180, i32 %184)
%186 = load i32, i32* @IXON
%187 = load i32, i32* @ICRNL
%188 = or i32 %187, %186
%189 = load i32, i32* @INLCR
%190 = or i32 %188, %189
%191 = xor i32 %190, -1
%192 = getelementptr inbounds %struct.termios, %struct.termios* %10, i64 0, i32 2
%193 = load i32, i32* %192
%194 = and i32 %193, %191
store i32 %194, i32* %192
%195 = load i32, i32* @OCRNL
%196 = xor i32 %195, -1
%197 = getelementptr inbounds %struct.termios, %struct.termios* %10, i64 0, i32 3
%198 = load i32, i32* %197
%199 = and i32 %198, %196
%200 = load i64, i64* @ONLCR
%201 = trunc i64 %200 to i32
%202 = or i32 %199, %201
store i32 %202, i32* %197
%203 = load i32, i32* @ICANON
%204 = load i32, i32* @ECHO
%205 = or i32 %204, %203
%206 = load i32, i32* @ISIG
%207 = or i32 %205, %206
%208 = xor i32 %207, -1
%209 = getelementptr inbounds %struct.termios, %struct.termios* %10, i64 0, i32 1
%210 = load i32, i32* %209
%211 = and i32 %210, %208
store i32 %211, i32* %209
%212 = getelementptr inbounds %struct.termios, %struct.termios* %10, i64 0, i32 4
%213 = load i32*, i32** %212
%214 = load i64, i64* @VMIN
%215 = getelementptr inbounds i32, i32* %213, i64 %214
store i32 1, i32* %215
%216 = load i64, i64* @VTIME
%217 = getelementptr inbounds i32, i32* %213, i64 %216
store i32 0, i32* %217
%218 = load i32, i32* @TCSANOW
%219 = call i64 @tcsetattr(i32 0, i32 %218, %struct.termios* %10)
%220 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%221 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %8, i64 0, i32 0
store i32 %56, i32* %221
%222 = load i32, i32* @POLLIN
%223 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %8, i64 0, i32 1
store i32 %222, i32* %223
%224 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 4
br label %225
225: ; preds = %257, %176
%226 = call i32 @poll(%struct.pollfd* %8, i32 1, i32 100)
%227 = icmp eq i32 %226, 1
br i1 %227, label %228, label %239
228: ; preds = %225
%229 = call i32 @read(i32 %56, i8* %12, i32 255)
%230 = icmp eq i32 %229, -1
br i1 %230, label %231, label %237
231: ; preds = %228
%232 = load i64, i64* @errno
%233 = load i64, i64* @EAGAIN
%234 = icmp eq i64 %232, %233
br i1 %234, label %257, label %235
235: ; preds = %231
%236 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0))
br label %258
237: ; preds = %228
%238 = call i32 @write(i32 1, i8* %12, i32 %229)
br label %239
239: ; preds = %237, %225
%240 = call i32 @read(i32 0, i8* %11, i32 255)
%241 = icmp sgt i32 %240, 0
br i1 %241, label %242, label %257
242: ; preds = %239
%243 = add nsw i32 %240, -1
%244 = zext i32 %243 to i64
%245 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %244
%246 = load i8, i8* %245
%247 = sext i8 %246 to i32
%248 = load i32*, i32** %224
%249 = load i64, i64* @VEOF
%250 = getelementptr inbounds i32, i32* %248, i64 %249
%251 = load i32, i32* %250
%252 = icmp eq i32 %251, %247
br i1 %252, label %253, label %255
253: ; preds = %242
%254 = call i32 @write(i32 %56, i8* %11, i32 %243)
br label %258
255: ; preds = %242
%256 = call i32 @write(i32 %56, i8* %11, i32 %240)
br label %257
257: ; preds = %255, %239, %231
br label %225
258: ; preds = %235, %253
%259 = load i32, i32* @TCSANOW
%260 = call i64 @tcsetattr(i32 0, i32 %259, %struct.termios* %5)
%261 = load i32, i32* @TCSANOW
%262 = call i64 @tcsetattr(i32 %56, i32 %261, %struct.termios* %6)
%263 = call i32 @close(i32 %56)
ret i32 0
}