// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/jpeg.c
// Function: get_marker_info
static int get_marker_info(deark *c, lctx *d, u8 seg_type,
	struct marker_info *mi)
{
	i64 k;

	de_zeromem(mi, sizeof(struct marker_info));
	mi->seg_type = seg_type;

	// First, try to find the segment type in the static marker info.
	for(k=0; k<(i64)DE_ARRAYCOUNT(marker_info1_arr); k++) {
		const struct marker_info1 *mi1 = &marker_info1_arr[k];

		if(!d->is_jpegls && !(mi1->flags&FLAG_JPEG_COMPAT)) continue;
		if(d->is_jpegls && !(mi1->flags&FLAG_JPEGLS_COMPAT)) continue;
		if(!d->is_pegasus_pic2 && (mi1->flags&FLAG_PIC2_ONLY)) continue;

		if(mi1->seg_type == seg_type) {
			mi->flags = mi1->flags;
			mi->hfn = mi1->hfn;
			de_strlcpy(mi->shortname, mi1->shortname, sizeof(mi->shortname));
			if(mi1->longname) {
				de_snprintf(mi->longname, sizeof(mi->longname), "%s: %s",
					mi1->shortname, mi1->longname);
			}
			goto done;
		}
	}

	// Handle some pattern-based markers.

	if(seg_type>=0xe0 && seg_type<=0xef) {
		de_snprintf(mi->shortname, sizeof(mi->shortname), "APP%d", (int)(seg_type-0xe0));
		mi->hfn = handler_app;
		goto done;
	}

	if(seg_type>=0xc0 && seg_type<=0xcf) {
		de_snprintf(mi->shortname, sizeof(mi->shortname), "SOF%d", (int)(seg_type-0xc0));
		de_snprintf(mi->longname, sizeof(mi->longname), "%s: Start of frame", mi->shortname);
		mi->flags |= FLAG_IS_SOF;
		mi->hfn = handler_sof;
		goto done;
	}

	if(seg_type>=0xd0 && seg_type<=0xd7) {
		int rstn = (int)(seg_type-0xd0);
		de_snprintf(mi->shortname, sizeof(mi->shortname), "RST%d", rstn);
		de_snprintf(mi->longname, sizeof(mi->longname), "%s: Restart with mod 8 count %d",
			mi->shortname, rstn);
		mi->flags |= FLAG_NO_DATA;
		goto done;
	}

	if(seg_type>=0xf0 && seg_type<=0xfd) {
		de_snprintf(mi->shortname, sizeof(mi->shortname), "JPG%d", (int)(seg_type-0xf0));
		goto done;
	}

	de_strlcpy(mi->shortname, "???", sizeof(mi->shortname));
	de_strlcpy(mi->longname, "???", sizeof(mi->longname));
	return 0;

done:
	if(!mi->longname[0]) {
		// If no longname was set, use the shortname
		de_strlcpy(mi->longname, mi->shortname, sizeof(mi->longname));
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x19140
movb -0x19(%rbp), %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movq $0x0, -0x30(%rbp)
cmpq $0x11, -0x30(%rbp)
jge 0xbc63b
movq -0x30(%rbp), %rcx
leaq 0x15d6f0(%rip), %rax    # 0x219c30
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0xbc568
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xbc568
jmp 0xbc62a
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0xbc588
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xbc588
jmp 0xbc62a
movq -0x18(%rbp), %rax
cmpb $0x0, 0x1(%rax)
jne 0xbc5a6
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xbc5a6
jmp 0xbc62a
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
movzbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jne 0xbc628
movq -0x38(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
movl $0xc, %edx
callq 0x15aa30
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xbc623
movq -0x28(%rbp), %rdi
addq $0x14, %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x38(%rbp), %rax
movq 0x10(%rax), %r8
movl $0x50, %esi
leaq 0x1188aa(%rip), %rdx    # 0x1d4ec6
movb $0x0, %al
callq 0x15a980
jmp 0xbc7fd
jmp 0xbc62a
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xbc52a
movzbl -0x19(%rbp), %eax
cmpl $0xe0, %eax
jl 0xbc68a
movzbl -0x19(%rbp), %eax
cmpl $0xef, %eax
jg 0xbc68a
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movzbl -0x19(%rbp), %ecx
subl $0xe0, %ecx
movl $0xc, %esi
leaq 0xf9eb6(%rip), %rdx     # 0x1b6525
movb $0x0, %al
callq 0x15a980
movq -0x28(%rbp), %rax
leaq 0x61f(%rip), %rcx       # 0xbcca0
movq %rcx, 0x68(%rax)
jmp 0xbc7fd
movzbl -0x19(%rbp), %eax
cmpl $0xc0, %eax
jl 0xbc70c
movzbl -0x19(%rbp), %eax
cmpl $0xcf, %eax
jg 0xbc70c
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movzbl -0x19(%rbp), %ecx
subl $0xc0, %ecx
movl $0xc, %esi
leaq 0xf9e6d(%rip), %rdx     # 0x1b652b
movb $0x0, %al
callq 0x15a980
movq -0x28(%rbp), %rdi
addq $0x14, %rdi
movq -0x28(%rbp), %rcx
addq $0x8, %rcx
movl $0x50, %esi
leaq 0xf9e50(%rip), %rdx     # 0x1b6531
movb $0x0, %al
callq 0x15a980
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
leaq 0x8fd(%rip), %rcx       # 0xbd000
movq %rcx, 0x68(%rax)
jmp 0xbc7fd
movzbl -0x19(%rbp), %eax
cmpl $0xd0, %eax
jl 0xbc785
movzbl -0x19(%rbp), %eax
cmpl $0xd7, %eax
jg 0xbc785
movzbl -0x19(%rbp), %eax
subl $0xd0, %eax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movl -0x3c(%rbp), %ecx
movl $0xc, %esi
leaq 0xf9dff(%rip), %rdx     # 0x1b6544
movb $0x0, %al
callq 0x15a980
movq -0x28(%rbp), %rdi
addq $0x14, %rdi
movq -0x28(%rbp), %rcx
addq $0x8, %rcx
movl -0x3c(%rbp), %r8d
movl $0x50, %esi
leaq 0xf9dde(%rip), %rdx     # 0x1b654a
movb $0x0, %al
callq 0x15a980
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movl %ecx, 0x4(%rax)
jmp 0xbc7fd
movzbl -0x19(%rbp), %eax
cmpl $0xf0, %eax
jl 0xbc7c2
movzbl -0x19(%rbp), %eax
cmpl $0xfd, %eax
jg 0xbc7c2
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movzbl -0x19(%rbp), %ecx
subl $0xf0, %ecx
movl $0xc, %esi
leaq 0xf9db1(%rip), %rdx     # 0x1b656a
movb $0x0, %al
callq 0x15a980
jmp 0xbc7fd
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
leaq 0xf9d9f(%rip), %rsi     # 0x1b6570
movl $0xc, %edx
callq 0x15aa30
movq -0x28(%rbp), %rdi
addq $0x14, %rdi
leaq 0xf9d86(%rip), %rsi     # 0x1b6570
movl $0x50, %edx
callq 0x15aa30
movl $0x0, -0x4(%rbp)
jmp 0xbc828
movq -0x28(%rbp), %rax
cmpb $0x0, 0x14(%rax)
jne 0xbc821
movq -0x28(%rbp), %rdi
addq $0x14, %rdi
movq -0x28(%rbp), %rsi
addq $0x8, %rsi
movl $0x50, %edx
callq 0x15aa30
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)