#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 *, unsigned char);
int /*<<< orphan*/ puts(char *);
void DumpMem_Real(void *addr, unsigned int count, unsigned int size) {
  unsigned int *data_dword = addr;
  unsigned short *data_word = addr;
  unsigned char *data_byte = addr;
  unsigned int i;
  puts("");
  printf("Dump of offset %.8X\n", (int)addr);
  puts("-------------------------------");
  switch (size) {
  case 4:
    for (i = 0; i < count; i++) {
      printf("%.8X  ", data_dword[i]);
    }
    break;
  case 2:
    for (i = 0; i < count; i++) {
      printf("%.4X ", data_word[i]);
    }
    break;
  case 1:
  default:
    for (i = 0; i < count; i++) {
      printf("%.2X ", data_byte[i]);
      if ((i + 1) % 16 == 0) {
        puts("");
      }
    }
  }
  puts("");
}


x86 assembly (clang, -O0):
<DumpMem_Real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
movzbl -0x8(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x1,%eax
je     1227 <DumpMem_Real+0x107>
jmp    1186 <DumpMem_Real+0x66>
mov    -0x30(%rbp),%eax
sub    $0x2,%eax
je     11e7 <DumpMem_Real+0xc7>
jmp    1197 <DumpMem_Real+0x77>
mov    -0x30(%rbp),%eax
sub    $0x4,%eax
jne    122c <DumpMem_Real+0x10c>
jmp    11a8 <DumpMem_Real+0x88>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11e2 <DumpMem_Real+0xc2>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
lea    0xe69(%rip),%rdi
movzbl %al,%esi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11af <DumpMem_Real+0x8f>
jmp    128c <DumpMem_Real+0x16c>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1222 <DumpMem_Real+0x102>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,2),%ax
lea    0xe30(%rip),%rdi
movzbl %al,%esi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ee <DumpMem_Real+0xce>
jmp    128c <DumpMem_Real+0x16c>
jmp    122c <DumpMem_Real+0x10c>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1287 <DumpMem_Real+0x167>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
lea    0xdf5(%rip),%rdi
movzbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1274 <DumpMem_Real+0x154>
lea    0xda5(%rip),%rdi
call   1030 <puts@plt>
jmp    1279 <DumpMem_Real+0x159>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1233 <DumpMem_Real+0x113>
jmp    128c <DumpMem_Real+0x16c>
lea    0xd81(%rip),%rdi
call   1030 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DumpMem_Real>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
movzbl %bl,%esi
lea    0xead(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x4,%ebp
je     11a7 <DumpMem_Real+0x77>
cmp    $0x2,%ebp
jne    11d7 <DumpMem_Real+0xa7>
test   %r14d,%r14d
je     1221 <DumpMem_Real+0xf1>
mov    %r14d,%r15d
xor    %ebp,%ebp
lea    0xeb9(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx,%rbp,2),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1190 <DumpMem_Real+0x60>
jmp    1221 <DumpMem_Real+0xf1>
test   %r14d,%r14d
je     1221 <DumpMem_Real+0xf1>
mov    %r14d,%r15d
xor    %ebp,%ebp
lea    0xe7d(%rip),%r14
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%rbp,4),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11c0 <DumpMem_Real+0x90>
jmp    1221 <DumpMem_Real+0xf1>
test   %r14d,%r14d
je     1221 <DumpMem_Real+0xf1>
mov    %r14d,%r15d
neg    %r15
mov    $0x1,%ebp
lea    0xe54(%rip),%r14
jmp    1202 <DumpMem_Real+0xd2>
lea    (%r15,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
je     1221 <DumpMem_Real+0xf1>
movzbl -0x1(%rbx,%rbp,1),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
test   $0xf,%bpl
jne    11f0 <DumpMem_Real+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11f0 <DumpMem_Real+0xc0>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.1 = [21 x i8] c"Dump of offset %.8X\0A\00"
@.str.2 = [32 x i8] c"-------------------------------\00"
@.str.3 = [7 x i8] c"%.8X \00"
@.str.4 = [6 x i8] c"%.4X \00"
@.str.5 = [6 x i8] c"%.2X \00"
define void @DumpMem_Real(i8* %0, i32 %1, i32 %2) {
%4 = bitcast i8* %0 to i32*
%5 = bitcast i8* %0 to i16*
%6 = tail call i32 @putchar(i32 10)
%7 = ptrtoint i8* %0 to i64
%8 = trunc i64 %7 to i8
%9 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
switch i32 %2, label %19 [
i32 4, label %15
i32 2, label %11
]
11: ; preds = %3
%12 = icmp eq i32 %1, 0
br i1 %12, label %51, label %13
13: ; preds = %11
%14 = zext i32 %1 to i64
br label %31
15: ; preds = %3
%16 = icmp eq i32 %1, 0
br i1 %16, label %51, label %17
17: ; preds = %15
%18 = zext i32 %1 to i64
br label %23
19: ; preds = %3
%20 = icmp eq i32 %1, 0
br i1 %20, label %51, label %21
21: ; preds = %19
%22 = zext i32 %1 to i64
br label %39
23: ; preds = %17, %23
%24 = phi i64 [ 0, %17 ], [ %29, %23 ]
%25 = getelementptr inbounds i32, i32* %4, i64 %24
%26 = load i32, i32* %25
%27 = trunc i32 %26 to i8
%28 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %27)
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %18
br i1 %30, label %51, label %23
31: ; preds = %13, %31
%32 = phi i64 [ 0, %13 ], [ %37, %31 ]
%33 = getelementptr inbounds i16, i16* %5, i64 %32
%34 = load i16, i16* %33
%35 = trunc i16 %34 to i8
%36 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %35)
%37 = add nuw nsw i64 %32, 1
%38 = icmp eq i64 %37, %14
br i1 %38, label %51, label %31
39: ; preds = %21, %49
%40 = phi i64 [ 0, %21 ], [ %44, %49 ]
%41 = getelementptr inbounds i8, i8* %0, i64 %40
%42 = load i8, i8* %41
%43 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %42)
%44 = add nuw nsw i64 %40, 1
%45 = and i64 %44, 15
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %39
%48 = tail call i32 @putchar(i32 10)
br label %49
49: ; preds = %39, %47
%50 = icmp eq i64 %44, %22
br i1 %50, label %51, label %39
51: ; preds = %31, %23, %49, %11, %15, %19
%52 = tail call i32 @putchar(i32 10)
ret void
}