// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/jpeg.c
// Function: handler_app
static void handler_app(deark *c, lctx *d,
	const struct marker_info *mi, i64 seg_data_pos, i64 seg_data_size)
{
	int appsegtype;
	i64 payload_pos;
	i64 payload_size;
	struct app_id_info_struct app_id_info;

	de_zeromem(&app_id_info, sizeof(struct app_id_info_struct));

	detect_app_seg_type(c, d, mi, seg_data_pos, seg_data_size, &app_id_info);
	appsegtype = app_id_info.appsegtype;
	payload_pos = app_id_info.payload_pos;
	if(app_id_info.app_id_found) {
		de_dbg(c, "app id: \"%s\", identified as: %s", ucstring_getpsz(app_id_info.app_id_str),
			app_id_info.app_type_name);
	}
	else {
		de_dbg(c, "app id: (not found), identified as: %s", app_id_info.app_type_name);
	}

	payload_size = seg_data_pos + seg_data_size - payload_pos;
	if(payload_size<0) goto done;

	switch(appsegtype) {
	case APPSEGTYPE_JFIF:
		do_jfif_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_JFXX:
		do_jfxx_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_ADOBEAPP14:
		do_adobeapp14_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_EXIF:
		do_exif_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_META:
		do_meta_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_ICC_PROFILE:
		do_icc_profile_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_FPXR:
		d->has_flashpix = 1;
		do_fpxr_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_SPIFF:
		d->has_spiff_seg = 1;
		break;
	case APPSEGTYPE_PHOTOSHOP:
		do_photoshop_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_DUCKY:
		do_ducky_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_XMP:
		de_dbg(c, "XMP data at %d, size=%d", (int)(payload_pos), (int)(payload_size));
		d->has_xmp = 1;
		dbuf_create_file_from_slice(c->infile, payload_pos, payload_size, "xmp", NULL, DE_CREATEFLAG_IS_AUX);
		break;
	case APPSEGTYPE_XMP_EXTENSION:
		d->has_xmp_ext = 1;
		do_xmp_extension_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_HDR_RI_VER:
		d->is_jpeghdr = 1;
		do_jpeghdr_segment(c, d, seg_data_pos, seg_data_size, 0);
		break;
	case APPSEGTYPE_HDR_RI_EXT:
		do_jpeghdr_segment(c, d, seg_data_pos, seg_data_size, 1);
		break;
	case APPSEGTYPE_BOXFORMAT:
		do_boxformat_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_MPF:
		do_mpf_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_JPS:
		d->is_jps = 1;
		do_jps_segment(c, d, payload_pos, payload_size);
		break;
	case APPSEGTYPE_AROT:
		do_arot_segment(c, d, payload_pos, payload_size);
		break;
	default:
		if(c->debug_level>=2) {
			de_dbg_hexdump(c, c->infile, seg_data_pos, seg_data_size, 256, "segment data", 0x1);
		}
		break;
	}

done:
	if(app_id_info.app_id_str) {
		ucstring_destroy(app_id_info.app_id_str);
	}
}

// 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)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x19140
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x60(%rbp), %r9
callq 0xbe080
movl -0x5c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x60(%rbp)
je 0xbcd2c
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rdi
callq 0x172500
movq -0x68(%rbp), %rdi
movq %rax, %rdx
movq -0x48(%rbp), %rcx
leaq 0xf9b39(%rip), %rsi     # 0x1b685c
movb $0x0, %al
callq 0x15b0d0
jmp 0xbcd42
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq 0xf9b41(%rip), %rsi     # 0x1b687c
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
addq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jge 0xbcd5e
jmp 0xbcfe0
movl -0x2c(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x19, %eax
ja 0xbcfa6
movq -0x70(%rbp), %rax
leaq 0xf9552(%rip), %rcx     # 0x1b62d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbe9e0
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbec20
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbeda0
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbee70
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbef70
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbf010
jmp 0xbcfde
movq -0x10(%rbp), %rax
movb $0x1, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbf120
jmp 0xbcfde
movq -0x10(%rbp), %rax
movb $0x1, 0x7(%rax)
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbf620
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbf6d0
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %rax
movl %eax, %ecx
leaq 0xf9a06(%rip), %rsi     # 0x1b68a3
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movb $0x1, 0xd(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq 0x106503(%rip), %rcx    # 0x1c33c6
xorl %eax, %eax
movl %eax, %r8d
movl $0x1, %r9d
callq 0x166be0
jmp 0xbcfde
movq -0x10(%rbp), %rax
movb $0x1, 0xe(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbf800
jmp 0xbcfde
movq -0x10(%rbp), %rax
movb $0x1, 0x17(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
xorl %r8d, %r8d
callq 0xbfb30
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x1, %r8d
callq 0xbfb30
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbfca0
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbfe50
jmp 0xbcfde
movq -0x10(%rbp), %rax
movb $0x1, 0x1a(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xbff60
jmp 0xbcfde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xc0240
jmp 0xbcfde
movq -0x8(%rbp), %rax
cmpl $0x2, (%rax)
jl 0xbcfdc
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x100, %r8d            # imm = 0x100
leaq 0xf98eb(%rip), %r9      # 0x1b68bb
movl $0x1, (%rsp)
callq 0x15b840
jmp 0xbcfde
jmp 0xbcfe0
cmpq $0x0, -0x50(%rbp)
je 0xbcff0
movq -0x50(%rbp), %rdi
callq 0x171750
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)