// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/kplib.c
// Function: kprender
int kprender (const char *buf, int leng, intptr_t frameptr, int bpl,
					int xdim, int ydim, int xoff, int yoff)
{
	unsigned char *ubuf = (unsigned char *)buf;

	paleng = 0; bakcol = 0; numhufblocks = zlibcompflags = 0; filtype = -1;

	if ((ubuf[0] == 0x89) && (ubuf[1] == 0x50)) //.PNG
		return(kpngrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));

	if ((ubuf[0] == 0xff) && (ubuf[1] == 0xd8)) //.JPG
		return(kpegrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));

	if ((ubuf[0] == 'G') && (ubuf[1] == 'I') && (ubuf[2] == 'F')) //.GIF
		return(kgifrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));

	if ((ubuf[0] == 0x19) && (ubuf[1] == 0x91) && (ubuf[10] == 8) && (ubuf[11] == 0)) //old .CEL/.PIC
		return(kcelrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));

	if ((ubuf[0] == 'B') && (ubuf[1] == 'M')) //.BMP
		return(kbmprend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));

	if (*(int *)ubuf == LSWAPIB(0x0801050a)) //.PCX
		return(kpcxrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));

	if ((*(int *)ubuf == LSWAPIB(0x20534444)) && (*(int *)&ubuf[4] == LSWAPIB(124))) //.DDS
		return(kddsrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));

		//Unreliable .TGA identification - this MUST be final case!
	if ((leng >= 20) && (!(ubuf[1]&0xfe)))
		if ((ubuf[2] < 12) && ((1<<ubuf[2])&0xe0e))
			if ((!(ubuf[16]&7)) && (ubuf[16] != 0) && (ubuf[16] <= 32))
				if (!(ubuf[17]&0xc0))
					return(ktgarend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));

	return(-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, 0x5469fa(%rip)    # 0x5a8b50
movl $0x0, 0x5469f4(%rip)    # 0x5a8b54
movl $0x0, 0x5469ee(%rip)    # 0x5a8b58
movl $0x0, 0x5469e8(%rip)    # 0x5a8b5c
movb $-0x1, 0x5469e5(%rip)   # 0x5a8b60
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x89, %eax
jne 0x621c8
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x50, %eax
jne 0x621c8
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x62480
movl %eax, -0x4(%rbp)
jmp 0x62469
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xff, %eax
jne 0x62217
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xd8, %eax
jne 0x62217
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x634a0
movl %eax, -0x4(%rbp)
jmp 0x62469
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x47, %eax
jne 0x6226f
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x49, %eax
jne 0x6226f
movq -0x38(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x46, %eax
jne 0x6226f
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x655d0
movl %eax, -0x4(%rbp)
jmp 0x62469
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x19, %eax
jne 0x622d6
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x91, %eax
jne 0x622d6
movq -0x38(%rbp), %rax
movzbl 0xa(%rax), %eax
cmpl $0x8, %eax
jne 0x622d6
movq -0x38(%rbp), %rax
movzbl 0xb(%rax), %eax
cmpl $0x0, %eax
jne 0x622d6
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x660b0
movl %eax, -0x4(%rbp)
jmp 0x62469
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x42, %eax
jne 0x62321
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x4d, %eax
jne 0x62321
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x66280
movl %eax, -0x4(%rbp)
jmp 0x62469
movq -0x38(%rbp), %rax
cmpl $0x801050a, (%rax)      # imm = 0x801050A
jne 0x6235f
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x66a90
movl %eax, -0x4(%rbp)
jmp 0x62469
movq -0x38(%rbp), %rax
cmpl $0x20534444, (%rax)     # imm = 0x20534444
jne 0x623a7
movq -0x38(%rbp), %rax
cmpl $0x7c, 0x4(%rax)
jne 0x623a7
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x66ef0
movl %eax, -0x4(%rbp)
jmp 0x62469
cmpl $0x14, -0x14(%rbp)
jl 0x62462
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
andl $0xfe, %eax
cmpl $0x0, %eax
jne 0x62462
movq -0x38(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0xc, %eax
jge 0x62460
movq -0x38(%rbp), %rax
movzbl 0x2(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
andl $0xe0e, %eax            # imm = 0xE0E
cmpl $0x0, %eax
je 0x62460
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
andl $0x7, %eax
cmpl $0x0, %eax
jne 0x6245e
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x0, %eax
je 0x6245e
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x20, %eax
jg 0x6245e
movq -0x38(%rbp), %rax
movzbl 0x11(%rax), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
jne 0x6245c
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x67860
movl %eax, -0x4(%rbp)
jmp 0x62469
jmp 0x6245e
jmp 0x62460
jmp 0x62462
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)