void palette_init(void) {
  int i;
  volatile unsigned long *p = (volatile unsigned long *)0x77100400;
  (*((volatile unsigned long *)0x771001A0)) |= (1 << 9);
  (*((volatile unsigned long *)0x771001A0)) &= ~(0x7);
  (*((volatile unsigned long *)0x771001A0)) |= 1;
  p[0] = 0x000000;
  p[1] = 0x00ff00;
  p[2] = 0xff0000;
  p[3] = 0x0000ff;
  p[4] = 0xffffff;
  for (i = 0; i < 256; i++) {
  }
  (*((volatile unsigned long *)0x771001A0)) &= ~(1 << 9);
}


x86 assembly (clang, -O0):
<palette_init>:
push   %rbp
mov    %rsp,%rbp
mov    $0x77100400,%eax
mov    %rax,-0x10(%rbp)
mov    $0x771001a0,%eax
mov    (%rax),%rcx
or     $0x200,%rcx
mov    $0x771001a0,%eax
mov    %rcx,(%rax)
mov    $0x771001a0,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffff8,%rcx
mov    $0x771001a0,%eax
mov    %rcx,(%rax)
mov    $0x771001a0,%eax
mov    (%rax),%rcx
or     $0x1,%rcx
mov    $0x771001a0,%eax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0xff00,0x8(%rax)
mov    -0x10(%rbp),%rax
movq   $0xff0000,0x10(%rax)
mov    -0x10(%rbp),%rax
movq   $0xff,0x18(%rax)
mov    -0x10(%rbp),%rax
movq   $0xffffff,0x20(%rax)
movl   $0x0,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jge    11ae <palette_init+0xae>
jmp    11a0 <palette_init+0xa0>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118e <palette_init+0x8e>
mov    $0x771001a0,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffdff,%rcx
mov    $0x771001a0,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<palette_init>:
orq    $0x200,0x771001a0
andq   $0xfffffffffffffff8,0x771001a0
77 f8
orq    $0x1,0x771001a0
77 01
movq   $0x0,0x77100400
movq   $0xff00,0x77100408
movq   $0xff0000,0x77100410
movq   $0xff,0x77100418
movq   $0xffffff,0x77100420
andq   $0xfffffffffffffdff,0x771001a0
77 ff fd ff ff
ret

LLVM IR (-O0):
define void @palette_init() {
%1 = alloca i32
%2 = alloca i64*
store i64* inttoptr (i64 1997538304 to i64*), i64** %2
%3 = load volatile i64, i64* inttoptr (i64 1997537696 to i64*)
%4 = or i64 %3, 512
store volatile i64 %4, i64* inttoptr (i64 1997537696 to i64*)
%5 = load volatile i64, i64* inttoptr (i64 1997537696 to i64*)
%6 = and i64 %5, -8
store volatile i64 %6, i64* inttoptr (i64 1997537696 to i64*)
%7 = load volatile i64, i64* inttoptr (i64 1997537696 to i64*)
%8 = or i64 %7, 1
store volatile i64 %8, i64* inttoptr (i64 1997537696 to i64*)
%9 = load i64*, i64** %2
%10 = getelementptr inbounds i64, i64* %9, i64 0
store volatile i64 0, i64* %10
%11 = load i64*, i64** %2
%12 = getelementptr inbounds i64, i64* %11, i64 1
store volatile i64 65280, i64* %12
%13 = load i64*, i64** %2
%14 = getelementptr inbounds i64, i64* %13, i64 2
store volatile i64 16711680, i64* %14
%15 = load i64*, i64** %2
%16 = getelementptr inbounds i64, i64* %15, i64 3
store volatile i64 255, i64* %16
%17 = load i64*, i64** %2
%18 = getelementptr inbounds i64, i64* %17, i64 4
store volatile i64 16777215, i64* %18
store i32 0, i32* %1
br label %19
19: ; preds = %23, %0
%20 = load i32, i32* %1
%21 = icmp slt i32 %20, 256
br i1 %21, label %22, label %26
22: ; preds = %19
br label %23
23: ; preds = %22
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
br label %19
26: ; preds = %19
%27 = load volatile i64, i64* inttoptr (i64 1997537696 to i64*)
%28 = and i64 %27, -513
store volatile i64 %28, i64* inttoptr (i64 1997537696 to i64*)
ret void
}

LLVM IR (-O2):
define void @palette_init() {
%1 = load volatile i64, i64* inttoptr (i64 1997537696 to i64*)
%2 = or i64 %1, 512
store volatile i64 %2, i64* inttoptr (i64 1997537696 to i64*)
%3 = load volatile i64, i64* inttoptr (i64 1997537696 to i64*)
%4 = and i64 %3, -8
store volatile i64 %4, i64* inttoptr (i64 1997537696 to i64*)
%5 = load volatile i64, i64* inttoptr (i64 1997537696 to i64*)
%6 = or i64 %5, 1
store volatile i64 %6, i64* inttoptr (i64 1997537696 to i64*)
store volatile i64 0, i64* inttoptr (i64 1997538304 to i64*)
store volatile i64 65280, i64* inttoptr (i64 1997538312 to i64*)
store volatile i64 16711680, i64* inttoptr (i64 1997538320 to i64*)
store volatile i64 255, i64* inttoptr (i64 1997538328 to i64*)
store volatile i64 16777215, i64* inttoptr (i64 1997538336 to i64*)
%7 = load volatile i64, i64* inttoptr (i64 1997537696 to i64*)
%8 = and i64 %7, -513
store volatile i64 %8, i64* inttoptr (i64 1997537696 to i64*)
ret void
}