// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/rm.c
// Function: do_rm_chunk
static int do_rm_chunk(deark *c, lctx *d, i64 pos1, i64 maxlen,
	i64 *bytes_consumed)
{
	i64 chunklen;
	i64 pos = pos1;
	int retval = 0;
	int hexdump_flag = 0;
	struct chunkinfo *ci = NULL;

	ci = de_malloc(c, sizeof(struct chunkinfo));
	ci->pos = pos1;
	dbuf_read_fourcc(c->infile, pos, &ci->chunk4cc, 4, 0x0);
	de_dbg(c, "chunk type: '%s'", ci->chunk4cc.id_dbgstr);
	pos += 4;
	chunklen = de_getu32be_p(&pos);
	de_dbg(c, "chunk len: %"I64_FMT, chunklen);
	if(chunklen < 8) goto done;
	if(chunklen > maxlen) {
		de_warn(c, "Chunk at %"I64_FMT" exceeds its parent's bounds", pos1);
		chunklen = maxlen;
	}

	*bytes_consumed = chunklen;
	retval = 1;

	ci->dpos = pos;
	ci->dlen = chunklen - 8;
	de_dbg(c, "dpos: %"I64_FMT", dlen: %"I64_FMT, ci->dpos, ci->dlen);

	switch(ci->chunk4cc.id) {
	case CODE_CONT:
		do_chunk_CONT(c, d, ci);
		break;
	case CODE_MDPR:
		do_chunk_MDPR(c, d, ci);
		break;
	case CODE_PROP:
		do_chunk_PROP(c, d, ci);
		break;
	default:
		hexdump_flag = 1;
	}

	if(hexdump_flag && c->debug_level>=2) {
		de_dbg_hexdump(c, c->infile, ci->dpos, ci->dlen, 256, NULL, 0x1);
	}

done:
	de_free(c, ci);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movl $0x50, %esi
callq 0x15b780
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
addq $0x10, %rdx
leaq 0x7d107(%rip), %rsi     # 0x1d135f
movb $0x0, %al
callq 0x15b0d0
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x5983f(%rip), %rsi     # 0x1adace
movb $0x0, %al
callq 0x15b0d0
cmpq $0x8, -0x30(%rbp)
jge 0x1542a2
jmp 0x1543c5
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jle 0x1542ca
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x7d0b5(%rip), %rsi     # 0x1d1370
movb $0x0, %al
callq 0x15bc10
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x3c(%rbp)
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x30(%rbp), %rcx
addq $-0x8, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rdx
movq 0x40(%rax), %rcx
leaq 0x7d08a(%rip), %rsi     # 0x1d1399
xorl %eax, %eax
callq 0x15b0d0
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x4c(%rbp)
subl $0x434f4e54, %eax       # imm = 0x434F4E54
je 0x154341
jmp 0x154329
movl -0x4c(%rbp), %eax
subl $0x4d445052, %eax       # imm = 0x4D445052
je 0x154354
jmp 0x154335
movl -0x4c(%rbp), %eax
subl $0x50524f50, %eax       # imm = 0x50524F50
je 0x154367
jmp 0x15437a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x1543e0
jmp 0x154381
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x1545a0
jmp 0x154381
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x1547e0
jmp 0x154381
movl $0x1, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x1543c3
movq -0x8(%rbp), %rax
cmpl $0x2, (%rax)
jl 0x1543c3
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rdx
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rcx
movl $0x100, %r8d            # imm = 0x100
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, (%rsp)
callq 0x15b840
jmp 0x1543c5
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x15b820
movl -0x3c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)