// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/gemmeta.c
// Function: de_run_gemmeta
static void de_run_gemmeta(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos;
	i64 hdrlen_words;
	i64 version;
	i64 imgflag;
	i64 bytesused;

	d = de_malloc(c, sizeof(lctx));

	pos = 0;
	hdrlen_words = de_getu16le(pos+2);
	de_dbg(c, "header length: %d words", (int)hdrlen_words);
	version = de_getu16le(pos+4);
	de_dbg(c, "version number: %d", (int)version);
	// TODO: Read more header fields.
	imgflag = de_getu16le(pos+28);
	de_dbg(c, "image flag: %d", (int)imgflag);

	pos += hdrlen_words*2;

	while(1) {
		if(pos >= c->infile->len) break;
		if(!do_record(c, d, pos, &bytesused)) break;
		if(bytesused<=0) break;
		pos += bytesused;
	}
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
pushq $0x4
popq %r15
movq %r15, %rsi
callq 0xdecaf
movq %rax, 0x8(%rsp)
movq 0x18(%rbx), %rdi
pushq $0x2
popq %rsi
callq 0xe3fa3
movq %rax, %r14
leaq 0xc4de9(%rip), %rsi     # 0x112161
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fa3
leaq 0xdeffa(%rip), %rsi     # 0x12c392
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
pushq $0x1c
popq %rsi
callq 0xe3fa3
leaq 0xc4dc2(%rip), %rsi     # 0x112179
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
addq %r14, %r14
movq %rbx, (%rsp)
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r14
jge 0x4d51a
andq $0x0, 0x10(%rsp)
movq %rbx, %rdi
leaq 0xdb16f(%rip), %rsi     # 0x128557
movl %r14d, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3fa3
movq %rax, %r15
movq %rax, 0x28(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x2(%r14), %rsi
callq 0xe3fa3
movq %rax, %rbp
movq %rax, 0x38(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x4(%r14), %rsi
callq 0xe3fa3
movq %rax, %r12
movq %rax, 0x40(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x6(%r14), %rsi
callq 0xe3fa3
movq %rax, 0x30(%rsp)
leaq (,%rbp,4), %rcx
leaq (%rcx,%r12,2), %r10
leaq 0x8(%r14), %r13
movq %r13, 0x18(%rsp)
leaq 0x8(%r14,%rbp,4), %rcx
movq %rcx, 0x20(%rsp)
pushq $0x19
popq %r14
leaq 0x1373a1(%rip), %rbx    # 0x184818
decq %r14
je 0x4d49d
movzwl 0x18(%rbx), %ecx
addq $0x18, %rbx
cmpq %rcx, %r15
jne 0x4d477
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
leaq 0xd1a4a(%rip), %rdx     # 0x11eee1
cmoveq %rdx, %rcx
jmp 0x4d4a6
xorl %ebx, %ebx
leaq 0xd1a3b(%rip), %rcx     # 0x11eee1
movq (%rsp), %rdi
leaq 0xc4cd7(%rip), %rsi     # 0x112188
movl %r15d, %edx
movl %eax, %r8d
movl %ebp, %r9d
xorl %eax, %eax
movq %r10, %rbp
pushq %r10
pushq %r12
callq 0xde896
popq %rax
popq %rcx
testq %r14, %r14
je 0x4d4f2
movq 0x10(%rbx), %rax
testq %rax, %rax
movq (%rsp), %rbx
je 0x4d4f6
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq *%rax
movq 0x28(%rsp), %r15
jmp 0x4d4f6
movq (%rsp), %rbx
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
cmpq $0xffff, %r15           # imm = 0xFFFF
je 0x4d51a
addq %rbp, %r13
movq %r13, %r14
cmpq $-0x8, %rbp
jg 0x4d3ca
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xded32
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq