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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isalnum(int const);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strncat(char *, char *, int);
void __hexdump(FILE *fp, const void *buff, unsigned int size) {
  unsigned int i;
  const uint8_t *b = (uint8_t *)buff;
  char ascii[17];
  char str[2] = {
      0x0,
  };
  if (size == 0)
    return;
  for (i = 0; i < size; i++) {
    if ((i & 0x0f) == 0x00) {
      fprintf(fp, " %08x:", i);
      memset(ascii, 0, sizeof(ascii));
    }
    fprintf(fp, " %02x", b[i]);
    str[0] = isalnum(b[i]) ? b[i] : '.';
    str[1] = '\0';
    strncat(ascii, str, sizeof(ascii) - 1);
    if ((i & 0x0f) == 0x0f)
      fprintf(fp, " | %s\n", ascii);
  }
  for (; i < ((size + 0xf) & ~0xf); i++) {
    fprintf(fp, "   ");
    str[0] = ' ';
    str[1] = '\0';
    strncat(ascii, str, sizeof(ascii) - 1);
    if ((i & 0x0f) == 0x0f)
      fprintf(fp, " | %s\n", ascii);
  }
  fprintf(fp, "\n");
}


x86 assembly (clang, -O0):
<__hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x42(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <memset@plt>
cmpl   $0x0,-0x14(%rbp)
jne    117a <__hexdump+0x3a>
jmp    12f8 <__hexdump+0x1b8>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1269 <__hexdump+0x129>
mov    -0x18(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11c1 <__hexdump+0x81>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,4),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     1208 <__hexdump+0xc8>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x48(%rbp)
jmp    1215 <__hexdump+0xd5>
mov    $0x2e,%eax
mov    %eax,-0x48(%rbp)
jmp    1215 <__hexdump+0xd5>
mov    -0x48(%rbp),%eax
mov    %al,-0x42(%rbp)
movb   $0x0,-0x41(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x42(%rbp),%rsi
mov    $0x10,%edx
call   1050 <strncat@plt>
mov    -0x18(%rbp),%eax
and    $0xf,%eax
cmp    $0xf,%eax
jne    1256 <__hexdump+0x116>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    125b <__hexdump+0x11b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <__hexdump+0x41>
jmp    126e <__hexdump+0x12e>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0xf,%ecx
and    $0xfffffff0,%ecx
cmp    %ecx,%eax
jae    12e6 <__hexdump+0x1a6>
mov    -0x8(%rbp),%rdi
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movb   $0x20,-0x42(%rbp)
movb   $0x0,-0x41(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x42(%rbp),%rsi
mov    $0x10,%edx
call   1050 <strncat@plt>
mov    -0x18(%rbp),%eax
and    $0xf,%eax
cmp    $0xf,%eax
jne    12d3 <__hexdump+0x193>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12d8 <__hexdump+0x198>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    126e <__hexdump+0x12e>
mov    -0x8(%rbp),%rdi
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movw   $0x0,0x6(%rsp)
test   %edx,%edx
je     12df <__hexdump+0x17f>
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %edx,%eax
mov    %rax,0x8(%rsp)
lea    0x10(%rsp),%r13
xor    %ebp,%ebp
jmp    11af <__hexdump+0x4f>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbp
cmp    %rbp,0x8(%rsp)
je     1253 <__hexdump+0xf3>
mov    %ebp,%r12d
and    $0xf,%r12d
jne    11da <__hexdump+0x7a>
mov    %r14,%rdi
lea    0xe3e(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
mov    (%r15,%rbp,4),%edx
mov    %r14,%rdi
lea    0xe1f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r15,%rbp,4),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1210 <__hexdump+0xb0>
mov    (%r15,%rbp,4),%eax
jmp    1215 <__hexdump+0xb5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2e,%eax
mov    %al,0x6(%rsp)
movb   $0x0,0x7(%rsp)
mov    %r13,%rdi
lea    0x6(%rsp),%rsi
mov    $0x10,%edx
call   1050 <strncat@plt>
cmp    $0xf,%r12d
jne    11a0 <__hexdump+0x40>
mov    %r14,%rdi
lea    0xdc9(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    11a0 <__hexdump+0x40>
lea    0xf(%rbx),%r13d
and    $0xfffffff0,%r13d
cmp    0x8(%rsp),%r13d
jbe    12d2 <__hexdump+0x172>
lea    0xdab(%rip),%r15
lea    0x10(%rsp),%rbp
lea    0x6(%rsp),%r12
jmp    1288 <__hexdump+0x128>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebx
cmp    %ebx,%r13d
je     12d2 <__hexdump+0x172>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
movw   $0x20,0x6(%rsp)
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x10,%edx
call   1050 <strncat@plt>
mov    %ebx,%eax
not    %eax
test   $0xf,%al
jne    1280 <__hexdump+0x120>
mov    %r14,%rdi
lea    0xd47(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1280 <__hexdump+0x120>
mov    $0xa,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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