// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/jpeg.c
// Function: do_jfif_segment
static void do_jfif_segment(deark *c, lctx *d,
	i64 pos1, i64 data_size)
{
	u8 units;
	const char *units_name;
	i64 xdens, ydens;
	i64 tn_size;
	i64 tn_w, tn_h;
	i64 pos;

	d->has_jfif_seg = 1;
	if(data_size<9) goto done;
	pos = pos1;
	d->jfif_ver_h = de_getbyte_p(&pos);
	d->jfif_ver_l = de_getbyte_p(&pos);
	de_dbg(c, "JFIF version: %d.%02d", (int)d->jfif_ver_h, (int)d->jfif_ver_l);
	units = de_getbyte_p(&pos);
	xdens = de_getu16be_p(&pos);
	ydens = de_getu16be_p(&pos);
	if(units==1) units_name="dpi";
	else if(units==2) units_name="dots/cm";
	else units_name="(unspecified)";
	de_dbg(c, "density: %d"DE_CHAR_TIMES"%d, units=%s", (int)xdens, (int)ydens, units_name);

	tn_w = (i64)de_getbyte_p(&pos);
	tn_h = (i64)de_getbyte_p(&pos);
	de_dbg(c, "thumbnail dimensions: %d"DE_CHAR_TIMES"%d", (int)tn_w, (int)tn_h);
	tn_size = pos1 + data_size - pos;
	if(tn_w>0 && tn_h>0 && tn_size>0) {
		de_dbg(c, "thunbnail at %"I64_FMT", len=%"I64_FMT, pos, tn_size);
		d->has_jfif_thumb = 1;
		if(tn_w*tn_h*3 != tn_size) {
			de_warn(c, "Expected %"I64_FMT" bytes of JFIF thumbnail image data, "
				"found %"I64_FMT, (i64)(tn_w*tn_h*3), tn_size);
		}
		extract_unc_jfif_thumbnail(c, d, pos, tn_size, tn_w, tn_h,
			0, "jfifthumb");
	}

done:
	;
}

// 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 -0x10(%rbp), %rax
movb $0x1, 0x2(%rax)
cmpq $0x9, -0x20(%rbp)
jge 0xbea0c
jmp 0xbec0e
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0x165170
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0x165170
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x39(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x38(%rax), %edx
movq -0x10(%rbp), %rax
movzbl 0x39(%rax), %ecx
leaq 0xf8039(%rip), %rsi     # 0x1b6a9c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0x165170
movb %al, -0x21(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0x165210
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0x165210
movq %rax, -0x40(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x1, %eax
jne 0xbeabe
leaq 0x10e5fa(%rip), %rax    # 0x1cd0b2
movq %rax, -0x30(%rbp)
jmp 0xbeae1
movzbl -0x21(%rbp), %eax
cmpl $0x2, %eax
jne 0xbead4
leaq 0xf7fe4(%rip), %rax     # 0x1b6ab2
movq %rax, -0x30(%rbp)
jmp 0xbeadf
leaq 0xf7fdf(%rip), %rax     # 0x1b6aba
movq %rax, -0x30(%rbp)
jmp 0xbeae1
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %r8
leaq 0xf7fcc(%rip), %rsi     # 0x1b6ac8
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x58(%rbp), %rax
movl %eax, %ecx
leaq 0xf8040(%rip), %rsi     # 0x1b6b8a
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
subq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x50(%rbp)
jle 0xbec0c
cmpq $0x0, -0x58(%rbp)
jle 0xbec0c
cmpq $0x0, -0x48(%rbp)
jle 0xbec0c
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rdx
movq -0x48(%rbp), %rcx
leaq 0xf7f4d(%rip), %rsi     # 0x1b6ae2
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movb $0x1, 0x3(%rax)
movq -0x50(%rbp), %rax
imulq -0x58(%rbp), %rax
imulq $0x3, %rax, %rax
cmpq -0x48(%rbp), %rax
je 0xbebda
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
imulq -0x58(%rbp), %rax
imulq $0x3, %rax, %rdx
movq -0x48(%rbp), %rcx
leaq 0xf7f29(%rip), %rsi     # 0x1b6afc
movb $0x0, %al
callq 0x15bc10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movq -0x58(%rbp), %r9
xorl %eax, %eax
leaq 0xf7f3c(%rip), %rax     # 0x1b6b37
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xc0460
jmp 0xbec0e
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)