// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/jpeg.c
// Function: handler_dht
static void handler_dht(deark *c, lctx *d,
	const struct marker_info *mi, i64 pos1, i64 data_size)
{
	i64 pos = pos1;
	u8 b;
	u8 table_class;
	u8 table_id;
	i64 num_huff_codes;
	i64 k;
	u8 codecounts[16];

	while(1) {
		if(pos >= pos1+data_size) goto done;

		b = de_getbyte(pos);
		table_class = b>>4;
		table_id = b&0x0f;
		de_dbg(c, "table: %s%d, at %d", table_class==0?"DC":"AC",
			(int)table_id, (int)pos);

		de_read(codecounts, pos+1, 16);
		num_huff_codes = 0;
		for(k=0; k<16; k++) {
			num_huff_codes += (i64)codecounts[k];
		}
		de_dbg_indent(c, 1);
		dump_htable_summary(c, d, codecounts);
		de_dbg(c, "number of codes: %d", (int)num_huff_codes);
		pos += 1 + 16;
		dump_htable_details(c, d, pos, codecounts, num_huff_codes);
		de_dbg_indent(c, -1);
		pos += num_huff_codes;
	}

done:
	;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x18(%rsp)
testq %r8, %r8
jle 0x83d47
movq %rcx, %r14
movq %rdi, %r15
addq %rcx, 0x18(%rsp)
leaq 0x30(%rsp), %r12
movq 0x18(%r15), %rdi
movq %r14, %rsi
callq 0xef0d5
movl %eax, %ecx
andb $0xf, %cl
cmpb $0x10, %al
leaq 0xa6d18(%rip), %rdx     # 0x12a8ba
leaq 0x97712(%rip), %rax     # 0x11b2bb
cmovbq %rax, %rdx
movzbl %cl, %ecx
movq %r15, %rdi
leaq 0xa6e33(%rip), %rsi     # 0x12a9ed
movl %r14d, %r8d
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r15), %rdi
leaq 0x1(%r14), %rdx
movl $0x10, %ecx
leaq 0x20(%rsp), %rsi
callq 0xeeee8
xorl %eax, %eax
xorl %ebx, %ebx
movzbl 0x20(%rsp,%rax), %ecx
addq %rcx, %rbx
incq %rax
cmpq $0x10, %rax
jne 0x83bdf
movq %r15, %rdi
movl $0x1, %esi
callq 0xe9585
cmpl $0x2, (%r15)
jl 0x83c88
movq %r14, 0x8(%rsp)
movq %r15, %rdi
callq 0xf6870
movq %rax, %r14
xorl %ebp, %ebp
movzbl 0x20(%rsp,%rbp), %ecx
movq %r14, %rdi
movl $0x5, %esi
leaq 0xa6de7(%rip), %rdx     # 0x12aa14
xorl %eax, %eax
callq 0xf6ab0
movl %ebp, %eax
notl %eax
testb $0x7, %al
jne 0x83c72
leal -0x6(%rbp), %eax
movl %eax, 0x14(%rsp)
leal 0x1(%rbp), %r13d
movq %r14, %rdi
callq 0xf74bd
movq %r15, %rdi
leaq 0xa6dc0(%rip), %rsi     # 0x12aa19
movl 0x14(%rsp), %edx
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
callq 0xf6883
incq %rbp
cmpq $0x10, %rbp
jne 0x83c19
movq %r14, %rdi
callq 0xf6bb0
movq 0x8(%rsp), %r14
movq %r15, %rdi
leaq 0xa6d6e(%rip), %rsi     # 0x12aa00
movl %ebx, %edx
xorl %eax, %eax
callq 0xe9226
addq $0x11, %r14
movq %r14, 0x30(%rsp)
leaq -0x1(%rbx), %rax
cmpq $0xa1, %rax
ja 0x83d2c
cmpl $0x3, (%r15)
jl 0x83d2c
movq %r14, 0x8(%rsp)
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x105165
movq %rax, %rbp
movl $0x1, %r13d
movzbl 0x1f(%rsp,%r13), %r14d
testl %r14d, %r14d
je 0x83cfe
movq 0x18(%r15), %rdi
movq %r12, %rsi
callq 0xef14d
movq 0x10(%rbp), %rsi
movzbl %al, %edx
movq %r15, %rdi
movl %r13d, %ecx
callq 0x104de7
decl %r14d
jne 0x83cdb
incq %r13
cmpq $0x11, %r13
jne 0x83cd0
movq 0x8(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x104e5d
movq %r15, %rdi
movq %rbp, %rsi
callq 0x10521e
movq 0x8(%rsp), %r14
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
addq %rbx, %r14
cmpq 0x18(%rsp), %r14
jl 0x83b88
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq