#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 getRAM(int);
int /*<<< orphan*/ printf(char *, ...);
void memmap(int start, int end) {
  printf("[MEMORY MAP]\n");
  for (int i = start; i < end; i += 8) {
    printf(" [%04x:%04x]\t", i, i + 7);
    for (int j = i; j < i + 8; j++) {
      printf("%02x ", getRAM(j));
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<memmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11be <memmap+0x9e>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
add    $0x7,%edx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x8,%ecx
cmp    %ecx,%eax
jge    11a2 <memmap+0x82>
mov    -0x10(%rbp),%edi
call   1040 <getRAM@plt>
mov    %eax,%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116b <memmap+0x4b>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
jmp    1142 <memmap+0x22>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memmap>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%ebx
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
cmp    %r15d,%ebx
jge    1238 <memmap+0xf8>
lea    0xe97(%rip),%r14
lea    0xe9e(%rip),%rbp
lea    0x7(%rbx),%r12d
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <getRAM@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1(%rbx),%edi
call   1060 <getRAM@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x2(%rbx),%edi
call   1060 <getRAM@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x3(%rbx),%edi
call   1060 <getRAM@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rbx),%edi
call   1060 <getRAM@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x5(%rbx),%edi
call   1060 <getRAM@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x6(%rbx),%edi
call   1060 <getRAM@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%edi
call   1060 <getRAM@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x8,%ebx
cmp    %r15d,%ebx
jl     1170 <memmap+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"[MEMORY MAP]\0A\00"
@.str.1 = [14 x i8] c" [%04x:%04x]\09\00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @memmap(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %3
store i32 %8, i32* %5
br label %9
9: ; preds = %33, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %36
13: ; preds = %9
%14 = load i32, i32* %5
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %16)
%18 = load i32, i32* %5
store i32 %18, i32* %6
br label %19
19: ; preds = %28, %13
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 8
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = load i32, i32* %6
%26 = call i32 @getRAM(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %19
31: ; preds = %19
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 8
store i32 %35, i32* %5
br label %9
36: ; preds = %9
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c" [%04x:%04x]\09\00"
@.str.2 = [6 x i8] c"%02x \00"
@str = [13 x i8] c"[MEMORY MAP]\00"
define void @memmap(i32 %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = icmp slt i32 %0, %1
br i1 %4, label %7, label %5
5: ; preds = %7, %2
%6 = tail call i32 @putchar(i32 10)
ret void
7: ; preds = %2, %7
%8 = phi i32 [ %11, %7 ], [ %0, %2 ]
%9 = add nsw i32 %8, 7
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %9)
%11 = add nsw i32 %8, 8
%12 = tail call i32 @getRAM(i32 %8)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = add nsw i32 %8, 1
%15 = tail call i32 @getRAM(i32 %14)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = add nsw i32 %8, 2
%18 = tail call i32 @getRAM(i32 %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = add nsw i32 %8, 3
%21 = tail call i32 @getRAM(i32 %20)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = add nsw i32 %8, 4
%24 = tail call i32 @getRAM(i32 %23)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = add nsw i32 %8, 5
%27 = tail call i32 @getRAM(i32 %26)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = add nsw i32 %8, 6
%30 = tail call i32 @getRAM(i32 %29)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = add nsw i32 %8, 7
%33 = tail call i32 @getRAM(i32 %32)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = tail call i32 @putchar(i32 10)
%36 = icmp slt i32 %11, %1
br i1 %36, label %7, label %5
}