// File: /workspace/github_c_makefile_star2_O1/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 %rsi, -0x48(%rbp)
movq %rdi, -0x50(%rbp)
movq %rdx, -0x58(%rbp)
movslq %edx, %r15
xorl %r13d, %r13d
leaq 0x1e51(%rip), %rdi      # 0x9db2
movl %r13d, %esi
xorl %eax, %eax
callq 0x20f0
movl %r13d, -0x2c(%rbp)
movslq %r13d, %r12
movq -0x50(%rbp), %rax
addq %r12, %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
addq %r12, %rax
movq %rax, -0x40(%rbp)
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %r14, -0x60(%rbp)
xorl %r13d, %r13d
leaq (%r12,%r13), %r14
movl $0xa, %eax
cmpq %r15, %r14
jge 0x8029
cmpq $0x0, -0x48(%rbp)
je 0x800d
movq -0x40(%rbp), %rax
cmpb $0x0, (%rax,%r13)
je 0x7fcd
leaq 0x119a(%rip), %rdi      # 0x9159
leaq 0x1ddf(%rip), %rsi      # 0x9da5
xorl %eax, %eax
callq 0x20f0
movq -0x38(%rbp), %rax
movzbl (%rax,%r13), %esi
leaq 0x1ddd(%rip), %rdi      # 0x9dba
xorl %eax, %eax
callq 0x20f0
cmpq $0x0, -0x48(%rbp)
je 0x8024
movq -0x40(%rbp), %rax
cmpb $0x0, (%rax,%r13)
je 0x8024
leaq 0x115c(%rip), %rdi      # 0x9159
leaq 0x1da9(%rip), %rsi      # 0x9dad
xorl %eax, %eax
callq 0x20f0
jmp 0x8024
movq -0x38(%rbp), %rax
movzbl (%rax,%r13), %esi
leaq 0x1d9d(%rip), %rdi      # 0x9dba
xorl %eax, %eax
callq 0x20f0
addl $0x2, %ebx
xorl %eax, %eax
cmpq %r15, %r14
jge 0x8040
incq %r13
cmpq $0x1, %r13
je 0x7f94
movl $0x7, %eax
cmpl $0x7, %eax
movq -0x60(%rbp), %r14
jne 0x8075
movl $0x20, %edi
callq 0x2040
incl %ebx
incq %r14
addq $0x2, -0x38(%rbp)
addq $0x2, -0x40(%rbp)
addq $0x2, %r12
cmpq $0x8, %r14
jne 0x7f8d
movl $0x4, %eax
movl -0x2c(%rbp), %r13d
cmpl $0x4, %eax
je 0x8083
cmpl $0xa, %eax
jne 0x80ec
cmpl $0x28, %ebx
jg 0x8099
addl $-0x29, %ebx
movl $0x20, %edi
callq 0x2040
incl %ebx
jne 0x808b
callq 0x22f0
movq %rax, %rbx
movslq %r13d, %r14
addq -0x50(%rbp), %r14
xorl %r12d, %r12d
movq (%rbx), %rcx
movsbl (%r14,%r12), %eax
movslq %eax, %rdx
movzwl (%rcx,%rdx,2), %ecx
btl $0xe, %ecx
movl $0x2e, %edi
jae 0x80c7
movl %eax, %edi
callq 0x2040
incq %r12
cmpq $0x10, %r12
jne 0x80ab
movl $0xa, %edi
callq 0x2040
addl $0x10, %r13d
xorl %eax, %eax
cmpl -0x58(%rbp), %r13d
setge %al
testl %eax, %eax
je 0x7f5a
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq