#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*/ pchar(char);
int /*<<< orphan*/ printHexByte(char);
int /*<<< orphan*/ printHexDword(int);
void ramdump(unsigned int address, unsigned int count) {
  int i = 0;
  char *ram = (char *)address;
  char *end = (char *)(address + count);
  while (ram < end) {
    pchar('\n');
    printHexDword((int)ram);
    pchar(':');
    pchar(' ');
    for (i = 0; i < 16 && ram < end; i++, ram++) {
      printHexByte(*ram);
      pchar(' ');
    }
    pchar('|');
    pchar(' ');
    for (i = -i; i < 0; i++)
      pchar(ram[i]);
  }
  while (1)
    ;
}


x86 assembly (clang, -O0):
<ramdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,%eax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    123d <ramdump+0x10d>
mov    $0xa,%edi
call   1040 <pchar@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
call   1030 <printHexDword@plt>
mov    $0x3a,%edi
call   1040 <pchar@plt>
mov    $0x20,%edi
call   1040 <pchar@plt>
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0xc(%rbp)
mov    %al,-0x21(%rbp)
jge    11b3 <ramdump+0x83>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
setb   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11c3 <ramdump+0x93>
jmp    11f3 <ramdump+0xc3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <printHexByte@plt>
mov    $0x20,%edi
call   1040 <pchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1196 <ramdump+0x66>
mov    $0x7c,%edi
call   1040 <pchar@plt>
mov    $0x20,%edi
call   1040 <pchar@plt>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1238 <ramdump+0x108>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <pchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    120f <ramdump+0xdf>
jmp    1158 <ramdump+0x28>
jmp    1242 <ramdump+0x112>
jmp    1242 <ramdump+0x112>

x86 assembly (clang, -O2):
<ramdump>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %edi,%r13d
add    %edi,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %r14,%r13
jae    1210 <ramdump+0xe0>
mov    $0xa,%edi
call   1040 <pchar@plt>
mov    %r13d,%edi
call   1030 <printHexDword@plt>
mov    $0x3a,%edi
call   1040 <pchar@plt>
mov    $0x20,%edi
call   1040 <pchar@plt>
xor    %r15d,%r15d
cmp    %r14,%r13
jae    11bc <ramdump+0x8c>
nopw   0x0(%rax,%rax,1)
mov    %r15d,%ebx
movsbl 0x0(%r13),%edi
call   1050 <printHexByte@plt>
mov    $0x20,%edi
call   1040 <pchar@plt>
lea    0x1(%rbx),%r15d
add    $0x1,%r13
cmp    $0xe,%ebx
ja     11b9 <ramdump+0x89>
cmp    %r14,%r13
jb     1190 <ramdump+0x60>
neg    %r15d
mov    $0x7c,%edi
call   1040 <pchar@plt>
mov    $0x20,%edi
call   1040 <pchar@plt>
test   %r15d,%r15d
jns    1150 <ramdump+0x20>
movslq %r15d,%r12
add    %r13,%r12
neg    %r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r12,%rbx,1),%edi
call   1040 <pchar@plt>
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    11f0 <ramdump+0xc0>
jmp    1150 <ramdump+0x20>
nopl   0x0(%rax,%rax,1)
jmp    1210 <ramdump+0xe0>

