_nand_read(unsigned dummy, unsigned target_addr, unsigned size) {
  unsigned i, j;
  unsigned page, is_4k_bugfix = 0;
  unsigned err_count;
  unsigned por_config = (*(volatile unsigned long *)0xc1107d54);
  unsigned bch15 = 0;
  unsigned nand_id;
  (*(volatile unsigned long *)(0xc1001000 + 0xc0c)) = por_config;
  unsigned base;
  (*(volatile unsigned long *)0xc1108600) |= (1 << 6);
  (*(volatile unsigned long *)0xc1200300) = 0x90;
  (*(volatile unsigned long *)0xc1200304) = 0x00;
  nand_id = (*(volatile unsigned long *)0xc1200308);
  if (((nand_id >> 24) & 0x3) == 2)
    is_4k_bugfix = 2;
  else
    is_4k_bugfix = 1;
  unsigned end_pages = 0;
  end_pages =
      (size * 4 + 0x800 * is_4k_bugfix - 1) & (~(0x800 * is_4k_bugfix - 1));
  end_pages = end_pages >> (11 + is_4k_bugfix - 1);
  base = ((((*(volatile unsigned long *)(0xc1001000 + 0xc08)))) << 8) + 2;
  for (i = 0; i < end_pages; i++) {
    (*(volatile unsigned long *)0xc1200300) = 0x00000000;
    (*(volatile unsigned long *)0xc1200304) = 0x00000000;
    (*(volatile unsigned long *)0xc1200304) = 0x00000000;
    (*(volatile unsigned long *)0xc1200304) = (i + base) & 0xff;
    (*(volatile unsigned long *)0xc1200304) = ((i + base) >> 8) & 0xff;
    (*(volatile unsigned long *)0xc1200304) = 0x00000000;
    (*(volatile unsigned long *)0xc1200300) = 0x00000030;
    (*(volatile unsigned long *)0xc1109954) = 0;
    while ((*(volatile unsigned long *)0xc1109954) < 1) {
    }
    if (i > 0)
      (*(volatile unsigned long *)0xc1108608) = target_addr +
                                                ((i * is_4k_bugfix) * 0x800) -
                                                (is_4k_bugfix * 0x800 - 0x400);
    else
      (*(volatile unsigned long *)0xc1108608) =
          target_addr + ((i * is_4k_bugfix) * 0x800);
    (*(volatile unsigned long *)0xc110860c) = 0x800 * is_4k_bugfix;
    (*(volatile unsigned long *)0xc1108610) =
        (bch15 << 26) | (1 << 24) | (0 << 21) | (1 << 20) | (0 << 19) |
        (0 << 17) | (1 << 16) | (10 << 0);
    while ((*(volatile unsigned long *)0xc1108610) & (1 << 31)) {
    }
    for (page = 0; page < (4 * is_4k_bugfix); page++) {
      if (!((*(volatile unsigned long *)0xc1108638) & (1 << page))) {
        unsigned sdram_base;
        err_count =
            ((*(volatile unsigned long *)0xc1108630) >> ((page)*4)) & 0xf;
        if (i > 0)
          sdram_base = target_addr + ((i * is_4k_bugfix) * 0x800) -
                       (is_4k_bugfix * 0x800 - 0x400) + page * 512;
        else
          sdram_base = target_addr + ((i * is_4k_bugfix) * 0x800) + page * 512;
        if (bch15) {
          (*(volatile unsigned long *)0xc110862c) = page * 15;
        } else {
          (*(volatile unsigned long *)0xc110862c) = page * 9;
        }
        for (j = 0; j < err_count; j++) {
          unsigned byte;
          unsigned bit;
          byte = (*(volatile unsigned long *)0xc110862c);
          bit = byte & 0x7;
          if ((byte >> 4) <= 511) {
            (*(volatile unsigned char *)(sdram_base + (byte >> 4))) ^=
                (1 << bit);
          }
          if ((byte >> 4) == 512) {
            (*(volatile unsigned char *)((volatile unsigned long *)0xc110861c +
                                         page)) ^= (1 << bit);
          }
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<_nand_read>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
mov    $0xc1107d54,%eax
mov    (%rax),%rax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
mov    $0xc1001c0c,%eax
mov    %rcx,(%rax)
mov    $0xc1108600,%eax
mov    (%rax),%rcx
or     $0x40,%rcx
mov    $0xc1108600,%eax
mov    %rcx,(%rax)
mov    $0xc1200300,%eax
movq   $0x90,(%rax)
mov    $0xc1200304,%eax
movq   $0x0,(%rax)
mov    $0xc1200308,%eax
mov    (%rax),%rax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
shr    $0x18,%eax
and    $0x3,%eax
cmp    $0x2,%eax
jne    1188 <_nand_read+0x88>
movl   $0x2,-0x20(%rbp)
jmp    118f <_nand_read+0x8f>
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x2,%eax
mov    -0x20(%rbp),%ecx
shl    $0xb,%ecx
add    %ecx,%eax
sub    $0x1,%eax
mov    -0x20(%rbp),%ecx
shl    $0xb,%ecx
sub    $0x1,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x20(%rbp),%ecx
add    $0xb,%ecx
sub    $0x1,%ecx
shr    %cl,%eax
mov    %eax,-0x38(%rbp)
mov    $0xc1001c08,%eax
mov    (%rax),%rax
shl    $0x8,%rax
add    $0x2,%rax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x38(%rbp),%eax
jae    14d1 <_nand_read+0x3d1>
mov    $0xc1200300,%eax
movq   $0x0,(%rax)
mov    $0xc1200304,%eax
movq   $0x0,(%rax)
mov    $0xc1200304,%eax
movq   $0x0,(%rax)
mov    -0x14(%rbp),%eax
add    -0x34(%rbp),%eax
and    $0xff,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xc1200304,%eax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
add    -0x34(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xc1200304,%eax
mov    %rcx,(%rax)
mov    $0xc1200304,%eax
movq   $0x0,(%rax)
mov    $0xc1200300,%eax
movq   $0x30,(%rax)
mov    $0xc1109954,%eax
movq   $0x0,(%rax)
mov    $0xc1109954,%eax
mov    (%rax),%rax
cmp    $0x1,%rax
jae    127f <_nand_read+0x17f>
jmp    1268 <_nand_read+0x168>
cmpl   $0x0,-0x14(%rbp)
jbe    12b7 <_nand_read+0x1b7>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x20(%rbp),%ecx
shl    $0xb,%ecx
add    %ecx,%eax
mov    -0x20(%rbp),%ecx
shl    $0xb,%ecx
sub    $0x400,%ecx
sub    %ecx,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xc1108608,%eax
mov    %rcx,(%rax)
jmp    12d2 <_nand_read+0x1d2>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x20(%rbp),%ecx
shl    $0xb,%ecx
add    %ecx,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xc1108608,%eax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%eax
shl    $0xb,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xc110860c,%eax
mov    %rcx,(%rax)
mov    -0x2c(%rbp),%eax
shl    $0x1a,%eax
or     $0x1000000,%eax
or     $0x0,%eax
or     $0x100000,%eax
or     $0x0,%eax
or     $0x0,%eax
or     $0x10000,%eax
or     $0xa,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xc1108610,%eax
mov    %rcx,(%rax)
mov    $0xc1108610,%eax
mov    (%rax),%rax
and    $0xffffffff80000000,%rax
cmp    $0x0,%rax
je     132e <_nand_read+0x22e>
jmp    1311 <_nand_read+0x211>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jae    14be <_nand_read+0x3be>
mov    $0xc1108638,%eax
mov    (%rax),%rax
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
jne    14ab <_nand_read+0x3ab>
mov    $0xc1108630,%eax
mov    (%rax),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
mov    %ecx,%ecx
shr    %cl,%rax
and    $0xf,%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x14(%rbp)
jbe    13bb <_nand_read+0x2bb>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x20(%rbp),%ecx
shl    $0xb,%ecx
add    %ecx,%eax
mov    -0x20(%rbp),%ecx
shl    $0xb,%ecx
sub    $0x400,%ecx
sub    %ecx,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x9,%ecx
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
jmp    13d5 <_nand_read+0x2d5>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x20(%rbp),%ecx
shl    $0xb,%ecx
add    %ecx,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x9,%ecx
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     13f4 <_nand_read+0x2f4>
imul   $0xf,-0x1c(%rbp),%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xc110862c,%eax
mov    %rcx,(%rax)
jmp    1404 <_nand_read+0x304>
imul   $0x9,-0x1c(%rbp),%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xc110862c,%eax
mov    %rcx,(%rax)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    14a6 <_nand_read+0x3a6>
mov    $0xc110862c,%eax
mov    (%rax),%rax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
shr    $0x4,%eax
cmp    $0x1ff,%eax
ja     145c <_nand_read+0x35c>
mov    -0x44(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x3c(%rbp),%eax
mov    -0x40(%rbp),%ecx
shr    $0x4,%ecx
add    %ecx,%eax
mov    %eax,%eax
mov    (%rax),%cl
movzbl %cl,%ecx
xor    %edx,%ecx
mov    %cl,(%rax)
mov    -0x40(%rbp),%eax
shr    $0x4,%eax
cmp    $0x200,%eax
jne    1493 <_nand_read+0x393>
mov    -0x44(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
mov    $0xc110861c,%eax
mov    (%rax,%rcx,8),%al
movzbl %al,%eax
xor    %edx,%eax
mov    %al,%dl
mov    $0xc110861c,%eax
mov    %dl,(%rax,%rcx,8)
jmp    1498 <_nand_read+0x398>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    140b <_nand_read+0x30b>
jmp    14ab <_nand_read+0x3ab>
jmp    14b0 <_nand_read+0x3b0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1335 <_nand_read+0x235>
jmp    14c3 <_nand_read+0x3c3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e3 <_nand_read+0xe3>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_nand_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0xc1200304,%r10d
mov    -0xf85b0(%r10),%rcx
mov    %ecx,%ecx
mov    %rcx,-0x1fe6f8(%r10)
orq    $0x40,-0xf7d04(%r10)
40
movq   $0x90,-0x4(%r10)
movq   $0x0,(%r10)
mov    0x4(%r10),%rcx
and    $0x3000000,%ecx
xor    %eax,%eax
cmp    $0x2000000,%ecx
sete   %al
add    $0x1,%eax
mov    %eax,%edi
shl    $0xb,%edi
mov    %edi,%ecx
neg    %ecx
lea    (%rdi,%rdx,4),%edx
add    $0xffffffff,%edx
and    %ecx,%edx
lea    0xa(%rax),%ecx
shr    %cl,%edx
mov    -0x1fe6fc(%r10),%rcx
test   %edx,%edx
je     1337 <_nand_read+0x237>
shl    $0x8,%ecx
or     $0x2,%ecx
mov    %rcx,-0x10(%rsp)
mov    %esi,%ebp
sub    %edi,%ebp
add    $0x400,%ebp
mov    %edi,%ecx
mov    %rcx,-0x18(%rsp)
lea    0x0(,%rax,4),%r13d
mov    %edx,%ecx
mov    %rcx,-0x20(%rsp)
xor    %r15d,%r15d
lea    -0x41200304(%r10),%r8
mov    %rax,-0x8(%rsp)
mov    %ebp,-0x24(%rsp)
jmp    11db <_nand_read+0xdb>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15
cmp    -0x20(%rsp),%r15
mov    -0x8(%rsp),%rax
mov    %r14d,%esi
mov    -0x24(%rsp),%ebp
je     1337 <_nand_read+0x237>
movq   $0x0,-0x4(%r10)
movq   $0x0,(%r10)
movq   $0x0,(%r10)
mov    -0x10(%rsp),%rcx
add    %r15d,%ecx
movzbl %cl,%edi
mov    %rdi,(%r10)
movzbl %ch,%ecx
mov    %rcx,(%r10)
movq   $0x0,(%r10)
movq   $0x30,-0x4(%r10)
movq   $0x0,-0xf69b0(%r10)
nop
cmpq   $0x0,-0xf69b0(%r10)
je     1220 <_nand_read+0x120>
mov    %eax,%ecx
imul   %r15d,%ecx
shl    $0xb,%ecx
add    %ebp,%ecx
test   %r15,%r15
cmove  %esi,%ecx
mov    %rcx,-0xf7cfc(%r10)
mov    -0x18(%rsp),%rcx
mov    %rcx,-0xf7cf8(%r10)
movq   $0x111000a,-0xf7cf4(%r10)
nopl   0x0(%rax)
mov    -0xf7cf4(%r10),%rcx
cmp    %r8,%rcx
jae    1260 <_nand_read+0x160>
mov    %eax,%r12d
imul   %r15d,%r12d
shl    $0xb,%r12d
add    %ebp,%r12d
test   %r15,%r15
mov    %esi,%r14d
cmove  %esi,%r12d
xor    %ebx,%ebx
jmp    129d <_nand_read+0x19d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r13,%rbx
je     11c0 <_nand_read+0xc0>
mov    -0xf7ccc(%r10),%rcx
bt     %rbx,%rcx
jb     1290 <_nand_read+0x190>
mov    -0xf7cd4(%r10),%rbp
lea    0x0(,%rbx,4),%ecx
shr    %cl,%rbp
lea    (%rbx,%rbx,8),%rcx
mov    %rcx,-0xf7cd8(%r10)
and    $0xf,%ebp
je     1290 <_nand_read+0x190>
mov    %ebx,%edi
shl    $0x9,%edi
add    %r12d,%edi
jmp    12e5 <_nand_read+0x1e5>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebp
je     1290 <_nand_read+0x190>
mov    -0xf7cd8(%r10),%r9
mov    %r9d,%ecx
and    $0x7,%ecx
mov    %r9d,%r11d
shr    $0x4,%r11d
cmp    $0x1fff,%r9d
jbe    1310 <_nand_read+0x210>
cmp    $0x200,%r11d
jne    12e0 <_nand_read+0x1e0>
jmp    1326 <_nand_read+0x226>
nopl   (%rax)
mov    $0x1,%edx
shl    %cl,%edx
lea    (%r11,%rdi,1),%eax
xor    %dl,(%rax)
cmp    $0x200,%r11d
jne    12e0 <_nand_read+0x1e0>
mov    $0x1,%eax
shl    %cl,%eax
xor    %al,-0xf7ce8(%r10,%rbx,8)
ff
jmp    12e0 <_nand_read+0x1e0>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @_nand_read(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %11
%21 = load volatile i64, i64* inttoptr (i64 3239083348 to i64*)
%22 = trunc i64 %21 to i32
store i32 %22, i32* %13
store i32 0, i32* %14
%23 = load i32, i32* %13
%24 = zext i32 %23 to i64
store volatile i64 %24, i64* inttoptr (i64 3238009868 to i64*)
%25 = load volatile i64, i64* inttoptr (i64 3239085568 to i64*)
%26 = or i64 %25, 64
store volatile i64 %26, i64* inttoptr (i64 3239085568 to i64*)
store volatile i64 144, i64* inttoptr (i64 3240100608 to i64*)
store volatile i64 0, i64* inttoptr (i64 3240100612 to i64*)
%27 = load volatile i64, i64* inttoptr (i64 3240100616 to i64*)
%28 = trunc i64 %27 to i32
store i32 %28, i32* %15
%29 = load i32, i32* %15
%30 = lshr i32 %29, 24
%31 = and i32 %30, 3
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %34
33: ; preds = %3
store i32 2, i32* %11
br label %35
34: ; preds = %3
store i32 1, i32* %11
br label %35
35: ; preds = %34, %33
store i32 0, i32* %17
%36 = load i32, i32* %7
%37 = mul i32 %36, 4
%38 = load i32, i32* %11
%39 = mul i32 2048, %38
%40 = add i32 %37, %39
%41 = sub i32 %40, 1
%42 = load i32, i32* %11
%43 = mul i32 2048, %42
%44 = sub i32 %43, 1
%45 = xor i32 %44, -1
%46 = and i32 %41, %45
store i32 %46, i32* %17
%47 = load i32, i32* %17
%48 = load i32, i32* %11
%49 = add i32 11, %48
%50 = sub i32 %49, 1
%51 = lshr i32 %47, %50
store i32 %51, i32* %17
%52 = load volatile i64, i64* inttoptr (i64 3238009864 to i64*)
%53 = shl i64 %52, 8
%54 = add i64 %53, 2
%55 = trunc i64 %54 to i32
store i32 %55, i32* %16
store i32 0, i32* %8
br label %56
56: ; preds = %227, %35
%57 = load i32, i32* %8
%58 = load i32, i32* %17
%59 = icmp ult i32 %57, %58
br i1 %59, label %60, label %230
60: ; preds = %56
store volatile i64 0, i64* inttoptr (i64 3240100608 to i64*)
store volatile i64 0, i64* inttoptr (i64 3240100612 to i64*)
store volatile i64 0, i64* inttoptr (i64 3240100612 to i64*)
%61 = load i32, i32* %8
%62 = load i32, i32* %16
%63 = add i32 %61, %62
%64 = and i32 %63, 255
%65 = zext i32 %64 to i64
store volatile i64 %65, i64* inttoptr (i64 3240100612 to i64*)
%66 = load i32, i32* %8
%67 = load i32, i32* %16
%68 = add i32 %66, %67
%69 = lshr i32 %68, 8
%70 = and i32 %69, 255
%71 = zext i32 %70 to i64
store volatile i64 %71, i64* inttoptr (i64 3240100612 to i64*)
store volatile i64 0, i64* inttoptr (i64 3240100612 to i64*)
store volatile i64 48, i64* inttoptr (i64 3240100608 to i64*)
store volatile i64 0, i64* inttoptr (i64 3239090516 to i64*)
br label %72
72: ; preds = %75, %60
%73 = load volatile i64, i64* inttoptr (i64 3239090516 to i64*)
%74 = icmp ult i64 %73, 1
br i1 %74, label %75, label %76
75: ; preds = %72
br label %72
76: ; preds = %72
%77 = load i32, i32* %8
%78 = icmp ugt i32 %77, 0
br i1 %78, label %79, label %91
79: ; preds = %76
%80 = load i32, i32* %6
%81 = load i32, i32* %8
%82 = load i32, i32* %11
%83 = mul i32 %81, %82
%84 = mul i32 %83, 2048
%85 = add i32 %80, %84
%86 = load i32, i32* %11
%87 = mul i32 %86, 2048
%88 = sub i32 %87, 1024
%89 = sub i32 %85, %88
%90 = zext i32 %89 to i64
store volatile i64 %90, i64* inttoptr (i64 3239085576 to i64*)
br label %99
91: ; preds = %76
%92 = load i32, i32* %6
%93 = load i32, i32* %8
%94 = load i32, i32* %11
%95 = mul i32 %93, %94
%96 = mul i32 %95, 2048
%97 = add i32 %92, %96
%98 = zext i32 %97 to i64
store volatile i64 %98, i64* inttoptr (i64 3239085576 to i64*)
br label %99
99: ; preds = %91, %79
%100 = load i32, i32* %11
%101 = mul i32 2048, %100
%102 = zext i32 %101 to i64
store volatile i64 %102, i64* inttoptr (i64 3239085580 to i64*)
%103 = load i32, i32* %14
%104 = shl i32 %103, 26
%105 = or i32 %104, 16777216
%106 = or i32 %105, 0
%107 = or i32 %106, 1048576
%108 = or i32 %107, 0
%109 = or i32 %108, 0
%110 = or i32 %109, 65536
%111 = or i32 %110, 10
%112 = zext i32 %111 to i64
store volatile i64 %112, i64* inttoptr (i64 3239085584 to i64*)
br label %113
113: ; preds = %117, %99
%114 = load volatile i64, i64* inttoptr (i64 3239085584 to i64*)
%115 = and i64 %114, -2147483648
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %118
117: ; preds = %113
br label %113
118: ; preds = %113
store i32 0, i32* %10
br label %119
119: ; preds = %223, %118
%120 = load i32, i32* %10
%121 = load i32, i32* %11
%122 = mul i32 4, %121
%123 = icmp ult i32 %120, %122
br i1 %123, label %124, label %226
124: ; preds = %119
%125 = load volatile i64, i64* inttoptr (i64 3239085624 to i64*)
%126 = load i32, i32* %10
%127 = shl i32 1, %126
%128 = sext i32 %127 to i64
%129 = and i64 %125, %128
%130 = icmp ne i64 %129, 0
br i1 %130, label %222, label %131
131: ; preds = %124
%132 = load volatile i64, i64* inttoptr (i64 3239085616 to i64*)
%133 = load i32, i32* %10
%134 = mul i32 %133, 4
%135 = zext i32 %134 to i64
%136 = lshr i64 %132, %135
%137 = and i64 %136, 15
%138 = trunc i64 %137 to i32
store i32 %138, i32* %12
%139 = load i32, i32* %8
%140 = icmp ugt i32 %139, 0
br i1 %140, label %141, label %155
141: ; preds = %131
%142 = load i32, i32* %6
%143 = load i32, i32* %8
%144 = load i32, i32* %11
%145 = mul i32 %143, %144
%146 = mul i32 %145, 2048
%147 = add i32 %142, %146
%148 = load i32, i32* %11
%149 = mul i32 %148, 2048
%150 = sub i32 %149, 1024
%151 = sub i32 %147, %150
%152 = load i32, i32* %10
%153 = mul i32 %152, 512
%154 = add i32 %151, %153
store i32 %154, i32* %18
br label %165
155: ; preds = %131
%156 = load i32, i32* %6
%157 = load i32, i32* %8
%158 = load i32, i32* %11
%159 = mul i32 %157, %158
%160 = mul i32 %159, 2048
%161 = add i32 %156, %160
%162 = load i32, i32* %10
%163 = mul i32 %162, 512
%164 = add i32 %161, %163
store i32 %164, i32* %18
br label %165
165: ; preds = %155, %141
%166 = load i32, i32* %14
%167 = icmp ne i32 %166, 0
br i1 %167, label %168, label %172
168: ; preds = %165
%169 = load i32, i32* %10
%170 = mul i32 %169, 15
%171 = zext i32 %170 to i64
store volatile i64 %171, i64* inttoptr (i64 3239085612 to i64*)
br label %176
172: ; preds = %165
%173 = load i32, i32* %10
%174 = mul i32 %173, 9
%175 = zext i32 %174 to i64
store volatile i64 %175, i64* inttoptr (i64 3239085612 to i64*)
br label %176
176: ; preds = %172, %168
store i32 0, i32* %9
br label %177
177: ; preds = %218, %176
%178 = load i32, i32* %9
%179 = load i32, i32* %12
%180 = icmp ult i32 %178, %179
br i1 %180, label %181, label %221
181: ; preds = %177
%182 = load volatile i64, i64* inttoptr (i64 3239085612 to i64*)
%183 = trunc i64 %182 to i32
store i32 %183, i32* %19
%184 = load i32, i32* %19
%185 = and i32 %184, 7
store i32 %185, i32* %20
%186 = load i32, i32* %19
%187 = lshr i32 %186, 4
%188 = icmp ule i32 %187, 511
br i1 %188, label %189, label %202
189: ; preds = %181
%190 = load i32, i32* %20
%191 = shl i32 1, %190
%192 = load i32, i32* %18
%193 = load i32, i32* %19
%194 = lshr i32 %193, 4
%195 = add i32 %192, %194
%196 = zext i32 %195 to i64
%197 = inttoptr i64 %196 to i8*
%198 = load volatile i8, i8* %197
%199 = zext i8 %198 to i32
%200 = xor i32 %199, %191
%201 = trunc i32 %200 to i8
store volatile i8 %201, i8* %197
br label %202
202: ; preds = %189, %181
%203 = load i32, i32* %19
%204 = lshr i32 %203, 4
%205 = icmp eq i32 %204, 512
br i1 %205, label %206, label %217
206: ; preds = %202
%207 = load i32, i32* %20
%208 = shl i32 1, %207
%209 = load i32, i32* %10
%210 = zext i32 %209 to i64
%211 = getelementptr inbounds i64, i64* inttoptr (i64 3239085596 to i64*), i64 %210
%212 = bitcast i64* %211 to i8*
%213 = load volatile i8, i8* %212
%214 = zext i8 %213 to i32
%215 = xor i32 %214, %208
%216 = trunc i32 %215 to i8
store volatile i8 %216, i8* %212
br label %217
217: ; preds = %206, %202
br label %218
218: ; preds = %217
%219 = load i32, i32* %9
%220 = add i32 %219, 1
store i32 %220, i32* %9
br label %177
221: ; preds = %177
br label %222
222: ; preds = %221, %124
br label %223
223: ; preds = %222
%224 = load i32, i32* %10
%225 = add i32 %224, 1
store i32 %225, i32* %10
br label %119
226: ; preds = %119
br label %227
227: ; preds = %226
%228 = load i32, i32* %8
%229 = add i32 %228, 1
store i32 %229, i32* %8
br label %56
230: ; preds = %56
%231 = load i32, i32* %4
ret i32 %231
}

LLVM IR (-O2):
define i32 @_nand_read(i32 %0, i32 %1, i32 %2) {
%4 = load volatile i64, i64* inttoptr (i64 3239083348 to i64*)
%5 = and i64 %4, 4294967295
store volatile i64 %5, i64* inttoptr (i64 3238009868 to i64*)
%6 = load volatile i64, i64* inttoptr (i64 3239085568 to i64*)
%7 = or i64 %6, 64
store volatile i64 %7, i64* inttoptr (i64 3239085568 to i64*)
store volatile i64 144, i64* inttoptr (i64 3240100608 to i64*)
store volatile i64 0, i64* inttoptr (i64 3240100612 to i64*)
%8 = load volatile i64, i64* inttoptr (i64 3240100616 to i64*)
%9 = and i64 %8, 50331648
%10 = icmp eq i64 %9, 33554432
%11 = select i1 %10, i32 2, i32 1
%12 = shl i32 %2, 2
%13 = shl nuw nsw i32 %11, 11
%14 = sub nsw i32 0, %13
%15 = add i32 %12, -1
%16 = add i32 %15, %13
%17 = and i32 %16, %14
%18 = add nuw nsw i32 %11, 10
%19 = lshr i32 %17, %18
%20 = load volatile i64, i64* inttoptr (i64 3238009864 to i64*)
%21 = trunc i64 %20 to i32
%22 = shl i32 %21, 8
%23 = or i32 %22, 2
%24 = icmp eq i32 %19, 0
br i1 %24, label %114, label %25
25: ; preds = %3
%26 = add i32 %1, 1024
%27 = sub i32 %26, %13
%28 = zext i32 %13 to i64
%29 = shl nuw nsw i32 %11, 2
%30 = zext i32 %19 to i64
%31 = zext i32 %29 to i64
br label %32
32: ; preds = %25, %111
%33 = phi i64 [ 0, %25 ], [ %112, %111 ]
store volatile i64 0, i64* inttoptr (i64 3240100608 to i64*)
store volatile i64 0, i64* inttoptr (i64 3240100612 to i64*)
store volatile i64 0, i64* inttoptr (i64 3240100612 to i64*)
%34 = trunc i64 %33 to i32
%35 = add i32 %23, %34
%36 = and i32 %35, 255
%37 = zext i32 %36 to i64
store volatile i64 %37, i64* inttoptr (i64 3240100612 to i64*)
%38 = lshr i32 %35, 8
%39 = and i32 %38, 255
%40 = zext i32 %39 to i64
store volatile i64 %40, i64* inttoptr (i64 3240100612 to i64*)
store volatile i64 0, i64* inttoptr (i64 3240100612 to i64*)
store volatile i64 48, i64* inttoptr (i64 3240100608 to i64*)
store volatile i64 0, i64* inttoptr (i64 3239090516 to i64*)
br label %41
41: ; preds = %41, %32
%42 = load volatile i64, i64* inttoptr (i64 3239090516 to i64*)
%43 = icmp eq i64 %42, 0
br i1 %43, label %41, label %44
44: ; preds = %41
%45 = icmp eq i64 %33, 0
%46 = trunc i64 %33 to i32
%47 = mul i32 %11, %46
%48 = shl i32 %47, 11
%49 = add i32 %27, %48
%50 = select i1 %45, i32 %1, i32 %49
%51 = zext i32 %50 to i64
store volatile i64 %51, i64* inttoptr (i64 3239085576 to i64*)
store volatile i64 %28, i64* inttoptr (i64 3239085580 to i64*)
store volatile i64 17891338, i64* inttoptr (i64 3239085584 to i64*)
br label %52
52: ; preds = %52, %44
%53 = load volatile i64, i64* inttoptr (i64 3239085584 to i64*)
%54 = icmp ult i64 %53, 2147483648
br i1 %54, label %55, label %52
55: ; preds = %52
%56 = trunc i64 %33 to i32
%57 = mul i32 %11, %56
%58 = shl i32 %57, 11
%59 = add i32 %27, %58
%60 = select i1 %45, i32 %1, i32 %59
br label %61
61: ; preds = %55, %108
%62 = phi i64 [ 0, %55 ], [ %109, %108 ]
%63 = load volatile i64, i64* inttoptr (i64 3239085624 to i64*)
%64 = trunc i64 %62 to i32
%65 = shl nuw i32 1, %64
%66 = zext i32 %65 to i64
%67 = and i64 %63, %66
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %108
69: ; preds = %61
%70 = load volatile i64, i64* inttoptr (i64 3239085616 to i64*)
%71 = shl i64 %62, 2
%72 = lshr i64 %70, %71
%73 = trunc i64 %72 to i32
%74 = and i32 %73, 15
%75 = trunc i64 %62 to i32
%76 = shl i32 %75, 9
%77 = add i32 %76, %60
%78 = mul nuw nsw i64 %62, 9
store volatile i64 %78, i64* inttoptr (i64 3239085612 to i64*)
%79 = icmp eq i32 %74, 0
br i1 %79, label %108, label %80
80: ; preds = %69
%81 = getelementptr inbounds i64, i64* inttoptr (i64 3239085596 to i64*), i64 %62
%82 = bitcast i64* %81 to i8*
br label %83
83: ; preds = %80, %105
%84 = phi i32 [ 0, %80 ], [ %106, %105 ]
%85 = load volatile i64, i64* inttoptr (i64 3239085612 to i64*)
%86 = trunc i64 %85 to i32
%87 = and i32 %86, 7
%88 = lshr i32 %86, 4
%89 = icmp ult i32 %86, 8192
br i1 %89, label %90, label %98
90: ; preds = %83
%91 = shl nuw nsw i32 1, %87
%92 = add i32 %88, %77
%93 = zext i32 %92 to i64
%94 = inttoptr i64 %93 to i8*
%95 = load volatile i8, i8* %94
%96 = trunc i32 %91 to i8
%97 = xor i8 %95, %96
store volatile i8 %97, i8* %94
br label %98
98: ; preds = %90, %83
%99 = icmp eq i32 %88, 512
br i1 %99, label %100, label %105
100: ; preds = %98
%101 = shl nuw nsw i32 1, %87
%102 = load volatile i8, i8* %82
%103 = trunc i32 %101 to i8
%104 = xor i8 %102, %103
store volatile i8 %104, i8* %82
br label %105
105: ; preds = %100, %98
%106 = add nuw nsw i32 %84, 1
%107 = icmp eq i32 %106, %74
br i1 %107, label %108, label %83
108: ; preds = %105, %69, %61
%109 = add nuw nsw i64 %62, 1
%110 = icmp eq i64 %109, %31
br i1 %110, label %111, label %61
111: ; preds = %108
%112 = add nuw nsw i64 %33, 1
%113 = icmp eq i64 %112, %30
br i1 %113, label %114, label %32
114: ; preds = %111, %3
ret i32 undef
}