unsigned int ReadKeys(void) {
  unsigned char x, y;
  unsigned int data = 0;
  (*((volatile unsigned long *)0xE0028004)) = 1 << 22;
  while ((*((volatile unsigned long *)0xE0028010)) & 1 << 25)
    ;
  (*((volatile unsigned long *)0xE002800C)) = 1 << 22;
  for (x = 0; x < 16; x++) {
    y = 200;
    while (y--)
      ;
    (*((volatile unsigned long *)0xE0028004)) = 1 << 22;
    y = 200;
    while (y--)
      ;
    (*((volatile unsigned long *)0xE002800C)) = 1 << 22;
    data |= !!((*((volatile unsigned long *)0xE0028000)) & 1 << 21) << 16;
    data >>= 1;
  }
  return data;
}


x86 assembly (clang, -O0):
<ReadKeys>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x8(%rbp)
mov    $0xe0028004,%eax
movq   $0x400000,(%rax)
mov    $0xe0028010,%eax
mov    (%rax),%rax
and    $0x2000000,%rax
cmp    $0x0,%rax
je     1134 <ReadKeys+0x34>
jmp    1117 <ReadKeys+0x17>
mov    $0xe002800c,%eax
movq   $0x400000,(%rax)
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x10,%eax
jge    11de <ReadKeys+0xde>
movb   $0xc8,-0x2(%rbp)
mov    -0x2(%rbp),%al
mov    %al,%cl
add    $0xff,%cl
mov    %cl,-0x2(%rbp)
cmp    $0x0,%al
je     116d <ReadKeys+0x6d>
jmp    1155 <ReadKeys+0x55>
mov    $0xe0028004,%eax
movq   $0x400000,(%rax)
movb   $0xc8,-0x2(%rbp)
mov    -0x2(%rbp),%al
mov    %al,%cl
add    $0xff,%cl
mov    %cl,-0x2(%rbp)
cmp    $0x0,%al
je     1195 <ReadKeys+0x95>
jmp    117d <ReadKeys+0x7d>
mov    $0xe002800c,%eax
movq   $0x400000,(%rax)
mov    $0xe0028000,%eax
mov    (%rax),%rax
and    $0x200000,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
shl    $0x10,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x1(%rbp),%al
add    $0x1,%al
mov    %al,-0x1(%rbp)
jmp    1144 <ReadKeys+0x44>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadKeys>:
mov    $0xe0028004,%eax
movq   $0x400000,(%rax)
nopl   0x0(%rax)
testq  $0x2000000,0xc(%rax)
02
jne    1110 <ReadKeys+0x10>
movq   $0x400000,0x8(%rax)
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rcx
shr    $0x15,%ecx
and    $0x1,%ecx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rdx
shr    $0x14,%edx
and    $0x2,%edx
or     %ecx,%edx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rcx
shr    $0x13,%ecx
and    $0x4,%ecx
or     %edx,%ecx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rdx
shr    $0x12,%edx
and    $0x8,%edx
or     %ecx,%edx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rcx
shr    $0x11,%ecx
and    $0x10,%ecx
or     %edx,%ecx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rdx
shr    $0x10,%edx
and    $0x20,%edx
or     %ecx,%edx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rcx
shr    $0xf,%ecx
and    $0x40,%ecx
or     %edx,%ecx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rdx
shr    $0xe,%edx
and    $0x80,%edx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rsi
shr    $0xd,%esi
and    $0x100,%esi
or     %edx,%esi
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rdx
shr    $0xc,%edx
and    $0x200,%edx
or     %esi,%edx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rsi
shr    $0xb,%esi
and    $0x400,%esi
or     %edx,%esi
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rdx
shr    $0xa,%edx
and    $0x800,%edx
or     %esi,%edx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rsi
shr    $0x9,%esi
and    $0x1000,%esi
or     %edx,%esi
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rdx
shr    $0x8,%edx
and    $0x2000,%edx
or     %esi,%edx
or     %ecx,%edx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rcx
shr    $0x7,%ecx
and    $0x4000,%ecx
movq   $0x400000,(%rax)
movq   $0x400000,0x8(%rax)
mov    -0x4(%rax),%rax
shr    $0x6,%eax
and    $0x8000,%eax
or     %ecx,%eax
or     %edx,%eax
ret

