#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 pollfd {
  int fd;
  int events;
  int revents;
};
typedef int /*<<< orphan*/ data;

/* Variables and functions */
int POLLIN;
int /*<<< orphan*/ STDERR_FILENO;
int STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ dprintf(int /*<<< orphan*/, char *, ...);
int poll(struct pollfd *, int, int);
int read(int, unsigned char *, int);
unsigned int strtoul(char *, char **, int);
int main() {
  unsigned char data[512];
  char loop = 1;
  do {
    struct pollfd fds[2];
    fds[0].fd = 3;
    fds[0].events = POLLIN;
    fds[1].fd = STDIN_FILENO;
    fds[1].events = POLLIN;
    int timeout_msecs = 5 * 1e3;
    int pollres = poll(fds, 2, timeout_msecs);
    if (pollres > 0) {
      int i;
      if (fds[0].revents & POLLIN) {
        int rd = read(fds[0].fd, data, sizeof(data));
        if (rd) {
          dprintf(STDERR_FILENO, "\e[1;36mIN:");
          for (i = 0; i < rd; ++i)
            dprintf(STDERR_FILENO, " %02X", data[i]);
          dprintf(STDERR_FILENO, "\e[0m\n");
        } else {
          loop = 0;
        }
      }
      if (fds[1].revents & POLLIN) {
        int rd = read(fds[1].fd, data, sizeof(data));
        if (rd) {
          dprintf(STDERR_FILENO, "\e[1;35mOUT:", rd);
          char *pdata = data;
          char *pdataold;
          char ok;
          do {
            pdataold = pdata;
            unsigned int hex = strtoul(pdata, &pdata, 16);
            ok = (pdata != pdataold && pdata < (char *)data + rd);
            if (ok) {
              unsigned char chex = hex;
              dprintf(STDOUT_FILENO, "%c", chex);
              dprintf(STDERR_FILENO,
                      (hex == chex) ? " %02X" : " \e[4m%02X\e[24m", chex);
            }
          } while (ok);
          dprintf(STDERR_FILENO, "\e[0m\n");
        } else {
          loop = 0;
        }
      }
    }
  } while (loop);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x1,-0x211(%rbp)
movl   $0x3,-0x230(%rbp)
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x22c(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x224(%rbp)
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x220(%rbp)
movl   $0x1388,-0x234(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x234(%rbp),%edx
mov    $0x2,%esi
call   1050 <poll@plt>
mov    %eax,-0x238(%rbp)
cmpl   $0x0,-0x238(%rbp)
jle    1433 <main+0x2f3>
mov    -0x228(%rbp),%eax
mov    0x2e0f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     129b <main+0x15b>
mov    -0x230(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1040 <read@plt>
mov    %eax,-0x240(%rbp)
cmpl   $0x0,-0x240(%rbp)
je     128f <main+0x14f>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1030 <dprintf@plt>
movl   $0x0,-0x23c(%rbp)
mov    -0x23c(%rbp),%eax
cmp    -0x240(%rbp),%eax
jge    1273 <main+0x133>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
movslq -0x23c(%rbp),%rax
movzbl -0x210(%rbp,%rax,1),%edx
ff
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1030 <dprintf@plt>
mov    -0x23c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x23c(%rbp)
jmp    1227 <main+0xe7>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1030 <dprintf@plt>
jmp    1296 <main+0x156>
movb   $0x0,-0x211(%rbp)
jmp    129b <main+0x15b>
mov    -0x21c(%rbp),%eax
mov    0x2d38(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     142e <main+0x2ee>
mov    -0x224(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1040 <read@plt>
mov    %eax,-0x244(%rbp)
cmpl   $0x0,-0x244(%rbp)
je     1422 <main+0x2e2>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
mov    -0x244(%rbp),%edx
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1030 <dprintf@plt>
lea    -0x210(%rbp),%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rax
mov    %rax,-0x258(%rbp)
mov    -0x250(%rbp),%rdi
lea    -0x250(%rbp),%rsi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x260(%rbp)
mov    -0x250(%rbp),%rcx
xor    %eax,%eax
cmp    -0x258(%rbp),%rcx
mov    %al,-0x262(%rbp)
je     1374 <main+0x234>
mov    -0x250(%rbp),%rax
lea    -0x210(%rbp),%rcx
movslq -0x244(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
setb   %al
mov    %al,-0x262(%rbp)
mov    -0x262(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x259(%rbp)
cmpb   $0x0,-0x259(%rbp)
je     13f4 <main+0x2b4>
mov    -0x260(%rbp),%eax
mov    %al,-0x261(%rbp)
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
movzbl -0x261(%rbp),%edx
lea    0xc6e(%rip),%rsi
mov    $0x0,%al
call   1030 <dprintf@plt>
mov    0x2c0d(%rip),%rax
mov    (%rax),%edi
mov    -0x260(%rbp),%ecx
movzbl -0x261(%rbp),%edx
lea    0xc4d(%rip),%rsi
lea    0xc2b(%rip),%rax
cmp    %edx,%ecx
cmove  %rax,%rsi
movzbl -0x261(%rbp),%edx
mov    $0x0,%al
call   1030 <dprintf@plt>
jmp    13f9 <main+0x2b9>
cmpb   $0x0,-0x259(%rbp)
jne    1308 <main+0x1c8>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    0xbfb(%rip),%rsi
mov    $0x0,%al
call   1030 <dprintf@plt>
jmp    1429 <main+0x2e9>
movb   $0x0,-0x211(%rbp)
jmp    142e <main+0x2ee>
jmp    1433 <main+0x2f3>
jmp    1438 <main+0x2f8>
cmpb   $0x0,-0x211(%rbp)
jne    1159 <main+0x19>
xor    %eax,%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    0x2e88(%rip),%rbx
mov    0x2e69(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x30(%rsp),%r12
lea    0xe9b(%rip),%r13
jmp    11bc <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
xor    %eax,%eax
call   1030 <dprintf@plt>
mov    0x2e2a(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x30(%rsp),%r12
mov    0xc(%rsp),%ebp
mov    0x2e2d(%rip),%rbx
test   %bpl,%bpl
je     137e <main+0x23e>
movl   $0x3,0x10(%rsp)
mov    (%rbx),%eax
mov    %eax,0x14(%rsp)
mov    (%r14),%ecx
mov    %ecx,0x1c(%rsp)
mov    %eax,0x20(%rsp)
mov    %r15,%rdi
mov    $0x2,%esi
mov    $0x1388,%edx
call   1050 <poll@plt>
test   %eax,%eax
jle    1290 <main+0x150>
mov    (%rbx),%eax
mov    $0x1,%bpl
test   %eax,0x18(%rsp)
je     129a <main+0x15a>
mov    0x10(%rsp),%edi
mov    %r12,%rsi
mov    $0x200,%edx
call   1040 <read@plt>
test   %eax,%eax
je     1298 <main+0x158>
mov    %eax,%ebp
mov    %r13,%r14
mov    0x2dad(%rip),%r13
mov    0x0(%r13),%edi
lea    0xdd2(%rip),%rsi
xor    %eax,%eax
call   1030 <dprintf@plt>
test   %ebp,%ebp
jle    125c <main+0x11c>
mov    %ebp,%ebx
xor    %ebp,%ebp
nopl   (%rax)
mov    0x0(%r13),%edi
movzbl 0x30(%rsp,%rbp,1),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <dprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1240 <main+0x100>
mov    0x0(%r13),%edi
lea    0xdaa(%rip),%rsi
xor    %eax,%eax
call   1030 <dprintf@plt>
mov    0x2d6b(%rip),%rbx
lea    0x30(%rsp),%r12
mov    %r14,%r13
mov    $0x1,%bpl
mov    0x2d41(%rip),%r14
jmp    129a <main+0x15a>
nopl   0x0(%rax)
mov    $0x1,%bpl
jmp    11b3 <main+0x73>
xor    %ebp,%ebp
mov    (%rbx),%eax
test   %eax,0x24(%rsp)
je     11b3 <main+0x73>
mov    0x1c(%rsp),%edi
mov    %r12,%rsi
mov    $0x200,%edx
call   1040 <read@plt>
test   %eax,%eax
je     137e <main+0x23e>
mov    %eax,%ebx
mov    %ebp,0xc(%rsp)
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <dprintf@plt>
mov    %r12,(%rsp)
mov    %r12,%rdi
mov    %rsp,%rbp
mov    %rbp,%rsi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,%r15d
mov    (%rsp),%rax
cmp    %r12,%rax
je     1180 <main+0x40>
movslq %ebx,%rcx
lea    (%rsp,%rcx,1),%r12
add    $0x30,%r12
cmp    %r12,%rax
jae    1180 <main+0x40>
mov    %rax,%r14
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
movzbl %r15b,%ebx
lea    0xcf3(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <dprintf@plt>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
cmp    $0x100,%r15d
lea    0xcd6(%rip),%rsi
cmovb  %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <dprintf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,%r15d
mov    (%rsp),%rax
cmp    %r14,%rax
jne    1310 <main+0x1d0>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
@POLLIN = global i32 0
@STDIN_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str = [11 x i8] c"\1B[1;36mIN:\00"
@.str.1 = [6 x i8] c" %02X\00"
@.str.2 = [6 x i8] c"\1B[0m\0A\00"
@.str.3 = [12 x i8] c"\1B[1;35mOUT:\00"
@STDOUT_FILENO = global i32 0
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [15 x i8] c" \1B[4m%02X\1B[24m\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca i8
%4 = alloca [2 x %struct.pollfd]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8
%13 = alloca i32
%14 = alloca i8
store i32 0, i32* %1
store i8 1, i8* %3
br label %15
15: ; preds = %138, %0
%16 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0
%17 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %16, i32 0, i32 0
store i32 3, i32* %17
%18 = load i32, i32* @POLLIN
%19 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0
%20 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %19, i32 0, i32 1
store i32 %18, i32* %20
%21 = load i32, i32* @STDIN_FILENO
%22 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 1
%23 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %22, i32 0, i32 0
store i32 %21, i32* %23
%24 = load i32, i32* @POLLIN
%25 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 1
%26 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %25, i32 0, i32 1
store i32 %24, i32* %26
store i32 5000, i32* %5
%27 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0
%28 = load i32, i32* %5
%29 = call i32 @poll(%struct.pollfd* %27, i32 2, i32 %28)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %137
32: ; preds = %15
%33 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0
%34 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %33, i32 0, i32 2
%35 = load i32, i32* %34
%36 = load i32, i32* @POLLIN
%37 = and i32 %35, %36
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %70
39: ; preds = %32
%40 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0
%41 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%44 = call i32 @read(i32 %42, i8* %43, i32 512)
store i32 %44, i32* %8
%45 = load i32, i32* %8
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %68
47: ; preds = %39
%48 = load i32, i32* @STDERR_FILENO
%49 = call i32 (i32, i8*, ...) @dprintf(i32 %48, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %50
50: ; preds = %62, %47
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %65
54: ; preds = %50
%55 = load i32, i32* @STDERR_FILENO
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = call i32 (i32, i8*, ...) @dprintf(i32 %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %54
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %50
65: ; preds = %50
%66 = load i32, i32* @STDERR_FILENO
%67 = call i32 (i32, i8*, ...) @dprintf(i32 %66, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %69
68: ; preds = %39
store i8 0, i8* %3
br label %69
69: ; preds = %68, %65
br label %70
70: ; preds = %69, %32
%71 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 1
%72 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %71, i32 0, i32 2
%73 = load i32, i32* %72
%74 = load i32, i32* @POLLIN
%75 = and i32 %73, %74
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %136
77: ; preds = %70
%78 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 1
%79 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %78, i32 0, i32 0
%80 = load i32, i32* %79
%81 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%82 = call i32 @read(i32 %80, i8* %81, i32 512)
store i32 %82, i32* %9
%83 = load i32, i32* %9
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %134
85: ; preds = %77
%86 = load i32, i32* @STDERR_FILENO
%87 = load i32, i32* %9
%88 = call i32 (i32, i8*, ...) @dprintf(i32 %86, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %87)
%89 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
store i8* %89, i8** %10
br label %90
90: ; preds = %128, %85
%91 = load i8*, i8** %10
store i8* %91, i8** %11
%92 = load i8*, i8** %10
%93 = call i32 @strtoul(i8* %92, i8** %10, i32 16)
store i32 %93, i32* %13
%94 = load i8*, i8** %10
%95 = load i8*, i8** %11
%96 = icmp ne i8* %94, %95
br i1 %96, label %97, label %104
97: ; preds = %90
%98 = load i8*, i8** %10
%99 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%100 = load i32, i32* %9
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %99, i64 %101
%103 = icmp ult i8* %98, %102
br label %104
104: ; preds = %97, %90
%105 = phi i1 [ false, %90 ], [ %103, %97 ]
%106 = zext i1 %105 to i32
%107 = trunc i32 %106 to i8
store i8 %107, i8* %12
%108 = load i8, i8* %12
%109 = icmp ne i8 %108, 0
br i1 %109, label %110, label %127
110: ; preds = %104
%111 = load i32, i32* %13
%112 = trunc i32 %111 to i8
store i8 %112, i8* %14
%113 = load i32, i32* @STDOUT_FILENO
%114 = load i8, i8* %14
%115 = zext i8 %114 to i32
%116 = call i32 (i32, i8*, ...) @dprintf(i32 %113, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %115)
%117 = load i32, i32* @STDERR_FILENO
%118 = load i32, i32* %13
%119 = load i8, i8* %14
%120 = zext i8 %119 to i32
%121 = icmp eq i32 %118, %120
%122 = zext i1 %121 to i64
%123 = select i1 %121, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0)
%124 = load i8, i8* %14
%125 = zext i8 %124 to i32
%126 = call i32 (i32, i8*, ...) @dprintf(i32 %117, i8* %123, i32 %125)
br label %127
127: ; preds = %110, %104
br label %128
128: ; preds = %127
%129 = load i8, i8* %12
%130 = icmp ne i8 %129, 0
br i1 %130, label %90, label %131
131: ; preds = %128
%132 = load i32, i32* @STDERR_FILENO
%133 = call i32 (i32, i8*, ...) @dprintf(i32 %132, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %135
134: ; preds = %77
store i8 0, i8* %3
br label %135
135: ; preds = %134, %131
br label %136
136: ; preds = %135, %70
br label %137
137: ; preds = %136, %15
br label %138
138: ; preds = %137
%139 = load i8, i8* %3
%140 = icmp ne i8 %139, 0
br i1 %140, label %15, label %141
141: ; preds = %138
ret i32 0
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
@POLLIN = global i32 0
@STDIN_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str = [11 x i8] c"\1B[1;36mIN:\00"
@.str.1 = [6 x i8] c" %02X\00"
@.str.2 = [6 x i8] c"\1B[0m\0A\00"
@.str.3 = [12 x i8] c"\1B[1;35mOUT:\00"
@STDOUT_FILENO = global i32 0
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [15 x i8] c" \1B[4m%02X\1B[24m\00"
define i32 @main() {
%1 = alloca [512 x i8]
%2 = alloca [2 x %struct.pollfd]
%3 = alloca i8*
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%5 = bitcast [2 x %struct.pollfd]* %2 to i8*
%6 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %2, i64 0, i64 0
%7 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %2, i64 0, i64 0, i32 0
%8 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %2, i64 0, i64 0, i32 1
%9 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %2, i64 0, i64 1, i32 0
%10 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %2, i64 0, i64 1, i32 1
%11 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %2, i64 0, i64 0, i32 2
%12 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %2, i64 0, i64 1, i32 2
%13 = bitcast i8** %3 to i8*
br label %14
14: ; preds = %85, %0
store i32 3, i32* %7
%15 = load i32, i32* @POLLIN
store i32 %15, i32* %8
%16 = load i32, i32* @STDIN_FILENO
store i32 %16, i32* %9
store i32 %15, i32* %10
%17 = call i32 @poll(%struct.pollfd* %6, i32 2, i32 5000)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %85
19: ; preds = %14
%20 = load i32, i32* %11
%21 = load i32, i32* @POLLIN
%22 = and i32 %21, %20
%23 = icmp eq i32 %22, 0
br i1 %23, label %46, label %24
24: ; preds = %19
%25 = load i32, i32* %7
%26 = call i32 @read(i32 %25, i8* %4, i32 512)
%27 = icmp eq i32 %26, 0
br i1 %27, label %46, label %28
28: ; preds = %24
%29 = load i32, i32* @STDERR_FILENO
%30 = call i32 (i32, i8*, ...) @dprintf(i32 %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%31 = icmp sgt i32 %26, 0
br i1 %31, label %32, label %43
32: ; preds = %28
%33 = zext i32 %26 to i64
br label %34
34: ; preds = %32, %34
%35 = phi i64 [ 0, %32 ], [ %41, %34 ]
%36 = load i32, i32* @STDERR_FILENO
%37 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 %35
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = call i32 (i32, i8*, ...) @dprintf(i32 %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = add nuw nsw i64 %35, 1
%42 = icmp eq i64 %41, %33
br i1 %42, label %43, label %34
43: ; preds = %34, %28
%44 = load i32, i32* @STDERR_FILENO
%45 = call i32 (i32, i8*, ...) @dprintf(i32 %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %43, %24, %19
%47 = phi i8 [ 1, %19 ], [ 1, %43 ], [ 0, %24 ]
%48 = load i32, i32* %12
%49 = load i32, i32* @POLLIN
%50 = and i32 %49, %48
%51 = icmp eq i32 %50, 0
br i1 %51, label %85, label %52
52: ; preds = %46
%53 = load i32, i32* %9
%54 = call i32 @read(i32 %53, i8* %4, i32 512)
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
br label %88
57: ; preds = %52
%58 = load i32, i32* @STDERR_FILENO
%59 = call i32 (i32, i8*, ...) @dprintf(i32 %58, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %54)
store i8* %4, i8** %3
%60 = sext i32 %54 to i64
%61 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 %60
%62 = call i32 @strtoul(i8* %4, i8** %3, i32 16)
%63 = load i8*, i8** %3
%64 = icmp ne i8* %63, %4
%65 = icmp ult i8* %63, %61
%66 = select i1 %64, i1 %65, i1 false
br i1 %66, label %67, label %82
67: ; preds = %57, %67
%68 = phi i8* [ %78, %67 ], [ %63, %57 ]
%69 = phi i32 [ %77, %67 ], [ %62, %57 ]
%70 = load i32, i32* @STDOUT_FILENO
%71 = and i32 %69, 255
%72 = call i32 (i32, i8*, ...) @dprintf(i32 %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %71)
%73 = load i32, i32* @STDERR_FILENO
%74 = icmp ult i32 %69, 256
%75 = select i1 %74, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0)
%76 = call i32 (i32, i8*, ...) @dprintf(i32 %73, i8* %75, i32 %71)
%77 = call i32 @strtoul(i8* %68, i8** %3, i32 16)
%78 = load i8*, i8** %3
%79 = icmp ne i8* %78, %68
%80 = icmp ult i8* %78, %61
%81 = select i1 %79, i1 %80, i1 false
br i1 %81, label %67, label %82
82: ; preds = %67, %57
%83 = load i32, i32* @STDERR_FILENO
%84 = call i32 (i32, i8*, ...) @dprintf(i32 %83, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %85
85: ; preds = %46, %82, %14
%86 = phi i8 [ 1, %14 ], [ %47, %46 ], [ %47, %82 ]
%87 = icmp eq i8 %86, 0
br i1 %87, label %88, label %14
88: ; preds = %85, %56
ret i32 0
}