// File: /workspace/github_c_makefile_star2_O2/mruby-zest[P]osc-bridge/test/common.h
// Function: hexdump
void hexdump(const char *data, const char *mask, size_t len)
{
    const char *bold_gray = "\x1b[30;1m";
    const char *reset      = "\x1b[0m";
    int offset = 0;
    while(1)
    {
        //print line
        printf("#%07x: ", offset);

        int char_covered = 0;

        //print hex groups (8)
        for(int i=0; i<8; ++i) {

            //print doublet
            for(int j=0; j<2; ++j) {
                int loffset = offset + 2*i + j;
                if(loffset >= (int)len)
                    goto escape;

                //print hex
                {
                    //start highlight
                    if(mask && mask[loffset]){printf("%s", bold_gray);}

                    //print chars
                    printf("%02x", 0xff&data[loffset]);

                    //end highlight
                    if(mask && mask[loffset]){printf("%s", reset);}
                    char_covered += 2;
                }
            }
            printf(" ");
            char_covered += 1;
        }
escape:

        //print filler if needed
        for(int i=char_covered; i<41; ++i)
            printf(" ");

        //print ascii (16)
        for(int i=0; i<16; ++i) {
            if(isprint(data[offset+i]))
                printf("%c", data[offset+i]);
            else
                printf(".");
        }
        printf("\n");
        offset += 16;
        if(offset >= (int)len)
            return;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, -0x30(%rbp)
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, -0x38(%rbp)
xorl %r13d, %r13d
leaq 0x1764(%rip), %rdi      # 0x8d6e
movl %r13d, %esi
xorl %eax, %eax
callq 0x20f0
movq %r13, -0x40(%rbp)
movq %rbx, -0x48(%rbp)
movq %r14, -0x50(%rbp)
movq %r14, %r15
xorl %eax, %eax
xorl %r12d, %r12d
cmpq $0x8, %rax
je 0x76ed
movq %rax, -0x58(%rbp)
xorl %r14d, %r14d
cmpq $0x2, %r14
je 0x76ca
leal (%r14,%r13), %eax
cmpl -0x30(%rbp), %eax
jge 0x76ed
cmpq $0x0, -0x38(%rbp)
je 0x76ab
cmpb $0x0, (%rbx,%r14)
je 0x7673
leaq 0xaf4(%rip), %rdi       # 0x8159
leaq 0x16f5(%rip), %rsi      # 0x8d61
xorl %eax, %eax
callq 0x20f0
movzbl (%r15,%r14), %esi
leaq 0x16f7(%rip), %rdi      # 0x8d76
xorl %eax, %eax
callq 0x20f0
cmpq $0x0, -0x38(%rbp)
je 0x76be
cmpb $0x0, (%rbx,%r14)
je 0x76be
leaq 0xabe(%rip), %rdi       # 0x8159
leaq 0x16c7(%rip), %rsi      # 0x8d69
xorl %eax, %eax
callq 0x20f0
jmp 0x76be
movzbl (%r15,%r14), %esi
leaq 0x16bf(%rip), %rdi      # 0x8d76
xorl %eax, %eax
callq 0x20f0
addl $0x2, %r12d
incq %r14
jmp 0x7639
pushq $0x20
popq %rdi
callq 0x2040
incl %r12d
movq -0x58(%rbp), %rax
incq %rax
addq $0x2, %r15
addq $0x2, %rbx
addq $0x2, %r13
jmp 0x7628
movq -0x50(%rbp), %r14
pushq $0x20
popq %rbx
pushq $0x2e
popq %r15
movq -0x40(%rbp), %r13
cmpl $0x29, %r12d
jge 0x770e
movl %ebx, %edi
callq 0x2040
incl %r12d
jmp 0x76fc
callq 0x22f0
movq %rax, %r12
xorl %ebx, %ebx
cmpq $0x10, %rbx
je 0x7743
movq (%r12), %rcx
movsbl (%r14,%rbx), %eax
movslq %eax, %rdx
movzwl (%rcx,%rdx,2), %ecx
btl $0xe, %ecx
movl %r15d, %edi
jae 0x7739
movl %eax, %edi
callq 0x2040
incq %rbx
jmp 0x7718
pushq $0xa
popq %rdi
callq 0x2040
addq $0x10, %r13
addq $0x10, %r14
movq -0x48(%rbp), %rbx
addq $0x10, %rbx
cmpl -0x30(%rbp), %r13d
jl 0x7603
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq