// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/deark-util.c
// Function: de_hexdump_internal
static void de_hexdump_internal(deark *c, struct hexdump_ctx *hctx,
	dbuf *f, i64 pos1,
	i64 nbytes_avail, i64 max_nbytes_to_dump)
{
	i64 pos = pos1;
	i64 len;
	int ndigits_for_offset;
	int was_truncated = 0;

	if(hctx->flags & 0x2) {
		// Don't print a prefix
		hctx->prefix = "";
		hctx->prefix_sep = "";
	}
	else {
		hctx->prefix_sep = ":";
	}

	if(nbytes_avail > max_nbytes_to_dump) {
		len = max_nbytes_to_dump;
		was_truncated = 1;
	}
	else {
		len = nbytes_avail;
	}

	// Construct a format string to use for byte offsets.
	if(was_truncated) {
		// If we're truncating, the highest offset we'll print is the number
		// of data bytes that we'll dump.
		ndigits_for_offset = get_ndigits_for_offset(len);
	}
	else {
		if(len<1) return;

		// If we're not truncating, the highest offset we'll print is the
		// highest byte offset that is a multiple of 16.
		ndigits_for_offset = get_ndigits_for_offset(((len-1)/16)*16);
	}
	de_snprintf(hctx->offset_fmtstr, sizeof(hctx->offset_fmtstr), "%%%d"I64_FMT, ndigits_for_offset);

	while(1) { // For each row...
		if(pos >= pos1+len) break;

		hctx->row_offset = pos-pos1;

		hctx->bytesthisrow = (pos1+len)-pos;
		if(hctx->bytesthisrow>16) hctx->bytesthisrow=16;

		dbuf_read(f, hctx->rowbuf, pos, hctx->bytesthisrow);

		do_hexdump_row(c, hctx);

		pos += hctx->bytesthisrow;
	}
	if(was_truncated) {
		de_snprintf(hctx->outbuf_sz, sizeof(hctx->outbuf_sz),
			"%s%s%"I64_FMT": ...", hctx->prefix, hctx->prefix_sep, len);
		hctx->printlinefn(c, hctx);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, 0x20(%rsp)
movq %rdx, 0x40(%rsp)
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
testb $0x2, 0x10(%rsi)
jne 0xe97ec
leaq 0x62add(%rip), %rax     # 0x14c2c7
jmp 0xe97f6
leaq 0x5c54d(%rip), %rax     # 0x145d40
movq %rax, (%rbx)
movq %rax, 0x8(%rbx)
movq %r9, %r14
cmpq %r9, %r8
cmovlq %r8, %r14
jle 0xe983e
movq %r8, (%rsp)
movq %r9, 0x8(%rsp)
movl $0x1, %ecx
cmpq $0xa, %r14
jl 0xe9889
movl $0x2, %ecx
cmpq $0x64, %r14
jl 0xe9889
movl $0x3, %ecx
cmpq $0x3e8, %r14            # imm = 0x3E8
jl 0xe9889
xorl %ecx, %ecx
cmpq $0x2710, %r14           # imm = 0x2710
jmp 0xe9883
testq %r14, %r14
jle 0xe9a9f
movq %r8, (%rsp)
movq %r9, 0x8(%rsp)
leaq -0x1(%r14), %rax
andq $-0x10, %rax
movl $0x1, %ecx
cmpq $0xa, %rax
jl 0xe9889
movl $0x2, %ecx
cmpq $0x64, %rax
jl 0xe9889
movl $0x3, %ecx
cmpq $0x3e8, %rax            # imm = 0x3E8
jl 0xe9889
xorl %ecx, %ecx
cmpq $0x2710, %rax           # imm = 0x2710
setl %cl
xorl $0x5, %ecx
leaq 0x20(%rbx), %rdi
leaq 0x5c74d(%rip), %rdx     # 0x145fe1
movl $0x20, %esi
movq %rdi, 0x38(%rsp)
xorl %eax, %eax
callq 0xe8d67
movq %r14, 0x10(%rsp)
testq %r14, %r14
jle 0xe9a66
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rbp
leaq (%rax,%rbp), %r12
leaq 0x50(%rbx), %r13
leaq 0x60(%rbx), %rax
movq %rax, 0x30(%rsp)
movq %r12, 0x28(%rsp)
movq %rbp, %rax
subq 0x20(%rsp), %rax
movq %rax, 0x40(%rbx)
movq %r12, %rcx
subq %rbp, %rcx
cmpq $0x10, %rcx
movl $0x10, %eax
cmovgeq %rax, %rcx
movq %rcx, 0x48(%rbx)
movq 0x40(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xeeee8
movb $0x22, 0x50(%rsp)
cmpq $0x0, 0x48(%rbx)
jle 0xe999d
movq %rbp, 0x48(%rsp)
movl $0x1, %r14d
xorl %r15d, %r15d
xorl %r12d, %r12d
movzbl (%r13,%r12), %ebp
movl %ebp, %edi
shrl $0x4, %edi
callq 0xec1b8
movb %al, 0x90(%rsp,%r15)
movl %ebp, %edi
andl $0xf, %edi
callq 0xec1b8
movb %al, 0x91(%rsp,%r15)
movb $0x20, 0x92(%rsp,%r15)
leal -0x20(%rbp), %ecx
movslq %r14d, %rax
leaq 0x1(%rax), %r14
cmpb $0x5e, %cl
ja 0xe9970
movb %bpl, 0x50(%rsp,%rax)
jmp 0xe9984
movb $0x1, 0x50(%rsp,%rax)
movb $0x2e, 0x50(%rsp,%r14)
leal 0x3(%rax), %r14d
movb $0x2, 0x52(%rsp,%rax)
incq %r12
addq $0x3, %r15
cmpq 0x48(%rbx), %r12
jl 0xe9927
movq 0x28(%rsp), %r12
movq 0x48(%rsp), %rbp
jmp 0xe99a6
movl $0x1, %r14d
xorl %r15d, %r15d
cmpl $0x2f, %r15d
ja 0xe99d5
movl %r15d, %eax
leaq (%rsp,%rax), %rdi
addq $0x90, %rdi
movl $0x2f, %edx
subl %r15d, %edx
incq %rdx
movl $0x20, %esi
callq 0x18140
movl $0x30, %r15d
movl %r15d, %eax
movb $0x0, 0x90(%rsp,%rax)
testb $0x1, 0x10(%rbx)
jne 0xe99ed
movb $0x0, 0x50(%rsp)
jmp 0xe99f7
movslq %r14d, %rax
movw $0x22, 0x50(%rsp,%rax)
movq 0x40(%rbx), %rcx
movl $0x20, %esi
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
movq 0x38(%rsp), %rdx
xorl %eax, %eax
callq 0xe8d67
movq (%rbx), %rcx
movq 0x8(%rbx), %r8
movl $0xc8, %esi
movq 0x30(%rsp), %rdi
leaq 0x5c5c6(%rip), %rdx     # 0x145ff5
movq %r14, %r9
xorl %eax, %eax
leaq 0x50(%rsp), %r10
pushq %r10
leaq 0x98(%rsp), %r10
pushq %r10
callq 0xe8d67
addq $0x10, %rsp
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq *0x18(%rbx)
addq 0x48(%rbx), %rbp
cmpq %r12, %rbp
jl 0xe98d3
movq (%rsp), %rax
cmpq 0x8(%rsp), %rax
movq 0x10(%rsp), %r9
jle 0xe9a9f
leaq 0x60(%rbx), %rdi
movq (%rbx), %rcx
movq 0x8(%rbx), %r8
leaq 0x5c560(%rip), %rdx     # 0x145fe8
movl $0xc8, %esi
xorl %eax, %eax
callq 0xe8d67
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq *0x18(%rbx)
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq