// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ProcessImage()
int CCapsImageStd::CheckEncoder(int encoder, int revision)
{
	if (!dii.civalid)
		return imgeOk;

	int err=0;

	switch (encoder) {
		case CAPS_ENCODER:
			if (revision < 1 || revision > CAPS_ENCODER_REV)
				err=1;
			break;

		case SPS_ENCODER:
			if (revision < 1 || revision > SPS_ENCODER_REV)
				err=1;
			break;

		default:
			err=1;
			break;
	}

	return err ? imgeIncompatible : imgeOk;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
cmpl $0x0, 0x48(%rdi)
je 0xa0a7
movl 0x54(%rdi), %eax
movl 0x50(%rdi), %ecx
movl $0xe, %r14d
cmpl $0x2, %ecx
je 0xa0a2
cmpl $0x1, %ecx
jne 0xa0d7
cmpl $0x1, %eax
jne 0xa0d7
movq 0x210(%rdi), %r13
movl 0x108(%r13), %eax
addl $-0xa, %eax
movl $0xe, %r14d
cmpl $-0x9, %eax
jb 0xa0d7
cmpl $0x1, 0x10c(%r13)
jne 0xa0d7
cmpl $0x0, 0x12c(%r13)
je 0xa0e9
movl %r14d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, 0x8(%rsp)
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8dc
movq 0x8(%rsp), %rdi
movl 0x208(%rdi), %r12d
testl %r12d, %r12d
js 0xa148
movl 0x108(%r13), %edx
leal -0x3(%rdx), %eax
cmpl $0x6, %eax
ja 0xa15c
movl %r12d, %edx
andl $0x7ffffffe, %edx       # imm = 0x7FFFFFFE
movl %edx, 0x208(%rdi)
movl 0x1c8(%rdi), %eax
xorl %ecx, %ecx
cmpl $0x40000000, %r12d      # imm = 0x40000000
setae %cl
leal 0x1(,%rcx,4), %ecx
movl %edx, %r12d
jmp 0xa19a
movq (%rdi), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *0x30(%rax)
movl 0x1c8(%rdi), %eax
xorl %ecx, %ecx
cmpl $0x40000000, %r12d      # imm = 0x40000000
setae %cl
leal 0x1(,%rcx,4), %ecx
cmpl $0x1, %edx
jne 0xa19a
testb $0x20, %r12b
jne 0xa184
xorl %ecx, %ecx
jmp 0xa19a
testb $0x40, %r12b
movl $0x2, %edx
cmovnel %edx, %ecx
testl %eax, %eax
movl $0x186a0, %edx          # imm = 0x186A0
cmovel %edx, %eax
btl $0x8, %r12d
movl $0x5, %ebx
cmovbl %ecx, %ebx
testb $0x1, 0x130(%r13)
cmovel %ecx, %ebx
movl %eax, %ecx
andl $-0x10, %ecx
addl $0x10, %ecx
testb $0xf, %al
cmovel %eax, %ecx
testb $0x2, %r12b
cmovel %eax, %ecx
movl %ecx, %eax
andl $-0x8, %eax
addl $0x8, %eax
testb $0x7, %cl
cmovel %ecx, %eax
testl $0x1000, %r12d          # imm = 0x1000
cmovnel %ecx, %eax
movl %eax, 0x4(%rsp)
movl %eax, %r15d
imull %ebx, %r15d
leal 0x7(%r15), %eax
movl %eax, %r14d
shrl $0x3, %r14d
cmpl $0x8, %eax
jae 0xa204
movq $0x0, 0x20(%rsp)
jmp 0xa226
movl %r14d, %ebp
movq %rbp, %rdi
callq 0x4040
movq %rax, 0x20(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x4140
movq 0x8(%rsp), %rdi
movl 0x1d4(%rdi), %edx
movl 0x4(%rsp), %ebp
testl %ebp, %ebp
je 0xa23a
movl %edx, %eax
xorl %edx, %edx
divl %ebp
xorl %eax, %eax
testb $0x1, %r12b
cmovnel %eax, %edx
movl %edx, 0x14(%rsp)
movl %ebx, 0x28(%r13)
movq 0x20(%rsp), %r12
movq %r12, 0x48(%r13)
movl %r14d, 0x50(%r13)
movl %edx, %eax
shrl $0x3, %eax
movl %eax, 0xc0(%r13)
movq $-0x1, 0xe0(%r13)
movl %r15d, 0xe8(%r13)
movl %ebp, 0xec(%r13)
movl %edx, 0xf0(%r13)
movl $0x87654321, 0xc4(%r13) # imm = 0x87654321
movq %r13, %rdi
callq 0xf312
movq 0x8(%rsp), %r14
movq %r12, 0x1b8(%r14)
movl %r15d, 0x1c0(%r14)
movl %ebp, 0x1c4(%r14)
leaq 0xb8(%r14), %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0x4994
testl %ebx, %ebx
je 0xa490
movq %r13, 0x38(%rsp)
movl 0x1c8(%r14), %eax
movl %ebp, %ecx
movl %eax, 0x30(%rsp)
subl %eax, %ecx
movl %ecx, 0x34(%rsp)
movl %ebx, %eax
movq %rax, 0x40(%rsp)
movl 0x14(%rsp), %r13d
xorl %esi, %esi
movl $0x0, 0x18(%rsp)
movl $0x0, 0x1c(%rsp)
movq %r14, %r15
xorl %r14d, %r14d
movl %esi, %eax
shrl $0x3, %eax
movq 0x20(%rsp), %rcx
addq %rax, %rcx
movq 0x38(%rsp), %rdx
movq %rcx, 0x58(%rdx,%r14,8)
movl %eax, 0x94(%rdx,%r14,4)
addl %ebp, %esi
movl %esi, 0x2c(%rsp)
movl %esi, %ecx
shrl $0x3, %ecx
subl %eax, %ecx
movl %ecx, 0x80(%rdx,%r14,4)
movl 0x204(%r15), %eax
testl %eax, %eax
jle 0xa41b
movl $0x4, %esi
xorl %r12d, %r12d
movl %r13d, %edx
movq %r14, 0x48(%rsp)
movq 0x1f8(%r15), %rcx
movl -0x4(%rcx,%rsi), %r13d
movl (%rcx,%rsi), %r8d
decl %eax
cmpq %rax, %r12
movq %rsi, 0x50(%rsp)
jne 0xa38e
testl %r8d, %r8d
jne 0xa389
movl 0x30(%rsp), %eax
cmpl %eax, 0x4(%rsp)
jne 0xa506
addl 0x34(%rsp), %r8d
movq %r15, %rdi
movl %r12d, %esi
movl %edx, %ebp
movl %r13d, %ecx
movl %r8d, %ebx
callq 0xa512
testl %eax, %eax
jne 0xa488
movl 0x204(%r15), %eax
movq 0x48(%rsp), %r14
testq %r14, %r14
jne 0xa3e5
leal -0x1(%rax), %ecx
cmpq %rcx, %r12
setne %cl
cmpl $0x0, 0x1e0(%r15)
sete %dl
orb %cl, %dl
jne 0xa3e5
movl $0x1, 0x1c(%rsp)
movl 0x1e4(%r15), %ecx
movl %ecx, 0x18(%rsp)
movslq %eax, %rcx
addl %ebp, %r13d
addl %ebx, %r13d
movl 0x1c0(%r15), %edx
cmpl %edx, %r13d
movl $0x0, %esi
cmovbl %esi, %edx
subl %edx, %r13d
incq %r12
movq 0x50(%rsp), %rsi
addq $0x28, %rsi
movl %r13d, %edx
cmpq %rcx, %r12
jl 0xa35a
movq 0x8(%rsp), %rdi
callq 0xa5ea
movq 0x8(%rsp), %r15
incq %r14
cmpq 0x40(%rsp), %r14
movl 0x4(%rsp), %ebp
movl 0x2c(%rsp), %esi
jne 0xa307
movl $0x2, %r14d
cmpl 0x14(%rsp), %r13d
movq 0x38(%rsp), %r13
jne 0xa0d7
movl 0x208(%r15), %ecx
cmpl $0x0, 0x1c(%rsp)
je 0xa49a
movl 0x18(%rsp), %eax
xorl %edx, %edx
divl %ebp
movl %edx, 0xe4(%r13)
movl %edx, %eax
shrl $0x3, %eax
btl $0xb, %ecx
cmovbl %edx, %eax
movl %eax, 0xe0(%r13)
jmp 0xa49a
movl %eax, %r14d
jmp 0xa0d7
movl 0x208(%r14), %ecx
movq %r14, %r15
cmpl $0x1, 0x108(%r13)
setne %al
testb $0x20, %cl
sete %dl
orb %al, %dl
jne 0xa4da
cmpl $0x0, 0x50(%r13)
jle 0xa4da
movl $0x10030f01, %eax       # imm = 0x10030F01
xorl %ecx, %ecx
movq 0x48(%r13), %rdx
movb %al, (%rdx,%rcx)
roll $0x8, %eax
incq %rcx
movslq 0x50(%r13), %rdx
cmpq %rdx, %rcx
jl 0xa4bd
movl 0x208(%r15), %ecx
movq 0x1e8(%r15), %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0xa68e
movq %r15, %rdi
callq 0x9ec4
xorl %r14d, %r14d
movq %r15, %rdi
xorl %esi, %esi
callq 0x9ca2
jmp 0xa0d7
movl $0x2, %r14d
jmp 0xa0d7
nop