LLVM IR (-O0):
define void @ramdump(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %6
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = add i32 %11, %12
%14 = zext i32 %13 to i64
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %7
br label %16
16: ; preds = %64, %2
%17 = load i8*, i8** %6
%18 = load i8*, i8** %7
%19 = icmp ult i8* %17, %18
br i1 %19, label %20, label %65
20: ; preds = %16
%21 = call i32 @pchar(i8 signext 10)
%22 = load i8*, i8** %6
%23 = ptrtoint i8* %22 to i32
%24 = call i32 @printHexDword(i32 %23)
%25 = call i32 @pchar(i8 signext 58)
%26 = call i32 @pchar(i8 signext 32)
store i32 0, i32* %5
br label %27
27: ; preds = %41, %20
%28 = load i32, i32* %5
%29 = icmp slt i32 %28, 16
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i8*, i8** %6
%32 = load i8*, i8** %7
%33 = icmp ult i8* %31, %32
br label %34
34: ; preds = %30, %27
%35 = phi i1 [ false, %27 ], [ %33, %30 ]
br i1 %35, label %36, label %46
36: ; preds = %34
%37 = load i8*, i8** %6
%38 = load i8, i8* %37
%39 = call i32 @printHexByte(i8 signext %38)
%40 = call i32 @pchar(i8 signext 32)
br label %41
41: ; preds = %36
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %6
br label %27
46: ; preds = %34
%47 = call i32 @pchar(i8 signext 124)
%48 = call i32 @pchar(i8 signext 32)
%49 = load i32, i32* %5
%50 = sub nsw i32 0, %49
store i32 %50, i32* %5
br label %51
51: ; preds = %61, %46
%52 = load i32, i32* %5
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %64
54: ; preds = %51
%55 = load i8*, i8** %6
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8, i8* %58
%60 = call i32 @pchar(i8 signext %59)
br label %61
61: ; preds = %54
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %51
64: ; preds = %51
br label %16
65: ; preds = %16
br label %66
66: ; preds = %65, %66
br label %66
}

LLVM IR (-O2):
define void @ramdump(i32 %0, i32 %1) {
%3 = zext i32 %0 to i64
%4 = inttoptr i64 %3 to i8*
%5 = add i32 %1, %0
%6 = zext i32 %5 to i64
%7 = inttoptr i64 %6 to i8*
%8 = icmp ult i8* %4, %7
br i1 %8, label %12, label %9
9: ; preds = %10, %2
br label %50
10: ; preds = %42, %34
%11 = icmp ult i8* %35, %7
br i1 %11, label %12, label %9
12: ; preds = %2, %10
%13 = phi i8* [ %35, %10 ], [ %4, %2 ]
%14 = tail call i32 @pchar(i8 signext 10)
%15 = ptrtoint i8* %13 to i64
%16 = trunc i64 %15 to i32
%17 = tail call i32 @printHexDword(i32 %16)
%18 = tail call i32 @pchar(i8 signext 58)
%19 = tail call i32 @pchar(i8 signext 32)
%20 = icmp ult i8* %13, %7
br i1 %20, label %21, label %34
21: ; preds = %12, %21
%22 = phi i32 [ %27, %21 ], [ 0, %12 ]
%23 = phi i8* [ %28, %21 ], [ %13, %12 ]
%24 = load i8, i8* %23
%25 = tail call i32 @printHexByte(i8 signext %24)
%26 = tail call i32 @pchar(i8 signext 32)
%27 = add nuw nsw i32 %22, 1
%28 = getelementptr inbounds i8, i8* %23, i64 1
%29 = icmp ult i32 %22, 15
%30 = icmp ult i8* %28, %7
%31 = select i1 %29, i1 %30, i1 false
br i1 %31, label %21, label %32
32: ; preds = %21
%33 = xor i32 %22, -1
br label %34
34: ; preds = %32, %12
%35 = phi i8* [ %13, %12 ], [ %28, %32 ]
%36 = phi i32 [ 0, %12 ], [ %33, %32 ]
%37 = tail call i32 @pchar(i8 signext 124)
%38 = tail call i32 @pchar(i8 signext 32)
%39 = icmp slt i32 %36, 0
br i1 %39, label %40, label %10
40: ; preds = %34
%41 = sext i32 %36 to i64
br label %42
42: ; preds = %40, %42
%43 = phi i64 [ %41, %40 ], [ %47, %42 ]
%44 = getelementptr inbounds i8, i8* %35, i64 %43
%45 = load i8, i8* %44
%46 = tail call i32 @pchar(i8 signext %45)
%47 = add nsw i64 %43, 1
%48 = trunc i64 %47 to i32
%49 = icmp eq i32 %48, 0
br i1 %49, label %10, label %42
50: ; preds = %9, %50
br label %50
}