#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 revents;
  int events;
};
struct input_event {
  scalar_t__ type;
  int value;
  int code;
};
typedef int /*<<< orphan*/ ie;

/* Variables and functions */
scalar_t__ EV_KEY;
#define KEY_0 143
#define KEY_1 142
#define KEY_2 141
#define KEY_3 140
#define KEY_4 139
#define KEY_5 138
#define KEY_6 137
#define KEY_7 136
#define KEY_8 135
#define KEY_9 134
#define KEY_A 133
#define KEY_B 132
#define KEY_BACKSLASH 131
#define KEY_C 130
#define KEY_ENTER 129
#define KEY_RIGHTBRACE 128
int O_NONBLOCK;
int O_RDWR;
int POLLERR;
int POLLIN;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int);
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ read(int, struct input_event *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strncat(char *, char *, int);
int keypad_fgets(char *input, unsigned short len) {
  int run = 1;
  unsigned short pos = 0;
  char l_input[80];
  char rx[16];
  struct pollfd p_fd[1];
  int p_res;
  struct input_event ie;
  p_fd[0].fd = open("/dev/input/event0", O_RDWR | O_NONBLOCK, 0);
  if (p_fd[0].fd == -1) {
    printf("open error %d\n", errno);
    exit(1);
  }
  l_input[0] = '\0';
  while (run && (pos < len)) {
    p_fd[0].revents = 0;
    p_fd[0].events = POLLIN | POLLERR;
    p_res = poll(p_fd, 1, 10);
    if (p_res < 0) {
      perror("read!");
      exit(1);
    }
    if (p_res > 0) {
      if (p_fd[0].revents & POLLIN) {
        while (read(p_fd[0].fd, &ie, sizeof(ie)) > 0) {
          if ((ie.type == EV_KEY) && (ie.value == 1)) {
            switch (ie.code) {
            case KEY_ENTER:
              sprintf(input, "%s\n", l_input);
              run = 0;
              break;
            case KEY_BACKSLASH:
              sprintf(rx, "#");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_0:
              sprintf(rx, "0");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_RIGHTBRACE:
              sprintf(rx, "*");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_C:
              sprintf(rx, "c");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_9:
              sprintf(rx, "9");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_8:
              sprintf(rx, "8");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_7:
              sprintf(rx, "7");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_B:
              sprintf(rx, "t");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_6:
              sprintf(rx, "6");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_5:
              sprintf(rx, "5");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_4:
              sprintf(rx, "4");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_A:
              sprintf(rx, "a");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_3:
              sprintf(rx, "3");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_2:
              sprintf(rx, "2");
              strncat(l_input, rx, 1);
              pos++;
              break;
            case KEY_1:
              sprintf(rx, "1");
              strncat(l_input, rx, 1);
              pos++;
              break;
            }
          }
        }
      } else if (p_fd[0].revents & POLLERR) {
        break;
      }
    }
  }
  close(p_fd[0].fd);
  return 0;
}


x86 assembly (clang, -O0):
<keypad_fgets>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
movl   $0x1,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
mov    0x2e1d(%rip),%rax
or     (%rax),%esi
lea    0xe74(%rip),%rdi
xor    %edx,%edx
call   1080 <open@plt>
mov    %eax,-0x90(%rbp)
cmpl   $0xffffffff,-0x90(%rbp)
jne    1205 <keypad_fgets+0x75>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
movb   $0x0,-0x70(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0xa9(%rbp)
je     122e <keypad_fgets+0x9e>
movzwl -0x12(%rbp),%eax
movzwl -0xa(%rbp),%ecx
cmp    %ecx,%eax
setl   %al
mov    %al,-0xa9(%rbp)
mov    -0xa9(%rbp),%al
test   $0x1,%al
jne    1241 <keypad_fgets+0xb1>
jmp    16b6 <keypad_fgets+0x526>
movl   $0x0,-0x8c(%rbp)
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    0x2d7d(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x88(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1070 <poll@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
jge    12a2 <keypad_fgets+0x112>
lea    0xdce(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x94(%rbp)
jle    16b1 <keypad_fgets+0x521>
mov    -0x8c(%rbp),%eax
mov    0x2d0c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     168a <keypad_fgets+0x4fa>
jmp    12cc <keypad_fgets+0x13c>
mov    -0x90(%rbp),%edi
lea    -0xa8(%rbp),%rsi
mov    $0x10,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
jle    1685 <keypad_fgets+0x4f5>
mov    -0xa8(%rbp),%rax
mov    0x2cd5(%rip),%rcx
cmp    (%rcx),%rax
jne    1680 <keypad_fgets+0x4f0>
cmpl   $0x1,-0xa0(%rbp)
jne    1680 <keypad_fgets+0x4f0>
mov    -0x9c(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0xb8(%rbp)
sub    $0xf,%eax
ja     167b <keypad_fgets+0x4eb>
mov    -0xb8(%rbp),%rax
lea    0xcc6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
movl   $0x0,-0x10(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xcab(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xc93(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xc60(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xc2d(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xbfa(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xbc7(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xb94(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xb61(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xb2e(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xafb(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xac8(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xa95(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xa62(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    167b <keypad_fgets+0x4eb>
lea    -0x80(%rbp),%rdi
lea    0xa2f(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    1680 <keypad_fgets+0x4f0>
jmp    12cc <keypad_fgets+0x13c>
jmp    16ac <keypad_fgets+0x51c>
mov    -0x8c(%rbp),%eax
mov    0x2941(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     16a7 <keypad_fgets+0x517>
jmp    16b6 <keypad_fgets+0x526>
jmp    16ac <keypad_fgets+0x51c>
jmp    16b1 <keypad_fgets+0x521>
jmp    1209 <keypad_fgets+0x79>
mov    -0x90(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keypad_fgets>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %esi,%ebx
mov    %rdi,0x28(%rsp)
mov    0x2e39(%rip),%rax
mov    0x2e2a(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe7f(%rip),%rdi
xor    %edx,%edx
call   1080 <open@plt>
mov    %eax,0x18(%rsp)
cmp    $0xffffffff,%eax
je     13e4 <keypad_fgets+0x254>
movb   $0x0,0x40(%rsp)
test   %bx,%bx
je     13b3 <keypad_fgets+0x223>
mov    %ebx,0x24(%rsp)
xor    %r14d,%r14d
lea    0x30(%rsp),%rbx
mov    0x2dda(%rip),%r15
lea    0xe03(%rip),%r12
lea    0x40(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movl   $0x0,0x1c(%rsp)
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    0x2da0(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x20(%rsp)
lea    0x18(%rsp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1070 <poll@plt>
test   %eax,%eax
js     13ce <keypad_fgets+0x23e>
mov    $0x1,%r13d
je     128f <keypad_fgets+0xff>
mov    0x1c(%rsp),%eax
mov    0x2d6b(%rip),%rcx
test   %eax,(%rcx)
je     1280 <keypad_fgets+0xf0>
mov    0x18(%rsp),%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    128f <keypad_fgets+0xff>
mov    $0x1,%r13d
jmp    12da <keypad_fgets+0x14a>
nop
mov    0x2d51(%rip),%rcx
test   %eax,(%rcx)
jne    13af <keypad_fgets+0x21f>
test   %r13d,%r13d
je     13af <keypad_fgets+0x21f>
cmp    0x24(%rsp),%r14w
jb     1210 <keypad_fgets+0x80>
jmp    13af <keypad_fgets+0x21f>
movw   $0x31,(%rsp)
nop
mov    %rbp,%rdi
mov    %rsp,%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
add    $0x1,%r14d
mov    0x18(%rsp),%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    128f <keypad_fgets+0xff>
mov    0x30(%rsp),%rax
cmp    (%r15),%rax
jne    12c4 <keypad_fgets+0x134>
cmpl   $0x1,0x38(%rsp)
jne    12c4 <keypad_fgets+0x134>
mov    0x3c(%rsp),%eax
add    $0xffffff80,%eax
cmp    $0xf,%eax
ja     12c4 <keypad_fgets+0x134>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
movw   $0x2a,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
xor    %r13d,%r13d
mov    0x28(%rsp),%rdi
lea    0xd50(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
jmp    12c4 <keypad_fgets+0x134>
movw   $0x63,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x23,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x74,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x61,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x39,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x38,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x37,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x36,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x35,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x34,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x33,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x32,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
movw   $0x30,(%rsp)
jmp    12b0 <keypad_fgets+0x120>
mov    0x18(%rsp),%eax
mov    %eax,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc8c(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2bcd(%rip),%rax
mov    (%rax),%esi
lea    0xc5e(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
%struct.input_event = type { i64, i32, i32 }
@.str = [18 x i8] c"/dev/input/event0\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [15 x i8] c"open error %d\0A\00"
@errno = global i32 0
@POLLIN = global i32 0
@POLLERR = global i32 0
@.str.2 = [6 x i8] c"read!\00"
@EV_KEY = global i64 0
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [2 x i8] c"#\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [2 x i8] c"*\00"
@.str.7 = [2 x i8] c"c\00"
@.str.8 = [2 x i8] c"9\00"
@.str.9 = [2 x i8] c"8\00"
@.str.10 = [2 x i8] c"7\00"
@.str.11 = [2 x i8] c"t\00"
@.str.12 = [2 x i8] c"6\00"
@.str.13 = [2 x i8] c"5\00"
@.str.14 = [2 x i8] c"4\00"
@.str.15 = [2 x i8] c"a\00"
@.str.16 = [2 x i8] c"3\00"
@.str.17 = [2 x i8] c"2\00"
@.str.18 = [2 x i8] c"1\00"
define i32 @keypad_fgets(i8* %0, i16 zeroext %1) {
%3 = alloca i8*
%4 = alloca i16
%5 = alloca i32
%6 = alloca i16
%7 = alloca [80 x i8]
%8 = alloca [16 x i8]
%9 = alloca [1 x %struct.pollfd]
%10 = alloca i32
%11 = alloca %struct.input_event
store i8* %0, i8** %3
store i16 %1, i16* %4
store i32 1, i32* %5
store i16 0, i16* %6
%12 = load i32, i32* @O_RDWR
%13 = load i32, i32* @O_NONBLOCK
%14 = or i32 %12, %13
%15 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %14, i32 0)
%16 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%17 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %16, i32 0, i32 0
store i32 %15, i32* %17
%18 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%19 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @errno
%24 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
store i8 0, i8* %27
br label %28
28: ; preds = %220, %26
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = load i16, i16* %6
%33 = zext i16 %32 to i32
%34 = load i16, i16* %4
%35 = zext i16 %34 to i32
%36 = icmp slt i32 %33, %35
br label %37
37: ; preds = %31, %28
%38 = phi i1 [ false, %28 ], [ %36, %31 ]
br i1 %38, label %39, label %221
39: ; preds = %37
%40 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%41 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %40, i32 0, i32 1
store i32 0, i32* %41
%42 = load i32, i32* @POLLIN
%43 = load i32, i32* @POLLERR
%44 = or i32 %42, %43
%45 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%46 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %45, i32 0, i32 2
store i32 %44, i32* %46
%47 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%48 = call i32 @poll(%struct.pollfd* %47, i32 1, i32 10)
store i32 %48, i32* %10
%49 = load i32, i32* %10
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %39
%52 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %39
%55 = load i32, i32* %10
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %220
57: ; preds = %54
%58 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%59 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %58, i32 0, i32 1
%60 = load i32, i32* %59
%61 = load i32, i32* @POLLIN
%62 = and i32 %60, %61
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %210
64: ; preds = %57
br label %65
65: ; preds = %208, %64
%66 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%67 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %66, i32 0, i32 0
%68 = load i32, i32* %67
%69 = call i64 @read(i32 %68, %struct.input_event* %11, i32 16)
%70 = icmp sgt i64 %69, 0
br i1 %70, label %71, label %209
71: ; preds = %65
%72 = getelementptr inbounds %struct.input_event, %struct.input_event* %11, i32 0, i32 0
%73 = load i64, i64* %72
%74 = load i64, i64* @EV_KEY
%75 = icmp eq i64 %73, %74
br i1 %75, label %76, label %208
76: ; preds = %71
%77 = getelementptr inbounds %struct.input_event, %struct.input_event* %11, i32 0, i32 1
%78 = load i32, i32* %77
%79 = icmp eq i32 %78, 1
br i1 %79, label %80, label %208
80: ; preds = %76
%81 = getelementptr inbounds %struct.input_event, %struct.input_event* %11, i32 0, i32 2
%82 = load i32, i32* %81
switch i32 %82, label %207 [
i32 129, label %83
i32 131, label %87
i32 143, label %95
i32 128, label %103
i32 130, label %111
i32 134, label %119
i32 135, label %127
i32 136, label %135
i32 132, label %143
i32 137, label %151
i32 138, label %159
i32 139, label %167
i32 133, label %175
i32 140, label %183
i32 141, label %191
i32 142, label %199
]
83: ; preds = %80
%84 = load i8*, i8** %3
%85 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%86 = call i32 (i8*, i8*, ...) @sprintf(i8* %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %85)
store i32 0, i32* %5
br label %207
87: ; preds = %80
%88 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%89 = call i32 (i8*, i8*, ...) @sprintf(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%90 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%91 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%92 = call i32 @strncat(i8* %90, i8* %91, i32 1)
%93 = load i16, i16* %6
%94 = add i16 %93, 1
store i16 %94, i16* %6
br label %207
95: ; preds = %80
%96 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%97 = call i32 (i8*, i8*, ...) @sprintf(i8* %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%98 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%99 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%100 = call i32 @strncat(i8* %98, i8* %99, i32 1)
%101 = load i16, i16* %6
%102 = add i16 %101, 1
store i16 %102, i16* %6
br label %207
103: ; preds = %80
%104 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%105 = call i32 (i8*, i8*, ...) @sprintf(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%106 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%107 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%108 = call i32 @strncat(i8* %106, i8* %107, i32 1)
%109 = load i16, i16* %6
%110 = add i16 %109, 1
store i16 %110, i16* %6
br label %207
111: ; preds = %80
%112 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%113 = call i32 (i8*, i8*, ...) @sprintf(i8* %112, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%114 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%115 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%116 = call i32 @strncat(i8* %114, i8* %115, i32 1)
%117 = load i16, i16* %6
%118 = add i16 %117, 1
store i16 %118, i16* %6
br label %207
119: ; preds = %80
%120 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%121 = call i32 (i8*, i8*, ...) @sprintf(i8* %120, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%122 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%123 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%124 = call i32 @strncat(i8* %122, i8* %123, i32 1)
%125 = load i16, i16* %6
%126 = add i16 %125, 1
store i16 %126, i16* %6
br label %207
127: ; preds = %80
%128 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%129 = call i32 (i8*, i8*, ...) @sprintf(i8* %128, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%130 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%131 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%132 = call i32 @strncat(i8* %130, i8* %131, i32 1)
%133 = load i16, i16* %6
%134 = add i16 %133, 1
store i16 %134, i16* %6
br label %207
135: ; preds = %80
%136 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%137 = call i32 (i8*, i8*, ...) @sprintf(i8* %136, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%138 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%139 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%140 = call i32 @strncat(i8* %138, i8* %139, i32 1)
%141 = load i16, i16* %6
%142 = add i16 %141, 1
store i16 %142, i16* %6
br label %207
143: ; preds = %80
%144 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%145 = call i32 (i8*, i8*, ...) @sprintf(i8* %144, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%146 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%147 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%148 = call i32 @strncat(i8* %146, i8* %147, i32 1)
%149 = load i16, i16* %6
%150 = add i16 %149, 1
store i16 %150, i16* %6
br label %207
151: ; preds = %80
%152 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%153 = call i32 (i8*, i8*, ...) @sprintf(i8* %152, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%154 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%155 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%156 = call i32 @strncat(i8* %154, i8* %155, i32 1)
%157 = load i16, i16* %6
%158 = add i16 %157, 1
store i16 %158, i16* %6
br label %207
159: ; preds = %80
%160 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%161 = call i32 (i8*, i8*, ...) @sprintf(i8* %160, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%162 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%163 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%164 = call i32 @strncat(i8* %162, i8* %163, i32 1)
%165 = load i16, i16* %6
%166 = add i16 %165, 1
store i16 %166, i16* %6
br label %207
167: ; preds = %80
%168 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%169 = call i32 (i8*, i8*, ...) @sprintf(i8* %168, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%170 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%171 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%172 = call i32 @strncat(i8* %170, i8* %171, i32 1)
%173 = load i16, i16* %6
%174 = add i16 %173, 1
store i16 %174, i16* %6
br label %207
175: ; preds = %80
%176 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%177 = call i32 (i8*, i8*, ...) @sprintf(i8* %176, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%178 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%179 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%180 = call i32 @strncat(i8* %178, i8* %179, i32 1)
%181 = load i16, i16* %6
%182 = add i16 %181, 1
store i16 %182, i16* %6
br label %207
183: ; preds = %80
%184 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%185 = call i32 (i8*, i8*, ...) @sprintf(i8* %184, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%186 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%187 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%188 = call i32 @strncat(i8* %186, i8* %187, i32 1)
%189 = load i16, i16* %6
%190 = add i16 %189, 1
store i16 %190, i16* %6
br label %207
191: ; preds = %80
%192 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%193 = call i32 (i8*, i8*, ...) @sprintf(i8* %192, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
%194 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%195 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%196 = call i32 @strncat(i8* %194, i8* %195, i32 1)
%197 = load i16, i16* %6
%198 = add i16 %197, 1
store i16 %198, i16* %6
br label %207
199: ; preds = %80
%200 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%201 = call i32 (i8*, i8*, ...) @sprintf(i8* %200, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%202 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%203 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%204 = call i32 @strncat(i8* %202, i8* %203, i32 1)
%205 = load i16, i16* %6
%206 = add i16 %205, 1
store i16 %206, i16* %6
br label %207
207: ; preds = %80, %199, %191, %183, %175, %167, %159, %151, %143, %135, %127, %119, %111, %103, %95, %87, %83
br label %208
208: ; preds = %207, %76, %71
br label %65
209: ; preds = %65
br label %219
210: ; preds = %57
%211 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%212 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %211, i32 0, i32 1
%213 = load i32, i32* %212
%214 = load i32, i32* @POLLERR
%215 = and i32 %213, %214
%216 = icmp ne i32 %215, 0
br i1 %216, label %217, label %218
217: ; preds = %210
br label %221
218: ; preds = %210
br label %219
219: ; preds = %218, %209
br label %220
220: ; preds = %219, %54
br label %28
221: ; preds = %217, %37
%222 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %9, i64 0, i64 0
%223 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %222, i32 0, i32 0
%224 = load i32, i32* %223
%225 = call i32 @close(i32 %224)
ret i32 0
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
%struct.input_event = type { i64, i32, i32 }
@.str = [18 x i8] c"/dev/input/event0\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [15 x i8] c"open error %d\0A\00"
@errno = global i32 0
@POLLIN = global i32 0
@POLLERR = global i32 0
@.str.2 = [6 x i8] c"read!\00"
@EV_KEY = global i64 0
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @keypad_fgets(i8* nocapture writeonly %0, i16 zeroext %1) {
%3 = alloca [80 x i8]
%4 = alloca [16 x i8]
%5 = alloca [1 x %struct.pollfd]
%6 = alloca %struct.input_event
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%9 = bitcast [1 x %struct.pollfd]* %5 to i8*
%10 = bitcast %struct.input_event* %6 to 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 ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %13, i32 0)
%15 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %5, i64 0, i64 0
%16 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %5, i64 0, i64 0, i32 0
store i32 %14, i32* %16
%17 = icmp eq i32 %14, -1
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32, i32* @errno
%20 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %2
store i8 0, i8* %7
%23 = icmp eq i16 %1, 0
br i1 %23, label %128, label %24
24: ; preds = %22
%25 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %5, i64 0, i64 0, i32 1
%26 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %5, i64 0, i64 0, i32 2
%27 = getelementptr inbounds %struct.input_event, %struct.input_event* %6, i64 0, i32 0
%28 = getelementptr inbounds %struct.input_event, %struct.input_event* %6, i64 0, i32 1
%29 = getelementptr inbounds %struct.input_event, %struct.input_event* %6, i64 0, i32 2
%30 = bitcast [16 x i8]* %4 to i16*
br label %31
31: ; preds = %24, %120
%32 = phi i16 [ 0, %24 ], [ %121, %120 ]
store i32 0, i32* %25
%33 = load i32, i32* @POLLIN
%34 = load i32, i32* @POLLERR
%35 = or i32 %34, %33
store i32 %35, i32* %26
%36 = call i32 @poll(%struct.pollfd* %15, i32 1, i32 10)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %31
%39 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %31
%42 = icmp eq i32 %36, 0
br i1 %42, label %120, label %43
43: ; preds = %41
%44 = load i32, i32* %25
%45 = load i32, i32* @POLLIN
%46 = and i32 %45, %44
%47 = icmp eq i32 %46, 0
br i1 %47, label %116, label %48
48: ; preds = %43
%49 = load i32, i32* %16
%50 = call i64 @read(i32 %49, %struct.input_event* %6, i32 16)
%51 = icmp sgt i64 %50, 0
br i1 %51, label %52, label %120
52: ; preds = %48, %110
%53 = phi i32 [ %112, %110 ], [ 1, %48 ]
%54 = phi i16 [ %111, %110 ], [ %32, %48 ]
%55 = load i64, i64* %27
%56 = load i64, i64* @EV_KEY
%57 = icmp eq i64 %55, %56
%58 = load i32, i32* %28
%59 = icmp eq i32 %58, 1
%60 = select i1 %57, i1 %59, i1 false
br i1 %60, label %61, label %110
61: ; preds = %52
%62 = load i32, i32* %29
switch i32 %62, label %110 [
i32 129, label %63
i32 131, label %65
i32 143, label %68
i32 128, label %71
i32 130, label %74
i32 134, label %77
i32 135, label %80
i32 136, label %83
i32 132, label %86
i32 137, label %89
i32 138, label %92
i32 139, label %95
i32 133, label %98
i32 140, label %101
i32 141, label %104
i32 142, label %107
]
63: ; preds = %61
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %110
65: ; preds = %61
store i16 35, i16* %30
%66 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%67 = add i16 %54, 1
br label %110
68: ; preds = %61
store i16 48, i16* %30
%69 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%70 = add i16 %54, 1
br label %110
71: ; preds = %61
store i16 42, i16* %30
%72 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%73 = add i16 %54, 1
br label %110
74: ; preds = %61
store i16 99, i16* %30
%75 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%76 = add i16 %54, 1
br label %110
77: ; preds = %61
store i16 57, i16* %30
%78 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%79 = add i16 %54, 1
br label %110
80: ; preds = %61
store i16 56, i16* %30
%81 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%82 = add i16 %54, 1
br label %110
83: ; preds = %61
store i16 55, i16* %30
%84 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%85 = add i16 %54, 1
br label %110
86: ; preds = %61
store i16 116, i16* %30
%87 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%88 = add i16 %54, 1
br label %110
89: ; preds = %61
store i16 54, i16* %30
%90 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%91 = add i16 %54, 1
br label %110
92: ; preds = %61
store i16 53, i16* %30
%93 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%94 = add i16 %54, 1
br label %110
95: ; preds = %61
store i16 52, i16* %30
%96 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%97 = add i16 %54, 1
br label %110
98: ; preds = %61
store i16 97, i16* %30
%99 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%100 = add i16 %54, 1
br label %110
101: ; preds = %61
store i16 51, i16* %30
%102 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%103 = add i16 %54, 1
br label %110
104: ; preds = %61
store i16 50, i16* %30
%105 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%106 = add i16 %54, 1
br label %110
107: ; preds = %61
store i16 49, i16* %30
%108 = call i32 @strncat(i8* %7, i8* %8, i32 1)
%109 = add i16 %54, 1
br label %110
110: ; preds = %63, %65, %68, %71, %74, %77, %80, %83, %86, %89, %92, %95, %98, %101, %104, %107, %61, %52
%111 = phi i16 [ %54, %61 ], [ %109, %107 ], [ %106, %104 ], [ %103, %101 ], [ %100, %98 ], [ %97, %95 ], [ %94, %92 ], [ %91, %89 ], [ %88, %86 ], [ %85, %83 ], [ %82, %80 ], [ %79, %77 ], [ %76, %74 ], [ %73, %71 ], [ %70, %68 ], [ %67, %65 ], [ %54, %63 ], [ %54, %52 ]
%112 = phi i32 [ %53, %61 ], [ %53, %107 ], [ %53, %104 ], [ %53, %101 ], [ %53, %98 ], [ %53, %95 ], [ %53, %92 ], [ %53, %89 ], [ %53, %86 ], [ %53, %83 ], [ %53, %80 ], [ %53, %77 ], [ %53, %74 ], [ %53, %71 ], [ %53, %68 ], [ %53, %65 ], [ 0, %63 ], [ %53, %52 ]
%113 = load i32, i32* %16
%114 = call i64 @read(i32 %113, %struct.input_event* %6, i32 16)
%115 = icmp sgt i64 %114, 0
br i1 %115, label %52, label %120
116: ; preds = %43
%117 = load i32, i32* @POLLERR
%118 = and i32 %117, %44
%119 = icmp eq i32 %118, 0
br i1 %119, label %120, label %126
120: ; preds = %110, %48, %116, %41
%121 = phi i16 [ %32, %116 ], [ %32, %41 ], [ %32, %48 ], [ %111, %110 ]
%122 = phi i32 [ 1, %116 ], [ 1, %41 ], [ 1, %48 ], [ %112, %110 ]
%123 = icmp ne i32 %122, 0
%124 = icmp ult i16 %121, %1
%125 = select i1 %123, i1 %124, i1 false
br i1 %125, label %31, label %126
126: ; preds = %116, %120
%127 = load i32, i32* %16
br label %128
128: ; preds = %126, %22
%129 = phi i32 [ %127, %126 ], [ %14, %22 ]
%130 = call i32 @close(i32 %129)
ret i32 0
}