// File: /workspace/github_c_makefile_star2_O3/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 0x8369f
movq %rcx, %r14
movq %rdi, %r15
addq %rcx, 0x18(%rsp)
leaq 0x30(%rsp), %r12
movq 0x18(%r15), %rdi
movq %r14, %rsi
callq 0xeead3
movl %eax, %ecx
andb $0xf, %cl
cmpb $0x10, %al
leaq 0xa7690(%rip), %rdx     # 0x12ab8a
leaq 0x97ee2(%rip), %rax     # 0x11b3e3
cmovbq %rax, %rdx
movzbl %cl, %ecx
movq %r15, %rdi
leaq 0xa77ab(%rip), %rsi     # 0x12acbd
movl %r14d, %r8d
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r15), %rdi
leaq 0x1(%r14), %rdx
movl $0x10, %ecx
leaq 0x20(%rsp), %rsi
callq 0xee8d4
xorl %eax, %eax
xorl %ebx, %ebx
movzbl 0x20(%rsp,%rax), %ecx
addq %rcx, %rbx
incq %rax
cmpq $0x10, %rax
jne 0x83537
movq %r15, %rdi
movl $0x1, %esi
callq 0xe8a15
cmpl $0x2, (%r15)
jl 0x835e0
movq %r14, 0x8(%rsp)
movq %r15, %rdi
callq 0xf6410
movq %rax, %r14
xorl %ebp, %ebp
movzbl 0x20(%rsp,%rbp), %ecx
movq %r14, %rdi
movl $0x5, %esi
leaq 0xa775f(%rip), %rdx     # 0x12ace4
xorl %eax, %eax
callq 0xf6653
movl %ebp, %eax
notl %eax
testb $0x7, %al
jne 0x835ca
leal -0x6(%rbp), %eax
movl %eax, 0x14(%rsp)
leal 0x1(%rbp), %r13d
movq %r14, %rdi
callq 0xf705c
movq %r15, %rdi
leaq 0xa7738(%rip), %rsi     # 0x12ace9
movl 0x14(%rsp), %edx
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
callq 0xf6423
incq %rbp
cmpq $0x10, %rbp
jne 0x83571
movq %r14, %rdi
callq 0xf6753
movq 0x8(%rsp), %r14
movq %r15, %rdi
leaq 0xa76e6(%rip), %rsi     # 0x12acd0
movl %ebx, %edx
xorl %eax, %eax
callq 0xe8617
addq $0x11, %r14
movq %r14, 0x30(%rsp)
leaq -0x1(%rbx), %rax
cmpq $0xa1, %rax
ja 0x83684
cmpl $0x3, (%r15)
jl 0x83684
movq %r14, 0x8(%rsp)
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x104d0e
movq %rax, %rbp
movl $0x1, %r13d
movzbl 0x1f(%rsp,%r13), %r14d
testl %r14d, %r14d
je 0x83656
movq 0x18(%r15), %rdi
movq %r12, %rsi
callq 0xeeb4b
movq 0x10(%rbp), %rsi
movzbl %al, %edx
movq %r15, %rdi
movl %r13d, %ecx
callq 0x1049cc
decl %r14d
jne 0x83633
incq %r13
cmpq $0x11, %r13
jne 0x83628
movq 0x8(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x104a46
movq %r15, %rdi
movq %rbp, %rsi
callq 0x104dc7
movq 0x8(%rsp), %r14
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
addq %rbx, %r14
cmpq 0x18(%rsp), %r14
jl 0x834e0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq