#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 *, ...);
int readMemorySingleWord(int);
void dumpMemory(int from, int to) {
  int i, j;
  int count = to - from;
  int cols = 16;
  int rows = count / cols;
  int offset = count % cols;
  printf("Memory Dump\n");
  printf("from 0x%02x to 0x%02x: \n", from, to);
  for (i = 0; i < rows; i++) {
    printf("0x%04x: ", i * cols);
    for (j = 0; j < cols; j++) {
      printf("0x%02x ", readMemorySingleWord(from + (i * cols + j)));
    }
    printf("\n");
  }
  if (offset > 0) {
    printf("0x%04x: ", rows * cols);
    for (i = 0; i < offset; i++) {
      printf("0x%02x ", readMemorySingleWord(from + (rows * cols + i)));
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dumpMemory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x10,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x20(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11fd <dumpMemory+0xdd>
mov    -0xc(%rbp),%esi
imul   -0x18(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e1 <dumpMemory+0xc1>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%eax
imul   -0x18(%rbp),%eax
add    -0x10(%rbp),%eax
add    %eax,%edi
call   1030 <readMemorySingleWord@plt>
mov    %eax,%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a3 <dumpMemory+0x83>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <dumpMemory+0x5b>
cmpl   $0x0,-0x20(%rbp)
jle    126f <dumpMemory+0x14f>
mov    -0x1c(%rbp),%esi
imul   -0x18(%rbp),%esi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1261 <dumpMemory+0x141>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%eax
imul   -0x18(%rbp),%eax
add    -0xc(%rbp),%eax
add    %eax,%edi
call   1030 <readMemorySingleWord@plt>
mov    %eax,%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1223 <dumpMemory+0x103>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpMemory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
mov    %esi,%ebp
sub    %edi,%ebp
lea    0xf(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
mov    %eax,%ecx
sar    $0x4,%ecx
mov    %ecx,0x4(%rsp)
and    $0xfffffff0,%eax
mov    %ebp,%r13d
sub    %eax,%r13d
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7f(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x10,%ebp
jl     1340 <dumpMemory+0x200>
lea    0xe7c(%rip),%r15
lea    0xe7e(%rip),%r12
xor    %ebp,%ebp
mov    0x4(%rsp),%r14d
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x1,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x2,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x3,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x4,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x5,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x6,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x7,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x8,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0x9,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0xa,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0xb,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0xc,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0xd,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0xe,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%edi
add    $0xf,%edi
call   1050 <readMemorySingleWord@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%ebp
add    $0xffffffff,%r14d
jne    11b0 <dumpMemory+0x70>
test   %r13d,%r13d
jle    13a4 <dumpMemory+0x264>
mov    0x4(%rsp),%ebp
shl    $0x4,%ebp
lea    0xcc6(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    %ebp,%ebx
lea    0xcbd(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
call   1050 <readMemorySingleWord@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
add    $0xffffffff,%r13d
jne    1370 <dumpMemory+0x230>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Memory Dump\0A\00"
@.str.1 = [25 x i8] c"from 0x%02x to 0x%02x: \0A\00"
@.str.2 = [9 x i8] c"0x%04x: \00"
@.str.3 = [8 x i8] c"0x%02x \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @dumpMemory(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = sub nsw i32 %11, %12
store i32 %13, i32* %7
store i32 16, i32* %8
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = sdiv i32 %14, %15
store i32 %16, i32* %9
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = srem i32 %17, %18
store i32 %19, i32* %10
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22)
store i32 0, i32* %5
br label %24
24: ; preds = %52, %2
%25 = load i32, i32* %5
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %55
28: ; preds = %24
%29 = load i32, i32* %5
%30 = load i32, i32* %8
%31 = mul nsw i32 %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %31)
store i32 0, i32* %6
br label %33
33: ; preds = %47, %28
%34 = load i32, i32* %6
%35 = load i32, i32* %8
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %50
37: ; preds = %33
%38 = load i32, i32* %3
%39 = load i32, i32* %5
%40 = load i32, i32* %8
%41 = mul nsw i32 %39, %40
%42 = load i32, i32* %6
%43 = add nsw i32 %41, %42
%44 = add nsw i32 %38, %43
%45 = call i32 @readMemorySingleWord(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %37
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %33
50: ; preds = %33
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %52
52: ; preds = %50
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %24
55: ; preds = %24
%56 = load i32, i32* %10
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %82
58: ; preds = %55
%59 = load i32, i32* %9
%60 = load i32, i32* %8
%61 = mul nsw i32 %59, %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %61)
store i32 0, i32* %5
br label %63
63: ; preds = %77, %58
%64 = load i32, i32* %5
%65 = load i32, i32* %10
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %80
67: ; preds = %63
%68 = load i32, i32* %3
%69 = load i32, i32* %9
%70 = load i32, i32* %8
%71 = mul nsw i32 %69, %70
%72 = load i32, i32* %5
%73 = add nsw i32 %71, %72
%74 = add nsw i32 %68, %73
%75 = call i32 @readMemorySingleWord(i32 %74)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %67
%78 = load i32, i32* %5
%79 = add nsw i32 %78, 1
store i32 %79, i32* %5
br label %63
80: ; preds = %63
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %80, %55
ret void
}

LLVM IR (-O2):
@.str.1 = [25 x i8] c"from 0x%02x to 0x%02x: \0A\00"
@.str.2 = [9 x i8] c"0x%04x: \00"
@.str.3 = [8 x i8] c"0x%02x \00"
@str = [12 x i8] c"Memory Dump\00"
define void @dumpMemory(i32 %0, i32 %1) {
%3 = sub nsw i32 %1, %0
%4 = sdiv i32 %3, 16
%5 = srem i32 %3, 16
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1)
%8 = icmp sgt i32 %3, 15
br i1 %8, label %9, label %64
9: ; preds = %2, %9
%10 = phi i32 [ %62, %9 ], [ 0, %2 ]
%11 = shl nsw i32 %10, 4
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = add i32 %11, %0
%14 = tail call i32 @readMemorySingleWord(i32 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = add i32 %13, 1
%17 = tail call i32 @readMemorySingleWord(i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = add i32 %13, 2
%20 = tail call i32 @readMemorySingleWord(i32 %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = add i32 %13, 3
%23 = tail call i32 @readMemorySingleWord(i32 %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = add i32 %13, 4
%26 = tail call i32 @readMemorySingleWord(i32 %25)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = add i32 %13, 5
%29 = tail call i32 @readMemorySingleWord(i32 %28)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = add i32 %13, 6
%32 = tail call i32 @readMemorySingleWord(i32 %31)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = add i32 %13, 7
%35 = tail call i32 @readMemorySingleWord(i32 %34)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = add i32 %13, 8
%38 = tail call i32 @readMemorySingleWord(i32 %37)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = add i32 %13, 9
%41 = tail call i32 @readMemorySingleWord(i32 %40)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = add i32 %13, 10
%44 = tail call i32 @readMemorySingleWord(i32 %43)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%46 = add i32 %13, 11
%47 = tail call i32 @readMemorySingleWord(i32 %46)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %47)
%49 = add i32 %13, 12
%50 = tail call i32 @readMemorySingleWord(i32 %49)
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = add i32 %13, 13
%53 = tail call i32 @readMemorySingleWord(i32 %52)
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = add i32 %13, 14
%56 = tail call i32 @readMemorySingleWord(i32 %55)
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = add i32 %13, 15
%59 = tail call i32 @readMemorySingleWord(i32 %58)
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = tail call i32 @putchar(i32 10)
%62 = add nuw nsw i32 %10, 1
%63 = icmp eq i32 %62, %4
br i1 %63, label %64, label %9
64: ; preds = %9, %2
%65 = icmp sgt i32 %5, 0
br i1 %65, label %66, label %79
66: ; preds = %64
%67 = shl nsw i32 %4, 4
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %67)
%69 = add i32 %67, %0
br label %70
70: ; preds = %66, %70
%71 = phi i32 [ 0, %66 ], [ %75, %70 ]
%72 = add i32 %69, %71
%73 = tail call i32 @readMemorySingleWord(i32 %72)
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %73)
%75 = add nuw nsw i32 %71, 1
%76 = icmp eq i32 %75, %5
br i1 %76, label %77, label %70
77: ; preds = %70
%78 = tail call i32 @putchar(i32 10)
br label %79
79: ; preds = %77, %64
ret void
}