// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x15b96d
movq -0x10(%rbp), %rax
leaq 0x75277(%rip), %rcx     # 0x1d0bd0
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
leaq 0x75269(%rip), %rcx     # 0x1d0bd0
movq %rcx, 0x8(%rax)
jmp 0x15b97c
movq -0x10(%rbp), %rax
leaq 0x7c8df(%rip), %rcx     # 0x1d8257
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jle 0x15b997
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x15b99f
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x15b9b3
movq -0x40(%rbp), %rdi
callq 0x15fa30
movl %eax, -0x44(%rbp)
jmp 0x15b9e0
cmpq $0x1, -0x40(%rbp)
jge 0x15b9bf
jmp 0x15bad1
movq -0x40(%rbp), %rax
subq $0x1, %rax
movl $0x10, %ecx
cqto
idivq %rcx
movq %rax, %rdi
shlq $0x4, %rdi
callq 0x15fa30
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movl -0x44(%rbp), %ecx
movl $0x20, %esi
leaq 0x76642(%rip), %rdx     # 0x1d2039
movb $0x0, %al
callq 0x15a980
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
addq -0x40(%rbp), %rcx
cmpq %rcx, %rax
jl 0x15ba11
jmp 0x15ba8b
movq -0x38(%rbp), %rcx
subq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x20(%rbp), %rcx
addq -0x40(%rbp), %rcx
subq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
cmpq $0x10, 0x48(%rax)
jle 0x15ba4c
movq -0x10(%rbp), %rax
movq $0x10, 0x48(%rax)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x50, %rsi
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
callq 0x164d10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x15fa90
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x15b9fe
cmpl $0x0, -0x48(%rbp)
je 0x15bad1
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x40(%rbp), %r9
movl $0xc8, %esi
leaq 0x76588(%rip), %rdx     # 0x1d2040
movb $0x0, %al
callq 0x15a980
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq *%rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)