#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*/ printf(char *, ...);
void memmap(int start, int end, unsigned char *output) {
  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++) {
      if (output[j])
        printf("%02x ", output[j]);
      else
        printf(":: ");
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<memmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11de <memmap+0xce>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
add    $0x7,%edx
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x8,%ecx
cmp    %ecx,%eax
jge    11c2 <memmap+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11a1 <memmap+0x91>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11af <memmap+0x9f>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b4 <memmap+0xa4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <memmap+0x4f>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <memmap+0x26>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xecf(%rip),%rdi
call   1040 <puts@plt>
cmp    %ebx,%ebp
jge    12c0 <memmap+0x190>
movslq %ebp,%r14
movslq %ebx,%rbp
lea    0xeb1(%rip),%r15
lea    0xea4(%rip),%r12
jmp    1193 <memmap+0x63>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %rbp,%r14
jge    12c0 <memmap+0x190>
mov    %r14,%rbx
lea    0x7(%r14),%edx
lea    0xe5f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x8,%r14
movzbl 0x0(%r13,%rbx,1),%esi
test   %esi,%esi
je     11d0 <memmap+0xa0>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11da <memmap+0xaa>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1(%rbx),%rax
cmp    %r14,%rax
jge    1180 <memmap+0x50>
movzbl 0x1(%r13,%rbx,1),%esi
test   %esi,%esi
je     11f9 <memmap+0xc9>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1203 <memmap+0xd3>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x2(%r13,%rbx,1),%esi
test   %esi,%esi
je     1219 <memmap+0xe9>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1223 <memmap+0xf3>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x3(%r13,%rbx,1),%esi
test   %esi,%esi
je     1239 <memmap+0x109>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1243 <memmap+0x113>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x4(%r13,%rbx,1),%esi
test   %esi,%esi
je     1259 <memmap+0x129>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1263 <memmap+0x133>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x5(%r13,%rbx,1),%esi
test   %esi,%esi
je     1279 <memmap+0x149>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1283 <memmap+0x153>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x6(%r13,%rbx,1),%esi
test   %esi,%esi
je     1299 <memmap+0x169>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12a3 <memmap+0x173>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x7(%r13,%rbx,1),%esi
test   %esi,%esi
je     116c <memmap+0x3c>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1180 <memmap+0x50>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = [4 x i8] c":: \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @memmap(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %4
store i32 %10, i32* %7
br label %11
11: ; preds = %49, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %52
15: ; preds = %11
%16 = load i32, i32* %7
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18)
%20 = load i32, i32* %7
store i32 %20, i32* %8
br label %21
21: ; preds = %44, %15
%22 = load i32, i32* %8
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 8
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %47
26: ; preds = %21
%27 = load i8*, i8** %6
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %26
%34 = load i8*, i8** %6
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %43
41: ; preds = %26
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %33
br label %44
44: ; preds = %43
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %21
47: ; preds = %21
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %47
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 8
store i32 %51, i32* %7
br label %11
52: ; preds = %11
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, 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.3 = [4 x i8] c":: \00"
@str = [13 x i8] c"[MEMORY MAP]\00"
define void @memmap(i32 %0, i32 %1, i8* nocapture %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%5 = icmp slt i32 %0, %1
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = sext i32 %0 to i64
%8 = sext i32 %1 to i64
br label %11
9: ; preds = %20, %3
%10 = tail call i32 @putchar(i32 10)
ret void
11: ; preds = %6, %20
%12 = phi i64 [ %7, %6 ], [ %16, %20 ]
%13 = trunc i64 %12 to i32
%14 = add nsw i32 %13, 7
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %14)
%16 = add i64 %12, 8
%17 = getelementptr inbounds i8, i8* %2, i64 %12
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %26, label %23
20: ; preds = %95, %98, %28
%21 = tail call i32 @putchar(i32 10)
%22 = icmp slt i64 %16, %8
br i1 %22, label %11, label %9
23: ; preds = %11
%24 = zext i8 %18 to i32
%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)
br label %28
26: ; preds = %11
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %23, %26
%29 = add nsw i64 %12, 1
%30 = icmp slt i64 %29, %16
br i1 %30, label %31, label %20
31: ; preds = %28
%32 = getelementptr inbounds i8, i8* %2, i64 %29
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = zext i8 %33 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %40
38: ; preds = %31
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
%41 = add nsw i64 %12, 2
%42 = getelementptr inbounds i8, i8* %2, i64 %41
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %40
%46 = zext i8 %43 to i32
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %50
48: ; preds = %40
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = add i64 %12, 3
%52 = getelementptr inbounds i8, i8* %2, i64 %51
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %50
%56 = zext i8 %53 to i32
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %56)
br label %60
58: ; preds = %50
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %60
60: ; preds = %58, %55
%61 = add i64 %12, 4
%62 = getelementptr inbounds i8, i8* %2, i64 %61
%63 = load i8, i8* %62
%64 = icmp eq i8 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %60
%66 = zext i8 %63 to i32
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %66)
br label %70
68: ; preds = %60
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %70
70: ; preds = %68, %65
%71 = add i64 %12, 5
%72 = getelementptr inbounds i8, i8* %2, i64 %71
%73 = load i8, i8* %72
%74 = icmp eq i8 %73, 0
br i1 %74, label %78, label %75
75: ; preds = %70
%76 = zext i8 %73 to i32
%77 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %76)
br label %80
78: ; preds = %70
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %80
80: ; preds = %78, %75
%81 = add i64 %12, 6
%82 = getelementptr inbounds i8, i8* %2, i64 %81
%83 = load i8, i8* %82
%84 = icmp eq i8 %83, 0
br i1 %84, label %88, label %85
85: ; preds = %80
%86 = zext i8 %83 to i32
%87 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %86)
br label %90
88: ; preds = %80
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %90
90: ; preds = %88, %85
%91 = add i64 %12, 7
%92 = getelementptr inbounds i8, i8* %2, i64 %91
%93 = load i8, i8* %92
%94 = icmp eq i8 %93, 0
br i1 %94, label %98, label %95
95: ; preds = %90
%96 = zext i8 %93 to i32
%97 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %96)
br label %20
98: ; preds = %90
%99 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %20
}