#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 *, char, ...);
void hexdump(FILE *fp, const void *ptr, unsigned len, int width) {
  unsigned char *data = (unsigned char *)ptr;
  for (unsigned jt = 0; jt < len; jt += width) {
    fprintf(fp, "; %05d ", jt);
    for (unsigned it = jt, next = it + width; it < len && it < next; ++it) {
      fprintf(fp, "%02x %s", (unsigned char)data[it],
              &" \n\0...\n"[(1 + it) < len ? 2 * !!((1 + it) % width) : 3]);
    }
    fprintf(fp, "; %05d ", jt);
    for (unsigned it = jt, next = it + width; it < len && it < next; ++it) {
      fprintf(fp, " %c %s",
              (signed char)data[it] >= 32 ? (signed char)data[it]
                                          : (signed char)'.',
              &" \n\0...\n"[(1 + it) < len ? 2 * !!((1 + it) % width) : 3]);
    }
  }
}


x86 assembly (clang, -O0):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1341 <hexdump+0x231>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
lea    0xeb1(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x35(%rbp)
jae    1185 <hexdump+0x75>
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
setb   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    1195 <hexdump+0x85>
jmp    1221 <hexdump+0x111>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x36(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jae    11de <hexdump+0xce>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
xor    %edx,%edx
divl   -0x18(%rbp)
cmp    $0x0,%edx
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
shl    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11eb <hexdump+0xdb>
mov    $0x3,%eax
mov    %eax,-0x44(%rbp)
jmp    11eb <hexdump+0xdb>
mov    -0x36(%rbp),%al
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%ecx
movslq %ecx,%rdx
lea    0xe18(%rip),%rcx
add    %rdx,%rcx
lea    0xdff(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1168 <hexdump+0x58>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
lea    0xdd1(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x45(%rbp)
jae    1265 <hexdump+0x155>
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
setb   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    1275 <hexdump+0x165>
jmp    132e <hexdump+0x21e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     12a4 <hexdump+0x194>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x54(%rbp)
jmp    12b1 <hexdump+0x1a1>
mov    $0x2e,%eax
mov    %eax,-0x54(%rbp)
jmp    12b1 <hexdump+0x1a1>
mov    -0x54(%rbp),%eax
mov    %al,-0x55(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jae    12eb <hexdump+0x1db>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
xor    %edx,%edx
divl   -0x18(%rbp)
cmp    $0x0,%edx
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
shl    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12f8 <hexdump+0x1e8>
mov    $0x3,%eax
mov    %eax,-0x5c(%rbp)
jmp    12f8 <hexdump+0x1e8>
mov    -0x55(%rbp),%al
mov    -0x50(%rbp),%rdi
mov    -0x5c(%rbp),%ecx
movslq %ecx,%rdx
lea    0xd0b(%rip),%rcx
add    %rdx,%rcx
lea    0xcfa(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1248 <hexdump+0x138>
jmp    1333 <hexdump+0x223>
mov    -0x18(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1135 <hexdump+0x25>
add    $0x60,%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    %rsi,0x18(%rsp)
test   %edx,%edx
je     12ea <hexdump+0x1da>
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %rdi,%r13
mov    %edx,%eax
mov    %rax,0x10(%rsp)
mov    $0x1,%r15d
lea    0xeb8(%rip),%rbp
xor    %eax,%eax
mov    %edx,0xc(%rsp)
jmp    1183 <hexdump+0x73>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r15,%r14
mov    (%rsp),%r15d
add    %r14d,%r15d
mov    0x4(%rsp),%eax
mov    0xc(%rsp),%r12d
cmp    %r12d,%eax
lea    0xe83(%rip),%rbp
jae    12ea <hexdump+0x1da>
mov    %r15d,(%rsp)
mov    %eax,%ebx
mov    %r14,%r15
movsbl %bl,%r14d
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    (%rbx,%r15,1),%ecx
cmp    %ecx,%ebx
mov    %ecx,0x4(%rsp)
jae    1150 <hexdump+0x40>
mov    %r14d,0x8(%rsp)
mov    %r15,%r14
mov    %ebx,%r12d
mov    %ecx,%ecx
mov    %rcx,0x20(%rsp)
mov    (%rsp),%ebx
mov    %r12,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x18(%rsp),%rax
movsbl (%rax,%r15,1),%ebp
add    $0x1,%r15
cmp    0x10(%rsp),%r15
jae    1220 <hexdump+0x110>
mov    %ebx,%eax
xor    %edx,%edx
div    %r14d
xor    %eax,%eax
test   %edx,%edx
setne  %al
lea    0xe1d(%rip),%rcx
lea    (%rcx,%rax,2),%rcx
mov    %r13,%rdi
lea    0xe00(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebx
cmp    0x20(%rsp),%r15
jb     11d0 <hexdump+0xc0>
jmp    123a <hexdump+0x12a>
nopl   (%rax)
mov    %r13,%rdi
lea    0xdde(%rip),%rsi
mov    %ebp,%edx
lea    0xde7(%rip),%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r13,%rdi
lea    0xdbc(%rip),%rsi
mov    0x8(%rsp),%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    0x4(%rsp),%r12d
mov    (%rsp),%r15d
mov    $0x2e,%ebp
jae    1167 <hexdump+0x57>
mov    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    0x18(%rsp),%rax
movzbl (%rax,%r12,1),%esi
cmp    $0x20,%sil
cmovl  %ebp,%esi
add    $0x1,%r12
cmp    0x10(%rsp),%r12
jae    12c9 <hexdump+0x1b9>
mov    %ebx,%eax
xor    %edx,%edx
div    %r14d
xor    %eax,%eax
test   %edx,%edx
setne  %al
lea    0xd76(%rip),%rcx
lea    (%rcx,%rax,2),%rcx
movsbl %sil,%edx
mov    %r13,%rdi
lea    0xd5d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebx
cmp    0x20(%rsp),%r12
jb     1270 <hexdump+0x160>
jmp    1167 <hexdump+0x57>
movsbl %sil,%edx
mov    %r13,%rdi
lea    0xd39(%rip),%rsi
lea    0xd3c(%rip),%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1167 <hexdump+0x57>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"; %05d \00"
@.str.1 = [8 x i8] c"%02x %s\00"
@.str.2 = [8 x i8] c" \0A\00...\0A\00"
@.str.3 = [7 x i8] c" %c %s\00"
define void @hexdump(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%15 = load i8*, i8** %6
store i8* %15, i8** %9
store i32 0, i32* %10
br label %16
16: ; preds = %132, %4
%17 = load i32, i32* %10
%18 = load i32, i32* %7
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %136
20: ; preds = %16
%21 = load i32*, i32** %5
%22 = load i32, i32* %10
%23 = trunc i32 %22 to i8
%24 = call i32 (i32*, i8*, i8, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext %23)
%25 = load i32, i32* %10
store i32 %25, i32* %11
%26 = load i32, i32* %11
%27 = load i32, i32* %8
%28 = add i32 %26, %27
store i32 %28, i32* %12
br label %29
29: ; preds = %66, %20
%30 = load i32, i32* %11
%31 = load i32, i32* %7
%32 = icmp ult i32 %30, %31
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* %11
%35 = load i32, i32* %12
%36 = icmp ult i32 %34, %35
br label %37
37: ; preds = %33, %29
%38 = phi i1 [ false, %29 ], [ %36, %33 ]
br i1 %38, label %39, label %69
39: ; preds = %37
%40 = load i32*, i32** %5
%41 = load i8*, i8** %9
%42 = load i32, i32* %11
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = load i32, i32* %11
%47 = add i32 1, %46
%48 = load i32, i32* %7
%49 = icmp ult i32 %47, %48
br i1 %49, label %50, label %60
50: ; preds = %39
%51 = load i32, i32* %11
%52 = add i32 1, %51
%53 = load i32, i32* %8
%54 = urem i32 %52, %53
%55 = icmp ne i32 %54, 0
%56 = xor i1 %55, true
%57 = xor i1 %56, true
%58 = zext i1 %57 to i32
%59 = mul nsw i32 2, %58
br label %61
60: ; preds = %39
br label %61
61: ; preds = %60, %50
%62 = phi i32 [ %59, %50 ], [ 3, %60 ]
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [8 x i8], [8 x i8]* @.str.2, i64 0, i64 %63
%65 = call i32 (i32*, i8*, i8, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8 signext %45, i8* %64)
br label %66
66: ; preds = %61
%67 = load i32, i32* %11
%68 = add i32 %67, 1
store i32 %68, i32* %11
br label %29
69: ; preds = %37
%70 = load i32*, i32** %5
%71 = load i32, i32* %10
%72 = trunc i32 %71 to i8
%73 = call i32 (i32*, i8*, i8, ...) @fprintf(i32* %70, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext %72)
%74 = load i32, i32* %10
store i32 %74, i32* %13
%75 = load i32, i32* %13
%76 = load i32, i32* %8
%77 = add i32 %75, %76
store i32 %77, i32* %14
br label %78
78: ; preds = %128, %69
%79 = load i32, i32* %13
%80 = load i32, i32* %7
%81 = icmp ult i32 %79, %80
br i1 %81, label %82, label %86
82: ; preds = %78
%83 = load i32, i32* %13
%84 = load i32, i32* %14
%85 = icmp ult i32 %83, %84
br label %86
86: ; preds = %82, %78
%87 = phi i1 [ false, %78 ], [ %85, %82 ]
br i1 %87, label %88, label %131
88: ; preds = %86
%89 = load i32*, i32** %5
%90 = load i8*, i8** %9
%91 = load i32, i32* %13
%92 = zext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp sge i32 %95, 32
br i1 %96, label %97, label %104
97: ; preds = %88
%98 = load i8*, i8** %9
%99 = load i32, i32* %13
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %98, i64 %100
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
br label %105
104: ; preds = %88
br label %105
105: ; preds = %104, %97
%106 = phi i32 [ %103, %97 ], [ 46, %104 ]
%107 = trunc i32 %106 to i8
%108 = load i32, i32* %13
%109 = add i32 1, %108
%110 = load i32, i32* %7
%111 = icmp ult i32 %109, %110
br i1 %111, label %112, label %122
112: ; preds = %105
%113 = load i32, i32* %13
%114 = add i32 1, %113
%115 = load i32, i32* %8
%116 = urem i32 %114, %115
%117 = icmp ne i32 %116, 0
%118 = xor i1 %117, true
%119 = xor i1 %118, true
%120 = zext i1 %119 to i32
%121 = mul nsw i32 2, %120
br label %123
122: ; preds = %105
br label %123
123: ; preds = %122, %112
%124 = phi i32 [ %121, %112 ], [ 3, %122 ]
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [8 x i8], [8 x i8]* @.str.2, i64 0, i64 %125
%127 = call i32 (i32*, i8*, i8, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 signext %107, i8* %126)
br label %128
128: ; preds = %123
%129 = load i32, i32* %13
%130 = add i32 %129, 1
store i32 %130, i32* %13
br label %78
131: ; preds = %86
br label %132
132: ; preds = %131
%133 = load i32, i32* %8
%134 = load i32, i32* %10
%135 = add i32 %134, %133
store i32 %135, i32* %10
br label %16
136: ; preds = %16
ret void
}

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