// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/exe.c
// Function: do_exesfx
static void do_exesfx(deark *c, lctx *d)
{
	u8 suggest_opt_sfx = 0;
	struct fmtutil_specialexe_detection_data edd;

	if(!d->ei) return;
	de_zeromem(&edd, sizeof(struct fmtutil_specialexe_detection_data));
	edd.flags_in |= 0x1;
	if(d->might_be_ishield_sfx_ne) {
		edd.detected_fmt = DE_SPECIALEXEFMT_ISHIELDNE;
		de_strlcpy(edd.detected_fmt_name, "InstallShield (NE)",
			sizeof(edd.detected_fmt_name));
	}
	else {
		fmtutil_detect_exesfx(c, d->ei, &edd);
	}

	if(edd.zip_eocd_found && !edd.detected_fmt) {
		// Probably a ZIP SFX, but maybe not, or maybe one we can't handle.
		// TODO?: Maybe we should just try to extract it anyway.
		de_info(c, "Note: This might be a self-extracting ZIP file "
			"(try \"-m zip -opt zip:reloc\").");
		goto done;
	}

	if(!edd.detected_fmt) goto done;

	de_dbg(c, "detected self-extracting exe: %s", edd.detected_fmt_name);
	if(edd.detected_fmt==DE_SPECIALEXEFMT_ZIPSFX) {
		// ZIP SFX generally needs special processing
		extract_zip_from_sfx(c, d, &edd);
	}
	else if(edd.detected_fmt==DE_SPECIALEXEFMT_ARJSFX) {
		// ARJ SFX generally needs special processing
		extract_arj_from_sfx(c, d, &edd);
	}
	else if(edd.detected_fmt==DE_SPECIALEXEFMT_PAK16SFX) {
		extract_pak16_from_sfx(c, d, &edd);
	}
	else if(edd.detected_fmt==DE_SPECIALEXEFMT_ISHIELDNE) {
		if(d->sfx_only_mode) {
			extract_ishieldsfx_ne(c, d, &edd);
		}
		else {
			suggest_opt_sfx = 1;
		}
	}
	else if(edd.payload_valid) {
		dbuf_create_file_from_slice(d->ei->f, edd.payload_pos, edd.payload_len,
			edd.payload_file_ext, NULL, 0);
	}
	else {
		de_info(c, "Note: This might be a self-extracting %s archive, but it's "
			"not a supported format or version.", edd.detected_fmt_name);
	}

	if(suggest_opt_sfx) {
		de_info(c, "Note: This looks like a self-extracting %s archive. Use "
			"\"-opt exe:sfx\" to attempt extraction.", edd.detected_fmt_name);
	}

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x5fb07
jmp 0x5fce4
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x78, %edx
callq 0x19140
movl -0x88(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x88(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x80(%rax)
je 0x5fb5b
movb $0x6e, -0x8f(%rbp)
leaq -0x90(%rbp), %rdi
addq $0x50, %rdi
leaq 0x149791(%rip), %rsi    # 0x1a92e0
movl $0x28, %edx
callq 0x15aa30
jmp 0x5fb73
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x90(%rbp), %rdx
callq 0x189e10
movzbl -0x8b(%rbp), %eax
cmpl $0x0, %eax
je 0x5fb9f
cmpb $0x0, -0x8f(%rbp)
jne 0x5fb9f
movq -0x8(%rbp), %rdi
leaq 0x149760(%rip), %rsi    # 0x1a92f3
movb $0x0, %al
callq 0x15c0c0
jmp 0x5fce4
cmpb $0x0, -0x8f(%rbp)
jne 0x5fbad
jmp 0x5fce4
movq -0x8(%rbp), %rdi
leaq -0x90(%rbp), %rdx
addq $0x50, %rdx
leaq 0x14977e(%rip), %rsi    # 0x1a9341
movb $0x0, %al
callq 0x15b0d0
movzbl -0x8f(%rbp), %eax
cmpl $0x65, %eax
jne 0x5fbef
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x63530
jmp 0x5fcbf
movzbl -0x8f(%rbp), %eax
cmpl $0x66, %eax
jne 0x5fc14
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x63620
jmp 0x5fcbd
movzbl -0x8f(%rbp), %eax
cmpl $0x67, %eax
jne 0x5fc39
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x63720
jmp 0x5fcbb
movzbl -0x8f(%rbp), %eax
cmpl $0x6e, %eax
jne 0x5fc6b
movq -0x10(%rbp), %rax
cmpb $0x0, 0x3(%rax)
je 0x5fc65
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x637f0
jmp 0x5fc69
movb $0x1, -0x11(%rbp)
jmp 0x5fcb9
cmpb $0x0, -0x8d(%rbp)
je 0x5fc9a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq -0x50(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x166be0
jmp 0x5fcb7
movq -0x8(%rbp), %rdi
leaq -0x90(%rbp), %rdx
addq $0x50, %rdx
leaq 0x1496b2(%rip), %rsi    # 0x1a9362
movb $0x0, %al
callq 0x15c0c0
jmp 0x5fcb9
jmp 0x5fcbb
jmp 0x5fcbd
jmp 0x5fcbf
cmpb $0x0, -0x11(%rbp)
je 0x5fce2
movq -0x8(%rbp), %rdi
leaq -0x90(%rbp), %rdx
addq $0x50, %rdx
leaq 0x1496e5(%rip), %rsi    # 0x1a93c0
movb $0x0, %al
callq 0x15c0c0
jmp 0x5fce4
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)