// File: /workspace/github_c_makefile_star2_O3/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 0x106770(%rip), %rsi    # 0x121037
xorl %eax, %eax
callq 0xe8617
movq 0x50(%r14), %rax
movl $0x6, %r15d
cmpq $0x7, 0x18(%rax)
jl 0x1aab1
leaq 0x70(%r14), %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
movl %ebp, 0x4(%rsp)
cmpq 0x60(%r14), %r12
jge 0x1aab1
cmpl $0x2, %ebp
jne 0x1a919
movq %rbx, %rdi
leaq 0xf6835(%rip), %rsi     # 0x111141
movl %r12d, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x50(%r14), %rdi
movq %r15, %rsi
callq 0xeeb67
movq %rax, 0x470(%r14)
movq 0x50(%r14), %rdi
leaq 0x2(%r15), %rsi
callq 0xeeb67
movq %rax, 0x478(%r14)
movq 0x50(%r14), %rdi
leaq 0x4(%r15), %rsi
callq 0xeeb67
movq %rax, %r13
movq %rax, 0x480(%r14)
cmpl $0x1, %ebp
jne 0x1a982
cmpq 0x488(%r14), %r13
jle 0x1aa73
movq %r13, 0x488(%r14)
jmp 0x1aa73
cmpl $0x2, %ebp
jne 0x1aa73
movq 0x470(%r14), %r13
movq 0x478(%r14), %rbp
shlq $0x4, %r13
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xe8f88
movl 0x480(%r14), %edx
movq %rbx, %rdi
leaq 0x120af3(%rip), %rsi    # 0x13b4af
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xf1db1
testl %eax, %eax
je 0x1a9f7
movq 0x480(%r14), %rdx
leaq -0x7(%rdx), %rax
cmpq $-0x7, %rax
ja 0x1a9fc
movq %rbx, %rdi
leaq 0xf66a1(%rip), %rsi     # 0x111091
xorl %eax, %eax
callq 0xe9295
xorl %r13d, %r13d
jmp 0x1aa60
leaq 0xa(%r15), %rax
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl $0x4, %ecx
callq 0xf266a
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 0xf30b3
addq $0x10, %rsp
movq %r13, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xf22dc
movl 0x4(%rsp), %ebp
movq %r13, %rdi
callq 0xf228d
movq 0x480(%r14), %r13
imulq 0x470(%r14), %r13
imulq 0x478(%r14), %r13
addq %r13, %r13
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpq $-0x9, %r13
jl 0x1aab1
addq %r13, %r15
addq $0xa, %r15
incq %r12
movq 0x50(%r14), %rax
cmpq 0x18(%rax), %r15
jl 0x1a8f3
cmpl $0x1, %ebp
jne 0x1aaf9
movq %r15, 0x68(%r14)
leaq 0x40(%r15), %rax
movq %rax, 0x38(%r14)
leaq 0xf6656(%rip), %rsi     # 0x11111f
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x38(%r14), %rdx
leaq 0xf6652(%rip), %rsi     # 0x111133
movq %rbx, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8617
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq