// File: /workspace/github_c_makefile_star2_O2/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 %rcx, %rbx
movq %rdi, %r15
addq %rcx, %r8
movq %r8, 0x28(%rsp)
leaq 0x30(%rsp), %rbp
cmpq 0x28(%rsp), %rbx
jge 0x7e980
movq 0x18(%r15), %rdi
movq %rbx, %rsi
callq 0xe3eb4
movl %eax, %ecx
andb $0xf, %cl
cmpb $0x10, %al
leaq 0x9f13b(%rip), %rdx     # 0x11d91a
leaq 0x8fb0d(%rip), %rax     # 0x10e2f3
cmovbq %rax, %rdx
movzbl %cl, %ecx
movq %r15, %rdi
leaq 0x9f256(%rip), %rsi     # 0x11da4d
movl %ebx, %r8d
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
leaq 0x1(%rbx), %rdx
leaq 0x10(%rsp), %rsi
pushq $0x10
popq %rcx
callq 0xe3cb7
xorl %r14d, %r14d
xorl %eax, %eax
cmpq $0x10, %rax
je 0x7e82e
movzbl 0x10(%rsp,%rax), %ecx
addq %rcx, %r14
incq %rax
jmp 0x7e81b
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
cmpl $0x2, (%r15)
movq %r14, 0x8(%rsp)
jl 0x7e8ca
movq %rbx, 0x20(%rsp)
movq %r15, %rdi
callq 0xeac74
movq %rax, %r13
xorl %ebx, %ebx
cmpq $0x10, %rbx
je 0x7e8b8
movzbl 0x10(%rsp,%rbx), %ecx
movq %r13, %rdi
pushq $0x5
popq %rsi
leaq 0x9f202(%rip), %rdx     # 0x11da74
xorl %eax, %eax
callq 0xeae8b
movl %ebx, %eax
notl %eax
testb $0x7, %al
jne 0x7e8b3
leal -0x6(%rbx), %r12d
leal 0x1(%rbx), %r14d
movq %r13, %rdi
callq 0xeb7e4
movq %r15, %rdi
leaq 0x9f1de(%rip), %rsi     # 0x11da79
movl %r12d, %edx
movl %r14d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xde896
movq %r13, %rdi
callq 0xeac85
incq %rbx
jmp 0x7e85a
movq %r13, %rdi
callq 0xeaf3c
movq 0x20(%rsp), %rbx
movq 0x8(%rsp), %r14
movq %r15, %rdi
leaq 0x9f18c(%rip), %rsi     # 0x11da60
movl %r14d, %edx
xorl %eax, %eax
callq 0xde896
addq $0x11, %rbx
movq %rbx, 0x30(%rsp)
leaq -0x1(%r14), %rax
cmpq $0xa1, %rax
ja 0x7e96d
cmpl $0x3, (%r15)
jl 0x7e96d
movq %rbx, %r14
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf8601
movq %rax, %r13
pushq $0x1
popq %r12
cmpq $0x11, %r12
je 0x7e945
movzbl 0xf(%rsp,%r12), %ebx
subl $0x1, %ebx
jb 0x7e940
movq 0x18(%r15), %rdi
movq %rbp, %rsi
callq 0xe3f2a
movq 0x10(%r13), %rsi
movzbl %al, %edx
movq %r15, %rdi
movl %r12d, %ecx
callq 0xf82ee
jmp 0x7e91b
incq %r12
jmp 0x7e90f
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xf8362
movq %r15, %rdi
movq %r13, %rsi
callq 0xf86b0
movq %r14, %rbx
movq 0x8(%rsp), %r14
movq %r15, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
addq %r14, %rbx
jmp 0x7e7ba
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq