// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-user.c
// Function: detect_module_for_file
static struct deark_module_info *detect_module_for_file(deark *c, int *errflag)
{
	int i;
	int result;
	int orig_errcount;
	struct deark_module_info *best_module = NULL;

	*errflag = 0;
	if(!c->detection_data) {
		c->detection_data = de_malloc(c, sizeof(struct de_detection_data_struct));
	}

	// This value is made available to modules' identification functions, so
	// that they can potentially skip expensive tests that cannot possibly return
	// a high enough confidence.
	c->detection_data->best_confidence_so_far = 0;

	orig_errcount = c->error_count;
	for(i=0; i<c->num_modules; i++) {
		if(c->module_info[i].identify_fn==NULL) continue;

		// If autodetect is disabled for this module, and its autodetect routine
		// doesn't do anything that may be needed by other modules, don't bother
		// to run this module's autodetection.
		if((c->module_info[i].flags & DE_MODFLAG_DISABLEDETECT) &&
			!(c->module_info[i].flags & DE_MODFLAG_SHAREDDETECTION))
		{
			continue;
		}

		result = c->module_info[i].identify_fn(c);

		if(c->error_count > orig_errcount) {
			// Detection routines don't normally produce errors. If one does,
			// it's probably an internal error, or other serious problem.
			*errflag = 1;
			return NULL;
		}

		if(c->module_info[i].flags & DE_MODFLAG_DISABLEDETECT) {
			// Ignore results of autodetection.
			continue;
		}

		if(result <= c->detection_data->best_confidence_so_far) continue;

		// This is the best result so far.
		c->detection_data->best_confidence_so_far = result;
		best_module = &c->module_info[i];
		if(c->detection_data->best_confidence_so_far>=100) break;
	}

	return best_module;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x18e526
movq -0x10(%rbp), %rdi
movl $0x20, %esi
callq 0x15b780
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1a8(%rcx), %eax
jge 0x18e685
movq -0x10(%rbp), %rax
movq 0x1b0(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x20(%rax)
jne 0x18e57a
jmp 0x18e677
movq -0x10(%rbp), %rax
movq 0x1b0(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x18e5c3
movq -0x10(%rbp), %rax
movq 0x1b0(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x18e5c3
jmp 0x18e677
movq -0x10(%rbp), %rax
movq 0x1b0(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x48(%rax), %eax
cmpl -0x24(%rbp), %eax
jle 0x18e609
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x18e68d
movq -0x10(%rbp), %rax
movq 0x1b0(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x18e62e
jmp 0x18e677
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
cmpl (%rcx), %eax
jg 0x18e63f
jmp 0x18e677
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x1b0(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
cmpl $0x64, (%rax)
jl 0x18e675
jmp 0x18e685
jmp 0x18e677
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x18e545
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)