// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: mdload
mdmodel *mdload (const char *filnam)
{
	mdmodel *vm;
	int fil;
	int i;

	vm = (mdmodel*)voxload(filnam); if (vm) return(vm);

	fil = kopen4load((char *)filnam,0); if (fil < 0) return(0);
	kread(fil,&i,4); klseek(fil,0,SEEK_SET);
	switch(B_LITTLE32(i))
	{
		case 0x32504449: vm = (mdmodel*)md2load(fil,filnam); break; //IDP2
		case 0x33504449: vm = (mdmodel*)md3load(fil); break; //IDP3
		default: vm = (mdmodel*)0; break;
	}
	kclose(fil);
	return(vm);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4c8, %rsp            # imm = 0x4C8
movq %rdi, %r15
callq 0x56db9
movq %rax, %r14
testq %rax, %rax
jne 0x562b6
xorl %r14d, %r14d
movq %r15, %rdi
xorl %esi, %esi
callq 0x1dc36
testl %eax, %eax
js 0x562b6
movl %eax, %ebp
leaq 0x50(%rsp), %rbx
pushq $0x4
popq %rdx
movl %eax, %edi
movq %rbx, %rsi
callq 0x1de3f
xorl %r14d, %r14d
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1e023
movl (%rbx), %eax
cmpl $0x33504449, %eax       # imm = 0x33504449
je 0x55e08
cmpl $0x32504449, %eax       # imm = 0x32504449
jne 0x562af
pushq $0x1
popq %rdi
movl $0x98, %esi
callq 0x6930
testq %rax, %rax
je 0x562ac
movq %rax, %r14
movl $0x2, (%rax)
movl $0x3c23d70a, 0x8(%rax)  # imm = 0x3C23D70A
leaq 0x54(%rsp), %rbx
pushq $0x44
popq %rdx
movl %ebp, %edi
movq %rbx, %rsi
callq 0x1de3f
cmpl $0x32504449, (%rbx)     # imm = 0x32504449
jne 0x562a4
cmpl $0x8, 0x58(%rsp)
jne 0x562a4
movl 0x68(%rsp), %eax
movl %eax, 0x50(%r14)
movl 0x7c(%rsp), %eax
movl %eax, 0x20(%r14)
movl 0x6c(%rsp), %eax
movl %eax, 0x58(%r14)
movq 0x70(%rsp), %rax
movq %rax, 0x5c(%r14)
movl 0x64(%rsp), %ecx
movl %ecx, 0x64(%r14)
movq 0x5c(%rsp), %rcx
movq %rcx, 0x68(%r14)
movslq %eax, %rdi
pushq $0x4
popq %rsi
callq 0x6930
movq %rax, 0x78(%r14)
testq %rax, %rax
je 0x562a4
movl 0x84(%rsp), %esi
movl %ebp, %edi
xorl %edx, %edx
callq 0x1e023
movq 0x78(%r14), %rsi
movl 0x5c(%r14), %edx
shll $0x2, %edx
movl %ebp, %edi
callq 0x1de3f
cltq
movslq 0x5c(%r14), %rcx
shlq $0x2, %rcx
cmpq %rax, %rcx
jne 0x562a4
movslq 0x60(%r14), %rdi
pushq $0xc
popq %rsi
callq 0x6930
movq %rax, 0x80(%r14)
testq %rax, %rax
je 0x562a4
movl 0x88(%rsp), %esi
movl %ebp, %edi
xorl %edx, %edx
callq 0x1e023
movq 0x80(%r14), %rsi
imull $0xc, 0x60(%r14), %edx
movl %ebp, %edi
callq 0x1de3f
cltq
movslq 0x60(%r14), %rcx
imulq $0xc, %rcx, %rcx
cmpq %rax, %rcx
jne 0x562a4
movslq 0x20(%r14), %rdi
movslq 0x64(%r14), %rsi
callq 0x6930
movq %rax, 0x70(%r14)
testq %rax, %rax
je 0x562a4
movl 0x8c(%rsp), %esi
movl %ebp, %edi
xorl %edx, %edx
callq 0x1e023
movq 0x70(%r14), %rsi
movl 0x64(%r14), %edx
imull 0x20(%r14), %edx
movl %ebp, %edi
callq 0x1de3f
movl 0x64(%r14), %ecx
imull 0x20(%r14), %ecx
cmpl %ecx, %eax
jne 0x562a4
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6430
movq %rbx, %rdi
callq 0x6420
incq %rax
cmpq $0x2, %rax
je 0x561e7
movzbl 0xbe(%rsp,%rax), %ecx
decq %rax
cmpl $0x5c, %ecx
je 0x561e9
cmpl $0x2f, %ecx
jne 0x55de0
jmp 0x561e9
pushq $0x1
popq %rdi
movl $0xd8, %esi
callq 0x6930
testq %rax, %rax
je 0x562ac
movq %rax, %r14
movl $0x3, (%rax)
movl $0x3c23d70a, 0x8(%rax)  # imm = 0x3C23D70A
leaq 0xc0(%rsp), %rbx
pushq $0x6c
popq %rdx
movl %ebp, %edi
movq %rbx, %rsi
callq 0x1de3f
movl (%rbx), %ecx
movl %ecx, 0x58(%r14)
movl 0x4(%rbx), %edx
movl %edx, 0x5c(%r14)
movups 0x8(%rbx), %xmm0
movups 0x18(%rbx), %xmm1
movups 0x28(%rbx), %xmm2
movups 0x38(%rbx), %xmm3
movups %xmm3, 0x90(%r14)
movups %xmm2, 0x80(%r14)
movups %xmm1, 0x70(%r14)
movups %xmm0, 0x60(%r14)
movl 0x48(%rbx), %eax
movl %eax, 0xa0(%r14)
movl %ebp, 0xc(%rsp)
movl 0x4c(%rbx), %ebp
movl %ebp, 0xa4(%r14)
movslq 0x50(%rbx), %r15
movl %r15d, 0xa8(%r14)
movslq 0x54(%rbx), %rax
movq %rax, 0x30(%rsp)
movl %eax, 0xac(%r14)
movl 0x58(%rbx), %eax
movl %eax, 0xb0(%r14)
movl 0x68(%rbx), %esi
movq %r14, 0x10(%rsp)
movl %esi, 0xd0(%r14)
cmpl $0x33504449, %ecx       # imm = 0x33504449
sete %cl
cmpl $0xf, %edx
sete %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x561c7
movslq %ebp, %rbx
movq 0x10(%rsp), %r14
movl %eax, 0x50(%r14)
movl %ebp, 0x20(%r14)
movl 0x11c(%rsp), %esi
movl 0xc(%rsp), %edi
xorl %edx, %edx
callq 0x1e023
pushq $0x38
popq %rsi
movq %rbx, %rdi
callq 0x6930
movq %rax, 0xb8(%r14)
testq %rax, %rax
je 0x561c7
imull $0x38, %ebp, %edx
movl 0xc(%rsp), %ebx
movl %ebx, %edi
movq %rax, %rsi
callq 0x1de3f
testl %r15d, %r15d
je 0x55f75
movl 0x120(%rsp), %esi
movl %ebx, %edi
xorl %edx, %edx
callq 0x1e023
pushq $0x70
popq %rsi
movq %r15, %rdi
callq 0x6930
movq 0x10(%rsp), %rcx
movq %rax, 0xc0(%rcx)
testq %rax, %rax
je 0x561c7
imull $0x70, %r15d, %edx
movl 0xc(%rsp), %ebx
movl %ebx, %edi
movq %rax, %rsi
callq 0x1de3f
movl 0x124(%rsp), %esi
movl %ebx, %edi
xorl %edx, %edx
callq 0x1e023
movl $0x80, %esi
movq 0x30(%rsp), %rdi
callq 0x6930
movq %rax, %r12
movq 0x10(%rsp), %rax
movq %r12, 0xc8(%rax)
testq %r12, %r12
je 0x561c7
movl 0x124(%rsp), %esi
addq $0x78, %r12
xorl %eax, %eax
movl 0xc(%rsp), %ebp
cmpq 0x30(%rsp), %rax
jge 0x561dd
movq %rax, 0x48(%rsp)
movl %ebp, %edi
xorl %edx, %edx
movl %esi, 0x1c(%rsp)
callq 0x1e023
movl %ebp, %edi
leaq 0x54(%rsp), %rsi
pushq $0x6c
popq %rdx
callq 0x1de3f
movl 0x54(%rsp), %eax
movl %eax, -0x78(%r12)
leaq 0x58(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups 0x30(%rax), %xmm3
movups %xmm3, -0x44(%r12)
movups %xmm2, -0x54(%r12)
movups %xmm1, -0x64(%r12)
movups %xmm0, -0x74(%r12)
movl 0x98(%rsp), %eax
movl %eax, -0x34(%r12)
movl 0x9c(%rsp), %r13d
movl %r13d, -0x30(%r12)
movl 0xa0(%rsp), %eax
movl %eax, -0x2c(%r12)
movl 0xa4(%rsp), %ebp
movl %ebp, -0x28(%r12)
movl 0xa8(%rsp), %ecx
movl %ecx, -0x24(%r12)
movl 0xbc(%rsp), %edx
movl %edx, (%r12)
movl 0xac(%rsp), %ebx
movl 0xb0(%rsp), %edx
movl %edx, 0x20(%rsp)
imull $0xc, %ecx, %r14d
imull $0x44, %eax, %ecx
movl 0xb4(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0xb8(%rsp), %r15d
imull %ebp, %r13d
movq %rcx, 0x40(%rsp)
leal (%rcx,%rbp,8), %eax
leal (%rax,%r13,8), %eax
addl %r14d, %eax
movslq %eax, %rdi
callq 0x69a0
movq %rax, -0x20(%r12)
testq %rax, %rax
je 0x561c7
shll $0x3, %ebp
shll $0x3, %r13d
movl 0x1c(%rsp), %ecx
addl %ecx, %r15d
movl %r15d, 0x2c(%rsp)
addl %ecx, 0x18(%rsp)
movl 0x20(%rsp), %r15d
addl %ecx, %r15d
addl %ecx, %ebx
movslq %r14d, %rcx
movq %rcx, 0x38(%rsp)
addq %rcx, %rax
movq %rax, -0x18(%r12)
movq 0x40(%rsp), %r14
movslq %r14d, %rcx
addq %rax, %rcx
movq %rcx, -0x10(%r12)
movslq %ebp, %rax
movq %rax, 0x20(%rsp)
addq %rax, %rcx
movq %rcx, -0x8(%r12)
movl 0xc(%rsp), %ebp
movl %ebp, %edi
movl %ebx, %esi
xorl %edx, %edx
callq 0x1e023
movq -0x20(%r12), %rsi
movl %ebp, %edi
movq 0x38(%rsp), %rdx
callq 0x1de3f
movl %ebp, %edi
movl %r15d, %esi
xorl %edx, %edx
callq 0x1e023
movq -0x18(%r12), %rsi
movl %ebp, %edi
movl %r14d, %edx
callq 0x1de3f
movl %ebp, %edi
movl 0x18(%rsp), %esi
xorl %edx, %edx
callq 0x1e023
movq -0x10(%r12), %rsi
movl %ebp, %edi
movq 0x20(%rsp), %rdx
callq 0x1de3f
movl %ebp, %edi
movl 0x2c(%rsp), %esi
xorl %edx, %edx
callq 0x1e023
movq -0x8(%r12), %rsi
movl %ebp, %edi
movl %r13d, %edx
callq 0x1de3f
movl 0x606ec1(%rip), %eax    # 0x65d048
movl -0x28(%r12), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x606eb1(%rip)    # 0x65d048
movl 0x606ebb(%rip), %eax    # 0x65d058
imull $0x3, -0x24(%r12), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x606eaa(%rip)    # 0x65d058
movl 0x1c(%rsp), %esi
addl (%r12), %esi
movq 0x48(%rsp), %rax
incq %rax
subq $-0x80, %r12
jmp 0x55fbd
movq 0x10(%rsp), %rdi
callq 0x5aa91
xorl %r14d, %r14d
movl 0xc(%rsp), %ebp
jmp 0x562af
movq 0x10(%rsp), %r14
jmp 0x562af
xorl %eax, %eax
movb $0x0, 0xc0(%rsp,%rax)
incq %rax
movq %rax, %rdi
callq 0x69a0
movq %rax, 0x88(%r14)
testq %rax, %rax
je 0x562a4
leaq 0xc0(%rsp), %rsi
movq %rax, %rdi
callq 0x6430
movslq 0x50(%r14), %rdi
pushq $0x40
popq %rsi
callq 0x6930
movq %rax, 0x90(%r14)
testq %rax, %rax
je 0x562a4
movl 0x80(%rsp), %esi
movl %ebp, %edi
xorl %edx, %edx
callq 0x1e023
movq 0x90(%r14), %rsi
movl 0x50(%r14), %edx
shll $0x6, %edx
movl %ebp, %edi
callq 0x1de3f
movslq 0x50(%r14), %rdi
movl %edi, %ecx
shll $0x6, %ecx
cmpl %ecx, %eax
jne 0x562a4
pushq $0x20
popq %rsi
callq 0x6930
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x562a4
movl 0x606dcb(%rip), %eax    # 0x65d048
movl 0x58(%r14), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x606dbc(%rip)    # 0x65d048
movl 0x606dc6(%rip), %eax    # 0x65d058
imull $0x3, 0x60(%r14), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x606db6(%rip)    # 0x65d058
jmp 0x562af
movq %r14, %rdi
callq 0x5a9f9
xorl %r14d, %r14d
movl %ebp, %edi
callq 0x1e2db
movq %r14, %rax
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq