#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int fd;
};
struct epoll_event {
  TYPE_1__ data;
  void *events;
};

/* Variables and functions */
void *EPOLLET;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int atoi(char *);
int epoll_create(int);
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int init_gpio(int);
int /*<<< orphan*/ printf(char *, unsigned int, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int n;
  int epfd;
  int fd_d0, fd_d1;
  if (argc != 3) {
    fprintf(stderr, "USAGE: %s <GPIO_D0> <GPIO_D1>\n", argv[0]);
    return 2;
  }
  int gpio_d0 = atoi(argv[1]);
  int gpio_d1 = atoi(argv[2]);
  fprintf(stderr, "Using GPIO %d for D0 and GPIO %d for D1\n", gpio_d0,
          gpio_d1);
  epfd = epoll_create(1);
  fd_d0 = init_gpio(gpio_d0);
  fd_d1 = init_gpio(gpio_d1);
  if (!(fd_d0 > 0) || !(fd_d1 > 0)) {
    fprintf(stderr, "error opening gpio sysfs entries\n");
    return 1;
  }
  char buf = 0;
  struct epoll_event ev_d0, ev_d1;
  struct epoll_event events[10];
  ev_d0.events = EPOLLET;
  ev_d1.events = EPOLLET;
  ev_d0.data.fd = fd_d0;
  ev_d1.data.fd = fd_d1;
  n = epoll_ctl(epfd, EPOLL_CTL_ADD, fd_d0, &ev_d0);
  if (n != 0) {
    fprintf(stderr, "epoll_ctl returned %d: %s\n", n, strerror(errno));
    return 1;
  }
  n = epoll_ctl(epfd, EPOLL_CTL_ADD, fd_d1, &ev_d1);
  if (n != 0) {
    printf("epoll_ctl returned %d: %s\n", n, strerror(errno));
    return 1;
  }
  size_t i;
  unsigned int value = 0;
  unsigned bit_counter = 0;
  while (1) {
    n = epoll_wait(epfd, events, 10, 15);
    for (i = 0; i < n; ++i) {
      value <<= 1;
      if (events[i].data.fd == ev_d1.data.fd) {
        value |= 0x01;
      }
      bit_counter += 1;
    }
    if (bit_counter && (n == 0)) {
      printf("got value %d = 0x%x (%d bits)\n", value, value, bit_counter);
      value = 0;
      bit_counter = 0;
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11cd <main+0x4d>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1466 <main+0x2e6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <epoll_create@plt>
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
call   1090 <init_gpio@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%edi
call   1090 <init_gpio@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1241 <main+0xc1>
cmpl   $0x0,-0x20(%rbp)
jg     1264 <main+0xe4>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1466 <main+0x2e6>
movb   $0x0,-0x29(%rbp)
mov    0x2d59(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d4b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
mov    -0x1c(%rbp),%edx
lea    -0x40(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1304 <main+0x184>
mov    0x2d1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x108(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x104(%rbp)
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x108(%rbp),%edi
mov    -0x104(%rbp),%edx
mov    %rax,%rcx
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1466 <main+0x2e6>
mov    -0x18(%rbp),%edi
mov    0x2cda(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%edx
lea    -0x50(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1363 <main+0x1e3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10c(%rbp)
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x10c(%rbp),%esi
mov    %rax,%rdx
lea    0xd1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1466 <main+0x2e6>
movl   $0x0,-0xfc(%rbp)
movl   $0x0,-0x100(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xf0(%rbp),%rsi
mov    $0xa,%edx
mov    $0xf,%ecx
call   1060 <epoll_wait@plt>
mov    %eax,-0x14(%rbp)
movq   $0x0,-0xf8(%rbp)
mov    -0xf8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jae    1416 <main+0x296>
mov    -0xfc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xfc(%rbp)
mov    -0xf8(%rbp),%rcx
lea    -0xf0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%eax
cmp    -0x50(%rbp),%eax
jne    13f0 <main+0x270>
mov    -0xfc(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0xfc(%rbp)
mov    -0x100(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x100(%rbp)
mov    -0xf8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
jmp    139e <main+0x21e>
cmpl   $0x0,-0x100(%rbp)
je     1461 <main+0x2e1>
cmpl   $0x0,-0x14(%rbp)
jne    1461 <main+0x2e1>
mov    -0xfc(%rbp),%esi
mov    -0xfc(%rbp),%edx
mov    -0x100(%rbp),%ecx
lea    0xc3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xfc(%rbp)
movl   $0x0,-0x100(%rbp)
jmp    1377 <main+0x1f7>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1267 <main+0xe7>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    0x2e1e(%rip),%r15
mov    (%r15),%edi
lea    0xe5b(%rip),%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%r14d
mov    $0x1,%edi
call   1080 <epoll_create@plt>
mov    %eax,%r12d
mov    %ebp,%edi
call   1090 <init_gpio@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1090 <init_gpio@plt>
test   %ebp,%ebp
jle    1289 <main+0x109>
mov    %eax,%ebx
test   %eax,%eax
jle    1289 <main+0x109>
mov    0x2dbd(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
mov    %rax,0x8(%rsp)
mov    %ebp,0x10(%rsp)
mov    %ebx,(%rsp)
mov    0x2dc2(%rip),%r13
mov    0x0(%r13),%esi
lea    0x10(%rsp),%rcx
mov    %r12d,%edi
mov    %ebp,%edx
call   1040 <epoll_ctl@plt>
test   %eax,%eax
je     12af <main+0x12f>
mov    %eax,%ebp
mov    (%r15),%ebx
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xe13(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    129a <main+0x11a>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd86(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x2,%r14d
jmp    129a <main+0x11a>
mov    (%r15),%edi
lea    0xdb5(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14d,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%esi
mov    %rsp,%rcx
mov    %r12d,%edi
mov    %ebx,%edx
call   1040 <epoll_ctl@plt>
test   %eax,%eax
je     12e9 <main+0x169>
mov    %eax,%ebx
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd8f(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    129a <main+0x11a>
xor    %ebx,%ebx
lea    0x20(%rsp),%r14
lea    0xd8e(%rip),%r15
nopw   0x0(%rax,%rax,1)
xor    %r13d,%r13d
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0xa,%edx
mov    $0xf,%ecx
call   1060 <epoll_wait@plt>
test   %eax,%eax
je     137e <main+0x1fe>
mov    (%rsp),%ecx
movslq %eax,%r8
cmp    $0x1,%eax
jne    1330 <main+0x1b0>
xor    %esi,%esi
jmp    1365 <main+0x1e5>
nopl   0x0(%rax,%rax,1)
mov    %r8,%rdi
and    $0xfffffffffffffffe,%rdi
lea    0x30(%rsp),%rdx
xor    %esi,%esi
xchg   %ax,%ax
xor    %ebp,%ebp
cmp    %ecx,-0x10(%rdx)
sete   %bpl
add    %ebp,%ebp
lea    0x0(%rbp,%rbx,4),%ebp
xor    %ebx,%ebx
cmp    %ecx,(%rdx)
sete   %bl
or     %ebp,%ebx
add    $0x2,%rsi
add    $0x20,%rdx
cmp    %rsi,%rdi
jne    1340 <main+0x1c0>
test   $0x1,%r8b
je     137b <main+0x1fb>
shl    $0x4,%rsi
xor    %edx,%edx
cmp    %ecx,0x20(%rsp,%rsi,1)
sete   %dl
lea    (%rdx,%rbx,2),%ebx
add    %eax,%r13d
test   %r13d,%r13d
je     1303 <main+0x183>
test   %eax,%eax
jne    1303 <main+0x183>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %ebx,%ebx
jmp    1300 <main+0x180>

LLVM IR (-O0):
%struct.epoll_event = type { %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"USAGE: %s <GPIO_D0> <GPIO_D1>\0A\00"
@.str.1 = [41 x i8] c"Using GPIO %d for D0 and GPIO %d for D1\0A\00"
@.str.2 = [34 x i8] c"error opening gpio sysfs entries\0A\00"
@EPOLLET = global i8* null
@EPOLL_CTL_ADD = global i32 0
@.str.3 = [27 x i8] c"epoll_ctl returned %d: %s\0A\00"
@errno = global i32 0
@.str.4 = [31 x i8] c"got value %d = 0x%x (%d bits)\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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca %struct.epoll_event
%14 = alloca %struct.epoll_event
%15 = alloca [10 x %struct.epoll_event]
%16 = alloca i64
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 3
br i1 %20, label %21, label %27
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %25)
store i32 2, i32* %3
br label %131
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %10
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %11
%36 = load i32, i32* @stderr
%37 = load i32, i32* %10
%38 = load i32, i32* %11
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %38)
%40 = call i32 @epoll_create(i32 1)
store i32 %40, i32* %7
%41 = load i32, i32* %10
%42 = call i32 @init_gpio(i32 %41)
store i32 %42, i32* %8
%43 = load i32, i32* %11
%44 = call i32 @init_gpio(i32 %43)
store i32 %44, i32* %9
%45 = load i32, i32* %8
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %27
%48 = load i32, i32* %9
%49 = icmp sgt i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %47, %27
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %131
53: ; preds = %47
store i8 0, i8* %12
%54 = load i8*, i8** @EPOLLET
%55 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %13, i32 0, i32 1
store i8* %54, i8** %55
%56 = load i8*, i8** @EPOLLET
%57 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %14, i32 0, i32 1
store i8* %56, i8** %57
%58 = load i32, i32* %8
%59 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %13, i32 0, i32 0
%60 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %59, i32 0, i32 0
store i32 %58, i32* %60
%61 = load i32, i32* %9
%62 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %14, i32 0, i32 0
%63 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %62, i32 0, i32 0
store i32 %61, i32* %63
%64 = load i32, i32* %7
%65 = load i32, i32* @EPOLL_CTL_ADD
%66 = load i32, i32* %8
%67 = call i32 @epoll_ctl(i32 %64, i32 %65, i32 %66, %struct.epoll_event* %13)
store i32 %67, i32* %6
%68 = load i32, i32* %6
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %53
%71 = load i32, i32* @stderr
%72 = load i32, i32* %6
%73 = load i32, i32* @errno
%74 = call i8* @strerror(i32 %73)
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %72, i8* %74)
store i32 1, i32* %3
br label %131
76: ; preds = %53
%77 = load i32, i32* %7
%78 = load i32, i32* @EPOLL_CTL_ADD
%79 = load i32, i32* %9
%80 = call i32 @epoll_ctl(i32 %77, i32 %78, i32 %79, %struct.epoll_event* %14)
store i32 %80, i32* %6
%81 = load i32, i32* %6
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %88
83: ; preds = %76
%84 = load i32, i32* %6
%85 = load i32, i32* @errno
%86 = call i8* @strerror(i32 %85)
%87 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %84, i8* %86)
store i32 1, i32* %3
br label %131
88: ; preds = %76
store i32 0, i32* %17
store i32 0, i32* %18
br label %89
89: ; preds = %88, %130
%90 = load i32, i32* %7
%91 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %15, i64 0, i64 0
%92 = call i32 @epoll_wait(i32 %90, %struct.epoll_event* %91, i32 10, i32 15)
store i32 %92, i32* %6
store i64 0, i64* %16
br label %93
93: ; preds = %116, %89
%94 = load i64, i64* %16
%95 = load i32, i32* %6
%96 = sext i32 %95 to i64
%97 = icmp ult i64 %94, %96
br i1 %97, label %98, label %119
98: ; preds = %93
%99 = load i32, i32* %17
%100 = shl i32 %99, 1
store i32 %100, i32* %17
%101 = load i64, i64* %16
%102 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %15, i64 0, i64 %101
%103 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %102, i32 0, i32 0
%104 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %103, i32 0, i32 0
%105 = load i32, i32* %104
%106 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %14, i32 0, i32 0
%107 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %106, i32 0, i32 0
%108 = load i32, i32* %107
%109 = icmp eq i32 %105, %108
br i1 %109, label %110, label %113
110: ; preds = %98
%111 = load i32, i32* %17
%112 = or i32 %111, 1
store i32 %112, i32* %17
br label %113
113: ; preds = %110, %98
%114 = load i32, i32* %18
%115 = add i32 %114, 1
store i32 %115, i32* %18
br label %116
116: ; preds = %113
%117 = load i64, i64* %16
%118 = add i64 %117, 1
store i64 %118, i64* %16
br label %93
119: ; preds = %93
%120 = load i32, i32* %18
%121 = icmp ne i32 %120, 0
br i1 %121, label %122, label %130
122: ; preds = %119
%123 = load i32, i32* %6
%124 = icmp eq i32 %123, 0
br i1 %124, label %125, label %130
125: ; preds = %122
%126 = load i32, i32* %17
%127 = load i32, i32* %17
%128 = load i32, i32* %18
%129 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %126, i32 %127, i32 %128)
store i32 0, i32* %17
store i32 0, i32* %18
br label %130
130: ; preds = %125, %122, %119
br label %89
131: ; preds = %83, %70, %50, %21
%132 = load i32, i32* %3
ret i32 %132
}

LLVM IR (-O2):
%struct.epoll_event = type { %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"USAGE: %s <GPIO_D0> <GPIO_D1>\0A\00"
@.str.1 = [41 x i8] c"Using GPIO %d for D0 and GPIO %d for D1\0A\00"
@.str.2 = [34 x i8] c"error opening gpio sysfs entries\0A\00"
@EPOLLET = global i8* null
@EPOLL_CTL_ADD = global i32 0
@.str.3 = [27 x i8] c"epoll_ctl returned %d: %s\0A\00"
@errno = global i32 0
@.str.4 = [31 x i8] c"got value %d = 0x%x (%d bits)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.epoll_event
%4 = alloca %struct.epoll_event
%5 = alloca [10 x %struct.epoll_event]
%6 = icmp eq i32 %0, 3
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %113
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %17)
%20 = tail call i32 @epoll_create(i32 1)
%21 = tail call i32 @init_gpio(i32 %14)
%22 = tail call i32 @init_gpio(i32 %17)
%23 = icmp sgt i32 %21, 0
%24 = icmp sgt i32 %22, 0
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %29, label %26
26: ; preds = %11
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %113
29: ; preds = %11
%30 = bitcast %struct.epoll_event* %3 to i8*
%31 = bitcast %struct.epoll_event* %4 to i8*
%32 = bitcast [10 x %struct.epoll_event]* %5 to i8*
%33 = load i8*, i8** @EPOLLET
%34 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 1
store i8* %33, i8** %34
%35 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 1
store i8* %33, i8** %35
%36 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0, i32 0
store i32 %21, i32* %36
%37 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0, i32 0
store i32 %22, i32* %37
%38 = load i32, i32* @EPOLL_CTL_ADD
%39 = call i32 @epoll_ctl(i32 %20, i32 %38, i32 %21, %struct.epoll_event* %3)
%40 = icmp eq i32 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %29
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %39, i8* %44)
br label %112
46: ; preds = %29
%47 = load i32, i32* @EPOLL_CTL_ADD
%48 = call i32 @epoll_ctl(i32 %20, i32 %47, i32 %22, %struct.epoll_event* %4)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 0
br label %56
52: ; preds = %46
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %48, i8* %54)
br label %112
56: ; preds = %109, %50
%57 = phi i32 [ 0, %50 ], [ %110, %109 ]
%58 = phi i32 [ 0, %50 ], [ %111, %109 ]
%59 = call i32 @epoll_wait(i32 %20, %struct.epoll_event* %51, i32 10, i32 15)
%60 = icmp eq i32 %59, 0
br i1 %60, label %102, label %61
61: ; preds = %56
%62 = load i32, i32* %37
%63 = sext i32 %59 to i64
%64 = and i64 %63, 1
%65 = icmp eq i32 %59, 1
br i1 %65, label %87, label %66
66: ; preds = %61
%67 = and i64 %63, -2
br label %68
68: ; preds = %68, %66
%69 = phi i32 [ %57, %66 ], [ %83, %68 ]
%70 = phi i64 [ 0, %66 ], [ %84, %68 ]
%71 = phi i64 [ 0, %66 ], [ %85, %68 ]
%72 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 %70, i32 0, i32 0
%73 = load i32, i32* %72
%74 = icmp eq i32 %73, %62
%75 = or i64 %70, 1
%76 = shl i32 %69, 2
%77 = select i1 %74, i32 2, i32 0
%78 = or i32 %76, %77
%79 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 %75, i32 0, i32 0
%80 = load i32, i32* %79
%81 = icmp eq i32 %80, %62
%82 = zext i1 %81 to i32
%83 = or i32 %78, %82
%84 = add nuw i64 %70, 2
%85 = add i64 %71, 2
%86 = icmp eq i64 %85, %67
br i1 %86, label %87, label %68
87: ; preds = %68, %61
%88 = phi i32 [ undef, %61 ], [ %83, %68 ]
%89 = phi i32 [ %57, %61 ], [ %83, %68 ]
%90 = phi i64 [ 0, %61 ], [ %84, %68 ]
%91 = icmp eq i64 %64, 0
br i1 %91, label %99, label %92
92: ; preds = %87
%93 = shl i32 %89, 1
%94 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 %90, i32 0, i32 0
%95 = load i32, i32* %94
%96 = icmp eq i32 %95, %62
%97 = zext i1 %96 to i32
%98 = or i32 %93, %97
br label %99
99: ; preds = %87, %92
%100 = phi i32 [ %88, %87 ], [ %98, %92 ]
%101 = add i32 %58, %59
br label %102
102: ; preds = %99, %56
%103 = phi i32 [ %57, %56 ], [ %100, %99 ]
%104 = phi i32 [ %58, %56 ], [ %101, %99 ]
%105 = icmp ne i32 %104, 0
%106 = select i1 %105, i1 %60, i1 false
br i1 %106, label %107, label %109
107: ; preds = %102
%108 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %103, i32 %103, i32 %104)
br label %109
109: ; preds = %107, %102
%110 = phi i32 [ 0, %107 ], [ %103, %102 ]
%111 = phi i32 [ 0, %107 ], [ %104, %102 ]
br label %56
112: ; preds = %52, %41
br label %113
113: ; preds = %26, %112, %7
%114 = phi i32 [ 2, %7 ], [ 1, %112 ], [ 1, %26 ]
ret i32 %114
}