#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 genwqe_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,
  };
  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):
<genwqe_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>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    125a <genwqe_hexdump+0x11a>
mov    -0x18(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11b2 <genwqe_hexdump+0x72>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe65(%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    0xe40(%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     11f9 <genwqe_hexdump+0xb9>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x48(%rbp)
jmp    1206 <genwqe_hexdump+0xc6>
mov    $0x2e,%eax
mov    %eax,-0x48(%rbp)
jmp    1206 <genwqe_hexdump+0xc6>
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    1247 <genwqe_hexdump+0x107>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    124c <genwqe_hexdump+0x10c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1172 <genwqe_hexdump+0x32>
jmp    125f <genwqe_hexdump+0x11f>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0xf,%ecx
and    $0xfffffff0,%ecx
cmp    %ecx,%eax
jae    12d7 <genwqe_hexdump+0x197>
mov    -0x8(%rbp),%rdi
lea    0xd96(%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    12c4 <genwqe_hexdump+0x184>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xd50(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12c9 <genwqe_hexdump+0x189>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    125f <genwqe_hexdump+0x11f>
mov    -0x8(%rbp),%rdi
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genwqe_hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%ebx
mov    %rdi,%r14
movw   $0x0,0xe(%rsp)
test   %edx,%edx
je     1247 <genwqe_hexdump+0xe7>
mov    %rsi,%r15
mov    %ebx,%r12d
xor    %ebp,%ebp
jmp    119d <genwqe_hexdump+0x3d>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %rbp,%r12
je     1247 <genwqe_hexdump+0xe7>
mov    %ebp,%r13d
and    $0xf,%r13d
jne    11ca <genwqe_hexdump+0x6a>
mov    %r14,%rdi
lea    0xe50(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
mov    (%r15,%rbp,4),%edx
mov    %r14,%rdi
lea    0xe2f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r15,%rbp,4),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1200 <genwqe_hexdump+0xa0>
mov    (%r15,%rbp,4),%eax
jmp    1205 <genwqe_hexdump+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2e,%eax
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
lea    0x10(%rsp),%rdi
lea    0xe(%rsp),%rsi
mov    $0x10,%edx
call   1050 <strncat@plt>
cmp    $0xf,%r13d
jne    1190 <genwqe_hexdump+0x30>
mov    %r14,%rdi
lea    0xdd7(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1190 <genwqe_hexdump+0x30>
lea    0xf(%rbx),%r13d
and    $0xfffffff0,%r13d
cmp    %ebx,%r13d
jbe    12c2 <genwqe_hexdump+0x162>
lea    0xdb9(%rip),%r15
lea    0x10(%rsp),%rbp
lea    0xe(%rsp),%r12
jmp    1278 <genwqe_hexdump+0x118>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%r13d
je     12c2 <genwqe_hexdump+0x162>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
movw   $0x20,0xe(%rsp)
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x10,%edx
call   1050 <strncat@plt>
mov    %ebx,%eax
not    %eax
test   $0xf,%al
jne    1270 <genwqe_hexdump+0x110>
mov    %r14,%rdi
lea    0xd57(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1270 <genwqe_hexdump+0x110>
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 @genwqe_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*
store i32 0, i32* %7
br label %14
14: ; preds = %66, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %69
18: ; preds = %14
%19 = load i32, i32* %7
%20 = and i32 %19, 15
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i32*, i32** %4
%24 = load i32, i32* %7
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%27 = call i32 @memset(i8* %26, i32 0, i32 17)
br label %28
28: ; preds = %22, %18
%29 = load i32*, i32** %4
%30 = load i32*, i32** %8
%31 = load i32, i32* %7
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32*, i32** %8
%37 = load i32, i32* %7
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = call i64 @isalnum(i32 %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %49
43: ; preds = %28
%44 = load i32*, i32** %8
%45 = load i32, i32* %7
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = load i32, i32* %47
br label %50
49: ; preds = %28
br label %50
50: ; preds = %49, %43
%51 = phi i32 [ %48, %43 ], [ 46, %49 ]
%52 = trunc i32 %51 to i8
%53 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
store i8 %52, i8* %53
%54 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 1
store i8 0, i8* %54
%55 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%56 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%57 = call i32 @strncat(i8* %55, i8* %56, i32 16)
%58 = load i32, i32* %7
%59 = and i32 %58, 15
%60 = icmp eq i32 %59, 15
br i1 %60, label %61, label %65
61: ; preds = %50
%62 = load i32*, i32** %4
%63 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %61, %50
br label %66
66: ; preds = %65
%67 = load i32, i32* %7
%68 = add i32 %67, 1
store i32 %68, i32* %7
br label %14
69: ; preds = %14
br label %70
70: ; preds = %92, %69
%71 = load i32, i32* %7
%72 = load i32, i32* %6
%73 = add i32 %72, 15
%74 = and i32 %73, -16
%75 = icmp ult i32 %71, %74
br i1 %75, label %76, label %95
76: ; preds = %70
%77 = load i32*, i32** %4
%78 = call i32 (i32*, i8*, ...) @fprintf(i32* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%79 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
store i8 32, i8* %79
%80 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 1
store i8 0, i8* %80
%81 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%82 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%83 = call i32 @strncat(i8* %81, i8* %82, i32 16)
%84 = load i32, i32* %7
%85 = and i32 %84, 15
%86 = icmp eq i32 %85, 15
br i1 %86, label %87, label %91
87: ; preds = %76
%88 = load i32*, i32** %4
%89 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %89)
br label %91
91: ; preds = %87, %76
br label %92
92: ; preds = %91
%93 = load i32, i32* %7
%94 = add i32 %93, 1
store i32 %94, i32* %7
br label %70
95: ; preds = %70
%96 = load i32*, i32** %4
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
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 @genwqe_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 %14, 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, %3
%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)
ret void
}