#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct termios {
  int c_cflag;
  scalar_t__ *c_cc;
  scalar_t__ c_lflag;
  scalar_t__ c_oflag;
  int /*<<< orphan*/ c_iflag;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ ioNew;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ client;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int B0;
int B110;
int B115200;
int B1200;
int B134;
int B150;
int B1800;
int B19200;
int B200;
int B230400;
int B2400;
int B300;
int B38400;
int B4800;
int B50;
int B57600;
int B600;
int B75;
int B9600;
int CLOCAL;
int CREAD;
int CS8;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ IGNPAR;
int /*<<< orphan*/ INADDR_ANY;
int O_NOCTTY;
int O_RDWR;
scalar_t__ Repeater(int, int);
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ TCIFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct termios *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ htons(int);
scalar_t__ listen(int, int);
int max(int, int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int tcsetattr(int, int /*<<< orphan*/, struct termios *);
int main(int argc, char **argv) {
  int fdSockListen, fdSock, fdSeri;
  struct sockaddr_in addr, client;
  int iLen;
  int i;
  fd_set rfds, rfds_tmp;
  struct termios ioOld, ioNew;
  int iBaud = B9600;
  if (argc >= 2) {
    iBaud = atoi(argv[1]);
    ;
    iBaud = iBaud == 0        ? B0
            : iBaud == 50     ? B50
            : iBaud == 75     ? B75
            : iBaud == 110    ? B110
            : iBaud == 134    ? B134
            : iBaud == 150    ? B150
            : iBaud == 200    ? B200
            : iBaud == 300    ? B300
            : iBaud == 600    ? B600
            : iBaud == 1200   ? B1200
            : iBaud == 1800   ? B1800
            : iBaud == 2400   ? B2400
            : iBaud == 4800   ? B4800
            : iBaud == 9600   ? B9600
            : iBaud == 19200  ? B19200
            : iBaud == 38400  ? B38400
            : iBaud == 57600  ? B57600
            : iBaud == 115200 ? B115200
            : iBaud == 230400 ? B230400
                              : B9600;
  }
  signal(SIGPIPE, SIG_IGN);
  fdSockListen = socket(AF_INET, SOCK_STREAM, 0);
  if (fdSockListen < 0) {
    perror("socket");
    return 1;
  }
  addr.sin_family = AF_INET;
  addr.sin_port = htons(12345);
  addr.sin_addr.s_addr = INADDR_ANY;
  if (bind(fdSockListen, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
    perror("bind");
    return 1;
  }
  if (listen(fdSockListen, 3) != 0) {
    perror("listen");
    return 1;
  }
  while (1) {
    iLen = sizeof(client);
    fdSock = accept(fdSockListen, (struct sockaddr *)&client, &iLen);
    if (fdSock < 0) {
      perror("accept");
      break;
    };
    fdSeri = open("/dev/ttyS0", O_RDWR | O_NOCTTY);
    if (fdSock < 0) {
      perror("tty");
      return 1;
    }
    bzero(&ioNew, sizeof(ioNew));
    ioNew.c_cflag = iBaud | CS8 | CLOCAL | CREAD;
    ioNew.c_iflag = IGNPAR;
    ioNew.c_oflag = 0;
    ioNew.c_lflag = 0;
    ioNew.c_cc[VTIME] = 0;
    ioNew.c_cc[VMIN] = 0;
    tcflush(fdSeri, TCIFLUSH);
    i = tcsetattr(fdSeri, TCSANOW, &ioNew);
    ;
    int fdMax = max(max(fdSock, fdSeri), fdSockListen) + 1;
    FD_ZERO(&rfds);
    FD_SET(fdSock, &rfds);
    FD_SET(fdSeri, &rfds);
    FD_SET(fdSockListen, &rfds);
    while (1) {
      rfds_tmp = rfds;
      i = select(fdMax, &rfds_tmp, NULL, NULL, NULL);
      if (i < 0) {
        perror("select");
        break;
      };
      if (FD_ISSET(fdSockListen, &rfds_tmp)) {
        ;
        break;
      }
      if (FD_ISSET(fdSock, &rfds_tmp) && Repeater(fdSeri, fdSock) <= 0)
        break;
      if (FD_ISSET(fdSeri, &rfds_tmp) && Repeater(fdSock, fdSeri) <= 0)
        break;
    };
    close(fdSeri);
    close(fdSock);
  }
  close(fdSockListen);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     2608 <main+0x3d8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   2130 <atoi@plt>
mov    %eax,-0x9c(%rbp)
cmpl   $0x0,-0x9c(%rbp)
jne    2296 <main+0x66>
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
jmp    25fc <main+0x3cc>
cmpl   $0x32,-0x9c(%rbp)
jne    22b7 <main+0x87>
mov    0x2cde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa8(%rbp)
jmp    25f0 <main+0x3c0>
cmpl   $0x4b,-0x9c(%rbp)
jne    22d8 <main+0xa8>
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
jmp    25e4 <main+0x3b4>
cmpl   $0x6e,-0x9c(%rbp)
jne    22f9 <main+0xc9>
mov    0x2cec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb0(%rbp)
jmp    25d8 <main+0x3a8>
cmpl   $0x86,-0x9c(%rbp)
jne    231d <main+0xed>
mov    0x2c98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
jmp    25cc <main+0x39c>
cmpl   $0x96,-0x9c(%rbp)
jne    2341 <main+0x111>
mov    0x2bec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb8(%rbp)
jmp    25c0 <main+0x390>
cmpl   $0xc8,-0x9c(%rbp)
jne    2365 <main+0x135>
mov    0x2c18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xbc(%rbp)
jmp    25b4 <main+0x384>
cmpl   $0x12c,-0x9c(%rbp)
jne    2389 <main+0x159>
mov    0x2c14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc0(%rbp)
jmp    25a8 <main+0x378>
cmpl   $0x258,-0x9c(%rbp)
jne    23ad <main+0x17d>
mov    0x2c18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
jmp    259c <main+0x36c>
cmpl   $0x4b0,-0x9c(%rbp)
jne    23d1 <main+0x1a1>
mov    0x2b44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc8(%rbp)
jmp    2590 <main+0x360>
cmpl   $0x708,-0x9c(%rbp)
jne    23f5 <main+0x1c5>
mov    0x2b58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xcc(%rbp)
jmp    2584 <main+0x354>
cmpl   $0x960,-0x9c(%rbp)
jne    2419 <main+0x1e9>
mov    0x2b1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd0(%rbp)
jmp    2578 <main+0x348>
cmpl   $0x12c0,-0x9c(%rbp)
jne    243d <main+0x20d>
mov    0x2b70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd4(%rbp)
jmp    256c <main+0x33c>
cmpl   $0x2580,-0x9c(%rbp)
jne    2461 <main+0x231>
mov    0x2b44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd8(%rbp)
jmp    2560 <main+0x330>
cmpl   $0x4b00,-0x9c(%rbp)
jne    2485 <main+0x255>
mov    0x2b78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xdc(%rbp)
jmp    2554 <main+0x324>
cmpl   $0x9600,-0x9c(%rbp)
jne    24a9 <main+0x279>
mov    0x2a34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe0(%rbp)
jmp    2548 <main+0x318>
cmpl   $0xe100,-0x9c(%rbp)
jne    24cd <main+0x29d>
mov    0x2aa0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe4(%rbp)
jmp    253c <main+0x30c>
cmpl   $0x1c200,-0x9c(%rbp)
jne    24f1 <main+0x2c1>
mov    0x2a1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe8(%rbp)
jmp    2530 <main+0x300>
cmpl   $0x38400,-0x9c(%rbp)
jne    2515 <main+0x2e5>
mov    0x29d8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xec(%rbp)
jmp    2524 <main+0x2f4>
mov    0x2a7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xec(%rbp)
mov    -0xec(%rbp),%eax
mov    %eax,-0xe8(%rbp)
mov    -0xe8(%rbp),%eax
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
mov    %eax,-0xe0(%rbp)
mov    -0xe0(%rbp),%eax
mov    %eax,-0xdc(%rbp)
mov    -0xdc(%rbp),%eax
mov    %eax,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
mov    %eax,-0xd0(%rbp)
mov    -0xd0(%rbp),%eax
mov    %eax,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
mov    %eax,-0xc8(%rbp)
mov    -0xc8(%rbp),%eax
mov    %eax,-0xc4(%rbp)
mov    -0xc4(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0xc0(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    -0xbc(%rbp),%eax
mov    %eax,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0xac(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    0x2901(%rip),%rax
mov    (%rax),%edi
mov    0x2940(%rip),%rax
mov    (%rax),%esi
call   2090 <signal@plt>
mov    0x29aa(%rip),%rax
mov    (%rax),%edi
mov    0x28e9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   2150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    265d <main+0x42d>
lea    0x9b4(%rip),%rdi
call   2100 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    2943 <main+0x713>
mov    0x296c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    $0x3039,%edi
call   2040 <htons@plt>
mov    %eax,-0x24(%rbp)
mov    0x2933(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   20d0 <bind@plt>
cmp    $0x0,%rax
je     26b5 <main+0x485>
lea    0x963(%rip),%rdi
call   2100 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    2943 <main+0x713>
mov    -0x14(%rbp),%edi
mov    $0x3,%esi
call   20c0 <listen@plt>
cmp    $0x0,%rax
je     26e4 <main+0x4b4>
lea    0x939(%rip),%rdi
call   2100 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    2943 <main+0x713>
jmp    26e9 <main+0x4b9>
movl   $0xc,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   2120 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    271e <main+0x4ee>
lea    0x8ff(%rip),%rdi
call   2100 <perror@plt>
jmp    2934 <main+0x704>
mov    0x28bb(%rip),%rax
mov    (%rax),%esi
mov    0x2802(%rip),%rax
or     (%rax),%esi
lea    0x8e3(%rip),%rdi
call   20f0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    2761 <main+0x531>
lea    0x8d5(%rip),%rdi
call   2100 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    2943 <main+0x713>
lea    -0x98(%rbp),%rdi
mov    $0x28,%esi
call   2110 <bzero@plt>
mov    -0x9c(%rbp),%eax
mov    0x27f9(%rip),%rcx
or     (%rcx),%eax
mov    0x2750(%rip),%rcx
or     (%rcx),%eax
mov    0x27ef(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x98(%rbp)
mov    0x2750(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
mov    -0x90(%rbp),%rax
mov    0x2732(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x90(%rbp),%rax
mov    0x2789(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%edi
mov    0x2744(%rip),%rax
mov    (%rax),%esi
call   2050 <tcflush@plt>
mov    -0x1c(%rbp),%edi
mov    0x27bb(%rip),%rax
mov    (%rax),%esi
lea    -0x98(%rbp),%rdx
call   20e0 <tcsetattr@plt>
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   2060 <max@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
call   2060 <max@plt>
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
lea    -0x44(%rbp),%rdi
call   20a0 <FD_ZERO@plt>
mov    -0x18(%rbp),%edi
lea    -0x44(%rbp),%rsi
call   2140 <FD_SET@plt>
mov    -0x1c(%rbp),%edi
lea    -0x44(%rbp),%rsi
call   2140 <FD_SET@plt>
mov    -0x14(%rbp),%edi
lea    -0x44(%rbp),%rsi
call   2140 <FD_SET@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0xa0(%rbp),%edi
lea    -0x48(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   20b0 <select@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    289f <main+0x66f>
lea    0x794(%rip),%rdi
call   2100 <perror@plt>
jmp    291f <main+0x6ef>
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
call   2030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     28ba <main+0x68a>
jmp    291f <main+0x6ef>
mov    -0x18(%rbp),%edi
lea    -0x48(%rbp),%rsi
call   2030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     28ea <main+0x6ba>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   2080 <Repeater@plt>
cmp    $0x0,%rax
jg     28ea <main+0x6ba>
jmp    291f <main+0x6ef>
mov    -0x1c(%rbp),%edi
lea    -0x48(%rbp),%rsi
call   2030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     291a <main+0x6ea>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   2080 <Repeater@plt>
cmp    $0x0,%rax
jg     291a <main+0x6ea>
jmp    291f <main+0x6ef>
jmp    2861 <main+0x631>
mov    -0x1c(%rbp),%edi
call   2070 <close@plt>
mov    -0x18(%rbp),%edi
call   2070 <close@plt>
jmp    26e9 <main+0x4b9>
mov    -0x14(%rbp),%edi
call   2070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    0x2d53(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
cmp    $0x2,%edi
jl     2402 <main+0x1d2>
mov    0x8(%rsi),%rdi
call   2130 <atoi@plt>
cmp    $0x4af,%eax
jg     22a2 <main+0x72>
cmp    $0x85,%eax
jle    22e1 <main+0xb1>
cmp    $0xc7,%eax
jle    2330 <main+0x100>
cmp    $0xc8,%eax
je     239e <main+0x16e>
cmp    $0x12c,%eax
je     23a7 <main+0x177>
cmp    $0x258,%eax
jne    23ef <main+0x1bf>
mov    0x2d1b(%rip),%rax
jmp    23fd <main+0x1cd>
cmp    $0x257f,%eax
jle    2307 <main+0xd7>
cmp    $0x95ff,%eax
jle    2352 <main+0x122>
cmp    $0x9600,%eax
je     23b0 <main+0x180>
cmp    $0xe100,%eax
je     23b9 <main+0x189>
cmp    $0x1c200,%eax
jne    23ef <main+0x1bf>
mov    0x2c24(%rip),%rax
jmp    23fd <main+0x1cd>
cmp    $0x4a,%eax
jg     2374 <main+0x144>
test   %eax,%eax
je     23c2 <main+0x192>
cmp    $0x32,%eax
jne    23ef <main+0x1bf>
mov    0x2c86(%rip),%rax
jmp    23fd <main+0x1cd>
cmp    $0x95f,%eax
jg     2387 <main+0x157>
cmp    $0x4b0,%eax
je     23cb <main+0x19b>
cmp    $0x708,%eax
jne    23ef <main+0x1bf>
mov    0x2c15(%rip),%rax
jmp    23fd <main+0x1cd>
cmp    $0x86,%eax
je     23d4 <main+0x1a4>
cmp    $0x96,%eax
jne    23ef <main+0x1bf>
mov    0x2bd3(%rip),%rax
jmp    23fd <main+0x1cd>
cmp    $0x2580,%eax
je     2402 <main+0x1d2>
cmp    $0x4b00,%eax
jne    23ef <main+0x1bf>
mov    0x2c81(%rip),%rax
jmp    23fd <main+0x1cd>
cmp    $0x4b,%eax
je     23dd <main+0x1ad>
cmp    $0x6e,%eax
jne    23ef <main+0x1bf>
mov    0x2c53(%rip),%rax
jmp    23fd <main+0x1cd>
cmp    $0x960,%eax
je     23e6 <main+0x1b6>
cmp    $0x12c0,%eax
jne    23ef <main+0x1bf>
mov    0x2c04(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2bcb(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2be2(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2b19(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2ba0(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2b7f(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2b36(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2bcd(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2be4(%rip),%rax
jmp    23fd <main+0x1cd>
mov    0x2b3b(%rip),%rax
jmp    23fd <main+0x1cd>
cmp    $0x38400,%eax
jne    2402 <main+0x1d2>
mov    0x2ae3(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
mov    0x2b46(%rip),%rax
mov    (%rax),%esi
call   2090 <signal@plt>
mov    0x2bb0(%rip),%rbx
mov    (%rbx),%edi
mov    0x2aef(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   2150 <socket@plt>
test   %eax,%eax
jns    2442 <main+0x212>
lea    0xbd3(%rip),%rdi
jmp    24d5 <main+0x2a5>
mov    %eax,%r13d
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    $0x3039,%edi
call   2040 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x2b50(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r13d,%edi
mov    $0xc,%edx
call   20d0 <bind@plt>
test   %rax,%rax
jne    24c5 <main+0x295>
mov    %r13d,%edi
mov    $0x3,%esi
call   20c0 <listen@plt>
test   %rax,%rax
jne    24ce <main+0x29e>
movl   $0xc,0x4(%rsp)
lea    0x20(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r13d,%edi
call   2120 <accept@plt>
test   %eax,%eax
jns    24ee <main+0x2be>
lea    0xb6f(%rip),%rdi
call   2100 <perror@plt>
mov    %r13d,%edi
call   2070 <close@plt>
xor    %eax,%eax
jmp    24df <main+0x2af>
lea    0xb4b(%rip),%rdi
jmp    24d5 <main+0x2a5>
lea    0xb47(%rip),%rdi
call   2100 <perror@plt>
mov    $0x1,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbx
jmp    2543 <main+0x313>
lea    0xb32(%rip),%rdi
call   2100 <perror@plt>
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
call   2070 <close@plt>
mov    %ebp,%edi
call   2070 <close@plt>
movl   $0xc,0x4(%rsp)
mov    %r13d,%edi
lea    0x20(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   2120 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
js     24ad <main+0x27d>
mov    0x29e6(%rip),%rax
mov    (%rax),%esi
mov    0x2a8d(%rip),%rax
or     (%rax),%esi
lea    0xace(%rip),%rdi
call   20f0 <open@plt>
mov    %eax,%r14d
lea    0x30(%rsp),%r15
mov    %r15,%rdi
mov    $0x28,%esi
call   2110 <bzero@plt>
mov    0x29fb(%rip),%rax
mov    (%rax),%eax
or     (%rsp),%eax
mov    0x294f(%rip),%rcx
or     (%rcx),%eax
mov    0x29ee(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x30(%rsp)
mov    0x2951(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rsp)
lea    0x40(%rsp),%rax
xorps  %xmm0,%xmm0
movups %xmm0,(%rax)
mov    0x38(%rsp),%rax
mov    0x293c(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x299a(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2958(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   2050 <tcflush@plt>
mov    0x29cf(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %r15,%rdx
call   20e0 <tcsetattr@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   2060 <max@plt>
mov    %eax,%edi
mov    %r13d,%esi
call   2060 <max@plt>
mov    %eax,%r15d
add    $0x1,%r15d
mov    %r12,%rdi
call   20a0 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %r12,%rsi
call   2140 <FD_SET@plt>
mov    %r14d,%edi
mov    %r12,%rsi
call   2140 <FD_SET@plt>
mov    %r13d,%edi
mov    %r12,%rsi
call   2140 <FD_SET@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   20b0 <select@plt>
test   %eax,%eax
js     24fc <main+0x2cc>
mov    %r13d,%edi
mov    %rbx,%rsi
call   2030 <FD_ISSET@plt>
test   %rax,%rax
jne    2510 <main+0x2e0>
mov    %ebp,%edi
mov    %rbx,%rsi
call   2030 <FD_ISSET@plt>
test   %rax,%rax
je     26a8 <main+0x478>
mov    %r14d,%edi
mov    %ebp,%esi
call   2080 <Repeater@plt>
test   %rax,%rax
jle    2510 <main+0x2e0>
mov    %r14d,%edi
mov    %rbx,%rsi
call   2030 <FD_ISSET@plt>
test   %rax,%rax
je     2650 <main+0x420>
mov    %ebp,%edi
mov    %r14d,%esi
call   2080 <Repeater@plt>
test   %rax,%rax
jg     2650 <main+0x420>
jmp    2510 <main+0x2e0>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.termios = type { i32, i64*, i64, i64, i32 }
%struct.sockaddr = type { i32 }
@B9600 = global i32 0
@B0 = global i32 0
@B50 = global i32 0
@B75 = global i32 0
@B110 = global i32 0
@B134 = global i32 0
@B150 = global i32 0
@B200 = global i32 0
@B300 = global i32 0
@B600 = global i32 0
@B1200 = global i32 0
@B1800 = global i32 0
@B2400 = global i32 0
@B4800 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@INADDR_ANY = global i32 0
@.str.1 = [5 x i8] c"bind\00"
@.str.2 = [7 x i8] c"listen\00"
@.str.3 = [7 x i8] c"accept\00"
@.str.4 = [11 x i8] c"/dev/ttyS0\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@.str.5 = [4 x i8] c"tty\00"
@CS8 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@IGNPAR = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@.str.6 = [7 x i8] c"select\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.sockaddr_in
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.termios
%16 = alloca %struct.termios
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* @B9600
store i32 %19, i32* %17
%20 = load i32, i32* %4
%21 = icmp sge i32 %20, 2
br i1 %21, label %22, label %161
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %17
%27 = load i32, i32* %17
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = load i32, i32* @B0
br label %159
31: ; preds = %22
%32 = load i32, i32* %17
%33 = icmp eq i32 %32, 50
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = load i32, i32* @B50
br label %157
36: ; preds = %31
%37 = load i32, i32* %17
%38 = icmp eq i32 %37, 75
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = load i32, i32* @B75
br label %155
41: ; preds = %36
%42 = load i32, i32* %17
%43 = icmp eq i32 %42, 110
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = load i32, i32* @B110
br label %153
46: ; preds = %41
%47 = load i32, i32* %17
%48 = icmp eq i32 %47, 134
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = load i32, i32* @B134
br label %151
51: ; preds = %46
%52 = load i32, i32* %17
%53 = icmp eq i32 %52, 150
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = load i32, i32* @B150
br label %149
56: ; preds = %51
%57 = load i32, i32* %17
%58 = icmp eq i32 %57, 200
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = load i32, i32* @B200
br label %147
61: ; preds = %56
%62 = load i32, i32* %17
%63 = icmp eq i32 %62, 300
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = load i32, i32* @B300
br label %145
66: ; preds = %61
%67 = load i32, i32* %17
%68 = icmp eq i32 %67, 600
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = load i32, i32* @B600
br label %143
71: ; preds = %66
%72 = load i32, i32* %17
%73 = icmp eq i32 %72, 1200
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = load i32, i32* @B1200
br label %141
76: ; preds = %71
%77 = load i32, i32* %17
%78 = icmp eq i32 %77, 1800
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = load i32, i32* @B1800
br label %139
81: ; preds = %76
%82 = load i32, i32* %17
%83 = icmp eq i32 %82, 2400
br i1 %83, label %84, label %86
84: ; preds = %81
%85 = load i32, i32* @B2400
br label %137
86: ; preds = %81
%87 = load i32, i32* %17
%88 = icmp eq i32 %87, 4800
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = load i32, i32* @B4800
br label %135
91: ; preds = %86
%92 = load i32, i32* %17
%93 = icmp eq i32 %92, 9600
br i1 %93, label %94, label %96
94: ; preds = %91
%95 = load i32, i32* @B9600
br label %133
96: ; preds = %91
%97 = load i32, i32* %17
%98 = icmp eq i32 %97, 19200
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = load i32, i32* @B19200
br label %131
101: ; preds = %96
%102 = load i32, i32* %17
%103 = icmp eq i32 %102, 38400
br i1 %103, label %104, label %106
104: ; preds = %101
%105 = load i32, i32* @B38400
br label %129
106: ; preds = %101
%107 = load i32, i32* %17
%108 = icmp eq i32 %107, 57600
br i1 %108, label %109, label %111
109: ; preds = %106
%110 = load i32, i32* @B57600
br label %127
111: ; preds = %106
%112 = load i32, i32* %17
%113 = icmp eq i32 %112, 115200
br i1 %113, label %114, label %116
114: ; preds = %111
%115 = load i32, i32* @B115200
br label %125
116: ; preds = %111
%117 = load i32, i32* %17
%118 = icmp eq i32 %117, 230400
br i1 %118, label %119, label %121
119: ; preds = %116
%120 = load i32, i32* @B230400
br label %123
121: ; preds = %116
%122 = load i32, i32* @B9600
br label %123
123: ; preds = %121, %119
%124 = phi i32 [ %120, %119 ], [ %122, %121 ]
br label %125
125: ; preds = %123, %114
%126 = phi i32 [ %115, %114 ], [ %124, %123 ]
br label %127
127: ; preds = %125, %109
%128 = phi i32 [ %110, %109 ], [ %126, %125 ]
br label %129
129: ; preds = %127, %104
%130 = phi i32 [ %105, %104 ], [ %128, %127 ]
br label %131
131: ; preds = %129, %99
%132 = phi i32 [ %100, %99 ], [ %130, %129 ]
br label %133
133: ; preds = %131, %94
%134 = phi i32 [ %95, %94 ], [ %132, %131 ]
br label %135
135: ; preds = %133, %89
%136 = phi i32 [ %90, %89 ], [ %134, %133 ]
br label %137
137: ; preds = %135, %84
%138 = phi i32 [ %85, %84 ], [ %136, %135 ]
br label %139
139: ; preds = %137, %79
%140 = phi i32 [ %80, %79 ], [ %138, %137 ]
br label %141
141: ; preds = %139, %74
%142 = phi i32 [ %75, %74 ], [ %140, %139 ]
br label %143
143: ; preds = %141, %69
%144 = phi i32 [ %70, %69 ], [ %142, %141 ]
br label %145
145: ; preds = %143, %64
%146 = phi i32 [ %65, %64 ], [ %144, %143 ]
br label %147
147: ; preds = %145, %59
%148 = phi i32 [ %60, %59 ], [ %146, %145 ]
br label %149
149: ; preds = %147, %54
%150 = phi i32 [ %55, %54 ], [ %148, %147 ]
br label %151
151: ; preds = %149, %49
%152 = phi i32 [ %50, %49 ], [ %150, %149 ]
br label %153
153: ; preds = %151, %44
%154 = phi i32 [ %45, %44 ], [ %152, %151 ]
br label %155
155: ; preds = %153, %39
%156 = phi i32 [ %40, %39 ], [ %154, %153 ]
br label %157
157: ; preds = %155, %34
%158 = phi i32 [ %35, %34 ], [ %156, %155 ]
br label %159
159: ; preds = %157, %29
%160 = phi i32 [ %30, %29 ], [ %158, %157 ]
store i32 %160, i32* %17
br label %161
161: ; preds = %159, %2
%162 = load i32, i32* @SIGPIPE
%163 = load i32, i32* @SIG_IGN
%164 = call i32 @signal(i32 %162, i32 %163)
%165 = load i32, i32* @AF_INET
%166 = load i32, i32* @SOCK_STREAM
%167 = call i32 @socket(i32 %165, i32 %166, i32 0)
store i32 %167, i32* %6
%168 = load i32, i32* %6
%169 = icmp slt i32 %168, 0
br i1 %169, label %170, label %172
170: ; preds = %161
%171 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %293
172: ; preds = %161
%173 = load i32, i32* @AF_INET
%174 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %173, i32* %174
%175 = call i32 @htons(i32 12345)
%176 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i32 %175, i32* %176
%177 = load i32, i32* @INADDR_ANY
%178 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%179 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %178, i32 0, i32 0
store i32 %177, i32* %179
%180 = load i32, i32* %6
%181 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%182 = call i64 @bind(i32 %180, %struct.sockaddr* %181, i32 12)
%183 = icmp ne i64 %182, 0
br i1 %183, label %184, label %186
184: ; preds = %172
%185 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %293
186: ; preds = %172
%187 = load i32, i32* %6
%188 = call i64 @listen(i32 %187, i32 3)
%189 = icmp ne i64 %188, 0
br i1 %189, label %190, label %192
190: ; preds = %186
%191 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %293
192: ; preds = %186
br label %193
193: ; preds = %192, %285
store i32 12, i32* %11
%194 = load i32, i32* %6
%195 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%196 = call i32 @accept(i32 %194, %struct.sockaddr* %195, i32* %11)
store i32 %196, i32* %7
%197 = load i32, i32* %7
%198 = icmp slt i32 %197, 0
br i1 %198, label %199, label %201
199: ; preds = %193
%200 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %290
201: ; preds = %193
%202 = load i32, i32* @O_RDWR
%203 = load i32, i32* @O_NOCTTY
%204 = or i32 %202, %203
%205 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %204)
store i32 %205, i32* %8
%206 = load i32, i32* %7
%207 = icmp slt i32 %206, 0
br i1 %207, label %208, label %210
208: ; preds = %201
%209 = call i32 @perror(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %293
210: ; preds = %201
%211 = call i32 @bzero(%struct.termios* %16, i32 40)
%212 = load i32, i32* %17
%213 = load i32, i32* @CS8
%214 = or i32 %212, %213
%215 = load i32, i32* @CLOCAL
%216 = or i32 %214, %215
%217 = load i32, i32* @CREAD
%218 = or i32 %216, %217
%219 = getelementptr inbounds %struct.termios, %struct.termios* %16, i32 0, i32 0
store i32 %218, i32* %219
%220 = load i32, i32* @IGNPAR
%221 = getelementptr inbounds %struct.termios, %struct.termios* %16, i32 0, i32 4
store i32 %220, i32* %221
%222 = getelementptr inbounds %struct.termios, %struct.termios* %16, i32 0, i32 3
store i64 0, i64* %222
%223 = getelementptr inbounds %struct.termios, %struct.termios* %16, i32 0, i32 2
store i64 0, i64* %223
%224 = getelementptr inbounds %struct.termios, %struct.termios* %16, i32 0, i32 1
%225 = load i64*, i64** %224
%226 = load i64, i64* @VTIME
%227 = getelementptr inbounds i64, i64* %225, i64 %226
store i64 0, i64* %227
%228 = getelementptr inbounds %struct.termios, %struct.termios* %16, i32 0, i32 1
%229 = load i64*, i64** %228
%230 = load i64, i64* @VMIN
%231 = getelementptr inbounds i64, i64* %229, i64 %230
store i64 0, i64* %231
%232 = load i32, i32* %8
%233 = load i32, i32* @TCIFLUSH
%234 = call i32 @tcflush(i32 %232, i32 %233)
%235 = load i32, i32* %8
%236 = load i32, i32* @TCSANOW
%237 = call i32 @tcsetattr(i32 %235, i32 %236, %struct.termios* %16)
store i32 %237, i32* %12
%238 = load i32, i32* %7
%239 = load i32, i32* %8
%240 = call i32 @max(i32 %238, i32 %239)
%241 = load i32, i32* %6
%242 = call i32 @max(i32 %240, i32 %241)
%243 = add nsw i32 %242, 1
store i32 %243, i32* %18
%244 = call i32 @FD_ZERO(i32* %13)
%245 = load i32, i32* %7
%246 = call i32 @FD_SET(i32 %245, i32* %13)
%247 = load i32, i32* %8
%248 = call i32 @FD_SET(i32 %247, i32* %13)
%249 = load i32, i32* %6
%250 = call i32 @FD_SET(i32 %249, i32* %13)
br label %251
251: ; preds = %210, %284
%252 = load i32, i32* %13
store i32 %252, i32* %14
%253 = load i32, i32* %18
%254 = call i32 @select(i32 %253, i32* %14, i32* null, i32* null, i32* null)
store i32 %254, i32* %12
%255 = load i32, i32* %12
%256 = icmp slt i32 %255, 0
br i1 %256, label %257, label %259
257: ; preds = %251
%258 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %285
259: ; preds = %251
%260 = load i32, i32* %6
%261 = call i64 @FD_ISSET(i32 %260, i32* %14)
%262 = icmp ne i64 %261, 0
br i1 %262, label %263, label %264
263: ; preds = %259
br label %285
264: ; preds = %259
%265 = load i32, i32* %7
%266 = call i64 @FD_ISSET(i32 %265, i32* %14)
%267 = icmp ne i64 %266, 0
br i1 %267, label %268, label %274
268: ; preds = %264
%269 = load i32, i32* %8
%270 = load i32, i32* %7
%271 = call i64 @Repeater(i32 %269, i32 %270)
%272 = icmp sle i64 %271, 0
br i1 %272, label %273, label %274
273: ; preds = %268
br label %285
274: ; preds = %268, %264
%275 = load i32, i32* %8
%276 = call i64 @FD_ISSET(i32 %275, i32* %14)
%277 = icmp ne i64 %276, 0
br i1 %277, label %278, label %284
278: ; preds = %274
%279 = load i32, i32* %7
%280 = load i32, i32* %8
%281 = call i64 @Repeater(i32 %279, i32 %280)
%282 = icmp sle i64 %281, 0
br i1 %282, label %283, label %284
283: ; preds = %278
br label %285
284: ; preds = %278, %274
br label %251
285: ; preds = %283, %273, %263, %257
%286 = load i32, i32* %8
%287 = call i32 @close(i32 %286)
%288 = load i32, i32* %7
%289 = call i32 @close(i32 %288)
br label %193
290: ; preds = %199
%291 = load i32, i32* %6
%292 = call i32 @close(i32 %291)
store i32 0, i32* %3
br label %293
293: ; preds = %290, %208, %190, %184, %170
%294 = load i32, i32* %3
ret i32 %294
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.termios = type { i32, i64*, i64, i64, i32 }
%struct.sockaddr = type { i32 }
@B9600 = global i32 0
@B0 = global i32 0
@B50 = global i32 0
@B75 = global i32 0
@B110 = global i32 0
@B134 = global i32 0
@B150 = global i32 0
@B200 = global i32 0
@B300 = global i32 0
@B600 = global i32 0
@B1200 = global i32 0
@B1800 = global i32 0
@B2400 = global i32 0
@B4800 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@INADDR_ANY = global i32 0
@.str.1 = [5 x i8] c"bind\00"
@.str.2 = [7 x i8] c"listen\00"
@.str.3 = [7 x i8] c"accept\00"
@.str.4 = [11 x i8] c"/dev/ttyS0\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@CS8 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@IGNPAR = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@.str.6 = [7 x i8] c"select\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.termios
%9 = bitcast %struct.sockaddr_in* %3 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast %struct.termios* %8 to i8*
%15 = load i32, i32* @B9600
%16 = icmp sgt i32 %0, 1
br i1 %16, label %17, label %59
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
switch i32 %20, label %55 [
i32 0, label %21
i32 50, label %23
i32 75, label %25
i32 110, label %27
i32 134, label %29
i32 150, label %31
i32 200, label %33
i32 300, label %35
i32 600, label %37
i32 1200, label %39
i32 1800, label %41
i32 2400, label %43
i32 4800, label %45
i32 9600, label %59
i32 19200, label %47
i32 38400, label %49
i32 57600, label %51
i32 115200, label %53
]
21: ; preds = %17
%22 = load i32, i32* @B0
br label %59
23: ; preds = %17
%24 = load i32, i32* @B50
br label %59
25: ; preds = %17
%26 = load i32, i32* @B75
br label %59
27: ; preds = %17
%28 = load i32, i32* @B110
br label %59
29: ; preds = %17
%30 = load i32, i32* @B134
br label %59
31: ; preds = %17
%32 = load i32, i32* @B150
br label %59
33: ; preds = %17
%34 = load i32, i32* @B200
br label %59
35: ; preds = %17
%36 = load i32, i32* @B300
br label %59
37: ; preds = %17
%38 = load i32, i32* @B600
br label %59
39: ; preds = %17
%40 = load i32, i32* @B1200
br label %59
41: ; preds = %17
%42 = load i32, i32* @B1800
br label %59
43: ; preds = %17
%44 = load i32, i32* @B2400
br label %59
45: ; preds = %17
%46 = load i32, i32* @B4800
br label %59
47: ; preds = %17
%48 = load i32, i32* @B19200
br label %59
49: ; preds = %17
%50 = load i32, i32* @B38400
br label %59
51: ; preds = %17
%52 = load i32, i32* @B57600
br label %59
53: ; preds = %17
%54 = load i32, i32* @B115200
br label %59
55: ; preds = %17
%56 = icmp eq i32 %20, 230400
%57 = load i32, i32* @B230400
%58 = select i1 %56, i32 %57, i32 %15
br label %59
59: ; preds = %21, %25, %29, %33, %37, %41, %45, %47, %51, %55, %53, %49, %43, %39, %35, %31, %27, %23, %17, %2
%60 = phi i32 [ %15, %2 ], [ %22, %21 ], [ %24, %23 ], [ %26, %25 ], [ %28, %27 ], [ %30, %29 ], [ %32, %31 ], [ %34, %33 ], [ %36, %35 ], [ %38, %37 ], [ %40, %39 ], [ %42, %41 ], [ %44, %43 ], [ %46, %45 ], [ %48, %47 ], [ %50, %49 ], [ %52, %51 ], [ %54, %53 ], [ %58, %55 ], [ %15, %17 ]
%61 = load i32, i32* @SIGPIPE
%62 = load i32, i32* @SIG_IGN
%63 = tail call i32 @signal(i32 %61, i32 %62)
%64 = load i32, i32* @AF_INET
%65 = load i32, i32* @SOCK_STREAM
%66 = tail call i32 @socket(i32 %64, i32 %65, i32 0)
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %59
%69 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %159
70: ; preds = %59
%71 = load i32, i32* @AF_INET
%72 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %71, i32* %72
%73 = tail call i32 @htons(i32 12345)
%74 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %73, i32* %74
%75 = load i32, i32* @INADDR_ANY
%76 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %75, i32* %76
%77 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%78 = call i64 @bind(i32 %66, %struct.sockaddr* %77, i32 12)
%79 = icmp eq i64 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %70
%81 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %159
82: ; preds = %70
%83 = call i64 @listen(i32 %66, i32 3)
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %95
85: ; preds = %82
%86 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
store i32 12, i32* %5
%87 = call i32 @accept(i32 %66, %struct.sockaddr* %86, i32* %5)
%88 = icmp slt i32 %87, 0
br i1 %88, label %97, label %89
89: ; preds = %85
%90 = getelementptr inbounds %struct.termios, %struct.termios* %8, i64 0, i32 0
%91 = getelementptr inbounds %struct.termios, %struct.termios* %8, i64 0, i32 4
%92 = getelementptr inbounds %struct.termios, %struct.termios* %8, i64 0, i32 2
%93 = getelementptr inbounds %struct.termios, %struct.termios* %8, i64 0, i32 1
%94 = bitcast i64* %92 to i8*
br label %100
95: ; preds = %82
%96 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %159
97: ; preds = %154, %85
%98 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%99 = call i32 @close(i32 %66)
br label %159
100: ; preds = %89, %154
%101 = phi i32 [ %87, %89 ], [ %157, %154 ]
%102 = load i32, i32* @O_RDWR
%103 = load i32, i32* @O_NOCTTY
%104 = or i32 %103, %102
%105 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %104)
%106 = call i32 @bzero(%struct.termios* %8, i32 40)
%107 = load i32, i32* @CS8
%108 = or i32 %107, %60
%109 = load i32, i32* @CLOCAL
%110 = or i32 %108, %109
%111 = load i32, i32* @CREAD
%112 = or i32 %110, %111
store i32 %112, i32* %90
%113 = load i32, i32* @IGNPAR
store i32 %113, i32* %91
%114 = load i64*, i64** %93
%115 = load i64, i64* @VTIME
%116 = getelementptr inbounds i64, i64* %114, i64 %115
store i64 0, i64* %116
%117 = load i64, i64* @VMIN
%118 = getelementptr inbounds i64, i64* %114, i64 %117
store i64 0, i64* %118
%119 = load i32, i32* @TCIFLUSH
%120 = call i32 @tcflush(i32 %105, i32 %119)
%121 = load i32, i32* @TCSANOW
%122 = call i32 @tcsetattr(i32 %105, i32 %121, %struct.termios* %8)
%123 = call i32 @max(i32 %101, i32 %105)
%124 = call i32 @max(i32 %123, i32 %66)
%125 = add nsw i32 %124, 1
%126 = call i32 @FD_ZERO(i32* %6)
%127 = call i32 @FD_SET(i32 %101, i32* %6)
%128 = call i32 @FD_SET(i32 %105, i32* %6)
%129 = call i32 @FD_SET(i32 %66, i32* %6)
%130 = load i32, i32* %6
store i32 %130, i32* %7
%131 = call i32 @select(i32 %125, i32* %7, i32* null, i32* null, i32* null)
%132 = icmp slt i32 %131, 0
br i1 %132, label %133, label %135
133: ; preds = %150, %100
%134 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %154
135: ; preds = %100, %150
%136 = call i64 @FD_ISSET(i32 %66, i32* %7)
%137 = icmp eq i64 %136, 0
br i1 %137, label %138, label %154
138: ; preds = %135
%139 = call i64 @FD_ISSET(i32 %101, i32* %7)
%140 = icmp eq i64 %139, 0
br i1 %140, label %144, label %141
141: ; preds = %138
%142 = call i64 @Repeater(i32 %105, i32 %101)
%143 = icmp slt i64 %142, 1
br i1 %143, label %154, label %144
144: ; preds = %141, %138
%145 = call i64 @FD_ISSET(i32 %105, i32* %7)
%146 = icmp eq i64 %145, 0
br i1 %146, label %150, label %147
147: ; preds = %144
%148 = call i64 @Repeater(i32 %101, i32 %105)
%149 = icmp slt i64 %148, 1
br i1 %149, label %154, label %150
150: ; preds = %147, %144
%151 = load i32, i32* %6
store i32 %151, i32* %7
%152 = call i32 @select(i32 %125, i32* %7, i32* null, i32* null, i32* null)
%153 = icmp slt i32 %152, 0
br i1 %153, label %133, label %135
154: ; preds = %147, %141, %135, %133
%155 = call i32 @close(i32 %105)
%156 = call i32 @close(i32 %101)
store i32 12, i32* %5
%157 = call i32 @accept(i32 %66, %struct.sockaddr* %86, i32* %5)
%158 = icmp slt i32 %157, 0
br i1 %158, label %97, label %100
159: ; preds = %97, %95, %80, %68
%160 = phi i32 [ 1, %68 ], [ 1, %80 ], [ 1, %95 ], [ 0, %97 ]
ret i32 %160
}