#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 timeval {
  int tv_sec;
  int /*<<< orphan*/ tv_usec;
};
typedef int /*<<< orphan*/ key;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int O_NONBLOCK;
int O_RDWR;
int /*<<< orphan*/ close(int);
int errno;
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int ret;
  int fd;
  char key;
  bool led[4];
  fd = open("/dev/character", O_RDWR | O_NONBLOCK);
  if (fd < 0)
    goto open_fail;
  for (int i = 0; i < 4; i++)
    led[i] = false;
  while (1) {
    fd_set rfds;
    fd_set efds;
    struct timeval timeout = {.tv_sec = 10, .tv_usec = 0};
    FD_ZERO(&rfds);
    FD_ZERO(&efds);
    FD_SET(fd, &rfds);
    FD_SET(fd, &efds);
    ret = select(fd + 1, &rfds, NULL, &efds, &timeout);
    if (ret < 0) {
      printf("select error %d\n", errno);
      break;
    } else if (ret == 0) {
      printf("select timeout 10s\n");
      continue;
    }
    if (FD_ISSET(fd, &efds)) {
      printf("catch an error %d\n", errno);
      break;
    } else if (!FD_ISSET(fd, &rfds)) {
      printf("don't catch a reading event\n");
      continue;
    }
    ret = read(fd, &key, sizeof(key));
    if (ret <= 0) {
      printf("read error %d\n", key);
    }
    printf("Read Key %d\n", key);
    if (key >= 5 && key <= 8) {
      char buf[2];
      int offset = key - 5;
      led[offset] = !led[offset];
      buf[0] = offset;
      buf[1] = led[offset];
      ret = write(fd, buf, sizeof(buf));
      if (ret <= 0) {
        printf("write error %d\n", ret);
      } else {
        printf("set LED %d state %d\n", buf[0], led[offset]);
      }
    }
  }
  close(fd);
  return 0;
