#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 */

/* Variables and functions */
int /*<<< orphan*/ pi_sleep(int);
int read_byte();
int write_block(int, int, int /*<<< orphan*/, int /*<<< orphan*/);
int digitalRead(int pin) {
  int dRead;
  if (pin == 10 || pin == 15 || pin == 0 || pin == 1) {
    if (write_block(13, pin, 0, 0) == -1)
      return -1;
    pi_sleep(100);
    dRead = read_byte();
    read_byte();
    if (dRead == -1)
      return -1;
    return dRead;
  } else
    return -2;
}


x86 assembly (clang, -O0):
<digitalRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
je     1163 <digitalRead+0x33>
cmpl   $0xf,-0x8(%rbp)
je     1163 <digitalRead+0x33>
cmpl   $0x0,-0x8(%rbp)
je     1163 <digitalRead+0x33>
cmpl   $0x1,-0x8(%rbp)
jne    11c5 <digitalRead+0x95>
mov    -0x8(%rbp),%esi
mov    $0xd,%edi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1040 <write_block@plt>
cmp    $0xffffffff,%eax
jne    1189 <digitalRead+0x59>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cc <digitalRead+0x9c>
mov    $0x64,%edi
call   1050 <pi_sleep@plt>
mov    $0x0,%al
call   1030 <read_byte@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <read_byte@plt>
cmpl   $0xffffffff,-0xc(%rbp)
jne    11ba <digitalRead+0x8a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cc <digitalRead+0x9c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <digitalRead+0x9c>
movl   $0xfffffffe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<digitalRead>:
push   %rbx
mov    $0xfffffffe,%eax
cmp    $0xf,%edi
ja     1176 <digitalRead+0x46>
mov    %edi,%esi
mov    $0x8403,%ecx
bt     %edi,%ecx
jae    1176 <digitalRead+0x46>
mov    $0xd,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <write_block@plt>
cmp    $0xffffffff,%eax
je     1178 <digitalRead+0x48>
mov    $0x64,%edi
call   1050 <pi_sleep@plt>
xor    %eax,%eax
call   1030 <read_byte@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <read_byte@plt>
mov    %ebx,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @digitalRead(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 10
br i1 %6, label %16, label %7
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 15
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %30
16: ; preds = %13, %10, %7, %1
%17 = load i32, i32* %3
%18 = call i32 @write_block(i32 13, i32 %17, i32 0, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %2
br label %31
21: ; preds = %16
%22 = call i32 @pi_sleep(i32 100)
%23 = call i32 (...) @read_byte()
store i32 %23, i32* %4
%24 = call i32 (...) @read_byte()
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 -1, i32* %2
br label %31
28: ; preds = %21
%29 = load i32, i32* %4
store i32 %29, i32* %2
br label %31
30: ; preds = %13
store i32 -2, i32* %2
br label %31
31: ; preds = %30, %28, %27, %20
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @digitalRead(i32 %0) {
switch i32 %0, label %9 [
i32 15, label %2
i32 10, label %2
i32 1, label %2
i32 0, label %2
]
2: ; preds = %1, %1, %1, %1
%3 = tail call i32 @write_block(i32 13, i32 %0, i32 0, i32 0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 @pi_sleep(i32 100)
%7 = tail call i32 (...) @read_byte()
%8 = tail call i32 (...) @read_byte()
br label %9
9: ; preds = %1, %5, %2
%10 = phi i32 [ -1, %2 ], [ %7, %5 ], [ -2, %1 ]
ret i32 %10
}