#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 /*<<< orphan*/ c_iflag;
};
struct pollfd {
  int fd;
  scalar_t__ revents;
  void *events;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ ICRNL;
int O_NOCTTY;
int O_NONBLOCK;
int O_RDWR;
void *POLLIN;
int STDIN_FILENO;
int STDOUT_FILENO;
int /*<<< orphan*/ TCSAFLUSH;
int /*<<< orphan*/ cfmakeraw(struct termios *);
scalar_t__ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ isatty(int);
int open(char *, int);
scalar_t__ poll(struct pollfd *, int, int);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  char ch;
  struct termios options, in_options;
  char buf[64];
  struct pollfd pfd[2];
  int fd = open("/dev/ttymxc1", O_RDWR | O_NOCTTY | O_NONBLOCK);
  if (fd < 0) {
    fprintf(stdout, "Cannot open port, error %d\n", fd);
    return fd;
  }
  tcgetattr(fd, &options);
  cfmakeraw(&options);
  options.c_iflag |= ICRNL;
  tcsetattr(fd, TCSAFLUSH, &options);
  if (isatty(STDIN_FILENO)) {
    tcgetattr(STDIN_FILENO, &in_options);
    options = in_options;
    cfmakeraw(&options);
    tcsetattr(STDIN_FILENO, TCSAFLUSH, &options);
  }
  pfd[0].fd = fd;
  pfd[0].events = POLLIN;
  pfd[1].fd = STDIN_FILENO;
  pfd[1].events = POLLIN;
  while (poll(pfd, 2, -1) > 0) {
    if (pfd[1].revents) {
      if (read(STDIN_FILENO, &ch, 1) > 0) {
        if (ch == 24) {
          break;
        }
        write(fd, &ch, 1);
      }
    }
    if (pfd[2].revents) {
      ssize_t len = read(fd, buf, sizeof(buf));
      if (len > 0)
        write(STDOUT_FILENO, buf, len);
    }
  }
  if (close(fd) < 0) {
    fprintf(stdout, "Cannot close port, error %d\n", fd);
    return fd;
  }
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &in_options);
  fprintf(stdout, "Goodbye\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
mov    0x2de7(%rip),%rax
or     (%rax),%esi
mov    0x2df6(%rip),%rax
or     (%rax),%esi
lea    0xe25(%rip),%rdi
call   10c0 <open@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
jge    121e <main+0x7e>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    -0x94(%rbp),%edx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x94(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1429 <main+0x289>
mov    -0x94(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   10a0 <tcgetattr@plt>
lea    -0x18(%rbp),%rdi
call   1080 <cfmakeraw@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x94(%rbp),%edi
mov    0x2d7e(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   10b0 <tcsetattr@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     12b1 <main+0x111>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   10a0 <tcgetattr@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1080 <cfmakeraw@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   10b0 <tcsetattr@plt>
mov    -0x94(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    0x2cfc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    0x2ce2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   1090 <poll@plt>
cmp    $0x0,%rax
jle    13b0 <main+0x210>
cmpq   $0x0,-0x70(%rbp)
je     135c <main+0x1bc>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
jle    1357 <main+0x1b7>
movsbl -0x11(%rbp),%eax
cmp    $0x18,%eax
jne    1343 <main+0x1a3>
jmp    13b0 <main+0x210>
mov    -0x94(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    135c <main+0x1bc>
cmpq   $0x0,-0x58(%rbp)
je     13ab <main+0x20b>
mov    -0x94(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1060 <read@plt>
mov    %eax,-0x98(%rbp)
cmpl   $0x0,-0x98(%rbp)
jle    13a6 <main+0x206>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
mov    -0x98(%rbp),%edx
call   1040 <write@plt>
jmp    13ab <main+0x20b>
jmp    12e5 <main+0x145>
mov    -0x94(%rbp),%edi
call   1050 <close@plt>
cmp    $0x0,%rax
jge    13f0 <main+0x250>
mov    0x2bdc(%rip),%rax
mov    (%rax),%edi
mov    -0x94(%rbp),%edx
lea    0xc4e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x94(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1429 <main+0x289>
mov    0x2ba9(%rip),%rax
mov    (%rax),%edi
mov    0x2bd0(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   10b0 <tcsetattr@plt>
mov    0x2b96(%rip),%rax
mov    (%rax),%edi
lea    0xc2b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0x2e28(%rip),%rax
mov    0x2df1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dfe(%rip),%rax
or     (%rax),%esi
lea    0xe2d(%rip),%rdi
call   10c0 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1372 <main+0x1d2>
lea    0x10(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   10a0 <tcgetattr@plt>
mov    %r14,%rdi
call   1080 <cfmakeraw@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
or     %eax,0x10(%rsp)
mov    0x2dc3(%rip),%r15
mov    (%r15),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   10b0 <tcsetattr@plt>
mov    0x2d7f(%rip),%rbp
mov    0x0(%rbp),%edi
call   1030 <isatty@plt>
test   %rax,%rax
je     125e <main+0xbe>
mov    0x0(%rbp),%edi
lea    0x18(%rsp),%rsi
call   10a0 <tcgetattr@plt>
mov    0x18(%rsp),%eax
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1080 <cfmakeraw@plt>
mov    0x0(%rbp),%edi
mov    (%r15),%esi
mov    %r14,%rdx
call   10b0 <tcsetattr@plt>
mov    %ebx,0x20(%rsp)
mov    0x2d57(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x30(%rsp)
mov    0x0(%rbp),%ecx
mov    %ecx,0x38(%rsp)
mov    %rax,0x48(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   1090 <poll@plt>
test   %rax,%rax
jle    1335 <main+0x195>
lea    0x20(%rsp),%r14
lea    0x50(%rsp),%r15
mov    0x2d45(%rip),%r13
lea    0xf(%rsp),%r12
jmp    12d7 <main+0x137>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   1090 <poll@plt>
test   %rax,%rax
jle    1335 <main+0x195>
cmpq   $0x0,0x40(%rsp)
je     130a <main+0x16a>
mov    0x0(%rbp),%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    130a <main+0x16a>
cmpb   $0x18,0xf(%rsp)
je     1335 <main+0x195>
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmpq   $0x0,0x58(%rsp)
je     12c0 <main+0x120>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x40,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    12c0 <main+0x120>
mov    0x0(%r13),%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <write@plt>
jmp    12c0 <main+0x120>
mov    %ebx,%edi
call   1050 <close@plt>
test   %rax,%rax
js     1384 <main+0x1e4>
mov    0x0(%rbp),%edi
mov    0x2c85(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
call   10b0 <tcsetattr@plt>
mov    0x2c4a(%rip),%rax
mov    (%rax),%edi
lea    0xcdf(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    139d <main+0x1fd>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
lea    0xc8b(%rip),%rsi
jmp    1394 <main+0x1f4>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
lea    0xc95(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebx,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
%struct.pollfd = type { i32, i64, i8* }
@.str = [13 x i8] c"/dev/ttymxc1\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@stdout = global i32 0
@.str.1 = [28 x i8] c"Cannot open port, error %d\0A\00"
@ICRNL = global i32 0
@TCSAFLUSH = global i32 0
@STDIN_FILENO = global i32 0
@POLLIN = global i8* null
@STDOUT_FILENO = global i32 0
@.str.2 = [29 x i8] c"Cannot close port, error %d\0A\00"
@.str.3 = [9 x i8] c"Goodbye\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca %struct.termios
%8 = alloca %struct.termios
%9 = alloca [64 x i8]
%10 = alloca [2 x %struct.pollfd]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @O_RDWR
%14 = load i32, i32* @O_NOCTTY
%15 = or i32 %13, %14
%16 = load i32, i32* @O_NONBLOCK
%17 = or i32 %15, %16
%18 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 %18, i32* %11
%19 = load i32, i32* %11
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %2
%22 = load i32, i32* @stdout
%23 = load i32, i32* %11
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %11
store i32 %25, i32* %3
br label %118
26: ; preds = %2
%27 = load i32, i32* %11
%28 = call i32 @tcgetattr(i32 %27, %struct.termios* %7)
%29 = call i32 @cfmakeraw(%struct.termios* %7)
%30 = load i32, i32* @ICRNL
%31 = getelementptr inbounds %struct.termios, %struct.termios* %7, i32 0, i32 0
%32 = load i32, i32* %31
%33 = or i32 %32, %30
store i32 %33, i32* %31
%34 = load i32, i32* %11
%35 = load i32, i32* @TCSAFLUSH
%36 = call i32 @tcsetattr(i32 %34, i32 %35, %struct.termios* %7)
%37 = load i32, i32* @STDIN_FILENO
%38 = call i64 @isatty(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %49
40: ; preds = %26
%41 = load i32, i32* @STDIN_FILENO
%42 = call i32 @tcgetattr(i32 %41, %struct.termios* %8)
%43 = bitcast %struct.termios* %7 to i8*
%44 = bitcast %struct.termios* %8 to i8*
%45 = call i32 @cfmakeraw(%struct.termios* %7)
%46 = load i32, i32* @STDIN_FILENO
%47 = load i32, i32* @TCSAFLUSH
%48 = call i32 @tcsetattr(i32 %46, i32 %47, %struct.termios* %7)
br label %49
49: ; preds = %40, %26
%50 = load i32, i32* %11
%51 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 0
%52 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %51, i32 0, i32 0
store i32 %50, i32* %52
%53 = load i8*, i8** @POLLIN
%54 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 0
%55 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %54, i32 0, i32 2
store i8* %53, i8** %55
%56 = load i32, i32* @STDIN_FILENO
%57 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 1
%58 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %57, i32 0, i32 0
store i32 %56, i32* %58
%59 = load i8*, i8** @POLLIN
%60 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 1
%61 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %60, i32 0, i32 2
store i8* %59, i8** %61
br label %62
62: ; preds = %102, %49
%63 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 0
%64 = call i64 @poll(%struct.pollfd* %63, i32 2, i32 -1)
%65 = icmp sgt i64 %64, 0
br i1 %65, label %66, label %103
66: ; preds = %62
%67 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 1
%68 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %67, i32 0, i32 1
%69 = load i64, i64* %68
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %84
71: ; preds = %66
%72 = load i32, i32* @STDIN_FILENO
%73 = call i64 @read(i32 %72, i8* %6, i32 1)
%74 = icmp sgt i64 %73, 0
br i1 %74, label %75, label %83
75: ; preds = %71
%76 = load i8, i8* %6
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 24
br i1 %78, label %79, label %80
79: ; preds = %75
br label %103
80: ; preds = %75
%81 = load i32, i32* %11
%82 = call i32 @write(i32 %81, i8* %6, i32 1)
br label %83
83: ; preds = %80, %71
br label %84
84: ; preds = %83, %66
%85 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 2
%86 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %85, i32 0, i32 1
%87 = load i64, i64* %86
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %102
89: ; preds = %84
%90 = load i32, i32* %11
%91 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%92 = call i64 @read(i32 %90, i8* %91, i32 64)
%93 = trunc i64 %92 to i32
store i32 %93, i32* %12
%94 = load i32, i32* %12
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %101
96: ; preds = %89
%97 = load i32, i32* @STDOUT_FILENO
%98 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%99 = load i32, i32* %12
%100 = call i32 @write(i32 %97, i8* %98, i32 %99)
br label %101
101: ; preds = %96, %89
br label %102
102: ; preds = %101, %84
br label %62
103: ; preds = %79, %62
%104 = load i32, i32* %11
%105 = call i64 @close(i32 %104)
%106 = icmp slt i64 %105, 0
br i1 %106, label %107, label %112
107: ; preds = %103
%108 = load i32, i32* @stdout
%109 = load i32, i32* %11
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %109)
%111 = load i32, i32* %11
store i32 %111, i32* %3
br label %118
112: ; preds = %103
%113 = load i32, i32* @STDIN_FILENO
%114 = load i32, i32* @TCSAFLUSH
%115 = call i32 @tcsetattr(i32 %113, i32 %114, %struct.termios* %8)
%116 = load i32, i32* @stdout
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %118
118: ; preds = %112, %107, %21
%119 = load i32, i32* %3
ret i32 %119
}

LLVM IR (-O2):
%struct.termios = type { i32 }
%struct.pollfd = type { i32, i64, i8* }
@.str = [13 x i8] c"/dev/ttymxc1\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@stdout = global i32 0
@.str.1 = [28 x i8] c"Cannot open port, error %d\0A\00"
@ICRNL = global i32 0
@TCSAFLUSH = global i32 0
@STDIN_FILENO = global i32 0
@POLLIN = global i8* null
@STDOUT_FILENO = global i32 0
@.str.2 = [29 x i8] c"Cannot close port, error %d\0A\00"
@.str.3 = [9 x i8] c"Goodbye\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = alloca %struct.termios
%5 = alloca %struct.termios
%6 = alloca [64 x i8]
%7 = alloca [2 x %struct.pollfd]
%8 = bitcast %struct.termios* %4 to i8*
%9 = bitcast %struct.termios* %5 to i8*
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%11 = bitcast [2 x %struct.pollfd]* %7 to i8*
%12 = load i32, i32* @O_RDWR
%13 = load i32, i32* @O_NOCTTY
%14 = or i32 %13, %12
%15 = load i32, i32* @O_NONBLOCK
%16 = or i32 %14, %15
%17 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i32, i32* @stdout
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %93
22: ; preds = %2
%23 = call i32 @tcgetattr(i32 %17, %struct.termios* %4)
%24 = call i32 @cfmakeraw(%struct.termios* %4)
%25 = load i32, i32* @ICRNL
%26 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
%27 = load i32, i32* %26
%28 = or i32 %27, %25
store i32 %28, i32* %26
%29 = load i32, i32* @TCSAFLUSH
%30 = call i32 @tcsetattr(i32 %17, i32 %29, %struct.termios* %4)
%31 = load i32, i32* @STDIN_FILENO
%32 = call i64 @isatty(i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %43, label %34
34: ; preds = %22
%35 = load i32, i32* @STDIN_FILENO
%36 = call i32 @tcgetattr(i32 %35, %struct.termios* %5)
%37 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 0
%38 = load i32, i32* %37
store i32 %38, i32* %26
%39 = call i32 @cfmakeraw(%struct.termios* %4)
%40 = load i32, i32* @STDIN_FILENO
%41 = load i32, i32* @TCSAFLUSH
%42 = call i32 @tcsetattr(i32 %40, i32 %41, %struct.termios* %4)
br label %43
43: ; preds = %34, %22
%44 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 0
%45 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 0, i32 0
store i32 %17, i32* %45
%46 = load i8*, i8** @POLLIN
%47 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 0, i32 2
store i8* %46, i8** %47
%48 = load i32, i32* @STDIN_FILENO
%49 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 1, i32 0
store i32 %48, i32* %49
%50 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 1, i32 2
store i8* %46, i8** %50
%51 = call i64 @poll(%struct.pollfd* %44, i32 2, i32 -1)
%52 = icmp sgt i64 %51, 0
br i1 %52, label %53, label %81
53: ; preds = %43
%54 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 1, i32 1
%55 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 2, i32 1
br label %56
56: ; preds = %53, %78
%57 = load i64, i64* %54
%58 = icmp eq i64 %57, 0
br i1 %58, label %68, label %59
59: ; preds = %56
%60 = load i32, i32* @STDIN_FILENO
%61 = call i64 @read(i32 %60, i8* %3, i32 1)
%62 = icmp sgt i64 %61, 0
br i1 %62, label %63, label %68
63: ; preds = %59
%64 = load i8, i8* %3
%65 = icmp eq i8 %64, 24
br i1 %65, label %81, label %66
66: ; preds = %63
%67 = call i32 @write(i32 %17, i8* %3, i32 1)
br label %68
68: ; preds = %59, %66, %56
%69 = load i64, i64* %55
%70 = icmp eq i64 %69, 0
br i1 %70, label %78, label %71
71: ; preds = %68
%72 = call i64 @read(i32 %17, i8* %10, i32 64)
%73 = trunc i64 %72 to i32
%74 = icmp sgt i32 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %71
%76 = load i32, i32* @STDOUT_FILENO
%77 = call i32 @write(i32 %76, i8* %10, i32 %73)
br label %78
78: ; preds = %71, %75, %68
%79 = call i64 @poll(%struct.pollfd* %44, i32 2, i32 -1)
%80 = icmp sgt i64 %79, 0
br i1 %80, label %56, label %81
81: ; preds = %78, %63, %43
%82 = call i64 @close(i32 %17)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load i32, i32* @stdout
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %93
87: ; preds = %81
%88 = load i32, i32* @STDIN_FILENO
%89 = load i32, i32* @TCSAFLUSH
%90 = call i32 @tcsetattr(i32 %88, i32 %89, %struct.termios* %5)
%91 = load i32, i32* @stdout
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %93
93: ; preds = %87, %84, %19
%94 = phi i32 [ %17, %19 ], [ %17, %84 ], [ 0, %87 ]
ret i32 %94
}