#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*/ early_debug_put_hex_char(unsigned char);
int /*<<< orphan*/ early_debug_putc(char);
void early_debug_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) {
      early_debug_putc('\r');
      early_debug_putc('\n');
    }
    early_debug_put_hex_char(*ptr);
    ptr++;
    early_debug_putc(' ');
  }
}


x86 assembly (clang, -O0):
<early_debug_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    119c <early_debug_dump_memory+0x7c>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    116c <early_debug_dump_memory+0x4c>
mov    $0xd,%edi
call   1040 <early_debug_putc@plt>
mov    $0xa,%edi
call   1040 <early_debug_putc@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <early_debug_put_hex_char@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    $0x20,%edi
call   1040 <early_debug_putc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <early_debug_dump_memory+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<early_debug_dump_memory>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    1178 <early_debug_dump_memory+0x58>
movslq %edi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
jmp    115d <early_debug_dump_memory+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r14,%rbx,1),%edi
call   1030 <early_debug_put_hex_char@plt>
mov    $0x20,%edi
call   1040 <early_debug_putc@plt>
add    $0x1,%rbx
cmp    %ebx,%r15d
je     1178 <early_debug_dump_memory+0x58>
test   $0xf,%bl
jne    1140 <early_debug_dump_memory+0x20>
mov    $0xd,%edi
call   1040 <early_debug_putc@plt>
mov    $0xa,%edi
call   1040 <early_debug_putc@plt>
jmp    1140 <early_debug_dump_memory+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @early_debug_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 = call i32 @early_debug_putc(i8 signext 13)
%20 = call i32 @early_debug_putc(i8 signext 10)
br label %21
21: ; preds = %18, %14
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = call i32 @early_debug_put_hex_char(i8 zeroext %23)
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
%27 = call i32 @early_debug_putc(i8 signext 32)
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):
define void @early_debug_dump_memory(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = sext i32 %0 to i64
%6 = inttoptr i64 %5 to i8*
br label %7
7: ; preds = %4, %15
%8 = phi i32 [ %20, %15 ], [ 0, %4 ]
%9 = phi i8* [ %18, %15 ], [ %6, %4 ]
%10 = and i32 %8, 15
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = tail call i32 @early_debug_putc(i8 signext 13)
%14 = tail call i32 @early_debug_putc(i8 signext 10)
br label %15
15: ; preds = %12, %7
%16 = load i8, i8* %9
%17 = tail call i32 @early_debug_put_hex_char(i8 zeroext %16)
%18 = getelementptr inbounds i8, i8* %9, i64 1
%19 = tail call i32 @early_debug_putc(i8 signext 32)
%20 = add nuw nsw i32 %8, 1
%21 = icmp eq i32 %20, %1
br i1 %21, label %22, label %7
22: ; preds = %15, %2
ret void
}