LLVM IR (-O0):
define i32 @ReadKeys() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %3
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
br label %4
4: ; preds = %8, %0
%5 = load volatile i64, i64* inttoptr (i64 3758260240 to i64*)
%6 = and i64 %5, 33554432
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %4
br label %4
9: ; preds = %4
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
store i8 0, i8* %1
br label %10
10: ; preds = %38, %9
%11 = load i8, i8* %1
%12 = zext i8 %11 to i32
%13 = icmp slt i32 %12, 16
br i1 %13, label %14, label %41
14: ; preds = %10
store i8 -56, i8* %2
br label %15
15: ; preds = %19, %14
%16 = load i8, i8* %2
%17 = add i8 %16, -1
store i8 %17, i8* %2
%18 = icmp ne i8 %16, 0
br i1 %18, label %19, label %20
19: ; preds = %15
br label %15
20: ; preds = %15
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store i8 -56, i8* %2
br label %21
21: ; preds = %25, %20
%22 = load i8, i8* %2
%23 = add i8 %22, -1
store i8 %23, i8* %2
%24 = icmp ne i8 %22, 0
br i1 %24, label %25, label %26
25: ; preds = %21
br label %21
26: ; preds = %21
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%27 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%28 = and i64 %27, 2097152
%29 = icmp ne i64 %28, 0
%30 = xor i1 %29, true
%31 = xor i1 %30, true
%32 = zext i1 %31 to i32
%33 = shl i32 %32, 16
%34 = load i32, i32* %3
%35 = or i32 %34, %33
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = lshr i32 %36, 1
store i32 %37, i32* %3
br label %38
38: ; preds = %26
%39 = load i8, i8* %1
%40 = add i8 %39, 1
store i8 %40, i8* %1
br label %10
41: ; preds = %10
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
define i32 @ReadKeys() {
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
br label %1
1: ; preds = %1, %0
%2 = load volatile i64, i64* inttoptr (i64 3758260240 to i64*)
%3 = and i64 %2, 33554432
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %1
5: ; preds = %1
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%6 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%7 = trunc i64 %6 to i32
%8 = lshr i32 %7, 21
%9 = and i32 %8, 1
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%10 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%11 = trunc i64 %10 to i32
%12 = lshr i32 %11, 20
%13 = and i32 %12, 2
%14 = or i32 %13, %9
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%15 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%16 = trunc i64 %15 to i32
%17 = lshr i32 %16, 19
%18 = and i32 %17, 4
%19 = or i32 %18, %14
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%20 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%21 = trunc i64 %20 to i32
%22 = lshr i32 %21, 18
%23 = and i32 %22, 8
%24 = or i32 %23, %19
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%25 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%26 = trunc i64 %25 to i32
%27 = lshr i32 %26, 17
%28 = and i32 %27, 16
%29 = or i32 %28, %24
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%30 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%31 = trunc i64 %30 to i32
%32 = lshr i32 %31, 16
%33 = and i32 %32, 32
%34 = or i32 %33, %29
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%35 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%36 = trunc i64 %35 to i32
%37 = lshr i32 %36, 15
%38 = and i32 %37, 64
%39 = or i32 %38, %34
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%40 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%41 = trunc i64 %40 to i32
%42 = lshr i32 %41, 14
%43 = and i32 %42, 128
%44 = or i32 %43, %39
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%45 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%46 = trunc i64 %45 to i32
%47 = lshr i32 %46, 13
%48 = and i32 %47, 256
%49 = or i32 %48, %44
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%50 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%51 = trunc i64 %50 to i32
%52 = lshr i32 %51, 12
%53 = and i32 %52, 512
%54 = or i32 %53, %49
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%55 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%56 = trunc i64 %55 to i32
%57 = lshr i32 %56, 11
%58 = and i32 %57, 1024
%59 = or i32 %58, %54
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%60 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%61 = trunc i64 %60 to i32
%62 = lshr i32 %61, 10
%63 = and i32 %62, 2048
%64 = or i32 %63, %59
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%65 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%66 = trunc i64 %65 to i32
%67 = lshr i32 %66, 9
%68 = and i32 %67, 4096
%69 = or i32 %68, %64
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%70 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%71 = trunc i64 %70 to i32
%72 = lshr i32 %71, 8
%73 = and i32 %72, 8192
%74 = or i32 %73, %69
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%75 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%76 = trunc i64 %75 to i32
%77 = lshr i32 %76, 7
%78 = and i32 %77, 16384
%79 = or i32 %78, %74
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%80 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%81 = trunc i64 %80 to i32
%82 = lshr i32 %81, 6
%83 = and i32 %82, 32768
%84 = or i32 %83, %79
ret i32 %84
}