void create_page_table(void) {
  unsigned long *ttb = (unsigned long *)0x50000000;
  unsigned long vaddr, paddr;
  vaddr = 0xA0000000;
  paddr = 0x7f000000;
  *(ttb + (vaddr >> 20)) =
      (paddr & 0xFFF00000) | ((3 << 10) | (0 << 5) | (1 << 4) | (2));
  vaddr = 0x50000000;
  paddr = 0x50000000;
  while (vaddr < 0x54000000) {
    *(ttb + (vaddr >> 20)) =
        (paddr & 0xFFF00000) |
        ((3 << 10) | (0 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (2));
    vaddr += 0x100000;
    paddr += 0x100000;
  }
}


x86 assembly (clang, -O0):
<create_page_table>:
push   %rbp
mov    %rsp,%rbp
mov    $0x50000000,%eax
mov    %rax,-0x8(%rbp)
mov    $0xa0000000,%eax
mov    %rax,-0x10(%rbp)
movq   $0x7f000000,-0x18(%rbp)
7f
movabs $0xfff00000,%rdx
and    -0x18(%rbp),%rdx
or     $0xc12,%rdx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shr    $0x14,%rcx
mov    %rdx,(%rax,%rcx,8)
movq   $0x50000000,-0x10(%rbp)
50
movq   $0x50000000,-0x18(%rbp)
50
cmpq   $0x54000000,-0x10(%rbp)
54
jae    11a7 <create_page_table+0xa7>
movabs $0xfff00000,%rdx
and    -0x18(%rbp),%rdx
or     $0xc1e,%rdx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shr    $0x14,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x100000,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x100000,%rax
mov    %rax,-0x18(%rbp)
jmp    1153 <create_page_table+0x53>
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_page_table>:
mov    $0x50002830,%eax
movq   $0x7f000c12,0x50005000
movdqa 0xee7(%rip),%xmm0
xor    %ecx,%ecx
movdqa 0xeed(%rip),%xmm1
movdqa 0xef5(%rip),%xmm2
movdqa 0xefd(%rip),%xmm3
movdqa 0xf05(%rip),%xmm4
movdqa 0xf0d(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqa %xmm0,%xmm6
por    %xmm1,%xmm6
movdqa %xmm6,-0x30(%rax,%rcx,8)
movdqa %xmm0,%xmm6
paddq  %xmm2,%xmm6
por    %xmm1,%xmm6
movdqa %xmm6,-0x20(%rax,%rcx,8)
movdqa %xmm0,%xmm6
paddq  %xmm3,%xmm6
por    %xmm1,%xmm6
movdqa %xmm6,-0x10(%rax,%rcx,8)
movdqa %xmm0,%xmm6
paddq  %xmm4,%xmm6
por    %xmm1,%xmm6
movdqa %xmm6,(%rax,%rcx,8)
add    $0x8,%rcx
paddq  %xmm5,%xmm0
cmp    $0x40,%rcx
jne    1150 <create_page_table+0x50>
ret

LLVM IR (-O0):
define void @create_page_table() {
%1 = alloca i64*
%2 = alloca i64
%3 = alloca i64
store i64* inttoptr (i64 1342177280 to i64*), i64** %1
store i64 2684354560, i64* %2
store i64 2130706432, i64* %3
%4 = load i64, i64* %3
%5 = and i64 %4, 4293918720
%6 = or i64 %5, 3090
%7 = load i64*, i64** %1
%8 = load i64, i64* %2
%9 = lshr i64 %8, 20
%10 = getelementptr inbounds i64, i64* %7, i64 %9
store i64 %6, i64* %10
store i64 1342177280, i64* %2
store i64 1342177280, i64* %3
br label %11
11: ; preds = %14, %0
%12 = load i64, i64* %2
%13 = icmp ult i64 %12, 1409286144
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load i64, i64* %3
%16 = and i64 %15, 4293918720
%17 = or i64 %16, 3102
%18 = load i64*, i64** %1
%19 = load i64, i64* %2
%20 = lshr i64 %19, 20
%21 = getelementptr inbounds i64, i64* %18, i64 %20
store i64 %17, i64* %21
%22 = load i64, i64* %2
%23 = add i64 %22, 1048576
store i64 %23, i64* %2
%24 = load i64, i64* %3
%25 = add i64 %24, 1048576
store i64 %25, i64* %3
br label %11
26: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @create_page_table() {
store i64 2130709522, i64* inttoptr (i64 1342197760 to i64*)
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %23, %1 ]
%3 = phi <2 x i64> [ <i64 1342177280, i64 1343225856>, %0 ], [ %24, %1 ]
%4 = or <2 x i64> %3, <i64 3102, i64 3102>
%5 = add nuw nsw i64 %2, 1280
%6 = getelementptr inbounds i64, i64* inttoptr (i64 1342177280 to i64*), i64 %5
%7 = bitcast i64* %6 to <2 x i64>*
store <2 x i64> %4, <2 x i64>* %7
%8 = add <2 x i64> %3, <i64 2097152, i64 2097152>
%9 = or <2 x i64> %8, <i64 3102, i64 3102>
%10 = add nuw nsw i64 %2, 1282
%11 = getelementptr inbounds i64, i64* inttoptr (i64 1342177280 to i64*), i64 %10
%12 = bitcast i64* %11 to <2 x i64>*
store <2 x i64> %9, <2 x i64>* %12
%13 = add <2 x i64> %3, <i64 4194304, i64 4194304>
%14 = or <2 x i64> %13, <i64 3102, i64 3102>
%15 = add nuw nsw i64 %2, 1284
%16 = getelementptr inbounds i64, i64* inttoptr (i64 1342177280 to i64*), i64 %15
%17 = bitcast i64* %16 to <2 x i64>*
store <2 x i64> %14, <2 x i64>* %17
%18 = add <2 x i64> %3, <i64 6291456, i64 6291456>
%19 = or <2 x i64> %18, <i64 3102, i64 3102>
%20 = add nuw nsw i64 %2, 1286
%21 = getelementptr inbounds i64, i64* inttoptr (i64 1342177280 to i64*), i64 %20
%22 = bitcast i64* %21 to <2 x i64>*
store <2 x i64> %19, <2 x i64>* %22
%23 = add nuw nsw i64 %2, 8
%24 = add <2 x i64> %3, <i64 8388608, i64 8388608>
%25 = icmp eq i64 %23, 64
br i1 %25, label %26, label %1
26: ; preds = %1
ret void
}