// File: /workspace/github_c_makefile_star2_O1/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 0x1066ec(%rip), %rsi    # 0x120f0f
xorl %eax, %eax
callq 0xe9226
movq 0x50(%r14), %rax
movl $0x6, %r15d
cmpq $0x7, 0x18(%rax)
jl 0x1aa01
leaq 0x70(%r14), %rax
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
movl %ebp, 0x4(%rsp)
cmpq 0x60(%r14), %r13
jge 0x1aa01
cmpl $0x2, %ebp
jne 0x1a875
movq %rbx, %rdi
leaq 0xf68ca(%rip), %rsi     # 0x111132
movl %r13d, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x50(%r14), %rdi
movq %r15, %rsi
callq 0xef169
movq %rax, 0x470(%r14)
movq 0x50(%r14), %rdi
leaq 0x2(%r15), %rsi
callq 0xef169
movq %rax, 0x478(%r14)
movq 0x50(%r14), %rdi
leaq 0x4(%r15), %rsi
callq 0xef169
movq %rax, 0x480(%r14)
cmpl $0x1, %ebp
jne 0x1a8d2
cmpq 0x488(%r14), %rax
jle 0x1a8d2
movq %rax, 0x488(%r14)
cmpl $0x2, %ebp
jne 0x1a9bc
movq 0x470(%r14), %r12
movq 0x478(%r14), %rbp
shlq $0x4, %r12
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xe9b05
movl 0x480(%r14), %edx
movq %rbx, %rdi
leaq 0x1207eb(%rip), %rsi    # 0x13b0f7
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xf241d
testl %eax, %eax
je 0x1a947
movq 0x480(%r14), %rdx
leaq -0x7(%rdx), %rax
cmpq $-0x7, %rax
ja 0x1a94c
movq %rbx, %rdi
leaq 0xf6742(%rip), %rsi     # 0x111082
xorl %eax, %eax
callq 0xe9df7
xorl %r12d, %r12d
jmp 0x1a9b0
leaq 0xa(%r15), %rax
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movl $0x4, %ecx
callq 0xf2cab
movq %rax, %r12
movq 0x470(%r14), %rcx
addq %rcx, %rcx
movq 0x478(%r14), %r8
imulq %rcx, %r8
movq 0x50(%r14), %rdi
movq 0x480(%r14), %rdx
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %r9
pushq $0x2
pushq %rax
callq 0xf36f9
addq $0x10, %rsp
movq %r12, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xf2923
movl 0x4(%rsp), %ebp
movq %r12, %rdi
callq 0xf28d4
movq 0x470(%r14), %r12
imulq 0x478(%r14), %r12
imulq 0x480(%r14), %r12
addq %r12, %r12
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpq $-0x9, %r12
jl 0x1aa01
addq %r12, %r15
addq $0xa, %r15
incq %r13
movq 0x50(%r14), %rax
cmpq 0x18(%rax), %r15
jl 0x1a84f
cmpl $0x1, %ebp
jne 0x1aa49
movq %r15, 0x68(%r14)
leaq 0x40(%r15), %rax
movq %rax, 0x38(%r14)
leaq 0xf66f7(%rip), %rsi     # 0x111110
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x38(%r14), %rdx
leaq 0xf66f3(%rip), %rsi     # 0x111124
movq %rbx, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9226
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq