#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*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ isprint(char);
int /*<<< orphan*/ stderr;
void hexdump(char *hbuf, int start, int stop, int ascii) {
  char c;
  int diff, i;
  while (start < stop) {
    diff = stop - start;
    if (diff > 16)
      diff = 16;
    fprintf(stderr, ":%08X  ", start);
    for (i = 0; i < diff; i++) {
      if (8 == i)
        fprintf(stderr, " ");
      fprintf(stderr, "%02X ", (unsigned char)*(hbuf + start + i));
    }
    if (ascii) {
      for (i = diff; i < 16; i++)
        fprintf(stderr, "   ");
      for (i = 0; i < diff; i++) {
        c = *(hbuf + start + i);
        fprintf(stderr, "%c", isprint(c) ? c : '.');
      }
    }
    fprintf(stderr, "\n");
    start += 16;
  }
}


x86 assembly (clang, -O0):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12d0 <hexdump+0x1b0>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jle    115b <hexdump+0x3b>
movl   $0x10,-0x1c(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e5 <hexdump+0xc5>
mov    $0x8,%eax
cmp    -0x20(%rbp),%eax
jne    11ad <hexdump+0x8d>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117c <hexdump+0x5c>
cmpl   $0x0,-0x14(%rbp)
je     12ab <hexdump+0x18b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jge    1224 <hexdump+0x104>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11f5 <hexdump+0xd5>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12a6 <hexdump+0x186>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
movsbl -0x15(%rbp),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1277 <hexdump+0x157>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1284 <hexdump+0x164>
mov    $0x2e,%eax
mov    %eax,-0x28(%rbp)
jmp    1284 <hexdump+0x164>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%edx
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    122b <hexdump+0x10b>
jmp    12ab <hexdump+0x18b>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <hexdump+0x15>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,0x4(%rsp)
cmp    %edx,%esi
jge    12bf <hexdump+0x19f>
mov    %rdi,%r14
movslq %esi,%rax
movslq %edx,%r12
add    %rax,%r14
mov    %r12,%rcx
sub    %rax,%rcx
mov    0x2e8d(%rip),%rbx
mov    %r12,0x10(%rsp)
jmp    1199 <hexdump+0x79>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
lea    0xeaa(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x20(%rsp),%rax
add    $0x10,%rax
add    $0x10,%r14
mov    0x18(%rsp),%rcx
add    $0xfffffffffffffff0,%rcx
mov    0x10(%rsp),%r12
cmp    %r12,%rax
mov    %r13,%rbx
jge    12bf <hexdump+0x19f>
cmp    $0x10,%rcx
mov    $0x10,%ebp
mov    %rcx,0x18(%rsp)
cmovl  %rcx,%rbp
sub    %rax,%r12
cmp    $0x10,%r12
mov    $0x10,%ecx
cmovl  %r12,%rcx
mov    %rcx,0x8(%rsp)
mov    (%rbx),%edi
lea    0xe37(%rip),%rsi
mov    %rax,0x20(%rsp)
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r12,%r12
jle    1230 <hexdump+0x110>
movslq 0x8(%rsp),%r15
xor    %r13d,%r13d
jmp    120e <hexdump+0xee>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edi
movzbl (%r14,%r13,1),%edx
lea    0xe0a(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r13
cmp    %r15,%r13
jge    1230 <hexdump+0x110>
cmp    $0x8,%r13
jne    11f0 <hexdump+0xd0>
mov    (%rbx),%edi
lea    0xdf3(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11f0 <hexdump+0xd0>
cs nopw 0x0(%rax,%rax,1)
cmpl   $0x0,0x4(%rsp)
mov    %rbx,%r13
je     1160 <hexdump+0x40>
cmp    $0xf,%r12
lea    0xdc5(%rip),%rbx
jg     1266 <hexdump+0x146>
add    $0xffffffff,%ebp
xchg   %ax,%ax
mov    0x0(%r13),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebp
cmp    $0xf,%ebp
jl     1250 <hexdump+0x130>
test   %r12,%r12
jle    1160 <hexdump+0x40>
movslq 0x8(%rsp),%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%r12d
mov    0x0(%r13),%r15d
mov    %r12d,%edi
call   1040 <isprint@plt>
test   %rax,%rax
mov    $0x2e,%eax
cmove  %eax,%r12d
mov    %r15d,%edi
lea    0xd6b(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbp,%rbx
jl     1280 <hexdump+0x160>
jmp    1160 <hexdump+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c":%08X \00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"%02X \00"
@.str.3 = [4 x i8] c" \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c"\0A\00"
define void @hexdump(i8* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %1, %2
br i1 %5, label %6, label %69
6: ; preds = %4
%7 = icmp eq i32 %3, 0
%8 = sext i32 %1 to i64
%9 = sext i32 %2 to i64
br label %10
10: ; preds = %6, %64
%11 = phi i64 [ %8, %6 ], [ %67, %64 ]
%12 = sub nsw i64 %9, %11
%13 = icmp slt i64 %12, 16
%14 = icmp slt i64 %12, 16
%15 = select i1 %14, i64 %12, i64 16
%16 = trunc i64 %15 to i32
%17 = load i32, i32* @stderr
%18 = trunc i64 %11 to i32
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = icmp sgt i64 %12, 0
br i1 %20, label %21, label %39
21: ; preds = %10
%22 = getelementptr inbounds i8, i8* %0, i64 %11
%23 = shl i64 %15, 32
%24 = ashr exact i64 %23, 32
br label %25
25: ; preds = %21, %31
%26 = phi i64 [ 0, %21 ], [ %37, %31 ]
%27 = icmp eq i64 %26, 8
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %28, %25
%32 = load i32, i32* @stderr
%33 = getelementptr inbounds i8, i8* %22, i64 %26
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = add nuw nsw i64 %26, 1
%38 = icmp slt i64 %37, %24
br i1 %38, label %25, label %39
39: ; preds = %31, %10
br i1 %7, label %64, label %40
40: ; preds = %39
br i1 %13, label %46, label %41
41: ; preds = %46, %40
br i1 %20, label %42, label %64
42: ; preds = %41
%43 = getelementptr inbounds i8, i8* %0, i64 %11
%44 = shl i64 %15, 32
%45 = ashr exact i64 %44, 32
br label %52
46: ; preds = %40, %46
%47 = phi i32 [ %50, %46 ], [ %16, %40 ]
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%50 = add nsw i32 %47, 1
%51 = icmp slt i32 %47, 15
br i1 %51, label %46, label %41
52: ; preds = %42, %52
%53 = phi i64 [ 0, %42 ], [ %62, %52 ]
%54 = getelementptr inbounds i8, i8* %43, i64 %53
%55 = load i8, i8* %54
%56 = load i32, i32* @stderr
%57 = tail call i64 @isprint(i8 signext %55)
%58 = icmp eq i64 %57, 0
%59 = sext i8 %55 to i32
%60 = select i1 %58, i32 46, i32 %59
%61 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %60)
%62 = add nuw nsw i64 %53, 1
%63 = icmp slt i64 %62, %45
br i1 %63, label %52, label %64
64: ; preds = %52, %41, %39
%65 = load i32, i32* @stderr
%66 = tail call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%67 = add i64 %11, 16
%68 = icmp slt i64 %67, %9
br i1 %68, label %10, label %69
69: ; preds = %64, %4
ret void
}