#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 input_event {
  int type;
  int code;
  int value;
};
typedef size_t off_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned char *MAP_FAILED;
int /*<<< orphan*/ MAP_PRIVATE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_SYNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ _SC_PAGE_SIZE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
unsigned char *mmap(int /*<<< orphan*/ *, size_t, int, int /*<<< orphan*/, int,
                    size_t);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ read(int, struct input_event *, int);
char *readLine(int /*<<< orphan*/ *);
int /*<<< orphan*/ select_mode(int, int);
scalar_t__ strcmp(char const *, char *);
scalar_t__ strlen(char const *);
size_t sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(unsigned int);
int main(int argc, char **argv) {
  const char *device = NULL;
  const char *debug;
  int fd;
  struct input_event ie;
  FILE *uenv;
  uenv = fopen("/boot/uEnv.txt", "r");
  if (uenv) {
    while (1) {
      debug = readLine(uenv);
      if (strlen(debug) == 0) {
        break;
      }
      if (strcmp(debug, "debug=on") == 0) {
        select_mode(2, 0);
        select_mode(4, 0);
        exit(0);
      }
    }
  }
  off_t offset = 0x01c22c00 + 0x319;
  size_t len = 0x01;
  size_t pagesize = sysconf(_SC_PAGE_SIZE);
  off_t page_base = (offset / pagesize) * pagesize;
  off_t page_offset = offset - page_base;
  fd = open("/dev/mem", O_SYNC);
  if (fd == -1) {
    perror("Cannot open /dev/mem");
    return -1;
  }
  unsigned char *mem = mmap(NULL, page_offset + len, PROT_READ | PROT_WRITE,
                            MAP_PRIVATE, fd, page_base);
  if (mem == MAP_FAILED) {
    perror("Can't map memory");
    return -1;
  }
  if ((int)mem[page_offset] && 0x08) {
    select_mode(4, 1);
  } else {
    select_mode(4, 0);
  }
  if ((int)mem[page_offset] && 0x04) {
    select_mode(2, 1);
  } else {
    select_mode(2, 0);
  }
  for (;;) {
    if ((fd = open(device, O_RDONLY)) == -1) {
      perror("Could not open input device");
      exit(255);
    }
    while (read(fd, &ie, sizeof(struct input_event)) > 0) {
      if (ie.type == 5) {
        select_mode(ie.code, ie.value);
      }
    }
    close(fd);
    usleep(65535u);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe0b(%rip),%rdi
lea    0xe13(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     127d <main+0xad>
jmp    1215 <main+0x45>
mov    -0x38(%rbp),%rdi
call   1090 <readLine@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    123a <main+0x6a>
jmp    1278 <main+0xa8>
mov    -0x20(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1273 <main+0xa3>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <select_mode@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <select_mode@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
jmp    1215 <main+0x45>
jmp    127d <main+0xad>
movq   $0x1c22f19,-0x40(%rbp)
01
movq   $0x1,-0x48(%rbp)
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
call   10d0 <sysconf@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x50(%rbp)
imul   -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rax
sub    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2d19(%rip),%rax
mov    (%rax),%esi
lea    0xd56(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    12fa <main+0x12a>
lea    0xd31(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1452 <main+0x282>
mov    -0x60(%rbp),%rsi
add    -0x48(%rbp),%rsi
mov    0x2cef(%rip),%rax
mov    (%rax),%edx
mov    0x2cb6(%rip),%rax
or     (%rax),%edx
mov    0x2c9d(%rip),%rax
mov    (%rax),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x58(%rbp),%r9
xor    %eax,%eax
mov    %eax,%edi
call   1050 <mmap@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    0x2c73(%rip),%rcx
cmp    (%rcx),%rax
jne    135e <main+0x18e>
lea    0xce2(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1452 <main+0x282>
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1387 <main+0x1b7>
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <select_mode@plt>
jmp    1393 <main+0x1c3>
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <select_mode@plt>
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     13bc <main+0x1ec>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <select_mode@plt>
jmp    13c8 <main+0x1f8>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <select_mode@plt>
jmp    13cd <main+0x1fd>
mov    -0x18(%rbp),%rdi
mov    0x2c00(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1401 <main+0x231>
lea    0xc4e(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xff,%edi
call   10e0 <exit@plt>
jmp    1406 <main+0x236>
mov    -0x24(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   1070 <read@plt>
cmp    $0x0,%rax
jle    143b <main+0x26b>
cmpl   $0x5,-0x30(%rbp)
jne    1436 <main+0x266>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <select_mode@plt>
jmp    1406 <main+0x236>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    $0xffff,%edi
call   10f0 <usleep@plt>
jmp    13cd <main+0x1fd>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe31(%rip),%rdi
lea    0xe39(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
jne    122f <main+0x6f>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   10c0 <sysconf@plt>
mov    $0x1c22f19,%ebx
cmp    $0x1c22f19,%rax
ja     1209 <main+0x49>
mov    %rax,%rcx
mov    $0x1c22f19,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%ebx
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
lea    0xe0d(%rip),%rdi
call   1090 <open@plt>
cmp    $0xffffffff,%eax
jne    127c <main+0xbc>
lea    0xdf0(%rip),%rdi
jmp    12c4 <main+0x104>
mov    %rax,%rbx
lea    0xdd8(%rip),%rbp
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <readLine@plt>
cmpb   $0x0,(%rax)
je     11e0 <main+0x20>
mov    %rax,%rdi
mov    %rbp,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1240 <main+0x80>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <select_mode@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <select_mode@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    $0x1c22f19,%r9d
sub    %rbx,%r9
lea    0x1(%rbx),%rsi
mov    0x2d68(%rip),%rcx
mov    0x2d31(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d16(%rip),%rcx
mov    (%rcx),%ecx
xor    %edi,%edi
mov    %eax,%r8d
call   1040 <mmap@plt>
mov    %rax,%rbp
mov    0x2cf8(%rip),%rax
cmp    (%rax),%rbp
jne    12d7 <main+0x117>
lea    0xd6b(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %esi,%esi
cmpb   $0x0,0x0(%rbp,%rbx,1)
setne  %sil
mov    $0x4,%edi
call   1030 <select_mode@plt>
xor    %esi,%esi
cmpb   $0x0,0x0(%rbp,%rbx,1)
setne  %sil
mov    $0x2,%edi
call   1030 <select_mode@plt>
mov    0x2cd0(%rip),%r14
mov    (%r14),%esi
xor    %edi,%edi
call   1090 <open@plt>
cmp    $0xffffffff,%eax
jne    132d <main+0x16d>
lea    0xd22(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xff,%edi
call   10d0 <exit@plt>
mov    %eax,%ebp
mov    %rsp,%rbx
jmp    1360 <main+0x1a0>
mov    %ebp,%edi
call   1050 <close@plt>
mov    $0xffff,%edi
call   10e0 <usleep@plt>
mov    (%r14),%esi
xor    %edi,%edi
call   1090 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     1317 <main+0x157>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    1334 <main+0x174>
cmpl   $0x5,(%rsp)
jne    1360 <main+0x1a0>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   1030 <select_mode@plt>
jmp    1360 <main+0x1a0>

LLVM IR (-O0):
%struct.input_event = type { i32, i32, i32 }
@.str = [15 x i8] c"/boot/uEnv.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"debug=on\00"
@_SC_PAGE_SIZE = global i32 0
@.str.3 = [9 x i8] c"/dev/mem\00"
@O_SYNC = global i32 0
@.str.4 = [21 x i8] c"Cannot open /dev/mem\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [17 x i8] c"Can't map memory\00"
@O_RDONLY = global i32 0
@.str.6 = [28 x i8] c"Could not open input device\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.input_event
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%17 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %10
%18 = load i32*, i32** %10
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %38
20: ; preds = %2
br label %21
21: ; preds = %20, %36
%22 = load i32*, i32** %10
%23 = call i8* @readLine(i32* %22)
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = call i64 @strlen(i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
br label %37
28: ; preds = %21
%29 = load i8*, i8** %7
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = call i32 @select_mode(i32 2, i32 0)
%34 = call i32 @select_mode(i32 4, i32 0)
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %28
br label %21
37: ; preds = %27
br label %38
38: ; preds = %37, %2
store i64 29503257, i64* %11
store i64 1, i64* %12
%39 = load i32, i32* @_SC_PAGE_SIZE
%40 = call i64 @sysconf(i32 %39)
store i64 %40, i64* %13
%41 = load i64, i64* %11
%42 = load i64, i64* %13
%43 = udiv i64 %41, %42
%44 = load i64, i64* %13
%45 = mul i64 %43, %44
store i64 %45, i64* %14
%46 = load i64, i64* %11
%47 = load i64, i64* %14
%48 = sub i64 %46, %47
store i64 %48, i64* %15
%49 = load i32, i32* @O_SYNC
%50 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %49)
store i32 %50, i32* %8
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %55
53: ; preds = %38
%54 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %122
55: ; preds = %38
%56 = load i64, i64* %15
%57 = load i64, i64* %12
%58 = add i64 %56, %57
%59 = load i32, i32* @PROT_READ
%60 = load i32, i32* @PROT_WRITE
%61 = or i32 %59, %60
%62 = load i32, i32* @MAP_PRIVATE
%63 = load i32, i32* %8
%64 = load i64, i64* %14
%65 = call i8* @mmap(i32* null, i64 %58, i32 %61, i32 %62, i32 %63, i64 %64)
store i8* %65, i8** %16
%66 = load i8*, i8** %16
%67 = load i8*, i8** @MAP_FAILED
%68 = icmp eq i8* %66, %67
br i1 %68, label %69, label %71
69: ; preds = %55
%70 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %122
71: ; preds = %55
%72 = load i8*, i8** %16
%73 = load i64, i64* %15
%74 = getelementptr inbounds i8, i8* %72, i64 %73
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %71
%79 = call i32 @select_mode(i32 4, i32 1)
br label %82
80: ; preds = %71
%81 = call i32 @select_mode(i32 4, i32 0)
br label %82
82: ; preds = %80, %78
%83 = load i8*, i8** %16
%84 = load i64, i64* %15
%85 = getelementptr inbounds i8, i8* %83, i64 %84
%86 = load i8, i8* %85
%87 = zext i8 %86 to i32
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %82
%90 = call i32 @select_mode(i32 2, i32 1)
br label %93
91: ; preds = %82
%92 = call i32 @select_mode(i32 2, i32 0)
br label %93
93: ; preds = %91, %89
br label %94
94: ; preds = %118, %93
%95 = load i8*, i8** %6
%96 = load i32, i32* @O_RDONLY
%97 = call i32 @open(i8* %95, i32 %96)
store i32 %97, i32* %8
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %102
99: ; preds = %94
%100 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%101 = call i32 @exit(i32 255)
unreachable
102: ; preds = %94
br label %103
103: ; preds = %117, %102
%104 = load i32, i32* %8
%105 = call i64 @read(i32 %104, %struct.input_event* %9, i32 12)
%106 = icmp sgt i64 %105, 0
br i1 %106, label %107, label %118
107: ; preds = %103
%108 = getelementptr inbounds %struct.input_event, %struct.input_event* %9, i32 0, i32 0
%109 = load i32, i32* %108
%110 = icmp eq i32 %109, 5
br i1 %110, label %111, label %117
111: ; preds = %107
%112 = getelementptr inbounds %struct.input_event, %struct.input_event* %9, i32 0, i32 1
%113 = load i32, i32* %112
%114 = getelementptr inbounds %struct.input_event, %struct.input_event* %9, i32 0, i32 2
%115 = load i32, i32* %114
%116 = call i32 @select_mode(i32 %113, i32 %115)
br label %117
117: ; preds = %111, %107
br label %103
118: ; preds = %103
%119 = load i32, i32* %8
%120 = call i32 @close(i32 %119)
%121 = call i32 @usleep(i32 65535)
br label %94
122: ; preds = %69, %53
%123 = load i32, i32* %3
ret i32 %123
}

LLVM IR (-O2):
%struct.input_event = type { i32, i32, i32 }
@.str = [15 x i8] c"/boot/uEnv.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"debug=on\00"
@_SC_PAGE_SIZE = global i32 0
@.str.3 = [9 x i8] c"/dev/mem\00"
@O_SYNC = global i32 0
@.str.4 = [21 x i8] c"Cannot open /dev/mem\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [17 x i8] c"Can't map memory\00"
@O_RDONLY = global i32 0
@.str.6 = [28 x i8] c"Could not open input device\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.input_event
%4 = bitcast %struct.input_event* %3 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %18, label %7
7: ; preds = %2, %11
%8 = tail call i8* @readLine(i32* %5)
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %7
%12 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %7
14: ; preds = %11
%15 = tail call i32 @select_mode(i32 2, i32 0)
%16 = tail call i32 @select_mode(i32 4, i32 0)
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %7, %2
%19 = load i32, i32* @_SC_PAGE_SIZE
%20 = tail call i64 @sysconf(i32 %19)
%21 = urem i64 29503257, %20
%22 = load i32, i32* @O_SYNC
%23 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %75, label %25
25: ; preds = %18
%26 = sub nuw nsw i64 29503257, %21
%27 = add nuw nsw i64 %21, 1
%28 = load i32, i32* @PROT_READ
%29 = load i32, i32* @PROT_WRITE
%30 = or i32 %29, %28
%31 = load i32, i32* @MAP_PRIVATE
%32 = tail call i8* @mmap(i32* null, i64 %27, i32 %30, i32 %31, i32 %23, i64 %26)
%33 = load i8*, i8** @MAP_FAILED
%34 = icmp eq i8* %32, %33
br i1 %34, label %75, label %35
35: ; preds = %25
%36 = getelementptr inbounds i8, i8* %32, i64 %21
%37 = load i8, i8* %36
%38 = icmp ne i8 %37, 0
%39 = zext i1 %38 to i32
%40 = tail call i32 @select_mode(i32 4, i32 %39)
%41 = load i8, i8* %36
%42 = icmp ne i8 %41, 0
%43 = zext i1 %42 to i32
%44 = tail call i32 @select_mode(i32 2, i32 %43)
%45 = load i32, i32* @O_RDONLY
%46 = tail call i32 @open(i8* null, i32 %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %56, label %48
48: ; preds = %35
%49 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 0
%50 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 1
%51 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 2
br label %52
52: ; preds = %48, %69
%53 = phi i32 [ %46, %48 ], [ %73, %69 ]
%54 = call i64 @read(i32 %53, %struct.input_event* %3, i32 12)
%55 = icmp sgt i64 %54, 0
br i1 %55, label %59, label %69
56: ; preds = %69, %35
%57 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%58 = tail call i32 @exit(i32 255)
unreachable
59: ; preds = %52, %66
%60 = load i32, i32* %49
%61 = icmp eq i32 %60, 5
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i32, i32* %50
%64 = load i32, i32* %51
%65 = tail call i32 @select_mode(i32 %63, i32 %64)
br label %66
66: ; preds = %62, %59
%67 = call i64 @read(i32 %53, %struct.input_event* %3, i32 12)
%68 = icmp sgt i64 %67, 0
br i1 %68, label %59, label %69
69: ; preds = %66, %52
%70 = tail call i32 @close(i32 %53)
%71 = tail call i32 @usleep(i32 65535)
%72 = load i32, i32* @O_RDONLY
%73 = tail call i32 @open(i8* null, i32 %72)
%74 = icmp eq i32 %73, -1
br i1 %74, label %56, label %52
75: ; preds = %25, %18
%76 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), %18 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), %25 ]
%77 = tail call i32 @perror(i8* %76)
ret i32 -1
}