#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*/ uart_send(char *);
void pendnupISR(void) {
  if ((*(volatile unsigned int *)(0x7E00B00C)) & 0x8000) {
    uart_send("Stylus up state!\n\n");
    (*(volatile unsigned int *)(0x7E00B004)) = 0xD3;
  } else {
    uart_send("Stylus down state!\n");
    (*(volatile unsigned int *)(0x7E00B004)) = 0x0C;
    (*(volatile unsigned int *)(0x7E00B000)) |= 1;
  }
  (*(volatile unsigned int *)(0x7E00B020)) = 0;
  (*(volatile unsigned int *)(0x71300F00)) = 0;
  return;
}


x86 assembly (clang, -O0):
<pendnupISR>:
push   %rbp
mov    %rsp,%rbp
mov    $0x7e00b00c,%eax
mov    (%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1145 <pendnupISR+0x35>
lea    0xed0(%rip),%rdi
call   1030 <uart_send@plt>
mov    $0x7e00b004,%eax
movl   $0xd3,(%rax)
jmp    116d <pendnupISR+0x5d>
lea    0xec7(%rip),%rdi
call   1030 <uart_send@plt>
mov    $0x7e00b004,%eax
movl   $0xc,(%rax)
mov    $0x7e00b000,%eax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    $0x7e00b000,%eax
mov    %ecx,(%rax)
mov    $0x7e00b020,%eax
movl   $0x0,(%rax)
mov    $0x71300f00,%eax
movl   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<pendnupISR>:
push   %rax
testl  $0x8000,0x7e00b00c
jne    113f <pendnupISR+0x2f>
lea    0xeee(%rip),%rdi
call   1030 <uart_send@plt>
movl   $0xc,0x7e00b004
orl    $0x1,0x7e00b000
01
jmp    1156 <pendnupISR+0x46>
lea    0xeba(%rip),%rdi
call   1030 <uart_send@plt>
movl   $0xd3,0x7e00b004
movl   $0x0,0x7e00b020
movl   $0x0,0x71300f00
pop    %rax
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Stylus up state!\0A\0A\00"
@.str.1 = [20 x i8] c"Stylus down state!\0A\00"
define void @pendnupISR() {
%1 = load volatile i32, i32* inttoptr (i64 2113974284 to i32*)
%2 = and i32 %1, 32768
%3 = icmp ne i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @uart_send(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store volatile i32 211, i32* inttoptr (i64 2113974276 to i32*)
br label %10
6: ; preds = %0
%7 = call i32 @uart_send(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store volatile i32 12, i32* inttoptr (i64 2113974276 to i32*)
%8 = load volatile i32, i32* inttoptr (i64 2113974272 to i32*)
%9 = or i32 %8, 1
store volatile i32 %9, i32* inttoptr (i64 2113974272 to i32*)
br label %10
10: ; preds = %6, %4
store volatile i32 0, i32* inttoptr (i64 2113974304 to i32*)
store volatile i32 0, i32* inttoptr (i64 1898974976 to i32*)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Stylus up state!\0A\0A\00"
@.str.1 = [20 x i8] c"Stylus down state!\0A\00"
define void @pendnupISR() {
%1 = load volatile i32, i32* inttoptr (i64 2113974284 to i32*)
%2 = and i32 %1, 32768
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @uart_send(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store volatile i32 211, i32* inttoptr (i64 2113974276 to i32*)
br label %10
6: ; preds = %0
%7 = tail call i32 @uart_send(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store volatile i32 12, i32* inttoptr (i64 2113974276 to i32*)
%8 = load volatile i32, i32* inttoptr (i64 2113974272 to i32*)
%9 = or i32 %8, 1
store volatile i32 %9, i32* inttoptr (i64 2113974272 to i32*)
br label %10
10: ; preds = %6, %4
store volatile i32 0, i32* inttoptr (i64 2113974304 to i32*)
store volatile i32 0, i32* inttoptr (i64 1898974976 to i32*)
ret void
}