#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 dump_memory(void *p, int len) {
  int i;
  printf("Address          char   hexCh         shor         integer           "
         "    float         foubleFloat\n");
  for (i = 0; i < len; i++) {
    printf("0x%08x\t", p + i);
    if (((*(unsigned char *)(p + i)) < 32) ||
        ((*(unsigned char *)(p + i)) > 126)) {
      printf("  ?\t");
    } else {
      printf("%3c\t", *(unsigned char *)(p + i));
    }
    printf("0x%02x\t", *(unsigned char *)(p + i));
    if (i % 2 == 0) {
      printf("%+12hd\t", *(short *)(p + i));
    }
    if (i % 4 == 0) {
      printf("%+12d\t", *(int *)(p + i));
    }
    if (i % 4 == 0) {
      printf("\t%+.6e\t", *(float *)(p + i));
    }
    if (i % 8 == 0) {
      printf("%+.6e\t", *(double *)(p + i));
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dump_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12a3 <dump_memory+0x193>
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
add    %rax,%rsi
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     1183 <dump_memory+0x73>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    1196 <dump_memory+0x86>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b0 <dump_memory+0xa0>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f8 <dump_memory+0xe8>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movswl (%rax,%rcx,1),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1225 <dump_memory+0x115>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1258 <dump_memory+0x148>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,1),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1287 <dump_memory+0x177>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,1),%xmm0
lea    0xe0e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <dump_memory+0x24>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xeea(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jle    1252 <dump_memory+0x122>
mov    %ebp,%r13d
lea    0xea2(%rip),%r14
lea    0xead(%rip),%r12
xor    %ebp,%ebp
jmp    1187 <dump_memory+0x57>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     1252 <dump_memory+0x122>
lea    (%rbx,%rbp,1),%r15
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%rbp,1),%esi
lea    -0x7f(%rsi),%eax
cmp    $0xa0,%al
ja     11c0 <dump_memory+0x90>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ce <dump_memory+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%r15),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x1,%bpl
je     11f0 <dump_memory+0xc0>
test   $0x3,%bpl
je     1208 <dump_memory+0xd8>
test   $0x7,%bpl
jne    1170 <dump_memory+0x40>
jmp    123a <dump_memory+0x10a>
movswl (%rbx,%rbp,1),%esi
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x3,%bpl
jne    11e8 <dump_memory+0xb8>
mov    (%rbx,%rbp,1),%esi
lea    0xe10(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movss  (%rbx,%rbp,1),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe00(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
test   $0x7,%bpl
jne    1170 <dump_memory+0x40>
movsd  (%rbx,%rbp,1),%xmm0
lea    0xde4(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1170 <dump_memory+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [100 x i8] c"Address char hexCh shor integer float foubleFloat\0A\00"
@.str.1 = [8 x i8] c"0x%08x\09\00"
@.str.2 = [5 x i8] c" ?\09\00"
@.str.3 = [5 x i8] c"%3c\09\00"
@.str.4 = [8 x i8] c"0x%02x\09\00"
@.str.5 = [8 x i8] c"%+12hd\09\00"
@.str.6 = [7 x i8] c"%+12d\09\00"
@.str.7 = [8 x i8] c"\09%+.6e\09\00"
@.str.8 = [7 x i8] c"%+.6e\09\00"
@.str.9 = [2 x i8] c"\0A\00"
define void @dump_memory(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %101, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %104
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr i8, i8* %12, i64 %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = icmp slt i32 %22, 32
br i1 %23, label %32, label %24
24: ; preds = %11
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = icmp sgt i32 %30, 126
br i1 %31, label %32, label %34
32: ; preds = %24, %11
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %42
34: ; preds = %24
%35 = load i8*, i8** %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %34, %32
%43 = load i8*, i8** %3
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %5
%51 = srem i32 %50, 2
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %62
53: ; preds = %42
%54 = load i8*, i8** %3
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr i8, i8* %54, i64 %56
%58 = bitcast i8* %57 to i16*
%59 = load i16, i16* %58
%60 = sext i16 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %53, %42
%63 = load i32, i32* %5
%64 = srem i32 %63, 4
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %74
66: ; preds = %62
%67 = load i8*, i8** %3
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr i8, i8* %67, i64 %69
%71 = bitcast i8* %70 to i32*
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %66, %62
%75 = load i32, i32* %5
%76 = srem i32 %75, 4
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %87
78: ; preds = %74
%79 = load i8*, i8** %3
%80 = load i32, i32* %5
%81 = sext i32 %80 to i64
%82 = getelementptr i8, i8* %79, i64 %81
%83 = bitcast i8* %82 to float*
%84 = load float, float* %83
%85 = fpext float %84 to double
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), double %85)
br label %87
87: ; preds = %78, %74
%88 = load i32, i32* %5
%89 = srem i32 %88, 8
%90 = icmp eq i32 %89, 0
br i1 %90, label %91, label %99
91: ; preds = %87
%92 = load i8*, i8** %3
%93 = load i32, i32* %5
%94 = sext i32 %93 to i64
%95 = getelementptr i8, i8* %92, i64 %94
%96 = bitcast i8* %95 to double*
%97 = load double, double* %96
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), double %97)
br label %99
99: ; preds = %91, %87
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %101
101: ; preds = %99
%102 = load i32, i32* %5
%103 = add nsw i32 %102, 1
store i32 %103, i32* %5
br label %7
104: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"0x%08x\09\00"
@.str.2 = [5 x i8] c" ?\09\00"
@.str.3 = [5 x i8] c"%3c\09\00"
@.str.4 = [8 x i8] c"0x%02x\09\00"
@.str.5 = [8 x i8] c"%+12hd\09\00"
@.str.6 = [7 x i8] c"%+12d\09\00"
@.str.7 = [8 x i8] c"\09%+.6e\09\00"
@.str.8 = [7 x i8] c"%+.6e\09\00"
@str = [99 x i8] c"Address char hexCh shor integer float foubleFloat\00"
define void @dump_memory(i8* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %53
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %49
%8 = phi i64 [ 0, %5 ], [ %51, %49 ]
%9 = getelementptr i8, i8* %0, i64 %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i8, i8* %9
%12 = add i8 %11, -127
%13 = icmp ult i8 %12, -95
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %19
16: ; preds = %7
%17 = zext i8 %11 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %14
%20 = load i8, i8* %9
%21 = zext i8 %20 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = trunc i64 %8 to i32
%24 = and i32 %23, 1
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = bitcast i8* %9 to i16*
%28 = load i16, i16* %27
%29 = sext i16 %28 to i32
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %26, %19
%32 = and i32 %23, 3
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = bitcast i8* %9 to i32*
%36 = load i32, i32* %35
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %36)
%38 = bitcast i8* %9 to float*
%39 = load float, float* %38
%40 = fpext float %39 to double
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), double %40)
br label %42
42: ; preds = %31, %34
%43 = and i32 %23, 7
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = bitcast i8* %9 to double*
%47 = load double, double* %46
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), double %47)
br label %49
49: ; preds = %45, %42
%50 = tail call i32 @putchar(i32 10)
%51 = add nuw nsw i64 %8, 1
%52 = icmp eq i64 %51, %6
br i1 %52, label %53, label %7
53: ; preds = %49, %2
ret void
}