// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/mp3.c
// Function: do_ape_tag_header_or_footer
static int do_ape_tag_header_or_footer(deark *c, struct ape_tag_header_footer *ah,
	i64 pos1, int is_footer)
{
	int retval = 0;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	de_dbg(c, "APE tag %s at %"I64_FMT, (is_footer?"footer":"header"), pos1);
	de_dbg_indent(c, 1);

	ah->ape_ver = (u32)de_getu32le(pos1+8);
	de_dbg(c, "version: %u", (unsigned int)ah->ape_ver);
	ah->tag_size_raw = de_getu32le(pos1+12);
	de_dbg(c, "tag size: %d", (int)ah->tag_size_raw);
	if(is_footer) {
		ah->items_startpos = pos1 + 32 - ah->tag_size_raw;
		ah->items_size = pos1 - ah->items_startpos;
	}
	ah->item_count = de_getu32le(pos1+16);
	de_dbg(c, "item count: %d", (int)ah->item_count);
	ah->ape_flags = (u32)de_getu32le(pos1+20);
	de_dbg(c, "flags: 0x%08x", (unsigned int)ah->ape_flags);
	if(ah->ape_ver>=2000) {
		ah->has_header = (ah->ape_flags&0x80000000U) ? 1 : 0;
	}

	ah->tag_size_total = ah->tag_size_raw;
	if(ah->has_header)
		ah->tag_size_total += 32;

	if(ah->ape_ver<1000 || ah->ape_ver>=3000) {
		de_warn(c, "Unrecognized APE tag version: %u", (unsigned int)ah->ape_ver);
		goto done;
	}

	if(is_footer) {
		ah->tag_startpos = pos1 + 32 - ah->tag_size_total;
		de_dbg(c, "calculated start of APE tag: %"I64_FMT, ah->tag_startpos);
	}
	retval = 1;
done:
	de_dbg_indent_restore(c, saved_indent_level);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %ecx
leaq 0xc15f7(%rip), %rdx     # 0x1a1750
leaq 0xdc5a6(%rip), %rax     # 0x1bc706
cmpl $0x0, %ecx
cmovneq %rax, %rdx
movq -0x18(%rbp), %rcx
leaq 0xdc582(%rip), %rsi     # 0x1bc6f4
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
callq 0x165540
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0xe24d1(%rip), %rsi     # 0x1c2686
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
callq 0x165540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
leaq 0xdc51c(%rip), %rsi     # 0x1bc70d
movb $0x0, %al
callq 0x15b0d0
cmpl $0x0, -0x1c(%rbp)
je 0xe022a
movq -0x18(%rbp), %rcx
addq $0x20, %rcx
movq -0x10(%rbp), %rax
subq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
subq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
callq 0x165540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %edx
leaq 0xc17fe(%rip), %rsi     # 0x1a1a5d
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x14, %rsi
callq 0x165540
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0xd1de8(%rip), %rsi     # 0x1b207e
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpl $0x7d0, (%rax)          # imm = 0x7D0
jb 0xe02ca
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
andl $0x80000000, %edx       # imm = 0x80000000
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0xe02f4
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
cmpl $0x3e8, (%rax)          # imm = 0x3E8
jb 0xe030c
movq -0x10(%rbp), %rax
cmpl $0xbb8, (%rax)          # imm = 0xBB8
jb 0xe0326
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0xdc3fd(%rip), %rsi     # 0x1bc71a
movb $0x0, %al
callq 0x15bc10
jmp 0xe0365
cmpl $0x0, -0x1c(%rbp)
je 0xe035e
movq -0x18(%rbp), %rcx
addq $0x20, %rcx
movq -0x10(%rbp), %rax
subq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
leaq 0xdc3e4(%rip), %rsi     # 0x1bc73b
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x15b5a0
movl -0x20(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)