// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/rar.c
// Function: do_rar5_extra_area
static void do_rar5_extra_area(deark *c, de_arch_lctx *d, struct rar5_block *rb)
{
	int saved_indent_level;
	i64 pos = rb->extra_area_pos;
	i64 endpos = rb->data_area_pos;
	struct rar5_extra_data *ed = NULL;

	de_dbg_indent_save(c, &saved_indent_level);
	ed = de_malloc(c, sizeof(struct rar5_extra_data));
	if(rb->extra_area_size<1) goto done;

	de_dbg(c, "extra area at %"I64_FMT", len=%"I64_FMT, rb->extra_area_pos,
		rb->extra_area_size);
	de_dbg_indent(c, 1);
	while(1) {
		i64 reclen;
		i64 rec_dpos;
		i64 rec_dlen;
		i64 next_record_pos;
		UI rectype;
		int decoded;

		if(pos >= endpos) break;
		de_dbg(c, "record at %"I64_FMT, pos);
		de_dbg_indent(c, 1);
		reclen = rar_get_vint_i64_p(d, c->infile, &pos);
		de_dbg(c, "record len: %"I64_FMT, reclen);

		// Extra checks like the following are to guard against integer overflow.
		if(reclen > rb->extra_area_size) goto done;

		next_record_pos = pos + reclen;
		if(next_record_pos > endpos) goto done;
		rectype = (UI)rar_get_vint_p(d, c->infile, &pos);
		de_dbg(c, "record type: %u (%s)", rectype,
			get_rar5_extra_record_name(rb, rectype));

		rec_dpos = pos;
		rec_dlen = next_record_pos - rec_dpos;
		de_dbg(c, "record dpos: %"I64_FMT", len: %"I64_FMT, rec_dpos, rec_dlen);

		decoded = 0;
		if(rb->type==RAR5_HDRTYPE_FILE || rb->type==RAR5_HDRTYPE_SERVICE) {
			if(rectype==3) {
				do_rar5_extrarec_timestamps(c, d, ed, rec_dpos, rec_dlen);
				decoded = 1;
			}
		}

		if(!decoded && rec_dlen>0) {
			de_dbg_hexdump(c, c->infile, pos, rec_dlen, 256, NULL, 0x1);
		}

		pos = next_record_pos;
		de_dbg_indent(c, -1);
	}

done:
	de_free(c, ed);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0x58, %esi
callq 0x15b780
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x1, 0x28(%rax)
jge 0x152bc6
jmp 0x152d96
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
leaq 0x7e592(%rip), %rsi     # 0x1d1173
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jl 0x152c05
jmp 0x152d94
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x4d668(%rip), %rsi     # 0x1a027c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x28(%rbp), %rdx
callq 0x152640
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq 0x7e53d(%rip), %rsi     # 0x1d118e
movb $0x0, %al
callq 0x15b0d0
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jle 0x152c6b
jmp 0x152d96
movq -0x28(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x30(%rbp), %rax
jle 0x152c86
jmp 0x152d96
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x28(%rbp), %rdx
callq 0x152690
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x152e80
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %edx
movq %rax, %rcx
leaq 0x7e4d5(%rip), %rsi     # 0x1d119e
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x58(%rbp), %rax
subq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
leaq 0x7e4bc(%rip), %rsi     # 0x1d11b3
movb $0x0, %al
callq 0x15b0d0
movl $0x0, -0x60(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, 0x14(%rax)
je 0x152d19
movq -0x18(%rbp), %rax
cmpl $0x3, 0x14(%rax)
jne 0x152d41
cmpl $0x3, -0x5c(%rbp)
jne 0x152d3f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
callq 0x152f70
movl $0x1, -0x60(%rbp)
jmp 0x152d41
cmpl $0x0, -0x60(%rbp)
jne 0x152d79
cmpq $0x0, -0x50(%rbp)
jle 0x152d79
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x28(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x100, %r8d            # imm = 0x100
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, (%rsp)
callq 0x15b840
movq -0x58(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
jmp 0x152bf6
jmp 0x152d96
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x15b5a0
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)