#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*/ printk(char *, ...);
void Mali_PrintMem(volatile unsigned int *memory_address,
                   unsigned int word_count) {
  int j;
  printk("Memory readout for 0x%x:\n  ", memory_address);
  for (j = 0; j < word_count; j++) {
    if ((j % 4) == 0 && j != 0) {
      printk("\n  ");
    }
    printk("word[%02d]=0x%08x ", j, *memory_address);
    memory_address += 1;
  }
  printk("\n");
}


x86 assembly (clang, -O0):
<Mali_PrintMem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11a1 <Mali_PrintMem+0x91>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1170 <Mali_PrintMem+0x60>
cmpl   $0x0,-0x10(%rbp)
je     1170 <Mali_PrintMem+0x60>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1138 <Mali_PrintMem+0x28>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mali_PrintMem>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r12
lea    0xedb(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <printk@plt>
test   %ebx,%ebx
je     1180 <Mali_PrintMem+0x70>
mov    %ebx,%r13d
lea    0xedb(%rip),%r14
lea    0xed8(%rip),%r15
xor    %ebx,%ebx
jmp    1169 <Mali_PrintMem+0x59>
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%edx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printk@plt>
add    $0x1,%rbx
cmp    %ebx,%r13d
je     1180 <Mali_PrintMem+0x70>
test   %ebx,%ebx
je     1150 <Mali_PrintMem+0x40>
mov    %ebx,%eax
and    $0x3,%eax
jne    1150 <Mali_PrintMem+0x40>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printk@plt>
jmp    1150 <Mali_PrintMem+0x40>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <printk@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Memory readout for 0x%x:\0A \00"
@.str.1 = [4 x i8] c"\0A \00"
@.str.2 = [19 x i8] c"word[%02d]=0x%08x \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @Mali_PrintMem(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 0, i32* %5
br label %8
8: ; preds = %28, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %8
%13 = load i32, i32* %5
%14 = srem i32 %13, 4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %16, %12
%22 = load i32, i32* %5
%23 = load i32*, i32** %3
%24 = load volatile i32, i32* %23
%25 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %24)
%26 = load i32*, i32** %3
%27 = getelementptr inbounds i32, i32* %26, i64 1
store i32* %27, i32** %3
br label %28
28: ; preds = %21
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %8
31: ; preds = %8
%32 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Memory readout for 0x%x:\0A \00"
@.str.1 = [4 x i8] c"\0A \00"
@.str.2 = [19 x i8] c"word[%02d]=0x%08x \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @Mali_PrintMem(i32* %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32* %0)
%4 = icmp eq i32 %1, 0
br i1 %4, label %20, label %5
5: ; preds = %2, %14
%6 = phi i32 [ %18, %14 ], [ 0, %2 ]
%7 = phi i32* [ %17, %14 ], [ %0, %2 ]
%8 = and i32 %6, 3
%9 = icmp eq i32 %8, 0
%10 = icmp ne i32 %6, 0
%11 = and i1 %10, %9
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %5
%15 = load volatile i32, i32* %7
%16 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %15)
%17 = getelementptr inbounds i32, i32* %7, i64 1
%18 = add nuw i32 %6, 1
%19 = icmp eq i32 %18, %1
br i1 %19, label %20, label %5
20: ; preds = %14, %2
%21 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}