// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/j2c.c
// Function: handler_cod
static void handler_cod(deark *c, lctx *d, struct page_ctx *pg,
	const struct marker_info *mi, i64 pos1, i64 len)
{
	i64 pos = pos1;
	u8 coding_style;
	de_ucstring *s = NULL;
	u8 b;
	i64 n;

	if(len<5) goto done;
	coding_style = de_getbyte_p(&pos);
	s = ucstring_create(c);

	if((coding_style&0xf8)==0) {
		switch(coding_style&0x01) {
		case 0x0: ucstring_append_flags_item(s, "entropy coder, without partitions"); break;
		case 0x1: ucstring_append_flags_item(s, "entropy coder, with partitions"); break;
		}
		switch((coding_style&0x02)>>1) {
		case 0x0: ucstring_append_flags_item(s, "no SOP segments"); break;
		case 0x1: ucstring_append_flags_item(s, "has SOP segments"); break;
		}
		switch((coding_style&0x04)>>2) {
		case 0x0: ucstring_append_flags_item(s, "no EPH segments"); break;
		case 0x1: ucstring_append_flags_item(s, "has EPH segments"); break;
		}
	}
	else {
		ucstring_append_flags_item(s, "?");
	}
	de_dbg(c, "coding style: 0x%02x (%s)", (unsigned int)coding_style,
		ucstring_getpsz(s));

	b = de_getbyte_p(&pos);
	de_dbg(c, "progression order: %d", (int)b);
	n = de_getu16be_p(&pos);
	de_dbg(c, "number of layers: %d", (int)n);
	(void)de_getbyte_p(&pos);

	if(pos < pos1+len) {
		// TODO
		de_dbg2(c, "[not decoding the rest of this segment]");
	}

done:
	ucstring_destroy(s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %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, -0x38(%rbp)
movq $0x0, -0x48(%rbp)
cmpq $0x5, -0x30(%rbp)
jge 0xc7f0c
jmp 0xc80c5
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x165170
movb %al, -0x39(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x48(%rbp)
movzbl -0x39(%rbp), %eax
andl $0xf8, %eax
cmpl $0x0, %eax
jne 0xc7ff8
movzbl -0x39(%rbp), %eax
andl $0x1, %eax
movl %eax, -0x5c(%rbp)
je 0xc7f57
jmp 0xc7f4d
movl -0x5c(%rbp), %eax
subl $0x1, %eax
je 0xc7f69
jmp 0xc7f79
movq -0x48(%rbp), %rdi
leaq 0xf05b4(%rip), %rsi     # 0x1b8516
callq 0x172680
jmp 0xc7f79
movq -0x48(%rbp), %rdi
leaq 0xf05c4(%rip), %rsi     # 0x1b8538
callq 0x172680
movzbl -0x39(%rbp), %eax
andl $0x2, %eax
shrl %eax
movl %eax, -0x60(%rbp)
testl %eax, %eax
je 0xc7f95
jmp 0xc7f8b
movl -0x60(%rbp), %eax
subl $0x1, %eax
je 0xc7fa7
jmp 0xc7fb7
movq -0x48(%rbp), %rdi
leaq 0xf05b7(%rip), %rsi     # 0x1b8557
callq 0x172680
jmp 0xc7fb7
movq -0x48(%rbp), %rdi
leaq 0xf05b5(%rip), %rsi     # 0x1b8567
callq 0x172680
movzbl -0x39(%rbp), %eax
andl $0x4, %eax
shrl $0x2, %eax
movl %eax, -0x64(%rbp)
testl %eax, %eax
je 0xc7fd4
jmp 0xc7fca
movl -0x64(%rbp), %eax
subl $0x1, %eax
je 0xc7fe6
jmp 0xc7ff6
movq -0x48(%rbp), %rdi
leaq 0xf0599(%rip), %rsi     # 0x1b8578
callq 0x172680
jmp 0xc7ff6
movq -0x48(%rbp), %rdi
leaq 0xf0597(%rip), %rsi     # 0x1b8588
callq 0x172680
jmp 0xc8008
movq -0x48(%rbp), %rdi
leaq 0xefc2a(%rip), %rsi     # 0x1b7c2d
callq 0x172680
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movzbl -0x39(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x48(%rbp), %rdi
callq 0x172500
movq -0x70(%rbp), %rdi
movl -0x68(%rbp), %edx
movq %rax, %rcx
leaq 0xf0568(%rip), %rsi     # 0x1b8599
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x165170
movb %al, -0x49(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x49(%rbp), %edx
leaq 0xf0558(%rip), %rsi     # 0x1b85b3
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x165210
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rax
movl %eax, %edx
leaq 0xf0541(%rip), %rsi     # 0x1b85c9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x165170
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
addq -0x30(%rbp), %rcx
cmpq %rcx, %rax
jge 0xc80c3
movq -0x8(%rbp), %rdi
leaq 0xf0522(%rip), %rsi     # 0x1b85de
movb $0x0, %al
callq 0x15b350
jmp 0xc80c5
movq -0x48(%rbp), %rdi
callq 0x171750
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)