void nand_reset(void) {
  do {
    (*(volatile unsigned long *)(0x4E000000 + 0x04)) &= (~(1 << 1));
  } while (0);
  do {
    (*(volatile unsigned long *)(0x4E000000 + 0x20)) |= (1 << 2);
  } while (0);
  do {
    (*(volatile unsigned char *)(0x4E000000 + 0x08)) = 0xFF;
  } while (0);
  while (!((*(volatile unsigned long *)(0x4E000000 + 0x20)) & (1 << 2)))
    ;
  do {
    (*(volatile unsigned long *)(0x4E000000 + 0x04)) |= (1 << 1);
  } while (0);
}


x86 assembly (clang, -O0):
<nand_reset>:
push   %rbp
mov    %rsp,%rbp
jmp    1109 <nand_reset+0x9>
mov    $0x4e000004,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffffd,%rcx
mov    $0x4e000004,%eax
mov    %rcx,(%rax)
jmp    1122 <nand_reset+0x22>
mov    $0x4e000020,%eax
mov    (%rax),%rcx
or     $0x4,%rcx
mov    $0x4e000020,%eax
mov    %rcx,(%rax)
jmp    113b <nand_reset+0x3b>
mov    $0x4e000008,%eax
movb   $0xff,(%rax)
jmp    1148 <nand_reset+0x48>
mov    $0x4e000020,%eax
mov    (%rax),%rax
and    $0x4,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    116a <nand_reset+0x6a>
jmp    116f <nand_reset+0x6f>
jmp    1148 <nand_reset+0x48>
jmp    1174 <nand_reset+0x74>
mov    $0x4e000004,%eax
mov    (%rax),%rcx
or     $0x2,%rcx
mov    $0x4e000004,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<nand_reset>:
andq   $0xfffffffffffffffd,0x4e000004
4e fd
orq    $0x4,0x4e000020
4e 04
movb   $0xff,0x4e000008
ff
nopw   0x0(%rax,%rax,1)
testq  $0x4,0x4e000020
je     1120 <nand_reset+0x20>
orq    $0x2,0x4e000004
4e 02
ret

LLVM IR (-O0):
define void @nand_reset() {
br label %1
1: ; preds = %0
%2 = load volatile i64, i64* inttoptr (i64 1308622852 to i64*)
%3 = and i64 %2, -3
store volatile i64 %3, i64* inttoptr (i64 1308622852 to i64*)
br label %4
4: ; preds = %1
br label %5
5: ; preds = %4
%6 = load volatile i64, i64* inttoptr (i64 1308622880 to i64*)
%7 = or i64 %6, 4
store volatile i64 %7, i64* inttoptr (i64 1308622880 to i64*)
br label %8
8: ; preds = %5
br label %9
9: ; preds = %8
store volatile i8 -1, i8* inttoptr (i64 1308622856 to i8*)
br label %10
10: ; preds = %9
br label %11
11: ; preds = %16, %10
%12 = load volatile i64, i64* inttoptr (i64 1308622880 to i64*)
%13 = and i64 %12, 4
%14 = icmp ne i64 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %17
16: ; preds = %11
br label %11
17: ; preds = %11
br label %18
18: ; preds = %17
%19 = load volatile i64, i64* inttoptr (i64 1308622852 to i64*)
%20 = or i64 %19, 2
store volatile i64 %20, i64* inttoptr (i64 1308622852 to i64*)
br label %21
21: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @nand_reset() {
%1 = load volatile i64, i64* inttoptr (i64 1308622852 to i64*)
%2 = and i64 %1, -3
store volatile i64 %2, i64* inttoptr (i64 1308622852 to i64*)
%3 = load volatile i64, i64* inttoptr (i64 1308622880 to i64*)
%4 = or i64 %3, 4
store volatile i64 %4, i64* inttoptr (i64 1308622880 to i64*)
store volatile i8 -1, i8* inttoptr (i64 1308622856 to i8*)
br label %5
5: ; preds = %5, %0
%6 = load volatile i64, i64* inttoptr (i64 1308622880 to i64*)
%7 = and i64 %6, 4
%8 = icmp eq i64 %7, 0
br i1 %8, label %5, label %9
9: ; preds = %5
%10 = load volatile i64, i64* inttoptr (i64 1308622852 to i64*)
%11 = or i64 %10, 2
store volatile i64 %11, i64* inttoptr (i64 1308622852 to i64*)
ret void
}