void Nand_ReadPage(const int page, unsigned char *const buffer) {
  int i;
  Nand_Reset();
  { (*(volatile unsigned *)0x4E000004) &= ~(1 << 1); };
  { (*(volatile unsigned *)0x4E000020) |= (1 << 2); };
  { (*(volatile unsigned *)0x4E000008) = (0x00); };
  { (*(volatile unsigned *)0x4E00000C) = (0x0); };
  { (*(volatile unsigned *)0x4E00000C) = (0x0); };
  { (*(volatile unsigned *)0x4E00000C) = (page & 0xff); };
  { (*(volatile unsigned *)0x4E00000C) = ((page >> 8) & 0xff); };
  { (*(volatile unsigned *)0x4E00000C) = ((page >> 16) & 0xff); };
  { (*(volatile unsigned *)0x4E000008) = (0x30); };
  {
    while (!((*(volatile unsigned *)0x4E000020) & (1 << 2)))
      ;
  };
  for (i = 0; i < 2048; i++) {
    buffer[i] = ((*(volatile unsigned char *)0x4E000010));
  }
  { (*(volatile unsigned *)0x4E000004) |= (1 << 1); };
}


x86 assembly (clang, -O0):
<Nand_ReadPage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <Nand_Reset@plt>
mov    $0x4e000004,%eax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    $0x4e000004,%eax
mov    %ecx,(%rax)
mov    $0x4e000020,%eax
mov    (%rax),%ecx
or     $0x4,%ecx
mov    $0x4e000020,%eax
mov    %ecx,(%rax)
mov    $0x4e000008,%eax
movl   $0x0,(%rax)
mov    $0x4e00000c,%eax
movl   $0x0,(%rax)
mov    $0x4e00000c,%eax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    $0x4e00000c,%eax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    $0x4e00000c,%eax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    $0x4e00000c,%eax
mov    %ecx,(%rax)
mov    $0x4e000008,%eax
movl   $0x30,(%rax)
mov    $0x4e000020,%eax
mov    (%rax),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c9 <Nand_ReadPage+0xb9>
jmp    11ce <Nand_ReadPage+0xbe>
jmp    11aa <Nand_ReadPage+0x9a>
movl   $0x0,-0x14(%rbp)
cmpl   $0x800,-0x14(%rbp)
jge    1202 <Nand_ReadPage+0xf2>
mov    $0x4e000010,%eax
mov    (%rax),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d5 <Nand_ReadPage+0xc5>
mov    $0x4e000004,%eax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    $0x4e000004,%eax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Nand_ReadPage>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <Nand_Reset@plt>
andl   $0xfffffffd,0x4e000004
fd
orl    $0x4,0x4e000020
04
movl   $0x0,0x4e000008
movl   $0x0,0x4e00000c
movl   $0x0,0x4e00000c
mov    %ebp,%ecx
movzbl %cl,%eax
mov    %eax,0x4e00000c
movzbl %ch,%eax
mov    %eax,0x4e00000c
shr    $0x10,%ecx
movzbl %cl,%eax
mov    %eax,0x4e00000c
movl   $0x30,0x4e000008
xchg   %ax,%ax
testl  $0x4,0x4e000020
je     1180 <Nand_ReadPage+0x70>
xor    %eax,%eax
nop
movzbl 0x4e000010,%ecx
4e
mov    %cl,(%rbx,%rax,1)
movzbl 0x4e000010,%ecx
4e
mov    %cl,0x1(%rbx,%rax,1)
movzbl 0x4e000010,%ecx
4e
mov    %cl,0x2(%rbx,%rax,1)
movzbl 0x4e000010,%ecx
4e
mov    %cl,0x3(%rbx,%rax,1)
add    $0x4,%rax
cmp    $0x800,%rax
jne    1190 <Nand_ReadPage+0x80>
orl    $0x2,0x4e000004
02
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @Nand_ReadPage(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = call i32 (...) @Nand_Reset()
%7 = load volatile i32, i32* inttoptr (i64 1308622852 to i32*)
%8 = and i32 %7, -3
store volatile i32 %8, i32* inttoptr (i64 1308622852 to i32*)
%9 = load volatile i32, i32* inttoptr (i64 1308622880 to i32*)
%10 = or i32 %9, 4
store volatile i32 %10, i32* inttoptr (i64 1308622880 to i32*)
store volatile i32 0, i32* inttoptr (i64 1308622856 to i32*)
store volatile i32 0, i32* inttoptr (i64 1308622860 to i32*)
store volatile i32 0, i32* inttoptr (i64 1308622860 to i32*)
%11 = load i32, i32* %3
%12 = and i32 %11, 255
store volatile i32 %12, i32* inttoptr (i64 1308622860 to i32*)
%13 = load i32, i32* %3
%14 = ashr i32 %13, 8
%15 = and i32 %14, 255
store volatile i32 %15, i32* inttoptr (i64 1308622860 to i32*)
%16 = load i32, i32* %3
%17 = ashr i32 %16, 16
%18 = and i32 %17, 255
store volatile i32 %18, i32* inttoptr (i64 1308622860 to i32*)
store volatile i32 48, i32* inttoptr (i64 1308622856 to i32*)
br label %19
19: ; preds = %24, %2
%20 = load volatile i32, i32* inttoptr (i64 1308622880 to i32*)
%21 = and i32 %20, 4
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %25
24: ; preds = %19
br label %19
25: ; preds = %19
store i32 0, i32* %5
br label %26
26: ; preds = %35, %25
%27 = load i32, i32* %5
%28 = icmp slt i32 %27, 2048
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load volatile i8, i8* inttoptr (i64 1308622864 to i8*)
%31 = load i8*, i8** %4
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 %30, i8* %34
br label %35
35: ; preds = %29
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %26
38: ; preds = %26
%39 = load volatile i32, i32* inttoptr (i64 1308622852 to i32*)
%40 = or i32 %39, 2
store volatile i32 %40, i32* inttoptr (i64 1308622852 to i32*)
ret void
}

