#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 */
scalar_t__ isprint(char);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ putchar(char);
void memdump(char *start, char *end) {
  char *i;
  int j = 0;
  printf("Memory contents from %p to %p:\n", start, end);
  for (i = start; i < end; i++) {
    putchar(isprint(*i) ? *i : '.');
    if (!((++j) % 64))
      putchar('\n');
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<memdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11e8 <memdump+0xb8>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     1196 <memdump+0x66>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x20(%rbp)
jmp    11a3 <memdump+0x73>
mov    $0x2e,%eax
mov    %eax,-0x20(%rbp)
jmp    11a3 <memdump+0x73>
mov    -0x20(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x40,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d2 <memdump+0xa2>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11d7 <memdump+0xa7>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1163 <memdump+0x33>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memdump>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xebe(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
cmp    %r14,%r15
jae    119d <memdump+0x6d>
sub    %r15,%r14
xor    %ebx,%ebx
jmp    1169 <memdump+0x39>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r14
je     119d <memdump+0x6d>
movsbl (%r15,%rbx,1),%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     1180 <memdump+0x50>
movzbl (%r15,%rbx,1),%eax
jmp    1182 <memdump+0x52>
nop
mov    $0x2e,%al
movsbl %al,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%eax
test   $0x3f,%al
jne    1160 <memdump+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1160 <memdump+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Memory contents from %p to %p:\0A\00"
define void @memdump(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%10 = load i8*, i8** %3
store i8* %10, i8** %5
br label %11
11: ; preds = %36, %2
%12 = load i8*, i8** %5
%13 = load i8*, i8** %4
%14 = icmp ult i8* %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = call i64 @isprint(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
br label %25
24: ; preds = %15
br label %25
25: ; preds = %24, %20
%26 = phi i32 [ %23, %20 ], [ 46, %24 ]
%27 = trunc i32 %26 to i8
%28 = call i32 @putchar(i8 signext %27)
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
%31 = srem i32 %30, 64
%32 = icmp ne i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %25
%34 = call i32 @putchar(i8 signext 10)
br label %35
35: ; preds = %33, %25
br label %36
36: ; preds = %35
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
br label %11
39: ; preds = %11
%40 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"Memory contents from %p to %p:\0A\00"
define void @memdump(i8* %0, i8* %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%4 = icmp ult i8* %0, %1
br i1 %4, label %5, label %29
5: ; preds = %2
%6 = ptrtoint i8* %1 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = getelementptr i8, i8* %0, i64 %8
br label %10
10: ; preds = %5, %26
%11 = phi i32 [ %21, %26 ], [ 0, %5 ]
%12 = phi i8* [ %27, %26 ], [ %0, %5 ]
%13 = load i8, i8* %12
%14 = tail call i64 @isprint(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %10
%17 = load i8, i8* %12
br label %18
18: ; preds = %10, %16
%19 = phi i8 [ %17, %16 ], [ 46, %10 ]
%20 = tail call i32 @putchar(i8 signext %19)
%21 = add nuw nsw i32 %11, 1
%22 = and i32 %21, 63
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = tail call i32 @putchar(i8 signext 10)
br label %26
26: ; preds = %18, %24
%27 = getelementptr inbounds i8, i8* %12, i64 1
%28 = icmp eq i8* %27, %9
br i1 %28, label %29, label %10
29: ; preds = %26, %2
%30 = tail call i32 @putchar(i8 signext 10)
ret void
}