// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/ilbm.c
// Function: deep_make_sample_map
static int deep_make_sample_map(deark *c, struct deep_ctx *d)
{
	UI k;
	u8 flags[5] = {0,0,0,0,0};
	int retval = 0;

	de_zeromem(d->sample_map, sizeof(d->sample_map));
	d->have_alpha = 0;
	d->is_assoc_alpha = 0;

	if(d->num_components<3 || d->num_components>DEEP_MAX_COMPONENTS) {
		goto done;
	}

	for(k=0; k<(UI)d->num_components; k++) {
		switch(d->cmp_type[k]) {
		case 1:
			d->sample_map[k] = 0;
			break;
		case 2:
			d->sample_map[k] = 1;
			break;
		case 3:
			d->sample_map[k] = 2;
			break;
		case 4:
			d->sample_map[k] = 3;
			d->have_alpha = 1;
			d->is_assoc_alpha = 0;
			break;
		case 17: // Undocumented type 17 used in Video Toaster "Brushes" files.
			d->sample_map[k] = 3;
			d->have_alpha = 1;
			d->is_assoc_alpha = 1;
			break;
		default:
			d->sample_map[k] = 4;
		}

		flags[d->sample_map[k]] = 1;
	}

	if(!flags[0] || !flags[1] || !flags[2]) { // Need R, G, B
		goto done;
	}
	if(flags[4]) { // Found an unsupported sample type
		de_warn(c, "Image type not fully supported");
	}
	retval = 1;

done:
	if(!retval) {
		de_err(c, "Unsupported image type");
	}
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x19(%rbp), %rdi
xorl %esi, %esi
movl $0x5, %edx
callq 0x19140
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
addq $0x94, %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x19140
movq -0x10(%rbp), %rax
movb $0x0, 0x50(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x52(%rax)
movq -0x10(%rbp), %rax
cmpq $0x3, 0x48(%rax)
jl 0xb6c24
movq -0x10(%rbp), %rax
cmpq $0x8, 0x48(%rax)
jle 0xb6c29
jmp 0xb6d60
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl %ecx, %eax
jae 0xb6d2d
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x74(%rax,%rcx,4), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x10, %eax
ja 0xb6cfa
movq -0x28(%rbp), %rax
leaq 0xfd73e(%rip), %rcx     # 0x1b43a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl $0x0, 0x94(%rax,%rcx,4)
jmp 0xb6d0c
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl $0x1, 0x94(%rax,%rcx,4)
jmp 0xb6d0c
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl $0x2, 0x94(%rax,%rcx,4)
jmp 0xb6d0c
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl $0x3, 0x94(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movb $0x1, 0x50(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x52(%rax)
jmp 0xb6d0c
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl $0x3, 0x94(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movb $0x1, 0x50(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x52(%rax)
jmp 0xb6d0c
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl $0x4, 0x94(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x94(%rax,%rcx,4), %eax
movb $0x1, -0x19(%rbp,%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xb6c30
cmpb $0x0, -0x19(%rbp)
je 0xb6d3f
cmpb $0x0, -0x18(%rbp)
je 0xb6d3f
cmpb $0x0, -0x17(%rbp)
jne 0xb6d41
jmp 0xb6d60
cmpb $0x0, -0x15(%rbp)
je 0xb6d59
movq -0x8(%rbp), %rdi
leaq 0xfe3ea(%rip), %rsi     # 0x1b513c
movb $0x0, %al
callq 0x15bc10
movl $0x1, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0xb6d78
movq -0x8(%rbp), %rdi
leaq 0xec74f(%rip), %rsi     # 0x1a34c0
movb $0x0, %al
callq 0x15bfb0
movl -0x20(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)