open_fail:
  printf("open fail %d\n", errno);
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
mov    0x2e2a(%rip),%rax
or     (%rax),%esi
lea    0xe41(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11d6 <main+0x46>
jmp    13ff <main+0x26f>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    1201 <main+0x71>
movslq -0x34(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11dd <main+0x4d>
jmp    1206 <main+0x76>
mov    0xea7(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x38(%rbp),%rdi
call   1080 <FD_ZERO@plt>
lea    -0x3c(%rbp),%rdi
call   1080 <FD_ZERO@plt>
mov    -0x18(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   10b0 <FD_SET@plt>
mov    -0x18(%rbp),%edi
lea    -0x3c(%rbp),%rsi
call   10b0 <FD_SET@plt>
mov    -0x18(%rbp),%edi
add    $0x1,%edi
lea    -0x38(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x3c(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1090 <select@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    127f <main+0xef>
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13eb <main+0x25b>
cmpl   $0x0,-0x14(%rbp)
jne    129c <main+0x10c>
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1206 <main+0x76>
jmp    12a1 <main+0x111>
mov    -0x18(%rbp),%edi
lea    -0x3c(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     12d3 <main+0x143>
mov    0x2d12(%rip),%rax
mov    (%rax),%esi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13eb <main+0x25b>
mov    -0x18(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
jne    12fc <main+0x16c>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1206 <main+0x76>
jmp    1301 <main+0x171>
mov    -0x18(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1070 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1331 <main+0x1a1>
movsbl -0x19(%rbp),%esi
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0x19(%rbp),%esi
lea    0xd37(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x5,%eax
jl     13e6 <main+0x256>
movsbl -0x19(%rbp),%eax
cmp    $0x8,%eax
jg     13e6 <main+0x256>
movsbl -0x19(%rbp),%eax
sub    $0x5,%eax
mov    %eax,-0x50(%rbp)
movslq -0x50(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%ecx
movslq -0x50(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x50(%rbp),%eax
mov    %al,-0x4a(%rbp)
movslq -0x50(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %al,-0x49(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x4a(%rbp),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     13c7 <main+0x237>
mov    -0x14(%rbp),%esi
lea    0xcc5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13e1 <main+0x251>
movsbl -0x4a(%rbp),%esi
movslq -0x50(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xcb6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13e6 <main+0x256>
jmp    1206 <main+0x76>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    141d <main+0x28d>
mov    0x2bca(%rip),%rax
mov    (%rax),%esi
lea    0xc96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x2e33(%rip),%rax
mov    0x2e24(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe39(%rip),%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     136b <main+0x1cb>
mov    %eax,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
mov    %eax,%r15d
add    $0x1,%r15d
lea    0x1c(%rsp),%r12
lea    0x18(%rsp),%r13
jmp    1210 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe48(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rbp
jmp    122c <main+0x8c>
nopw   0x0(%rax,%rax,1)
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
movq   $0xa,0x10(%rsp)
mov    %r12,%rdi
call   1090 <FD_ZERO@plt>
mov    %r13,%rdi
call   1090 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %r12,%rsi
call   10c0 <FD_SET@plt>
mov    %ebx,%edi
mov    %r13,%rsi
call   10c0 <FD_SET@plt>
mov    %r15d,%edi
mov    %r12,%rsi
xor    %edx,%edx
mov    %r13,%rcx
mov    %rbp,%r8
call   10a0 <select@plt>
test   %eax,%eax
js     1362 <main+0x1c2>
je     1220 <main+0x80>
mov    %ebx,%edi
mov    %r13,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
jne    1389 <main+0x1e9>
mov    %ebx,%edi
mov    %r12,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     12f0 <main+0x150>
mov    %ebx,%edi
lea    0xd(%rsp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
movsbl 0xd(%rsp),%r14d
test   %eax,%eax
jg     12c4 <main+0x124>
lea    0xd79(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd77(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    -0x5(%r14),%eax
cmp    $0x3,%al
ja     122c <main+0x8c>
jmp    1310 <main+0x170>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xd8b(%rip),%rdi
call   1030 <puts@plt>
jmp    122c <main+0x8c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %r14d,%rax
lea    -0x5(%rax),%r14
xor    %ebp,%ebp
cmpl   $0x0,0xc(%rsp,%rax,4)
sete   %bpl
mov    %ebp,0xc(%rsp,%rax,4)
mov    %r14b,0xe(%rsp)
sete   0xf(%rsp)
mov    %ebx,%edi
lea    0xe(%rsp),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
test   %eax,%eax
jle    1200 <main+0x60>
movsbl %r14b,%esi
lea    0xd0b(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1210 <main+0x70>
lea    0xca6(%rip),%rdi
jmp    1390 <main+0x1f0>
mov    0x2c5e(%rip),%rax
mov    (%rax),%esi
lea    0xcf9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%ebp
jmp    13a9 <main+0x209>
lea    0xc90(%rip),%rdi
mov    0x2c39(%rip),%rax
mov    (%rax),%esi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [15 x i8] c"/dev/character\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@__const.main.timeout = %struct.timeval { i32 10, i32 0 }
@.str.1 = [17 x i8] c"select error %d\0A\00"
@errno = global i32 0
@.str.2 = [20 x i8] c"select timeout 10s\0A\00"
@.str.3 = [19 x i8] c"catch an error %d\0A\00"
@.str.4 = [29 x i8] c"don't catch a reading event\0A\00"
@.str.5 = [15 x i8] c"read error %d\0A\00"
@.str.6 = [13 x i8] c"Read Key %d\0A\00"
@.str.7 = [16 x i8] c"write error %d\0A\00"
@.str.8 = [21 x i8] c"set LED %d state %d\0A\00"
@.str.9 = [14 x i8] c"open fail %d\0A\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 i8
%9 = alloca [4 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.timeval
%14 = alloca [2 x i8]
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @O_RDWR
%17 = load i32, i32* @O_NONBLOCK
%18 = or i32 %16, %17
%19 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %2
br label %136
23: ; preds = %2
store i32 0, i32* %10
br label %24
24: ; preds = %31, %23
%25 = load i32, i32* %10
%26 = icmp slt i32 %25, 4
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %29
store i32 0, i32* %30
br label %31
31: ; preds = %27
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %24
34: ; preds = %24
br label %35
35: ; preds = %34, %54, %68, %132
%36 = bitcast %struct.timeval* %13 to i8*
%37 = call i32 @FD_ZERO(i32* %11)
%38 = call i32 @FD_ZERO(i32* %12)
%39 = load i32, i32* %7
%40 = call i32 @FD_SET(i32 %39, i32* %11)
%41 = load i32, i32* %7
%42 = call i32 @FD_SET(i32 %41, i32* %12)
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
%45 = call i32 @select(i32 %44, i32* %11, i32* null, i32* %12, %struct.timeval* %13)
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %35
%49 = load i32, i32* @errno
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %49)
br label %133
51: ; preds = %35
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %35
56: ; preds = %51
br label %57
57: ; preds = %56
%58 = load i32, i32* %7
%59 = call i64 @FD_ISSET(i32 %58, i32* %12)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %57
%62 = load i32, i32* @errno
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %62)
br label %133
64: ; preds = %57
%65 = load i32, i32* %7
%66 = call i64 @FD_ISSET(i32 %65, i32* %11)
%67 = icmp ne i64 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %64
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %35
70: ; preds = %64
br label %71
71: ; preds = %70
%72 = load i32, i32* %7
%73 = call i32 @read(i32 %72, i8* %8, i32 1)
store i32 %73, i32* %6
%74 = load i32, i32* %6
%75 = icmp sle i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = load i8, i8* %8
%78 = sext i8 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %76, %71
%81 = load i8, i8* %8
%82 = sext i8 %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %82)
%84 = load i8, i8* %8
%85 = sext i8 %84 to i32
%86 = icmp sge i32 %85, 5
br i1 %86, label %87, label %132
87: ; preds = %80
%88 = load i8, i8* %8
%89 = sext i8 %88 to i32
%90 = icmp sle i32 %89, 8
br i1 %90, label %91, label %132
91: ; preds = %87
%92 = load i8, i8* %8
%93 = sext i8 %92 to i32
%94 = sub nsw i32 %93, 5
store i32 %94, i32* %15
%95 = load i32, i32* %15
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %96
%98 = load i32, i32* %97
%99 = icmp ne i32 %98, 0
%100 = xor i1 %99, true
%101 = zext i1 %100 to i32
%102 = load i32, i32* %15
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %103
store i32 %101, i32* %104
%105 = load i32, i32* %15
%106 = trunc i32 %105 to i8
%107 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
store i8 %106, i8* %107
%108 = load i32, i32* %15
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %109
%111 = load i32, i32* %110
%112 = trunc i32 %111 to i8
%113 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 1
store i8 %112, i8* %113
%114 = load i32, i32* %7
%115 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%116 = call i32 @write(i32 %114, i8* %115, i32 2)
store i32 %116, i32* %6
%117 = load i32, i32* %6
%118 = icmp sle i32 %117, 0
br i1 %118, label %119, label %122
119: ; preds = %91
%120 = load i32, i32* %6
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %120)
br label %131
122: ; preds = %91
%123 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%124 = load i8, i8* %123
%125 = sext i8 %124 to i32
%126 = load i32, i32* %15
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %127
%129 = load i32, i32* %128
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %125, i32 %129)
br label %131
131: ; preds = %122, %119
br label %132
132: ; preds = %131, %87, %80
br label %35
133: ; preds = %61, %48
%134 = load i32, i32* %7
%135 = call i32 @close(i32 %134)
store i32 0, i32* %3
br label %139
136: ; preds = %22
%137 = load i32, i32* @errno
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %137)
store i32 -1, i32* %3
br label %139
139: ; preds = %136, %133
%140 = load i32, i32* %3
ret i32 %140
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [15 x i8] c"/dev/character\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [17 x i8] c"select error %d\0A\00"
@errno = global i32 0
@.str.3 = [19 x i8] c"catch an error %d\0A\00"
@.str.5 = [15 x i8] c"read error %d\0A\00"
@.str.6 = [13 x i8] c"Read Key %d\0A\00"
@.str.7 = [16 x i8] c"write error %d\0A\00"
@.str.8 = [21 x i8] c"set LED %d state %d\0A\00"
@.str.9 = [14 x i8] c"open fail %d\0A\00"
@str = [28 x i8] c"don't catch a reading event\00"
@str.10 = [19 x i8] c"select timeout 10s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = alloca [4 x i32]
%5 = bitcast [4 x i32]* %4 to i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = bitcast i64* %8 to %struct.timeval*
%10 = alloca [2 x i8]
%11 = load i32, i32* @O_RDWR
%12 = load i32, i32* @O_NONBLOCK
%13 = or i32 %12, %11
%14 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = icmp slt i32 %14, 0
br i1 %15, label %77, label %16
16: ; preds = %2
%17 = bitcast i32* %6 to i8*
%18 = bitcast i32* %7 to i8*
%19 = bitcast i64* %8 to i8*
%20 = add nuw nsw i32 %14, 1
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%22 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 1
br label %23
23: ; preds = %16, %71
store i64 10, i64* %8
%24 = call i32 @FD_ZERO(i32* %6)
%25 = call i32 @FD_ZERO(i32* %7)
%26 = call i32 @FD_SET(i32 %14, i32* %6)
%27 = call i32 @FD_SET(i32 %14, i32* %7)
%28 = call i32 @select(i32 %20, i32* %6, i32* null, i32* %7, %struct.timeval* %9)
%29 = icmp slt i32 %28, 0
br i1 %29, label %72, label %30
30: ; preds = %23
%31 = icmp eq i32 %28, 0
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
br label %71
34: ; preds = %30
%35 = call i64 @FD_ISSET(i32 %14, i32* %7)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %72
37: ; preds = %34
%38 = call i64 @FD_ISSET(i32 %14, i32* %6)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %71
42: ; preds = %37
%43 = call i32 @read(i32 %14, i8* %3, i32 1)
%44 = icmp slt i32 %43, 1
%45 = load i8, i8* %3
%46 = sext i8 %45 to i32
br i1 %44, label %47, label %49
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %46)
br label %49
49: ; preds = %42, %47
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %46)
%51 = add i8 %45, -5
%52 = icmp ult i8 %51, 4
br i1 %52, label %53, label %71
53: ; preds = %49
%54 = add nsw i32 %46, -5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = icmp eq i32 %57, 0
%59 = zext i1 %58 to i32
store i32 %59, i32* %56
%60 = trunc i32 %54 to i8
store i8 %60, i8* %21
%61 = zext i1 %58 to i8
store i8 %61, i8* %22
%62 = call i32 @write(i32 %14, i8* %21, i32 2)
%63 = icmp slt i32 %62, 1
br i1 %63, label %64, label %66
64: ; preds = %53
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %62)
br label %70
66: ; preds = %53
%67 = shl i32 %54, 24
%68 = ashr exact i32 %67, 24
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %68, i32 %59)
br label %70
70: ; preds = %66, %64
br label %71
71: ; preds = %49, %70, %40, %32
br label %23
72: ; preds = %34, %23
%73 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %23 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %34 ]
%74 = load i32, i32* @errno
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %73, i32 %74)
%76 = call i32 @close(i32 %14)
br label %80
77: ; preds = %2
%78 = load i32, i32* @errno
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %77, %72
%81 = phi i32 [ -1, %77 ], [ 0, %72 ]
ret i32 %81
}