#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*/ enable_paging();
int /*<<< orphan*/ map_page_pse(int, int, int);
void paging_load() {
  unsigned int *page_directory = (unsigned int *)0xC0010000;
  for (int i = 0; i < 0x400; i++) {
    page_directory[i] = 2;
  }
  for (int i = 0; i <= 0x1400000; i += 0x400000) {
    map_page_pse(i, 0xC0000000 + i, 2);
  }
  enable_paging();
}


x86 assembly (clang, -O0):
<paging_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xc0010000,%eax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x400,-0xc(%rbp)
jge    1162 <paging_load+0x42>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movl   $0x2,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <paging_load+0x18>
movl   $0x0,-0x10(%rbp)
cmpl   $0x1400000,-0x10(%rbp)
jg     119c <paging_load+0x7c>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
add    $0xc0000000,%esi
mov    $0x2,%edx
call   1040 <map_page_pse@plt>
mov    -0x10(%rbp),%eax
add    $0x400000,%eax
mov    %eax,-0x10(%rbp)
jmp    1169 <paging_load+0x49>
mov    $0x0,%al
call   1030 <enable_paging@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<paging_load>:
push   %rax
mov    $0xc00100f0,%eax
xor    %ecx,%ecx
movaps 0xed1(%rip),%xmm0
nop
movaps %xmm0,-0xf0(%rax,%rcx,4)
ff
movaps %xmm0,-0xe0(%rax,%rcx,4)
ff
movaps %xmm0,-0xd0(%rax,%rcx,4)
ff
movaps %xmm0,-0xc0(%rax,%rcx,4)
ff
movaps %xmm0,-0xb0(%rax,%rcx,4)
ff
movaps %xmm0,-0xa0(%rax,%rcx,4)
ff
movaps %xmm0,-0x90(%rax,%rcx,4)
ff
movaps %xmm0,-0x80(%rax,%rcx,4)
movaps %xmm0,-0x70(%rax,%rcx,4)
movaps %xmm0,-0x60(%rax,%rcx,4)
movaps %xmm0,-0x50(%rax,%rcx,4)
movaps %xmm0,-0x40(%rax,%rcx,4)
movaps %xmm0,-0x30(%rax,%rcx,4)
movaps %xmm0,-0x20(%rax,%rcx,4)
movaps %xmm0,-0x10(%rax,%rcx,4)
movaps %xmm0,(%rax,%rcx,4)
add    $0x40,%rcx
cmp    $0x400,%rcx
jne    1130 <paging_load+0x10>
xor    %edi,%edi
mov    $0xc0000000,%esi
mov    $0x2,%edx
call   1040 <map_page_pse@plt>
mov    $0x400000,%edi
mov    $0xc0400000,%esi
mov    $0x2,%edx
call   1040 <map_page_pse@plt>
mov    $0x800000,%edi
mov    $0xc0800000,%esi
mov    $0x2,%edx
call   1040 <map_page_pse@plt>
mov    $0xc00000,%edi
mov    $0xc0c00000,%esi
mov    $0x2,%edx
call   1040 <map_page_pse@plt>
mov    $0x1000000,%edi
mov    $0xc1000000,%esi
mov    $0x2,%edx
call   1040 <map_page_pse@plt>
mov    $0x1400000,%edi
mov    $0xc1400000,%esi
mov    $0x2,%edx
call   1040 <map_page_pse@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <enable_paging@plt>

LLVM IR (-O0):
define void @paging_load() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
store i32* inttoptr (i64 3221291008 to i32*), i32** %1
store i32 0, i32* %2
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 1024
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32*, i32** %1
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %8, i64 %10
store i32 2, i32* %11
br label %12
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
store i32 0, i32* %3
br label %16
16: ; preds = %24, %15
%17 = load i32, i32* %3
%18 = icmp sle i32 %17, 20971520
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i32, i32* %3
%21 = load i32, i32* %3
%22 = add i32 -1073741824, %21
%23 = call i32 @map_page_pse(i32 %20, i32 %22, i32 2)
br label %24
24: ; preds = %19
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 4194304
store i32 %26, i32* %3
br label %16
27: ; preds = %16
%28 = call i32 (...) @enable_paging()
ret void
}

LLVM IR (-O2):
define void @paging_load() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %42, %1 ]
%3 = getelementptr inbounds i32, i32* inttoptr (i64 3221291008 to i32*), i64 %2
%4 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %4
%5 = getelementptr inbounds i32, i32* %3, i64 4
%6 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %6
%7 = or i64 %2, 8
%8 = getelementptr inbounds i32, i32* inttoptr (i64 3221291008 to i32*), i64 %7
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %8, i64 4
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %11
%12 = or i64 %2, 16
%13 = getelementptr inbounds i32, i32* inttoptr (i64 3221291008 to i32*), i64 %12
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %14
%15 = getelementptr inbounds i32, i32* %13, i64 4
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %16
%17 = or i64 %2, 24
%18 = getelementptr inbounds i32, i32* inttoptr (i64 3221291008 to i32*), i64 %17
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %19
%20 = getelementptr inbounds i32, i32* %18, i64 4
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %21
%22 = or i64 %2, 32
%23 = getelementptr inbounds i32, i32* inttoptr (i64 3221291008 to i32*), i64 %22
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %24
%25 = getelementptr inbounds i32, i32* %23, i64 4
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %26
%27 = or i64 %2, 40
%28 = getelementptr inbounds i32, i32* inttoptr (i64 3221291008 to i32*), i64 %27
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %29
%30 = getelementptr inbounds i32, i32* %28, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %31
%32 = or i64 %2, 48
%33 = getelementptr inbounds i32, i32* inttoptr (i64 3221291008 to i32*), i64 %32
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %34
%35 = getelementptr inbounds i32, i32* %33, i64 4
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %36
%37 = or i64 %2, 56
%38 = getelementptr inbounds i32, i32* inttoptr (i64 3221291008 to i32*), i64 %37
%39 = bitcast i32* %38 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %39
%40 = getelementptr inbounds i32, i32* %38, i64 4
%41 = bitcast i32* %40 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %41
%42 = add nuw nsw i64 %2, 64
%43 = icmp eq i64 %42, 1024
br i1 %43, label %44, label %1
44: ; preds = %1
%45 = tail call i32 @map_page_pse(i32 0, i32 -1073741824, i32 2)
%46 = tail call i32 @map_page_pse(i32 4194304, i32 -1069547520, i32 2)
%47 = tail call i32 @map_page_pse(i32 8388608, i32 -1065353216, i32 2)
%48 = tail call i32 @map_page_pse(i32 12582912, i32 -1061158912, i32 2)
%49 = tail call i32 @map_page_pse(i32 16777216, i32 -1056964608, i32 2)
%50 = tail call i32 @map_page_pse(i32 20971520, i32 -1052770304, i32 2)
%51 = tail call i32 (...) @enable_paging()
ret void
}