#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*/ Mali_WrReg(int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printk(char *, int);
void *Mali_LdMem(void *srcptr, int size, int ttb_base) {
  Mali_WrReg(0x20, 0, 0x240c, 0);
  Mali_WrReg(0x20, 0, 0x2408, 0x88888888);
  Mali_WrReg(0x20, 0, 0x2404, 0);
  Mali_WrReg(0x20, 0, 0x2400, ttb_base | 0x3);
  printk(" - - - - - - - - > ttb_base = %x\n", ttb_base);
  Mali_WrReg(0x20, 0, 0x2418, 1);
  Mali_WrReg(0x20, 0, 0x2004, 0xFFFFFFFF);
  Mali_WrReg(0x20, 0, 0x2008, 0xFFFFFFFF);
  return srcptr;
}


x86 assembly (clang, -O0):
<Mali_LdMem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x20,%edi
xor    %ecx,%ecx
mov    $0x240c,%edx
mov    %ecx,%esi
call   1040 <Mali_WrReg@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2408,%edx
mov    $0x88888888,%ecx
call   1040 <Mali_WrReg@plt>
mov    $0x20,%edi
xor    %ecx,%ecx
mov    $0x2404,%edx
mov    %ecx,%esi
call   1040 <Mali_WrReg@plt>
mov    -0x10(%rbp),%ecx
or     $0x3,%ecx
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2400,%edx
call   1040 <Mali_WrReg@plt>
mov    -0x10(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1030 <printk@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2418,%edx
mov    $0x1,%ecx
call   1040 <Mali_WrReg@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2004,%edx
mov    $0xffffffff,%ecx
call   1040 <Mali_WrReg@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2008,%edx
mov    $0xffffffff,%ecx
call   1040 <Mali_WrReg@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mali_LdMem>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x240c,%edx
xor    %ecx,%ecx
call   1040 <Mali_WrReg@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2408,%edx
mov    $0x88888888,%ecx
call   1040 <Mali_WrReg@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2404,%edx
xor    %ecx,%ecx
call   1040 <Mali_WrReg@plt>
mov    %ebp,%ecx
or     $0x3,%ecx
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2400,%edx
call   1040 <Mali_WrReg@plt>
lea    0xe7f(%rip),%rdi
mov    %ebp,%esi
call   1030 <printk@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2418,%edx
mov    $0x1,%ecx
call   1040 <Mali_WrReg@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2004,%edx
mov    $0xffffffff,%ecx
call   1040 <Mali_WrReg@plt>
mov    $0x20,%edi
xor    %esi,%esi
mov    $0x2008,%edx
mov    $0xffffffff,%ecx
call   1040 <Mali_WrReg@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c" - - - - - - - - > ttb_base = %x\0A\00"
define i8* @Mali_LdMem(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = call i32 @Mali_WrReg(i32 32, i32 0, i32 9228, i32 0)
%8 = call i32 @Mali_WrReg(i32 32, i32 0, i32 9224, i32 -2004318072)
%9 = call i32 @Mali_WrReg(i32 32, i32 0, i32 9220, i32 0)
%10 = load i32, i32* %6
%11 = or i32 %10, 3
%12 = call i32 @Mali_WrReg(i32 32, i32 0, i32 9216, i32 %11)
%13 = load i32, i32* %6
%14 = call i32 @printk(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @Mali_WrReg(i32 32, i32 0, i32 9240, i32 1)
%16 = call i32 @Mali_WrReg(i32 32, i32 0, i32 8196, i32 -1)
%17 = call i32 @Mali_WrReg(i32 32, i32 0, i32 8200, i32 -1)
%18 = load i8*, i8** %4
ret i8* %18
}

LLVM IR (-O2):
@.str = [34 x i8] c" - - - - - - - - > ttb_base = %x\0A\00"
define i8* @Mali_LdMem(i8* readnone returned %0, i32 %1, i32 %2) {
%4 = tail call i32 @Mali_WrReg(i32 32, i32 0, i32 9228, i32 0)
%5 = tail call i32 @Mali_WrReg(i32 32, i32 0, i32 9224, i32 -2004318072)
%6 = tail call i32 @Mali_WrReg(i32 32, i32 0, i32 9220, i32 0)
%7 = or i32 %2, 3
%8 = tail call i32 @Mali_WrReg(i32 32, i32 0, i32 9216, i32 %7)
%9 = tail call i32 @printk(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %2)
%10 = tail call i32 @Mali_WrReg(i32 32, i32 0, i32 9240, i32 1)
%11 = tail call i32 @Mali_WrReg(i32 32, i32 0, i32 8196, i32 -1)
%12 = tail call i32 @Mali_WrReg(i32 32, i32 0, i32 8200, i32 -1)
ret i8* %0
}