#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 *, ...);
int memdmp_lst(unsigned char *startpt_p, int length, int startpt) {
  int i, j;
  printf("    :  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F\n");
  printf("----:------------------------------------------------\n");
  for (i = 0; i < (length / 16); i++) {
    printf("%3X : ", ((startpt + (i << 4)) >> 4) & 0xFFF);
    for (j = 0; j < 16; j++) {
      printf("%2X ", (startpt_p[16 * i + j] & 0xFF));
    }
    printf("\n");
  }
  return 1;
}


x86 assembly (clang, -O0):
<memdmp_lst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11e8 <memdmp_lst+0xd8>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
add    %eax,%esi
sar    $0x4,%esi
and    $0xfff,%esi
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    11cc <memdmp_lst+0xbc>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118c <memdmp_lst+0x7c>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1145 <memdmp_lst+0x35>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memdmp_lst>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
lea    0xeeb(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x10,%r14d
jl     129d <memdmp_lst+0x16d>
and    $0xfffffff0,%r14d
shr    $0x4,%r12d
lea    0xe8b(%rip),%r15
lea    0xe8b(%rip),%r13
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %r12d,%esi
and    $0xfff,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x1(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x2(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x3(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x4(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x5(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x6(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x7(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x8(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x9(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xa(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xb(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xc(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xd(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xe(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xf(%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
add    $0x10,%rbp
cmp    %rbp,%r14
jne    1180 <memdmp_lst+0x50>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c" : 0 1 2 3 4 5 6 7 8 9 A B C D E F\0A\00"
@.str.1 = [55 x i8] c"----:------------------------------------------------\0A\00"
@.str.2 = [7 x i8] c"%3X : \00"
@.str.3 = [5 x i8] c"%2X \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @memdmp_lst(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %11
11: ; preds = %44, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = sdiv i32 %13, 16
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %47
16: ; preds = %11
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = shl i32 %18, 4
%20 = add nsw i32 %17, %19
%21 = ashr i32 %20, 4
%22 = and i32 %21, 4095
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %22)
store i32 0, i32* %8
br label %24
24: ; preds = %39, %16
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 16
br i1 %26, label %27, label %42
27: ; preds = %24
%28 = load i8*, i8** %4
%29 = load i32, i32* %7
%30 = mul nsw i32 16, %29
%31 = load i32, i32* %8
%32 = add nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %28, i64 %33
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = and i32 %36, 255
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %27
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %24
42: ; preds = %24
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %11
47: ; preds = %11
ret i32 1
}

LLVM IR (-O2):
@.str.2 = [7 x i8] c"%3X : \00"
@.str.3 = [5 x i8] c"%2X \00"
@str = [54 x i8] c" : 0 1 2 3 4 5 6 7 8 9 A B C D E F\00"
@str.5 = [54 x i8] c"----:------------------------------------------------\00"
define i32 @memdmp_lst(i8* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.5, i64 0, i64 0))
%6 = icmp sgt i32 %1, 15
br i1 %6, label %7, label %100
7: ; preds = %3
%8 = lshr i32 %1, 4
%9 = lshr i32 %2, 4
%10 = zext i32 %8 to i64
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %98, %11 ]
%13 = trunc i64 %12 to i32
%14 = add i32 %9, %13
%15 = and i32 %14, 4095
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = shl nsw i64 %12, 4
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = or i64 %17, 1
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = or i64 %17, 2
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = or i64 %17, 3
%33 = getelementptr inbounds i8, i8* %0, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = or i64 %17, 4
%38 = getelementptr inbounds i8, i8* %0, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = or i64 %17, 5
%43 = getelementptr inbounds i8, i8* %0, i64 %42
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = or i64 %17, 6
%48 = getelementptr inbounds i8, i8* %0, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = or i64 %17, 7
%53 = getelementptr inbounds i8, i8* %0, i64 %52
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %55)
%57 = or i64 %17, 8
%58 = getelementptr inbounds i8, i8* %0, i64 %57
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = or i64 %17, 9
%63 = getelementptr inbounds i8, i8* %0, i64 %62
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %65)
%67 = or i64 %17, 10
%68 = getelementptr inbounds i8, i8* %0, i64 %67
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %70)
%72 = or i64 %17, 11
%73 = getelementptr inbounds i8, i8* %0, i64 %72
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %75)
%77 = or i64 %17, 12
%78 = getelementptr inbounds i8, i8* %0, i64 %77
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %80)
%82 = or i64 %17, 13
%83 = getelementptr inbounds i8, i8* %0, i64 %82
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %85)
%87 = or i64 %17, 14
%88 = getelementptr inbounds i8, i8* %0, i64 %87
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %90)
%92 = or i64 %17, 15
%93 = getelementptr inbounds i8, i8* %0, i64 %92
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %95)
%97 = tail call i32 @putchar(i32 10)
%98 = add nuw nsw i64 %12, 1
%99 = icmp eq i64 %98, %10
br i1 %99, label %100, label %11
100: ; preds = %11, %3
ret i32 1
}