#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void mymemdump(FILE *fd, char *p, int len) {
  struct X {
    char a;
    int i;
    char b;
    int *p;
  };
  int i;
  int count = 0;
  int c;
  char buffer[1000];
  int g;
  for (i = 0; i < len; i++) {
    if (i % 16 == 0) {
      fprintf(fd, "0x%016lX: ", (unsigned long)p);
    }
    for (g = i - 16; g < i; g++) {
      c = p[g] & 0xFF;
      buffer[count] = c;
      count++;
      fprintf(fd, "%02X ", c);
    }
    for (i = count - 16; i != count; i++) {
      int f = 0;
      fprintf(fd, "%i ", (i >= 16) ? c : '.');
      f++;
      if (f == 16) {
        break;
        fprintf(fd, "\n");
      }
    }
    if (i % 16 == 0) {
      fprintf(fd, "\n");
    }
  }
}


x86 assembly (clang, -O0):
<mymemdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12b8 <mymemdump+0x1a8>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116a <mymemdump+0x5a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0x414(%rbp)
mov    -0x414(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11de <mymemdump+0xce>
mov    -0x10(%rbp),%rax
movslq -0x414(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %al,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1176 <mymemdump+0x66>
mov    -0x1c(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     127f <mymemdump+0x16f>
movl   $0x0,-0x418(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x420(%rbp)
cmpl   $0x10,-0x18(%rbp)
jl     1220 <mymemdump+0x110>
mov    -0x20(%rbp),%eax
mov    %eax,-0x424(%rbp)
jmp    1230 <mymemdump+0x120>
mov    $0x2e,%eax
mov    %eax,-0x424(%rbp)
jmp    1230 <mymemdump+0x120>
mov    -0x420(%rbp),%rdi
mov    -0x424(%rbp),%edx
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
cmpl   $0x10,-0x418(%rbp)
jne    126c <mymemdump+0x15c>
jmp    127f <mymemdump+0x16f>
jmp    1271 <mymemdump+0x161>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e7 <mymemdump+0xd7>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12a5 <mymemdump+0x195>
mov    -0x8(%rbp),%rdi
lea    0xd77(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12aa <mymemdump+0x19a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1134 <mymemdump+0x24>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mymemdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0xc(%rsp)
test   %edx,%edx
jle    1377 <mymemdump+0x257>
mov    %rsi,%rbp
mov    %rdi,%r12
xor    %r15d,%r15d
xor    %r14d,%r14d
mov    %rdi,0x10(%rsp)
jmp    1162 <mymemdump+0x42>
nopl   (%rax)
lea    0x1(%r14),%r15d
cmp    0xc(%rsp),%r15d
mov    %r13,%rbp
jge    1377 <mymemdump+0x257>
test   $0xf,%r15b
jne    117c <mymemdump+0x5c>
mov    %r12,%rdi
lea    0xe8e(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x10(%r15),%eax
movslq %eax,%rbx
movslq %r15d,%r13
lea    0xe7e(%rip),%r12
nopl   (%rax)
movzbl 0x0(%rbp,%rbx,1),%r15d
add    $0x1,%r14d
mov    0x10(%rsp),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %r13,%rbx
jl     1190 <mymemdump+0x70>
mov    %rbp,%r13
lea    -0x1(%r14),%ebx
cmp    $0x1f,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    0x10(%rsp),%r12
mov    %r12,%rdi
lea    0xe3a(%rip),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x1e,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x1d,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x1c,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x1b,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x1a,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x19,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x18,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x17,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x16,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x15,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x14,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x13,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x12,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x11,%ebx
mov    $0x2e,%edx
cmovge %r15d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x10,%ebx
mov    $0x2e,%eax
cmovl  %eax,%r15d
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   $0xf,%r14b
jne    1150 <mymemdump+0x30>
mov    $0xa,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
jmp    1150 <mymemdump+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0x%016lX: \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [4 x i8] c"%i \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @mymemdump(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1000 x i8]
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %13
13: ; preds = %88, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %91
17: ; preds = %13
%18 = load i32, i32* %7
%19 = srem i32 %18, 16
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i32*, i32** %4
%23 = load i8*, i8** %5
%24 = ptrtoint i8* %23 to i64
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %24)
br label %26
26: ; preds = %21, %17
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 16
store i32 %28, i32* %11
br label %29
29: ; preds = %51, %26
%30 = load i32, i32* %11
%31 = load i32, i32* %7
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %54
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = and i32 %39, 255
store i32 %40, i32* %9
%41 = load i32, i32* %9
%42 = trunc i32 %41 to i8
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 %44
store i8 %42, i8* %45
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
%48 = load i32*, i32** %4
%49 = load i32, i32* %9
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %33
%52 = load i32, i32* %11
%53 = add nsw i32 %52, 1
store i32 %53, i32* %11
br label %29
54: ; preds = %29
%55 = load i32, i32* %8
%56 = sub nsw i32 %55, 16
store i32 %56, i32* %7
br label %57
57: ; preds = %77, %54
%58 = load i32, i32* %7
%59 = load i32, i32* %8
%60 = icmp ne i32 %58, %59
br i1 %60, label %61, label %80
61: ; preds = %57
store i32 0, i32* %12
%62 = load i32*, i32** %4
%63 = load i32, i32* %7
%64 = icmp sge i32 %63, 16
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = load i32, i32* %9
br label %68
67: ; preds = %61
br label %68
68: ; preds = %67, %65
%69 = phi i32 [ %66, %65 ], [ 46, %67 ]
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %69)
%71 = load i32, i32* %12
%72 = add nsw i32 %71, 1
store i32 %72, i32* %12
%73 = load i32, i32* %12
%74 = icmp eq i32 %73, 16
br i1 %74, label %75, label %76
75: ; preds = %68
br label %80
76: ; preds = %68
br label %77
77: ; preds = %76
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
store i32 %79, i32* %7
br label %57
80: ; preds = %75, %57
%81 = load i32, i32* %7
%82 = srem i32 %81, 16
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = load i32*, i32** %4
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %87
87: ; preds = %84, %80
br label %88
88: ; preds = %87
%89 = load i32, i32* %7
%90 = add nsw i32 %89, 1
store i32 %90, i32* %7
br label %13
91: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"0x%016lX: \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [4 x i8] c"%i \00"
define void @mymemdump(i32* nocapture %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %86
5: ; preds = %3
%6 = ptrtoint i8* %1 to i64
br label %7
7: ; preds = %5, %83
%8 = phi i32 [ 0, %5 ], [ %84, %83 ]
%9 = phi i32 [ 0, %5 ], [ %24, %83 ]
%10 = and i32 %8, 15
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %6)
br label %14
14: ; preds = %12, %7
%15 = add i32 %8, -16
%16 = sext i32 %15 to i64
%17 = sext i32 %8 to i64
br label %18
18: ; preds = %14, %18
%19 = phi i64 [ %16, %14 ], [ %26, %18 ]
%20 = phi i32 [ %9, %14 ], [ %24, %18 ]
%21 = getelementptr inbounds i8, i8* %1, i64 %19
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = add nsw i32 %20, 1
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%26 = add nsw i64 %19, 1
%27 = icmp slt i64 %26, %17
br i1 %27, label %18, label %28
28: ; preds = %18
%29 = zext i8 %22 to i32
%30 = icmp sgt i32 %20, 30
%31 = select i1 %30, i32 %29, i32 46
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = icmp sgt i32 %20, 29
%34 = select i1 %33, i32 %29, i32 46
%35 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = icmp sgt i32 %20, 28
%37 = select i1 %36, i32 %29, i32 46
%38 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = icmp sgt i32 %20, 27
%40 = select i1 %39, i32 %29, i32 46
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = icmp sgt i32 %20, 26
%43 = select i1 %42, i32 %29, i32 46
%44 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = icmp sgt i32 %20, 25
%46 = select i1 %45, i32 %29, i32 46
%47 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = icmp sgt i32 %20, 24
%49 = select i1 %48, i32 %29, i32 46
%50 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = icmp sgt i32 %20, 23
%52 = select i1 %51, i32 %29, i32 46
%53 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%54 = icmp sgt i32 %20, 22
%55 = select i1 %54, i32 %29, i32 46
%56 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = icmp sgt i32 %20, 21
%58 = select i1 %57, i32 %29, i32 46
%59 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = icmp sgt i32 %20, 20
%61 = select i1 %60, i32 %29, i32 46
%62 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %61)
%63 = icmp sgt i32 %20, 19
%64 = select i1 %63, i32 %29, i32 46
%65 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %64)
%66 = icmp sgt i32 %20, 18
%67 = select i1 %66, i32 %29, i32 46
%68 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %67)
%69 = icmp sgt i32 %20, 17
%70 = select i1 %69, i32 %29, i32 46
%71 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %70)
%72 = icmp sgt i32 %20, 16
%73 = select i1 %72, i32 %29, i32 46
%74 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %73)
%75 = icmp sgt i32 %20, 15
%76 = select i1 %75, i32 %29, i32 46
%77 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %76)
%78 = add nsw i32 %20, 1
%79 = and i32 %78, 15
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %28
%82 = tail call i32 @fputc(i32 10, i32* %0)
br label %83
83: ; preds = %28, %81
%84 = add nsw i32 %20, 2
%85 = icmp slt i32 %84, %2
br i1 %85, label %7, label %86
86: ; preds = %83, %3
ret void
}