LLVM IR (-O2):
define void @Nand_ReadPage(i32 %0, i8* nocapture writeonly %1) {
%3 = tail call i32 (...) @Nand_Reset()
%4 = load volatile i32, i32* inttoptr (i64 1308622852 to i32*)
%5 = and i32 %4, -3
store volatile i32 %5, i32* inttoptr (i64 1308622852 to i32*)
%6 = load volatile i32, i32* inttoptr (i64 1308622880 to i32*)
%7 = or i32 %6, 4
store volatile i32 %7, i32* inttoptr (i64 1308622880 to i32*)
store volatile i32 0, i32* inttoptr (i64 1308622856 to i32*)
store volatile i32 0, i32* inttoptr (i64 1308622860 to i32*)
store volatile i32 0, i32* inttoptr (i64 1308622860 to i32*)
%8 = and i32 %0, 255
store volatile i32 %8, i32* inttoptr (i64 1308622860 to i32*)
%9 = lshr i32 %0, 8
%10 = and i32 %9, 255
store volatile i32 %10, i32* inttoptr (i64 1308622860 to i32*)
%11 = lshr i32 %0, 16
%12 = and i32 %11, 255
store volatile i32 %12, i32* inttoptr (i64 1308622860 to i32*)
store volatile i32 48, i32* inttoptr (i64 1308622856 to i32*)
br label %13
13: ; preds = %13, %2
%14 = load volatile i32, i32* inttoptr (i64 1308622880 to i32*)
%15 = and i32 %14, 4
%16 = icmp eq i32 %15, 0
br i1 %16, label %13, label %17
17: ; preds = %13, %17
%18 = phi i64 [ %30, %17 ], [ 0, %13 ]
%19 = load volatile i8, i8* inttoptr (i64 1308622864 to i8*)
%20 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 %19, i8* %20
%21 = or i64 %18, 1
%22 = load volatile i8, i8* inttoptr (i64 1308622864 to i8*)
%23 = getelementptr inbounds i8, i8* %1, i64 %21
store i8 %22, i8* %23
%24 = or i64 %18, 2
%25 = load volatile i8, i8* inttoptr (i64 1308622864 to i8*)
%26 = getelementptr inbounds i8, i8* %1, i64 %24
store i8 %25, i8* %26
%27 = or i64 %18, 3
%28 = load volatile i8, i8* inttoptr (i64 1308622864 to i8*)
%29 = getelementptr inbounds i8, i8* %1, i64 %27
store i8 %28, i8* %29
%30 = add nuw nsw i64 %18, 4
%31 = icmp eq i64 %30, 2048
br i1 %31, label %32, label %17
32: ; preds = %17
%33 = load volatile i32, i32* inttoptr (i64 1308622852 to i32*)
%34 = or i32 %33, 2
store volatile i32 %34, i32* inttoptr (i64 1308622852 to i32*)
ret void
}