// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/j2c.c
// Function: handler_tlm
static void handler_tlm(deark *c, lctx *d, struct page_ctx *pg,
	const struct marker_info *mi, i64 pos1, i64 len)
{
	u8 b;
	u8 item_size_code;
	i64 item_size;
	i64 pos = pos1;
	u8 t_code, p_code;
	i64 t_size, p_size;
	i64 num_items;
	i64 k;

	if(len<2) goto done;
	b = de_getbyte_p(&pos);
	de_dbg(c, "index: %d", (int)b);

	item_size_code = (i64)de_getbyte_p(&pos);
	de_dbg(c, "item size code: 0x%02x", (unsigned int)item_size_code);
	de_dbg_indent(c, 1);
	t_code = (item_size_code & 0x30)>>4;
	de_dbg(c, "size code for number field: %d", (int)t_code);
	p_code = (item_size_code & 0x40)>>6;
	de_dbg(c, "size code for length field: %d", (int)p_code);
	de_dbg_indent(c, -1);
	if(t_code==0) t_size=0;
	else if(t_code==1) t_size = 1;
	else if(t_code==2) t_size = 2;
	else goto done;
	if(p_code==0) p_size = 2;
	else p_size = 4;
	item_size = t_size + p_size;

	num_items = (pos1 + len - pos)/item_size;
	de_dbg(c, "calculated number of items: %d", (int)num_items);

	for(k=0; k<num_items; k++) {
		i64 x;
		de_dbg(c, "item[%d] at %"I64_FMT, (int)k, pos);
		de_dbg_indent(c, 1);
		if(t_size>0) {
			if(t_size==1) {
				x = (i64)de_getbyte_p(&pos);
			}
			else {
				x = de_getu16be_p(&pos);
			}
			de_dbg(c, "tile number: %u", (unsigned int)x);
		}

		if(p_size==2) {
			x = de_getu16be_p(&pos);
		}
		else {
			x = de_getu32be_p(&pos);
		}
		de_dbg(c, "tile length: %u", (unsigned int)x);
		de_dbg_indent(c, -1);
	}

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %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 -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x2, -0x30(%rbp)
jge 0xc8117
jmp 0xc8368
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x165170
movb %al, -0x31(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x31(%rbp), %edx
leaq 0xd689e(%rip), %rsi     # 0x19e9d8
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movb %al, -0x32(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x32(%rbp), %edx
leaq 0xf049f(%rip), %rsi     # 0x1b8606
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movzbl -0x32(%rbp), %eax
andl $0x30, %eax
sarl $0x4, %eax
movb %al, -0x49(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x49(%rbp), %edx
leaq 0xf0485(%rip), %rsi     # 0x1b861d
movb $0x0, %al
callq 0x15b0d0
movzbl -0x32(%rbp), %eax
andl $0x40, %eax
sarl $0x6, %eax
movb %al, -0x4a(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x4a(%rbp), %edx
leaq 0xf0481(%rip), %rsi     # 0x1b863c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movzbl -0x49(%rbp), %eax
cmpl $0x0, %eax
jne 0xc81e3
movq $0x0, -0x58(%rbp)
jmp 0xc8212
movzbl -0x49(%rbp), %eax
cmpl $0x1, %eax
jne 0xc81f6
movq $0x1, -0x58(%rbp)
jmp 0xc8210
movzbl -0x49(%rbp), %eax
cmpl $0x2, %eax
jne 0xc8209
movq $0x2, -0x58(%rbp)
jmp 0xc820e
jmp 0xc8368
jmp 0xc8210
jmp 0xc8212
movzbl -0x4a(%rbp), %eax
cmpl $0x0, %eax
jne 0xc8225
movq $0x2, -0x60(%rbp)
jmp 0xc822d
movq $0x4, -0x60(%rbp)
movq -0x58(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
subq -0x48(%rbp), %rax
cqto
idivq -0x40(%rbp)
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rax
movl %eax, %edx
leaq 0xf03fb(%rip), %rsi     # 0x1b865b
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0xc8366
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rax
movl %eax, %edx
movq -0x48(%rbp), %rcx
leaq 0xd97da(%rip), %rsi     # 0x1a1a6c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
cmpq $0x0, -0x58(%rbp)
jle 0xc82fc
cmpq $0x1, -0x58(%rbp)
jne 0xc82cf
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movq %rax, -0x78(%rbp)
jmp 0xc82e4
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x165210
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movl %eax, %edx
leaq 0xf0385(%rip), %rsi     # 0x1b867a
movb $0x0, %al
callq 0x15b0d0
cmpq $0x2, -0x60(%rbp)
jne 0xc831a
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x165210
movq %rax, -0x78(%rbp)
jmp 0xc832f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movl %eax, %edx
leaq 0xf034a(%rip), %rsi     # 0x1b868a
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0xc826f
jmp 0xc8368
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)