void nand_readID(unsigned char *buffer) {
  char i = 0;
  ((*(volatile unsigned long *)(0x70200000 + 0x04)) &= ~(1 << 1));
  (*(volatile unsigned long *)(0x70200000 + 0x08)) = 0x90;
  (*(volatile unsigned long *)(0x70200000 + 0x0c)) = 0;
  for (i = 0; i < 6; i++)
    buffer[i] = (*(volatile unsigned char *)(0x70200000 + 0x10));
}


x86 assembly (clang, -O0):
<nand_readID>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    $0x70200004,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffffd,%rcx
mov    $0x70200004,%eax
mov    %rcx,(%rax)
mov    $0x70200008,%eax
movq   $0x90,(%rax)
mov    $0x7020000c,%eax
movq   $0x0,(%rax)
movb   $0x0,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x6,%eax
jge    1169 <nand_readID+0x69>
mov    $0x70200010,%eax
mov    (%rax),%dl
mov    -0x8(%rbp),%rax
movsbq -0x9(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x9(%rbp),%al
add    $0x1,%al
mov    %al,-0x9(%rbp)
jmp    113c <nand_readID+0x3c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<nand_readID>:
andq   $0xfffffffffffffffd,0x70200004
70 fd
movq   $0x90,0x70200008
movq   $0x0,0x7020000c
mov    0x70200010,%al
mov    %al,(%rdi)
mov    0x70200010,%al
mov    %al,0x1(%rdi)
mov    0x70200010,%al
mov    %al,0x2(%rdi)
mov    0x70200010,%al
mov    %al,0x3(%rdi)
mov    0x70200010,%al
mov    %al,0x4(%rdi)
mov    0x70200010,%al
mov    %al,0x5(%rdi)
ret

LLVM IR (-O0):
define void @nand_readID(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
store i8 0, i8* %3
%4 = load volatile i64, i64* inttoptr (i64 1881145348 to i64*)
%5 = and i64 %4, -3
store volatile i64 %5, i64* inttoptr (i64 1881145348 to i64*)
store volatile i64 144, i64* inttoptr (i64 1881145352 to i64*)
store volatile i64 0, i64* inttoptr (i64 1881145356 to i64*)
store i8 0, i8* %3
br label %6
6: ; preds = %16, %1
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = load volatile i8, i8* inttoptr (i64 1881145360 to i8*)
%12 = load i8*, i8** %2
%13 = load i8, i8* %3
%14 = sext i8 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 %11, i8* %15
br label %16
16: ; preds = %10
%17 = load i8, i8* %3
%18 = add i8 %17, 1
store i8 %18, i8* %3
br label %6
19: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @nand_readID(i8* nocapture writeonly %0) {
%2 = load volatile i64, i64* inttoptr (i64 1881145348 to i64*)
%3 = and i64 %2, -3
store volatile i64 %3, i64* inttoptr (i64 1881145348 to i64*)
store volatile i64 144, i64* inttoptr (i64 1881145352 to i64*)
store volatile i64 0, i64* inttoptr (i64 1881145356 to i64*)
%4 = load volatile i8, i8* inttoptr (i64 1881145360 to i8*)
store i8 %4, i8* %0
%5 = load volatile i8, i8* inttoptr (i64 1881145360 to i8*)
%6 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %5, i8* %6
%7 = load volatile i8, i8* inttoptr (i64 1881145360 to i8*)
%8 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %7, i8* %8
%9 = load volatile i8, i8* inttoptr (i64 1881145360 to i8*)
%10 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %9, i8* %10
%11 = load volatile i8, i8* inttoptr (i64 1881145360 to i8*)
%12 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %11, i8* %12
%13 = load volatile i8, i8* inttoptr (i64 1881145360 to i8*)
%14 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %13, i8* %14
ret void
}