#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printk(char *, ...);
void dump_memory(uint32_t address, uint32_t size) {
  unsigned char *ptr;
  int i;
  ptr = (unsigned char *)address;
  for (i = 0; i < size; i++) {
    if ((i & 0xf) == 0) {
      printk("\n%x: ", ptr);
    }
    printk("%x ", *ptr);
    ptr++;
  }
}


x86 assembly (clang, -O0):
<dump_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1189 <dump_memory+0x79>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    115a <dump_memory+0x4a>
mov    -0x10(%rbp),%rsi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <dump_memory+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    116f <dump_memory+0x5f>
movslq %edi,%r12
mov    %esi,%r13d
lea    0xed4(%rip),%r14
lea    0xed3(%rip),%r15
xor    %ebp,%ebp
jmp    1156 <dump_memory+0x46>
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printk@plt>
add    $0x1,%rbp
cmp    %ebp,%r13d
je     116f <dump_memory+0x5f>
lea    (%r12,%rbp,1),%rbx
test   $0xf,%bpl
jne    1140 <dump_memory+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printk@plt>
jmp    1140 <dump_memory+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\0A%x: \00"
@.str.1 = [4 x i8] c"%x \00"
define void @dump_memory(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %5
store i32 0, i32* %6
br label %10
10: ; preds = %28, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load i32, i32* %6
%16 = and i32 %15, 15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %14
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %5
br label %28
28: ; preds = %21
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %10
31: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\0A%x: \00"
@.str.1 = [4 x i8] c"%x \00"
define void @dump_memory(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = sext i32 %0 to i64
%6 = inttoptr i64 %5 to i8*
br label %7
7: ; preds = %4, %14
%8 = phi i32 [ %19, %14 ], [ 0, %4 ]
%9 = phi i8* [ %18, %14 ], [ %6, %4 ]
%10 = and i32 %8, 15
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %14
14: ; preds = %12, %7
%15 = load i8, i8* %9
%16 = zext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds i8, i8* %9, i64 1
%19 = add nuw nsw i32 %8, 1
%20 = icmp eq i32 %19, %1
br i1 %20, label %21, label %7
21: ; preds = %14, %2
ret void
}