#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__ hasDouble(int);
scalar_t__ hasIntAndFloat(int);
scalar_t__ hasShort(int);
scalar_t__ isCharVisible(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void dump_memory(void *p, int len) {
  void *memAddress;
  unsigned char mChar;
  unsigned short mShort;
  unsigned int mInt;
  float mFloat;
  double mDouble;
  int i;
  printf("%s\t\t%s\t%s\t%s\t%s\t\t%s\t\t%s\n", "address", "char", "hexCh",
         "short", "integer", "float", "doubleFloat");
  for (i = 0; i < len; i++) {
    memAddress = p + i;
    mChar = *(unsigned char *)(p + i);
    mShort = *(unsigned short *)(p + i);
    mInt = *(unsigned int *)(p + i);
    mFloat = *(float *)(p + i);
    mDouble = *(double *)(p + i);
    if (isCharVisible(mChar))
      printf("%8p:\t%c\t0x%02x\t", memAddress, mChar, mChar);
    else
      printf("%8p:\t?\t0x%02x\t", memAddress, mChar);
    if (hasShort(i))
      printf("%+5hu\t", mShort);
    if (hasIntAndFloat(i))
      printf("%+10d\t%+e\t", mInt, mFloat);
    if (hasDouble(i))
      printf("%+e", mDouble);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dump_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xeac(%rip),%rsi
lea    0xead(%rip),%rdx
lea    0xeab(%rip),%rcx
lea    0xeaa(%rip),%r8
lea    0xea9(%rip),%r9
lea    0xeaa(%rip),%r10
lea    0xea9(%rip),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12f2 <dump_memory+0x1a2>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%ax
mov    %ax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,1),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,1),%xmm0
movsd  %xmm0,-0x30(%rbp)
movzbl -0x19(%rbp),%edi
call   1060 <isCharVisible@plt>
cmp    $0x0,%rax
je     124b <dump_memory+0xfb>
mov    -0x18(%rbp),%rsi
movzbl -0x19(%rbp),%edx
movzbl -0x19(%rbp),%ecx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1261 <dump_memory+0x111>
mov    -0x18(%rbp),%rsi
movzbl -0x19(%rbp),%edx
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%edi
call   1070 <hasShort@plt>
cmp    $0x0,%rax
je     1285 <dump_memory+0x135>
movzwl -0x1c(%rbp),%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%edi
call   1050 <hasIntAndFloat@plt>
cmp    $0x0,%rax
je     12b1 <dump_memory+0x161>
mov    -0x20(%rbp),%esi
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%edi
call   1030 <hasDouble@plt>
cmp    $0x0,%rax
je     12d6 <dump_memory+0x186>
movsd  -0x30(%rbp),%xmm0
lea    0xdae(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ae <dump_memory+0x5e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xec6(%rip),%r10
lea    0xeb9(%rip),%r11
lea    0xe78(%rip),%rdi
lea    0xe8a(%rip),%rsi
lea    0xe8b(%rip),%rdx
lea    0xe89(%rip),%rcx
lea    0xe88(%rip),%r8
lea    0xe87(%rip),%r9
xor    %eax,%eax
push   %r10
push   %r11
call   1050 <printf@plt>
add    $0x10,%rsp
test   %ebp,%ebp
jle    12b3 <dump_memory+0x153>
mov    %ebp,%eax
mov    %rax,0x8(%rsp)
xor    %r14d,%r14d
jmp    11e9 <dump_memory+0x89>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r14,0x8(%rsp)
je     12b3 <dump_memory+0x153>
lea    (%rbx,%r14,1),%rbp
movzbl (%rbx,%r14,1),%r13d
movzwl (%rbx,%r14,1),%r12d
mov    (%rbx,%r14,1),%r15d
movsd  (%rbx,%r14,1),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r13d,%edi
call   1070 <isCharVisible@plt>
test   %rax,%rax
je     1230 <dump_memory+0xd0>
lea    0xe31(%rip),%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1244 <dump_memory+0xe4>
nopl   (%rax)
lea    0xe25(%rip),%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
call   1080 <hasShort@plt>
test   %rax,%rax
je     1262 <dump_memory+0x102>
lea    0xe13(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
call   1060 <hasIntAndFloat@plt>
test   %rax,%rax
je     1289 <dump_memory+0x129>
movd   %r15d,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf3(%rip),%rdi
mov    %r15d,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r14d,%edi
call   1040 <hasDouble@plt>
test   %rax,%rax
je     11d0 <dump_memory+0x70>
lea    0xddc(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
jmp    11d0 <dump_memory+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c"%s\09\09%s\09%s\09%s\09%s\09\09%s\09\09%s\0A\00"
@.str.1 = [8 x i8] c"address\00"
@.str.2 = [5 x i8] c"char\00"
@.str.3 = [6 x i8] c"hexCh\00"
@.str.4 = [6 x i8] c"short\00"
@.str.5 = [8 x i8] c"integer\00"
@.str.6 = [6 x i8] c"float\00"
@.str.7 = [12 x i8] c"doubleFloat\00"
@.str.8 = [16 x i8] c"%8p:\09%c\090x%02x\09\00"
@.str.9 = [15 x i8] c"%8p:\09?\090x%02x\09\00"
@.str.10 = [7 x i8] c"%+5hu\09\00"
@.str.11 = [11 x i8] c"%+10d\09%+e\09\00"
@.str.12 = [4 x i8] c"%+e\00"
define void @dump_memory(i8* %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %47
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %43
%8 = phi i64 [ 0, %5 ], [ %45, %43 ]
%9 = getelementptr i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = bitcast i8* %9 to i16*
%12 = load i16, i16* %11
%13 = bitcast i8* %9 to i32*
%14 = load i32, i32* %13
%15 = bitcast i32 %14 to float
%16 = bitcast i8* %9 to double*
%17 = load double, double* %16
%18 = tail call i64 @isCharVisible(i8 zeroext %10)
%19 = icmp eq i64 %18, 0
%20 = zext i8 %10 to i32
br i1 %19, label %23, label %21
21: ; preds = %7
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %9, i32 %20, i32 %20)
br label %25
23: ; preds = %7
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %9, i32 %20)
br label %25
25: ; preds = %23, %21
%26 = trunc i64 %8 to i32
%27 = tail call i64 @hasShort(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = zext i16 %12 to i32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %25
%33 = tail call i64 @hasIntAndFloat(i32 %26)
%34 = icmp eq i64 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = fpext float %15 to double
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32 %14, double %36)
br label %38
38: ; preds = %35, %32
%39 = tail call i64 @hasDouble(i32 %26)
%40 = icmp eq i64 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %38
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), double %17)
br label %43
43: ; preds = %41, %38
%44 = tail call i32 @putchar(i32 10)
%45 = add nuw nsw i64 %8, 1
%46 = icmp eq i64 %45, %6
br i1 %46, label %47, label %7
47: ; preds = %43, %2
ret void
}