#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*/ nand_reset();
void nand_init() {
  (*(volatile unsigned long *)(0x7F008140)) =
      ((*(volatile unsigned long *)(0x7F008140)) & ~0xf) | 0xa;
  (*(volatile unsigned long *)(0x7F008148)) &= ~0xf;
  (*(volatile unsigned long *)(0x7F008160)) =
      ((*(volatile unsigned long *)(0x7F008160)) & ~(0xfff << 4)) |
      (0xaaa << 4);
  (*(volatile unsigned long *)(0x7F008168)) &= ~(0xfff << 4);
  *((volatile unsigned long *)0x7E00F120) &= ~(1 << 1);
  *((volatile unsigned long *)0x70200000) &=
      ~((0x7 << 4) | (0x7 << 8) | (0x7 << 12) | (1 << 30));
  *((volatile unsigned long *)0x70200000) |= (7 << 4) | (7 << 8) | (7 << 12);
  *((volatile unsigned long *)0x70200004) |= 1;
  *((volatile unsigned long *)0x70200004) &= ~(1 << 16);
  nand_reset();
}


x86 assembly (clang, -O0):
<nand_init>:
push   %rbp
mov    %rsp,%rbp
mov    $0x7f008140,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffff0,%rcx
or     $0xa,%rcx
mov    $0x7f008140,%eax
mov    %rcx,(%rax)
mov    $0x7f008148,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffff0,%rcx
mov    $0x7f008148,%eax
mov    %rcx,(%rax)
mov    $0x7f008160,%eax
mov    (%rax),%rcx
and    $0xffffffffffff000f,%rcx
or     $0xaaa0,%rcx
mov    $0x7f008160,%eax
mov    %rcx,(%rax)
mov    $0x7f008168,%eax
mov    (%rax),%rcx
and    $0xffffffffffff000f,%rcx
mov    $0x7f008168,%eax
mov    %rcx,(%rax)
mov    $0x7e00f120,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffffd,%rcx
mov    $0x7e00f120,%eax
mov    %rcx,(%rax)
mov    $0x70200000,%eax
mov    (%rax),%rcx
and    $0xffffffffbfff888f,%rcx
mov    $0x70200000,%eax
mov    %rcx,(%rax)
mov    $0x70200000,%eax
mov    (%rax),%rcx
or     $0x7770,%rcx
mov    $0x70200000,%eax
mov    %rcx,(%rax)
mov    $0x70200004,%eax
mov    (%rax),%rcx
or     $0x1,%rcx
mov    $0x70200004,%eax
mov    %rcx,(%rax)
mov    $0x70200004,%eax
mov    (%rax),%rcx
and    $0xfffffffffffeffff,%rcx
mov    $0x70200004,%eax
mov    %rcx,(%rax)
mov    $0x0,%al
call   1030 <nand_reset@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<nand_init>:
mov    0x7f008140,%rax
7f
and    $0xfffffffffffffff0,%rax
or     $0xa,%rax
mov    %rax,0x7f008140
7f
andq   $0xfffffffffffffff0,0x7f008148
7f f0
mov    $0xffffffffffff000f,%rax
and    0x7f008160,%rax
7f
or     $0xaaa0,%rax
mov    %rax,0x7f008160
7f
andq   $0xffffffffffff000f,0x7f008168
andq   $0xfffffffffffffffd,0x7e00f120
7e fd
andq   $0xffffffffbfff888f,0x70200000
70 8f 88 ff bf
orq    $0x7770,0x70200000
orq    $0x1,0x70200004
70 01
andq   $0xfffffffffffeffff,0x70200004
70 ff ff fe ff
xor    %eax,%eax
jmp    1030 <nand_reset@plt>

