// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/hightile.c
// Function: hicsetskybox
int hicsetskybox(int picnum, int palnum, char *faces[6])
{
	hicreplctyp *hr, *hrn;
	int j;

	if ((unsigned int)picnum >= (unsigned int)MAXTILES) return -1;
	if ((unsigned int)palnum >= (unsigned int)MAXPALOOKUPS) return -1;
	for (j=5;j>=0;j--) if (!faces[j]) return -1;
	if (!hicfirstinit) hicinit();

	for (hr = hicreplc[picnum]; hr; hr = hr->next) {
		if (hr->palnum == palnum)
			break;
	}

	if (!hr) {
		// no replacement yet defined
		hrn = (hicreplctyp *)calloc(1,sizeof(hicreplctyp));
		if (!hrn) return -1;

		hrn->palnum = palnum;
	} else hrn = hr;

	if (!hrn->skybox) {
		hrn->skybox = (struct hicskybox_t *)calloc(1,sizeof(struct hicskybox_t));
		if (!hrn->skybox) {
			if (hr == NULL) free(hrn);	// not yet a link in the chain
			return -1;
		}
	} else {
		for (j=5;j>=0;j--) {
			if (hrn->skybox->face[j])
				free(hrn->skybox->face[j]);
		}
	}

	// store each face's filename
	for (j=0;j<6;j++) {
		hrn->skybox->face[j] = strdup(faces[j]);
		if (!hrn->skybox->face[j]) {
			for (--j; j>=0; --j)	// free any previous faces
				free(hrn->skybox->face[j]);
			free(hrn->skybox);
			hrn->skybox = NULL;
			if (hr == NULL) free(hrn);
			return -1;
		}
	}
	hrn->skybox->ignore = 0;
	if (hr == NULL) {
		hrn->next = hicreplc[picnum];
		hicreplc[picnum] = hrn;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cmpl $0x2400, -0x8(%rbp)     # imm = 0x2400
jb 0x8e437
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8e6a0
cmpl $0x100, -0xc(%rbp)      # imm = 0x100
jb 0x8e44c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8e6a0
movl $0x5, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x8e481
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x8e474
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8e6a0
jmp 0x8e476
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8e453
cmpl $0x0, 0x59b768(%rip)    # 0x629bf0
jne 0x8e48f
callq 0x8e030
movslq -0x8(%rbp), %rcx
leaq 0x59b766(%rip), %rax    # 0x629c00
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x8e4c7
movq -0x20(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x8e4b8
jmp 0x8e4c7
jmp 0x8e4ba
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x8e4a2
cmpq $0x0, -0x20(%rbp)
jne 0x8e502
movl $0x1, %edi
movl $0x28, %esi
callq 0x6880
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x8e4f4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8e6a0
movl -0xc(%rbp), %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x8(%rax)
jmp 0x8e50a
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x8e558
movl $0x1, %edi
movl $0x38, %esi
callq 0x6880
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x8e556
cmpq $0x0, -0x20(%rbp)
jne 0x8e54a
movq -0x28(%rbp), %rdi
callq 0x61c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8e6a0
jmp 0x8e59e
movl $0x5, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x8e59c
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
cmpq $0x0, 0x8(%rax,%rcx,8)
je 0x8e58f
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
callq 0x61c0
jmp 0x8e591
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8e55f
jmp 0x8e59e
movl $0x0, -0x2c(%rbp)
cmpl $0x6, -0x2c(%rbp)
jge 0x8e65a
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x6060
movq %rax, %rdx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
cmpq $0x0, 0x8(%rax,%rcx,8)
jne 0x8e64a
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x8e618
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
callq 0x61c0
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8e5f1
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x61c0
movq -0x28(%rbp), %rax
movq $0x0, 0x20(%rax)
cmpq $0x0, -0x20(%rbp)
jne 0x8e641
movq -0x28(%rbp), %rdi
callq 0x61c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8e6a0
jmp 0x8e64c
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8e5a5
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x20(%rbp)
jne 0x8e699
movslq -0x8(%rbp), %rcx
leaq 0x59b585(%rip), %rax    # 0x629c00
movq (%rax,%rcx,8), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rdx
movslq -0x8(%rbp), %rcx
leaq 0x59b56b(%rip), %rax    # 0x629c00
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)