#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_iflag;
  int c_oflag;
  int c_lflag;
  int c_cflag;
  int *c_cc;
};

/* Variables and functions */
int /*<<< orphan*/ B115200;
int /*<<< orphan*/ B1200;
int /*<<< orphan*/ B1800;
int /*<<< orphan*/ B19200;
int /*<<< orphan*/ B38400;
int /*<<< orphan*/ B460800;
int /*<<< orphan*/ B57600;
int /*<<< orphan*/ B921600;
int /*<<< orphan*/ B9600;
int BRKINT;
int CS8;
int CSIZE;
int ECHO;
int ECHONL;
int ICANON;
int ICRNL;
int IEXTEN;
int IGNBRK;
int INLCR;
int INPCK;
int ISIG;
int ISTRIP;
int IXON;
int OCRNL;
int OFILL;
int ONLCR;
int ONLRET;
int ONOCR;
int OPOST;
int PARENB;
int PARMRK;
int /*<<< orphan*/ TCSAFLUSH;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ isatty(int);
int /*<<< orphan*/ stderr;
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int setup_uart(int fd, int baud) {
  if (!isatty(fd)) {
    fprintf(stderr, "\nERROR: file descriptor %d is NOT a serial port\n", fd);
    return -1;
  }
  struct termios config;
  if (tcgetattr(fd, &config) < 0) {
    fprintf(stderr, "\nERROR: could not read configuration of fd %d\n", fd);
    return -1;
  }
  config.c_iflag &=
      ~(IGNBRK | BRKINT | ICRNL | INLCR | PARMRK | INPCK | ISTRIP | IXON);
  config.c_oflag &= ~(OCRNL | ONLCR | ONLRET | ONOCR | OFILL | OPOST);
  config.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
  config.c_cflag &= ~(CSIZE | PARENB);
  config.c_cflag |= CS8;
  config.c_cc[VMIN] = 1;
  config.c_cc[VTIME] = 10;
  switch (baud) {
  case 1200:
    if (cfsetispeed(&config, B1200) < 0 || cfsetospeed(&config, B1200) < 0) {
      fprintf(stderr, "\nERROR: Could not set desired baud rate of %d Baud\n",
              baud);
      return -1;
    }
    break;
  case 1800:
    cfsetispeed(&config, B1800);
    cfsetospeed(&config, B1800);
    break;
  case 9600:
    cfsetispeed(&config, B9600);
    cfsetospeed(&config, B9600);
    break;
  case 19200:
    cfsetispeed(&config, B19200);
    cfsetospeed(&config, B19200);
    break;
  case 38400:
    if (cfsetispeed(&config, B38400) < 0 || cfsetospeed(&config, B38400) < 0) {
      fprintf(stderr, "\nERROR: Could not set desired baud rate of %d Baud\n",
              baud);
      return -1;
    }
    break;
  case 57600:
    if (cfsetispeed(&config, B57600) < 0 || cfsetospeed(&config, B57600) < 0) {
      fprintf(stderr, "\nERROR: Could not set desired baud rate of %d Baud\n",
              baud);
      return -1;
    }
    break;
  case 115200:
    if (cfsetispeed(&config, B115200) < 0 ||
        cfsetospeed(&config, B115200) < 0) {
      fprintf(stderr, "\nERROR: Could not set desired baud rate of %d Baud\n",
              baud);
      return -1;
    }
    break;
  case 460800:
    if (cfsetispeed(&config, B460800) < 0 ||
        cfsetospeed(&config, B460800) < 0) {
      fprintf(stderr, "\nERROR: Could not set desired baud rate of %d Baud\n",
              baud);
      return -1;
    }
    break;
  case 921600:
    if (cfsetispeed(&config, B921600) < 0 ||
        cfsetospeed(&config, B921600) < 0) {
      fprintf(stderr, "\nERROR: Could not set desired baud rate of %d Baud\n",
              baud);
      return -1;
    }
    break;
  default:
    fprintf(stderr, "ERROR: Desired baud rate %d could not be set, aborting.\n",
            baud);
    return -1;
    break;
  }
  if (tcsetattr(fd, TCSAFLUSH, &config) < 0) {
    fprintf(stderr, "\nERROR: could not set configuration of fd %d\n", fd);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<setup_uart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <isatty@plt>
cmp    $0x0,%eax
jne    11a3 <setup_uart+0x43>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe6e(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1060 <tcgetattr@plt>
cmp    $0x0,%rax
jge    11dd <setup_uart+0x7d>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe65(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
mov    0x2d1c(%rip),%rax
mov    (%rax),%ecx
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2cf4(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x28(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    0x2dac(%rip),%rax
mov    (%rax),%ecx
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2c88(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2d55(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2cb2(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x24(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    0x2d0a(%rip),%rax
mov    (%rax),%ecx
mov    0x2c79(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2c36(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x20(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    0x2c93(%rip),%rax
mov    (%rax),%ecx
mov    0x2cca(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x1c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c85(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2c68(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    0x2bd3(%rip),%rcx
mov    (%rcx),%rcx
movl   $0xa,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x4b0,%eax
je     13cd <setup_uart+0x26d>
jmp    1335 <setup_uart+0x1d5>
mov    -0x2c(%rbp),%eax
sub    $0x708,%eax
je     142c <setup_uart+0x2cc>
jmp    1348 <setup_uart+0x1e8>
mov    -0x2c(%rbp),%eax
sub    $0x2580,%eax
je     1455 <setup_uart+0x2f5>
jmp    135b <setup_uart+0x1fb>
mov    -0x2c(%rbp),%eax
sub    $0x4b00,%eax
je     147e <setup_uart+0x31e>
jmp    136e <setup_uart+0x20e>
mov    -0x2c(%rbp),%eax
sub    $0x9600,%eax
je     14a7 <setup_uart+0x347>
jmp    1381 <setup_uart+0x221>
mov    -0x2c(%rbp),%eax
sub    $0xe100,%eax
je     1506 <setup_uart+0x3a6>
jmp    1394 <setup_uart+0x234>
mov    -0x2c(%rbp),%eax
sub    $0x1c200,%eax
je     1565 <setup_uart+0x405>
jmp    13a7 <setup_uart+0x247>
mov    -0x2c(%rbp),%eax
sub    $0x70800,%eax
je     15c4 <setup_uart+0x464>
jmp    13ba <setup_uart+0x25a>
mov    -0x2c(%rbp),%eax
sub    $0xe1000,%eax
je     1623 <setup_uart+0x4c3>
jmp    1682 <setup_uart+0x522>
mov    0x2b34(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
cmp    $0x0,%eax
jl     1403 <setup_uart+0x2a3>
mov    0x2b19(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
cmp    $0x0,%eax
jge    1427 <setup_uart+0x2c7>
mov    0x2b2e(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xc4a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
jmp    16a6 <setup_uart+0x546>
mov    0x2b0d(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2afb(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
jmp    16a6 <setup_uart+0x546>
mov    0x2b24(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2b12(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
jmp    16a6 <setup_uart+0x546>
mov    0x2b63(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2b51(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
jmp    16a6 <setup_uart+0x546>
mov    0x2a1a(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
cmp    $0x0,%eax
jl     14dd <setup_uart+0x37d>
mov    0x29ff(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
cmp    $0x0,%eax
jge    1501 <setup_uart+0x3a1>
mov    0x2a54(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xb70(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
jmp    16a6 <setup_uart+0x546>
mov    0x2a4b(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
cmp    $0x0,%eax
jl     153c <setup_uart+0x3dc>
mov    0x2a30(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
cmp    $0x0,%eax
jge    1560 <setup_uart+0x400>
mov    0x29f5(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xb11(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
jmp    16a6 <setup_uart+0x546>
mov    0x298c(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
cmp    $0x0,%eax
jl     159b <setup_uart+0x43b>
mov    0x2971(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
cmp    $0x0,%eax
jge    15bf <setup_uart+0x45f>
mov    0x2996(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xab2(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
jmp    16a6 <setup_uart+0x546>
mov    0x295d(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
cmp    $0x0,%eax
jl     15fa <setup_uart+0x49a>
mov    0x2942(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
cmp    $0x0,%eax
jge    161e <setup_uart+0x4be>
mov    0x2937(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xa53(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
jmp    16a6 <setup_uart+0x546>
mov    0x2966(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1080 <cfsetispeed@plt>
cmp    $0x0,%eax
jl     1659 <setup_uart+0x4f9>
mov    0x294b(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1040 <cfsetospeed@plt>
cmp    $0x0,%eax
jge    167d <setup_uart+0x51d>
mov    0x28d8(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0x9f4(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
jmp    16a6 <setup_uart+0x546>
mov    0x28af(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0x9ff(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
mov    -0x8(%rbp),%edi
mov    0x2910(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1070 <tcsetattr@plt>
cmp    $0x0,%rax
jge    16e9 <setup_uart+0x589>
mov    0x286c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0x9f5(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16f0 <setup_uart+0x590>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_uart>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <isatty@plt>
test   %eax,%eax
je     131a <setup_uart+0x1ba>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
call   1060 <tcgetattr@plt>
test   %rax,%rax
js     132f <setup_uart+0x1cf>
mov    0x2d6b(%rip),%rax
mov    0x2ddc(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e29(%rip),%rax
or     (%rax),%ecx
mov    0x2e18(%rip),%rax
or     (%rax),%ecx
mov    0x2e27(%rip),%rax
or     (%rax),%ecx
mov    0x2d6e(%rip),%rax
or     (%rax),%ecx
mov    0x2d4d(%rip),%rax
or     (%rax),%ecx
mov    0x2dd4(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x8(%rsp)
mov    0x2e0d(%rip),%rax
mov    0x2d06(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ceb(%rip),%rax
or     (%rax),%ecx
mov    0x2dba(%rip),%rax
or     (%rax),%ecx
mov    0x2d19(%rip),%rax
or     (%rax),%ecx
mov    0x2da0(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0xc(%rsp)
mov    0x2d79(%rip),%rax
mov    0x2cea(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ca7(%rip),%rax
or     (%rax),%ecx
mov    0x2d16(%rip),%rax
or     (%rax),%ecx
mov    0x2d45(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x10(%rsp)
mov    0x2d0e(%rip),%rax
mov    0x2d47(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
not    %ecx
and    0x14(%rsp),%ecx
mov    0x2d06(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x14(%rsp)
mov    0x18(%rsp),%rax
mov    0x2cec(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2c5b(%rip),%rcx
mov    (%rcx),%rcx
movl   $0xa,(%rax,%rcx,4)
cmp    $0x95ff,%ebp
jle    1344 <setup_uart+0x1e4>
cmp    $0x1c1ff,%ebp
jle    1374 <setup_uart+0x214>
cmp    $0x1c200,%ebp
je     13f7 <setup_uart+0x297>
cmp    $0x70800,%ebp
je     143e <setup_uart+0x2de>
cmp    $0xe1000,%ebp
jne    156e <setup_uart+0x40e>
mov    0x2cb6(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1080 <cfsetispeed@plt>
test   %eax,%eax
js     1300 <setup_uart+0x1a0>
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1040 <cfsetospeed@plt>
test   %eax,%eax
jns    152a <setup_uart+0x3ca>
mov    0x2c31(%rip),%rax
mov    (%rax),%edi
lea    0xd50(%rip),%rsi
mov    $0xe1000,%edx
jmp    155b <setup_uart+0x3fb>
mov    0x2c17(%rip),%rax
mov    (%rax),%edi
lea    0xcd6(%rip),%rsi
jmp    1559 <setup_uart+0x3f9>
mov    0x2c02(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
jmp    1559 <setup_uart+0x3f9>
cmp    $0x257f,%ebp
jg     13d3 <setup_uart+0x273>
cmp    $0x4b0,%ebp
je     1485 <setup_uart+0x325>
cmp    $0x708,%ebp
jne    156e <setup_uart+0x40e>
mov    0x2bd1(%rip),%rbp
jmp    150f <setup_uart+0x3af>
cmp    $0x9600,%ebp
je     14c8 <setup_uart+0x368>
cmp    $0xe100,%ebp
jne    156e <setup_uart+0x40e>
mov    0x2bc5(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1080 <cfsetispeed@plt>
test   %eax,%eax
js     13b9 <setup_uart+0x259>
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1040 <cfsetospeed@plt>
test   %eax,%eax
jns    152a <setup_uart+0x3ca>
mov    0x2b78(%rip),%rax
mov    (%rax),%edi
lea    0xc97(%rip),%rsi
mov    $0xe100,%edx
jmp    155b <setup_uart+0x3fb>
cmp    $0x2580,%ebp
je     1508 <setup_uart+0x3a8>
cmp    $0x4b00,%ebp
jne    156e <setup_uart+0x40e>
mov    0x2bf6(%rip),%rbp
jmp    150f <setup_uart+0x3af>
mov    0x2afa(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1080 <cfsetispeed@plt>
test   %eax,%eax
js     1424 <setup_uart+0x2c4>
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1040 <cfsetospeed@plt>
test   %eax,%eax
jns    152a <setup_uart+0x3ca>
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
lea    0xc2c(%rip),%rsi
mov    $0x1c200,%edx
jmp    155b <setup_uart+0x3fb>
mov    0x2ae3(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1080 <cfsetispeed@plt>
test   %eax,%eax
js     146b <setup_uart+0x30b>
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1040 <cfsetospeed@plt>
test   %eax,%eax
jns    152a <setup_uart+0x3ca>
mov    0x2ac6(%rip),%rax
mov    (%rax),%edi
lea    0xbe5(%rip),%rsi
mov    $0x70800,%edx
jmp    155b <setup_uart+0x3fb>
mov    0x2a7c(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1080 <cfsetispeed@plt>
test   %eax,%eax
js     14ae <setup_uart+0x34e>
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1040 <cfsetospeed@plt>
test   %eax,%eax
jns    152a <setup_uart+0x3ca>
mov    0x2a83(%rip),%rax
mov    (%rax),%edi
lea    0xba2(%rip),%rsi
mov    $0x4b0,%edx
jmp    155b <setup_uart+0x3fb>
mov    0x29f9(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1080 <cfsetispeed@plt>
test   %eax,%eax
js     14f1 <setup_uart+0x391>
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%rdi
call   1040 <cfsetospeed@plt>
test   %eax,%eax
jns    152a <setup_uart+0x3ca>
mov    0x2a40(%rip),%rax
mov    (%rax),%edi
lea    0xb5f(%rip),%rsi
mov    $0x9600,%edx
jmp    155b <setup_uart+0x3fb>
mov    0x2a71(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1080 <cfsetispeed@plt>
mov    0x0(%rbp),%esi
mov    %r14,%rdi
call   1040 <cfsetospeed@plt>
mov    0x2a8f(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1070 <tcsetattr@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    1565 <setup_uart+0x405>
mov    0x29e8(%rip),%rax
mov    (%rax),%edi
lea    0xb74(%rip),%rsi
mov    %ebx,%edx
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x29c3(%rip),%rax
mov    (%rax),%edi
lea    0xb16(%rip),%rsi
mov    %ebp,%edx
jmp    155b <setup_uart+0x3fb>

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i32, i32* }
@stderr = global i32 0
@.str = [49 x i8] c"\0AERROR: file descriptor %d is NOT a serial port\0A\00"
@.str.1 = [47 x i8] c"\0AERROR: could not read configuration of fd %d\0A\00"
@IGNBRK = global i32 0
@BRKINT = global i32 0
@ICRNL = global i32 0
@INLCR = global i32 0
@PARMRK = global i32 0
@INPCK = global i32 0
@ISTRIP = global i32 0
@IXON = global i32 0
@OCRNL = global i32 0
@ONLCR = global i32 0
@ONLRET = global i32 0
@ONOCR = global i32 0
@OFILL = global i32 0
@OPOST = global i32 0
@ECHO = global i32 0
@ECHONL = global i32 0
@ICANON = global i32 0
@IEXTEN = global i32 0
@ISIG = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@CS8 = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@B1200 = global i32 0
@.str.2 = [52 x i8] c"\0AERROR: Could not set desired baud rate of %d Baud\0A\00"
@B1800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@B460800 = global i32 0
@B921600 = global i32 0
@.str.3 = [57 x i8] c"ERROR: Desired baud rate %d could not be set, aborting.\0A\00"
@TCSAFLUSH = global i32 0
@.str.4 = [46 x i8] c"\0AERROR: could not set configuration of fd %d\0A\00"
define i32 @setup_uart(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.termios
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = call i32 @isatty(i32 %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* %4
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 -1, i32* %3
br label %197
14: ; preds = %2
%15 = load i32, i32* %4
%16 = call i64 @tcgetattr(i32 %15, %struct.termios* %6)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = load i32, i32* %4
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %20)
store i32 -1, i32* %3
br label %197
22: ; preds = %14
%23 = load i32, i32* @IGNBRK
%24 = load i32, i32* @BRKINT
%25 = or i32 %23, %24
%26 = load i32, i32* @ICRNL
%27 = or i32 %25, %26
%28 = load i32, i32* @INLCR
%29 = or i32 %27, %28
%30 = load i32, i32* @PARMRK
%31 = or i32 %29, %30
%32 = load i32, i32* @INPCK
%33 = or i32 %31, %32
%34 = load i32, i32* @ISTRIP
%35 = or i32 %33, %34
%36 = load i32, i32* @IXON
%37 = or i32 %35, %36
%38 = xor i32 %37, -1
%39 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%40 = load i32, i32* %39
%41 = and i32 %40, %38
store i32 %41, i32* %39
%42 = load i32, i32* @OCRNL
%43 = load i32, i32* @ONLCR
%44 = or i32 %42, %43
%45 = load i32, i32* @ONLRET
%46 = or i32 %44, %45
%47 = load i32, i32* @ONOCR
%48 = or i32 %46, %47
%49 = load i32, i32* @OFILL
%50 = or i32 %48, %49
%51 = load i32, i32* @OPOST
%52 = or i32 %50, %51
%53 = xor i32 %52, -1
%54 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 1
%55 = load i32, i32* %54
%56 = and i32 %55, %53
store i32 %56, i32* %54
%57 = load i32, i32* @ECHO
%58 = load i32, i32* @ECHONL
%59 = or i32 %57, %58
%60 = load i32, i32* @ICANON
%61 = or i32 %59, %60
%62 = load i32, i32* @IEXTEN
%63 = or i32 %61, %62
%64 = load i32, i32* @ISIG
%65 = or i32 %63, %64
%66 = xor i32 %65, -1
%67 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 2
%68 = load i32, i32* %67
%69 = and i32 %68, %66
store i32 %69, i32* %67
%70 = load i32, i32* @CSIZE
%71 = load i32, i32* @PARENB
%72 = or i32 %70, %71
%73 = xor i32 %72, -1
%74 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 3
%75 = load i32, i32* %74
%76 = and i32 %75, %73
store i32 %76, i32* %74
%77 = load i32, i32* @CS8
%78 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 3
%79 = load i32, i32* %78
%80 = or i32 %79, %77
store i32 %80, i32* %78
%81 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 4
%82 = load i32*, i32** %81
%83 = load i64, i64* @VMIN
%84 = getelementptr inbounds i32, i32* %82, i64 %83
store i32 1, i32* %84
%85 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 4
%86 = load i32*, i32** %85
%87 = load i64, i64* @VTIME
%88 = getelementptr inbounds i32, i32* %86, i64 %87
store i32 10, i32* %88
%89 = load i32, i32* %5
switch i32 %89, label %183 [
i32 1200, label %90
i32 1800, label %103
i32 9600, label %108
i32 19200, label %113
i32 38400, label %118
i32 57600, label %131
i32 115200, label %144
i32 460800, label %157
i32 921600, label %170
]
90: ; preds = %22
%91 = load i32, i32* @B1200
%92 = call i32 @cfsetispeed(%struct.termios* %6, i32 %91)
%93 = icmp slt i32 %92, 0
br i1 %93, label %98, label %94
94: ; preds = %90
%95 = load i32, i32* @B1200
%96 = call i32 @cfsetospeed(%struct.termios* %6, i32 %95)
%97 = icmp slt i32 %96, 0
br i1 %97, label %98, label %102
98: ; preds = %94, %90
%99 = load i32, i32* @stderr
%100 = load i32, i32* %5
%101 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %100)
store i32 -1, i32* %3
br label %197
102: ; preds = %94
br label %187
103: ; preds = %22
%104 = load i32, i32* @B1800
%105 = call i32 @cfsetispeed(%struct.termios* %6, i32 %104)
%106 = load i32, i32* @B1800
%107 = call i32 @cfsetospeed(%struct.termios* %6, i32 %106)
br label %187
108: ; preds = %22
%109 = load i32, i32* @B9600
%110 = call i32 @cfsetispeed(%struct.termios* %6, i32 %109)
%111 = load i32, i32* @B9600
%112 = call i32 @cfsetospeed(%struct.termios* %6, i32 %111)
br label %187
113: ; preds = %22
%114 = load i32, i32* @B19200
%115 = call i32 @cfsetispeed(%struct.termios* %6, i32 %114)
%116 = load i32, i32* @B19200
%117 = call i32 @cfsetospeed(%struct.termios* %6, i32 %116)
br label %187
118: ; preds = %22
%119 = load i32, i32* @B38400
%120 = call i32 @cfsetispeed(%struct.termios* %6, i32 %119)
%121 = icmp slt i32 %120, 0
br i1 %121, label %126, label %122
122: ; preds = %118
%123 = load i32, i32* @B38400
%124 = call i32 @cfsetospeed(%struct.termios* %6, i32 %123)
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %130
126: ; preds = %122, %118
%127 = load i32, i32* @stderr
%128 = load i32, i32* %5
%129 = call i32 @fprintf(i32 %127, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %128)
store i32 -1, i32* %3
br label %197
130: ; preds = %122
br label %187
131: ; preds = %22
%132 = load i32, i32* @B57600
%133 = call i32 @cfsetispeed(%struct.termios* %6, i32 %132)
%134 = icmp slt i32 %133, 0
br i1 %134, label %139, label %135
135: ; preds = %131
%136 = load i32, i32* @B57600
%137 = call i32 @cfsetospeed(%struct.termios* %6, i32 %136)
%138 = icmp slt i32 %137, 0
br i1 %138, label %139, label %143
139: ; preds = %135, %131
%140 = load i32, i32* @stderr
%141 = load i32, i32* %5
%142 = call i32 @fprintf(i32 %140, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %141)
store i32 -1, i32* %3
br label %197
143: ; preds = %135
br label %187
144: ; preds = %22
%145 = load i32, i32* @B115200
%146 = call i32 @cfsetispeed(%struct.termios* %6, i32 %145)
%147 = icmp slt i32 %146, 0
br i1 %147, label %152, label %148
148: ; preds = %144
%149 = load i32, i32* @B115200
%150 = call i32 @cfsetospeed(%struct.termios* %6, i32 %149)
%151 = icmp slt i32 %150, 0
br i1 %151, label %152, label %156
152: ; preds = %148, %144
%153 = load i32, i32* @stderr
%154 = load i32, i32* %5
%155 = call i32 @fprintf(i32 %153, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %154)
store i32 -1, i32* %3
br label %197
156: ; preds = %148
br label %187
157: ; preds = %22
%158 = load i32, i32* @B460800
%159 = call i32 @cfsetispeed(%struct.termios* %6, i32 %158)
%160 = icmp slt i32 %159, 0
br i1 %160, label %165, label %161
161: ; preds = %157
%162 = load i32, i32* @B460800
%163 = call i32 @cfsetospeed(%struct.termios* %6, i32 %162)
%164 = icmp slt i32 %163, 0
br i1 %164, label %165, label %169
165: ; preds = %161, %157
%166 = load i32, i32* @stderr
%167 = load i32, i32* %5
%168 = call i32 @fprintf(i32 %166, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %167)
store i32 -1, i32* %3
br label %197
169: ; preds = %161
br label %187
170: ; preds = %22
%171 = load i32, i32* @B921600
%172 = call i32 @cfsetispeed(%struct.termios* %6, i32 %171)
%173 = icmp slt i32 %172, 0
br i1 %173, label %178, label %174
174: ; preds = %170
%175 = load i32, i32* @B921600
%176 = call i32 @cfsetospeed(%struct.termios* %6, i32 %175)
%177 = icmp slt i32 %176, 0
br i1 %177, label %178, label %182
178: ; preds = %174, %170
%179 = load i32, i32* @stderr
%180 = load i32, i32* %5
%181 = call i32 @fprintf(i32 %179, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %180)
store i32 -1, i32* %3
br label %197
182: ; preds = %174
br label %187
183: ; preds = %22
%184 = load i32, i32* @stderr
%185 = load i32, i32* %5
%186 = call i32 @fprintf(i32 %184, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i32 %185)
store i32 -1, i32* %3
br label %197
187: ; preds = %182, %169, %156, %143, %130, %113, %108, %103, %102
%188 = load i32, i32* %4
%189 = load i32, i32* @TCSAFLUSH
%190 = call i64 @tcsetattr(i32 %188, i32 %189, %struct.termios* %6)
%191 = icmp slt i64 %190, 0
br i1 %191, label %192, label %196
192: ; preds = %187
%193 = load i32, i32* @stderr
%194 = load i32, i32* %4
%195 = call i32 @fprintf(i32 %193, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %194)
store i32 -1, i32* %3
br label %197
196: ; preds = %187
store i32 0, i32* %3
br label %197
197: ; preds = %196, %192, %183, %178, %165, %152, %139, %126, %98, %18, %10
%198 = load i32, i32* %3
ret i32 %198
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32, i32* }
@stderr = global i32 0
@.str = [49 x i8] c"\0AERROR: file descriptor %d is NOT a serial port\0A\00"
@.str.1 = [47 x i8] c"\0AERROR: could not read configuration of fd %d\0A\00"
@IGNBRK = global i32 0
@BRKINT = global i32 0
@ICRNL = global i32 0
@INLCR = global i32 0
@PARMRK = global i32 0
@INPCK = global i32 0
@ISTRIP = global i32 0
@IXON = global i32 0
@OCRNL = global i32 0
@ONLCR = global i32 0
@ONLRET = global i32 0
@ONOCR = global i32 0
@OFILL = global i32 0
@OPOST = global i32 0
@ECHO = global i32 0
@ECHONL = global i32 0
@ICANON = global i32 0
@IEXTEN = global i32 0
@ISIG = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@CS8 = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@B1200 = global i32 0
@.str.2 = [52 x i8] c"\0AERROR: Could not set desired baud rate of %d Baud\0A\00"
@B1800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@B460800 = global i32 0
@B921600 = global i32 0
@.str.3 = [57 x i8] c"ERROR: Desired baud rate %d could not be set, aborting.\0A\00"
@TCSAFLUSH = global i32 0
@.str.4 = [46 x i8] c"\0AERROR: could not set configuration of fd %d\0A\00"
define i32 @setup_uart(i32 %0, i32 %1) {
%3 = alloca %struct.termios
%4 = tail call i32 @isatty(i32 %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %165
9: ; preds = %2
%10 = bitcast %struct.termios* %3 to i8*
%11 = call i64 @tcgetattr(i32 %0, %struct.termios* %3)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %163
16: ; preds = %9
%17 = load i32, i32* @IGNBRK
%18 = load i32, i32* @BRKINT
%19 = or i32 %18, %17
%20 = load i32, i32* @ICRNL
%21 = or i32 %19, %20
%22 = load i32, i32* @INLCR
%23 = or i32 %21, %22
%24 = load i32, i32* @PARMRK
%25 = or i32 %23, %24
%26 = load i32, i32* @INPCK
%27 = or i32 %25, %26
%28 = load i32, i32* @ISTRIP
%29 = or i32 %27, %28
%30 = load i32, i32* @IXON
%31 = or i32 %29, %30
%32 = xor i32 %31, -1
%33 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%34 = load i32, i32* %33
%35 = and i32 %34, %32
store i32 %35, i32* %33
%36 = load i32, i32* @OCRNL
%37 = load i32, i32* @ONLCR
%38 = or i32 %37, %36
%39 = load i32, i32* @ONLRET
%40 = or i32 %38, %39
%41 = load i32, i32* @ONOCR
%42 = or i32 %40, %41
%43 = load i32, i32* @OFILL
%44 = or i32 %42, %43
%45 = load i32, i32* @OPOST
%46 = or i32 %44, %45
%47 = xor i32 %46, -1
%48 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%49 = load i32, i32* %48
%50 = and i32 %49, %47
store i32 %50, i32* %48
%51 = load i32, i32* @ECHO
%52 = load i32, i32* @ECHONL
%53 = or i32 %52, %51
%54 = load i32, i32* @ICANON
%55 = or i32 %53, %54
%56 = load i32, i32* @IEXTEN
%57 = or i32 %55, %56
%58 = load i32, i32* @ISIG
%59 = or i32 %57, %58
%60 = xor i32 %59, -1
%61 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 2
%62 = load i32, i32* %61
%63 = and i32 %62, %60
store i32 %63, i32* %61
%64 = load i32, i32* @CSIZE
%65 = load i32, i32* @PARENB
%66 = or i32 %65, %64
%67 = xor i32 %66, -1
%68 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 3
%69 = load i32, i32* %68
%70 = and i32 %69, %67
%71 = load i32, i32* @CS8
%72 = or i32 %71, %70
store i32 %72, i32* %68
%73 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 4
%74 = load i32*, i32** %73
%75 = load i64, i64* @VMIN
%76 = getelementptr inbounds i32, i32* %74, i64 %75
store i32 1, i32* %76
%77 = load i64, i64* @VTIME
%78 = getelementptr inbounds i32, i32* %74, i64 %77
store i32 10, i32* %78
switch i32 %1, label %147 [
i32 1200, label %79
i32 1800, label %150
i32 9600, label %90
i32 19200, label %91
i32 38400, label %92
i32 57600, label %103
i32 115200, label %114
i32 460800, label %125
i32 921600, label %136
]
79: ; preds = %16
%80 = load i32, i32* @B1200
%81 = call i32 @cfsetispeed(%struct.termios* %3, i32 %80)
%82 = icmp slt i32 %81, 0
br i1 %82, label %87, label %83
83: ; preds = %79
%84 = load i32, i32* @B1200
%85 = call i32 @cfsetospeed(%struct.termios* %3, i32 %84)
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %156
87: ; preds = %83, %79
%88 = load i32, i32* @stderr
%89 = call i32 @fprintf(i32 %88, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 1200)
br label %163
90: ; preds = %16
br label %150
91: ; preds = %16
br label %150
92: ; preds = %16
%93 = load i32, i32* @B38400
%94 = call i32 @cfsetispeed(%struct.termios* %3, i32 %93)
%95 = icmp slt i32 %94, 0
br i1 %95, label %100, label %96
96: ; preds = %92
%97 = load i32, i32* @B38400
%98 = call i32 @cfsetospeed(%struct.termios* %3, i32 %97)
%99 = icmp slt i32 %98, 0
br i1 %99, label %100, label %156
100: ; preds = %96, %92
%101 = load i32, i32* @stderr
%102 = call i32 @fprintf(i32 %101, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 38400)
br label %163
103: ; preds = %16
%104 = load i32, i32* @B57600
%105 = call i32 @cfsetispeed(%struct.termios* %3, i32 %104)
%106 = icmp slt i32 %105, 0
br i1 %106, label %111, label %107
107: ; preds = %103
%108 = load i32, i32* @B57600
%109 = call i32 @cfsetospeed(%struct.termios* %3, i32 %108)
%110 = icmp slt i32 %109, 0
br i1 %110, label %111, label %156
111: ; preds = %107, %103
%112 = load i32, i32* @stderr
%113 = call i32 @fprintf(i32 %112, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 57600)
br label %163
114: ; preds = %16
%115 = load i32, i32* @B115200
%116 = call i32 @cfsetispeed(%struct.termios* %3, i32 %115)
%117 = icmp slt i32 %116, 0
br i1 %117, label %122, label %118
118: ; preds = %114
%119 = load i32, i32* @B115200
%120 = call i32 @cfsetospeed(%struct.termios* %3, i32 %119)
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %156
122: ; preds = %118, %114
%123 = load i32, i32* @stderr
%124 = call i32 @fprintf(i32 %123, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 115200)
br label %163
125: ; preds = %16
%126 = load i32, i32* @B460800
%127 = call i32 @cfsetispeed(%struct.termios* %3, i32 %126)
%128 = icmp slt i32 %127, 0
br i1 %128, label %133, label %129
129: ; preds = %125
%130 = load i32, i32* @B460800
%131 = call i32 @cfsetospeed(%struct.termios* %3, i32 %130)
%132 = icmp slt i32 %131, 0
br i1 %132, label %133, label %156
133: ; preds = %129, %125
%134 = load i32, i32* @stderr
%135 = call i32 @fprintf(i32 %134, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 460800)
br label %163
136: ; preds = %16
%137 = load i32, i32* @B921600
%138 = call i32 @cfsetispeed(%struct.termios* %3, i32 %137)
%139 = icmp slt i32 %138, 0
br i1 %139, label %144, label %140
140: ; preds = %136
%141 = load i32, i32* @B921600
%142 = call i32 @cfsetospeed(%struct.termios* %3, i32 %141)
%143 = icmp slt i32 %142, 0
br i1 %143, label %144, label %156
144: ; preds = %140, %136
%145 = load i32, i32* @stderr
%146 = call i32 @fprintf(i32 %145, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 921600)
br label %163
147: ; preds = %16
%148 = load i32, i32* @stderr
%149 = call i32 @fprintf(i32 %148, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i32 %1)
br label %163
150: ; preds = %16, %90, %91
%151 = phi i32* [ @B19200, %91 ], [ @B9600, %90 ], [ @B1800, %16 ]
%152 = load i32, i32* %151
%153 = call i32 @cfsetispeed(%struct.termios* %3, i32 %152)
%154 = load i32, i32* %151
%155 = call i32 @cfsetospeed(%struct.termios* %3, i32 %154)
br label %156
156: ; preds = %150, %140, %129, %118, %107, %96, %83
%157 = load i32, i32* @TCSAFLUSH
%158 = call i64 @tcsetattr(i32 %0, i32 %157, %struct.termios* %3)
%159 = icmp slt i64 %158, 0
br i1 %159, label %160, label %163
160: ; preds = %156
%161 = load i32, i32* @stderr
%162 = call i32 @fprintf(i32 %161, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %0)
br label %163
163: ; preds = %156, %160, %147, %144, %133, %122, %111, %100, %87, %13
%164 = phi i32 [ -1, %13 ], [ -1, %147 ], [ -1, %144 ], [ -1, %160 ], [ -1, %133 ], [ -1, %122 ], [ -1, %111 ], [ -1, %100 ], [ -1, %87 ], [ 0, %156 ]
br label %165
165: ; preds = %163, %6
%166 = phi i32 [ %164, %163 ], [ -1, %6 ]
ret i32 %166
}