LLVM IR (-O0):
define void @nand_init() {
%1 = load volatile i64, i64* inttoptr (i64 2130739520 to i64*)
%2 = and i64 %1, -16
%3 = or i64 %2, 10
store volatile i64 %3, i64* inttoptr (i64 2130739520 to i64*)
%4 = load volatile i64, i64* inttoptr (i64 2130739528 to i64*)
%5 = and i64 %4, -16
store volatile i64 %5, i64* inttoptr (i64 2130739528 to i64*)
%6 = load volatile i64, i64* inttoptr (i64 2130739552 to i64*)
%7 = and i64 %6, -65521
%8 = or i64 %7, 43680
store volatile i64 %8, i64* inttoptr (i64 2130739552 to i64*)
%9 = load volatile i64, i64* inttoptr (i64 2130739560 to i64*)
%10 = and i64 %9, -65521
store volatile i64 %10, i64* inttoptr (i64 2130739560 to i64*)
%11 = load volatile i64, i64* inttoptr (i64 2113990944 to i64*)
%12 = and i64 %11, -3
store volatile i64 %12, i64* inttoptr (i64 2113990944 to i64*)
%13 = load volatile i64, i64* inttoptr (i64 1881145344 to i64*)
%14 = and i64 %13, -1073772401
store volatile i64 %14, i64* inttoptr (i64 1881145344 to i64*)
%15 = load volatile i64, i64* inttoptr (i64 1881145344 to i64*)
%16 = or i64 %15, 30576
store volatile i64 %16, i64* inttoptr (i64 1881145344 to i64*)
%17 = load volatile i64, i64* inttoptr (i64 1881145348 to i64*)
%18 = or i64 %17, 1
store volatile i64 %18, i64* inttoptr (i64 1881145348 to i64*)
%19 = load volatile i64, i64* inttoptr (i64 1881145348 to i64*)
%20 = and i64 %19, -65537
store volatile i64 %20, i64* inttoptr (i64 1881145348 to i64*)
%21 = call i32 (...) @nand_reset()
ret void
}

LLVM IR (-O2):
define void @nand_init() {
%1 = load volatile i64, i64* inttoptr (i64 2130739520 to i64*)
%2 = and i64 %1, -16
%3 = or i64 %2, 10
store volatile i64 %3, i64* inttoptr (i64 2130739520 to i64*)
%4 = load volatile i64, i64* inttoptr (i64 2130739528 to i64*)
%5 = and i64 %4, -16
store volatile i64 %5, i64* inttoptr (i64 2130739528 to i64*)
%6 = load volatile i64, i64* inttoptr (i64 2130739552 to i64*)
%7 = and i64 %6, -65521
%8 = or i64 %7, 43680
store volatile i64 %8, i64* inttoptr (i64 2130739552 to i64*)
%9 = load volatile i64, i64* inttoptr (i64 2130739560 to i64*)
%10 = and i64 %9, -65521
store volatile i64 %10, i64* inttoptr (i64 2130739560 to i64*)
%11 = load volatile i64, i64* inttoptr (i64 2113990944 to i64*)
%12 = and i64 %11, -3
store volatile i64 %12, i64* inttoptr (i64 2113990944 to i64*)
%13 = load volatile i64, i64* inttoptr (i64 1881145344 to i64*)
%14 = and i64 %13, -1073772401
store volatile i64 %14, i64* inttoptr (i64 1881145344 to i64*)
%15 = load volatile i64, i64* inttoptr (i64 1881145344 to i64*)
%16 = or i64 %15, 30576
store volatile i64 %16, i64* inttoptr (i64 1881145344 to i64*)
%17 = load volatile i64, i64* inttoptr (i64 1881145348 to i64*)
%18 = or i64 %17, 1
store volatile i64 %18, i64* inttoptr (i64 1881145348 to i64*)
%19 = load volatile i64, i64* inttoptr (i64 1881145348 to i64*)
%20 = and i64 %19, -65537
store volatile i64 %20, i64* inttoptr (i64 1881145348 to i64*)
%21 = tail call i32 (...) @nand_reset()
ret void
}