// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/abk.c
// Function: do_read_sprite_objects
static void do_read_sprite_objects(deark *c, lctx *d, struct amosbank *bk, i64 pos, int pass)
{
	int ret;
	i64 bytes_consumed;
	i64 obj_idx;

	de_dbg(c, "pass %d", pass);

	obj_idx = 0;
	while(1) {
		if(pos >= bk->f->len) break;
		if(obj_idx >= bk->num_objects) break;
		bytes_consumed = 0;
		ret = do_sprite_object(c, d, bk, obj_idx, pos, pass, &bytes_consumed);
		if(!ret || bytes_consumed<1) break;
		pos += bytes_consumed;
		obj_idx++;
	}

	if(pass==1) {
		bk->pal_pos = pos;
		bk->bank_len = bk->pal_pos + 64;
		de_dbg(c, "palette offset: %"I64_FMT, bk->pal_pos);
		de_dbg(c, "bank len: %"I64_FMT, bk->bank_len);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xf98c6(%rip), %rsi     # 0x113f47
xorl %eax, %eax
callq 0xde896
leaq 0x70(%r14), %rax
movq %rax, 0x10(%rsp)
pushq $0x6
popq %r15
xorl %r12d, %r12d
movl %ebp, 0x4(%rsp)
movq 0x50(%r14), %rax
cmpq 0x18(%rax), %r15
jge 0x1a855
cmpq 0x60(%r14), %r12
jge 0x1a855
cmpl $0x2, %ebp
jne 0x1a6d0
movq %rbx, %rdi
leaq 0xe9a5b(%rip), %rsi     # 0x10411e
movl %r12d, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x50(%r14), %rdi
movq %r15, %rsi
callq 0xe3f46
movq %rax, 0x470(%r14)
movq 0x50(%r14), %rdi
leaq 0x2(%r15), %rsi
callq 0xe3f46
movq %rax, 0x478(%r14)
movq 0x50(%r14), %rdi
leaq 0x4(%r15), %rsi
callq 0xe3f46
movq %rax, %r13
movq %rax, 0x480(%r14)
cmpl $0x1, %ebp
jne 0x1a737
cmpq 0x488(%r14), %r13
jle 0x1a822
movq %r13, 0x488(%r14)
jmp 0x1a822
cmpl $0x2, %ebp
jne 0x1a822
movq 0x470(%r14), %r13
movq 0x478(%r14), %rbp
shlq $0x4, %r13
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xdf038
movl 0x480(%r14), %edx
movq %rbx, %rdi
leaq 0x113a4e(%rip), %rsi    # 0x12e1bf
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xe6be1
testl %eax, %eax
je 0x1a7ac
movq 0x480(%r14), %rdx
leaq -0x7(%rdx), %rax
cmpq $-0x7, %rax
ja 0x1a7b1
movq %rbx, %rdi
leaq 0xe98c9(%rip), %rsi     # 0x10406e
xorl %eax, %eax
callq 0xdf2a5
xorl %r13d, %r13d
jmp 0x1a80f
leaq 0xa(%r15), %rax
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
pushq $0x4
popq %rcx
callq 0xe7437
movq %rax, %r13
movq 0x470(%r14), %rcx
addq %rcx, %rcx
movq 0x478(%r14), %r8
imulq %rcx, %r8
movq 0x50(%r14), %rdi
movq 0x480(%r14), %rdx
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %r9
pushq $0x2
pushq %rax
callq 0xe7de1
popq %rax
popq %rcx
movq %r13, %rdi
xorl %esi, %esi
pushq $0x2
popq %rdx
callq 0xe70b7
movl 0x4(%rsp), %ebp
movq %r13, %rdi
callq 0xe7084
movq 0x480(%r14), %r13
imulq 0x470(%r14), %r13
imulq 0x478(%r14), %r13
addq %r13, %r13
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
cmpq $-0x9, %r13
jl 0x1a855
addq %r13, %r15
addq $0xa, %r15
incq %r12
jmp 0x1a69c
cmpl $0x1, %ebp
jne 0x1a89d
movq %r15, 0x68(%r14)
leaq 0x40(%r15), %rax
movq %rax, 0x38(%r14)
leaq 0xe988f(%rip), %rsi     # 0x1040fc
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x38(%r14), %rdx
leaq 0xe988b(%rip), %rsi     # 0x104110
movq %rbx, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xde896
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq