#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*/ PPCMMU(int, int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ SetPhys(int, int);
int /*<<< orphan*/ memcpy(int *, int /*<<< orphan*/, int);
void _MmuInit(void *_start, void *_end) {
  int target = 0x10000, copy;
  int *start = (int *)_start;
  while (start < (int *)_end) {
    memcpy(&copy, start++, sizeof(int));
    SetPhys(target, copy);
    target += sizeof(int);
  }
  PPCMMU(0x100, 0, 0, 0);
}


x86 assembly (clang, -O0):
<_MmuInit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x10000,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    %rcx,%rax
jae    119a <_MmuInit+0x6a>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    %eax,%esi
lea    -0x18(%rbp),%rdi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <SetPhys@plt>
movslq -0x14(%rbp),%rax
add    $0x4,%rax
mov    %eax,-0x14(%rbp)
jmp    114f <_MmuInit+0x1f>
mov    $0x100,%edi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1040 <PPCMMU@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_MmuInit>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    %rsi,%rdi
jae    118b <_MmuInit+0x5b>
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x10000,%ebp
lea    0xc(%rsp),%r15
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x4,%rbx
mov    %r15,%rdi
mov    %r12d,%esi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    0xc(%rsp),%esi
mov    %ebp,%edi
call   1050 <SetPhys@plt>
add    $0x4,%ebp
add    $0x4,%r12d
cmp    %r14,%rbx
jb     1160 <_MmuInit+0x30>
mov    $0x100,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <PPCMMU@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_MmuInit(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 65536, i32* %5
%8 = load i8*, i8** %3
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %7
br label %10
10: ; preds = %15, %2
%11 = load i32*, i32** %7
%12 = load i8*, i8** %4
%13 = bitcast i8* %12 to i32*
%14 = icmp ult i32* %11, %13
br i1 %14, label %15, label %27
15: ; preds = %10
%16 = load i32*, i32** %7
%17 = getelementptr inbounds i32, i32* %16, i32 1
store i32* %17, i32** %7
%18 = ptrtoint i32* %16 to i32
%19 = call i32 @memcpy(i32* %6, i32 %18, i32 4)
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @SetPhys(i32 %20, i32 %21)
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = add i64 %24, 4
%26 = trunc i64 %25 to i32
store i32 %26, i32* %5
br label %10
27: ; preds = %10
%28 = call i32 @PPCMMU(i32 256, i32 0, i32 0, i32 0)
ret void
}

LLVM IR (-O2):
define void @_MmuInit(i8* %0, i8* readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = bitcast i8* %1 to i32*
%6 = icmp ult i8* %0, %1
br i1 %6, label %7, label %20
7: ; preds = %2
%8 = bitcast i8* %0 to i32*
br label %9
9: ; preds = %7, %9
%10 = phi i32* [ %12, %9 ], [ %8, %7 ]
%11 = phi i32 [ %18, %9 ], [ 65536, %7 ]
%12 = getelementptr inbounds i32, i32* %10, i64 1
%13 = ptrtoint i32* %10 to i64
%14 = trunc i64 %13 to i32
%15 = call i32 @memcpy(i32* %3, i32 %14, i32 4)
%16 = load i32, i32* %3
%17 = call i32 @SetPhys(i32 %11, i32 %16)
%18 = add i32 %11, 4
%19 = icmp ult i32* %12, %5
br i1 %19, label %9, label %20
20: ; preds = %9, %2
%21 = call i32 @PPCMMU(i32 256, i32 0, i32 0, i32 0)
ret void
}