// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/mp3.c
// Function: do_mp3_frame
static void do_mp3_frame(deark *c, mp3ctx *d, i64 pos1, i64 len)
{
	u32 x;
	i64 pos = pos1;
	int saved_indent_level;
	char buf[32];

	de_dbg_indent_save(c, &saved_indent_level);
	x = (u32)de_getu32be(pos);
	if((x & 0xffe00000U) != 0xffe00000U) {
		int ret;
		i64 num_bytes_to_skip = 0;
		de_info(c, "Note: MP3/MPA frame header not found at %"I64_FMT". Scanning for frame header.", pos);
		if(d->frame_count==0 && c->module_disposition==DE_MODDISP_AUTODETECT &&
			d->has_id3v2)
		{
			// Format was presumably autodetected solely based on the existence
			// of ID3v2 data.
			de_warn(c, "This might not be an MPEG audio file. It might be an unrecognized "
				"audio format.");
		}
		ret = find_mp3_frame_header(c, d, pos1, len, &num_bytes_to_skip);
		if(!ret) {
			de_err(c, "MP3/MPA frame header not found");
			goto done;
		}
		pos += num_bytes_to_skip;
		de_info(c, "Note: Possible MP3 frame header found at %"I64_FMT".", pos);
		x = (u32)de_getu32be(pos);
	}

	de_dbg(c, "frame at %"I64_FMT, pos);
	de_dbg_indent(c, 1);
	de_dbg(c, "frame header: 0x%08x", (unsigned int)x);
	de_dbg_indent(c, 1);
	d->version_id = (x&0x00180000U)>>19;
	de_dbg(c, "audio version id: %u (%s)", d->version_id, get_mp3_ver_id_name(d->version_id));
	d->layer_desc = (x&0x00060000U)>>17;
	de_dbg(c, "layer description: %u (%s)", d->layer_desc, get_mp3_layer_desc_name(d->layer_desc));
	if(d->frame_count==0) {
		if(d->layer_desc==1) {
			de_declare_fmt(c, "MP3");
		}
		else if(d->layer_desc==2) {
			de_declare_fmt(c, "MP2 audio");
		}
		else if(d->layer_desc==3) {
			de_declare_fmt(c, "MP1 audio");
		}
	}
	d->has_crc = (x&0x00010000U)>>16;
	de_dbg(c, "has crc: %u", d->has_crc);
	d->bitrate_idx =  (x&0x0000f000U)>>12;
	de_dbg(c, "bitrate id: %u (%s)", d->bitrate_idx,
		get_bitrate_name(buf, sizeof(buf), d->bitrate_idx, d->version_id, d->layer_desc));
	d->samprate_idx = (x&0x00000c00U)>>10;
	de_dbg(c, "sampling rate frequency id: %u (%s)", d->samprate_idx,
		get_sampling_rate_name(buf, sizeof(buf), d->samprate_idx, d->version_id, d->layer_desc));
	d->has_padding =  (x&0x00000200U)>>9;
	de_dbg(c, "has padding: %u", d->has_padding);
	d->channel_mode = (x&0x000000c0U)>>6;
	de_dbg(c, "channel mode: %u (%s)", d->channel_mode, get_mp3_channel_mode_name(d->channel_mode));
	if(d->channel_mode==1) {
		d->mode_extension = (x&0x00000030U)>>4;
		de_dbg(c, "mode extension: %u", d->mode_extension);
	}
	d->copyright_flag = (x&0x00000008U)>>3;
	de_dbg(c, "copyright flag: %u", d->has_padding);
	d->orig_media_flag = (x&0x00000004U)>>2;
	de_dbg(c, "original media flag: %u", d->has_padding);
	d->emphasis = (x&0x00000003U);
	de_dbg(c, "emphasis: %u", d->emphasis);
	//pos += 4;
	d->frame_count++;

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x165470
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0xffe00000, %eax       # imm = 0xFFE00000
cmpl $0xffe00000, %eax       # imm = 0xFFE00000
je 0xe0c73
movq $0x0, -0x70(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0xdbc91(%rip), %rsi     # 0x1bc85f
movb $0x0, %al
callq 0x15c0c0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jne 0xe0c04
movq -0x8(%rbp), %rax
cmpl $0x1, 0x24(%rax)
jne 0xe0c04
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0xe0c04
movq -0x8(%rbp), %rdi
leaq 0xdbcaa(%rip), %rsi     # 0x1bc8a7
movb $0x0, %al
callq 0x15bc10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x70(%rbp), %r8
callq 0xe1010
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jne 0xe0c3d
movq -0x8(%rbp), %rdi
leaq 0xdbcc6(%rip), %rsi     # 0x1bc8f7
movb $0x0, %al
callq 0x15bfb0
jmp 0xe0ff9
movq -0x70(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0xdbcbe(%rip), %rsi     # 0x1bc916
movb $0x0, %al
callq 0x15c0c0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x165470
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0xdbcc2(%rip), %rsi     # 0x1bc944
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0xdbcac(%rip), %rsi     # 0x1bc951
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movl -0x24(%rbp), %ecx
andl $0x180000, %ecx         # imm = 0x180000
shrl $0x13, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
callq 0xe1120
movq -0x90(%rbp), %rdi
movl -0x84(%rbp), %edx
movq %rax, %rcx
leaq 0xdbc5e(%rip), %rsi     # 0x1bc966
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %ecx
andl $0x60000, %ecx          # imm = 0x60000
shrl $0x11, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
callq 0xe1180
movq -0x80(%rbp), %rdi
movl -0x74(%rbp), %edx
movq %rax, %rcx
leaq 0xdbc2f(%rip), %rsi     # 0x1bc980
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jne 0xe0dba
movq -0x10(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0xe0d7e
movq -0x8(%rbp), %rdi
leaq 0xdbc24(%rip), %rsi     # 0x1bc99b
callq 0x15e380
jmp 0xe0db8
movq -0x10(%rbp), %rax
cmpl $0x2, 0x8(%rax)
jne 0xe0d9a
movq -0x8(%rbp), %rdi
leaq 0xdbc0c(%rip), %rsi     # 0x1bc99f
callq 0x15e380
jmp 0xe0db6
movq -0x10(%rbp), %rax
cmpl $0x3, 0x8(%rax)
jne 0xe0db4
movq -0x8(%rbp), %rdi
leaq 0xdbbfa(%rip), %rsi     # 0x1bc9a9
callq 0x15e380
jmp 0xe0db6
jmp 0xe0db8
jmp 0xe0dba
movl -0x24(%rbp), %ecx
andl $0x10000, %ecx          # imm = 0x10000
shrl $0x10, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
leaq 0xdbbd4(%rip), %rsi     # 0x1bc9b3
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %ecx
andl $0xf000, %ecx           # imm = 0xF000
shrl $0xc, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0xb4(%rbp)
leaq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %r8d
movl $0x20, %esi
callq 0xe11e0
movq -0xc0(%rbp), %rdi
movl -0xb4(%rbp), %edx
movq %rax, %rcx
leaq 0xdbb73(%rip), %rsi     # 0x1bc9bf
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %ecx
andl $0xc00, %ecx            # imm = 0xC00
shrl $0xa, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0xa4(%rbp)
leaq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x14(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %r8d
movl $0x20, %esi
callq 0xe12f0
movq -0xb0(%rbp), %rdi
movl -0xa4(%rbp), %edx
movq %rax, %rcx
leaq 0xdbb1a(%rip), %rsi     # 0x1bc9d3
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %ecx
andl $0x200, %ecx            # imm = 0x200
shrl $0x9, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edx
leaq 0xdbb12(%rip), %rsi     # 0x1bc9f7
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %ecx
andl $0xc0, %ecx
shrl $0x6, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x94(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0xe13c0
movq -0xa0(%rbp), %rdi
movl -0x94(%rbp), %edx
movq %rax, %rcx
leaq 0xdbacd(%rip), %rsi     # 0x1bca07
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0xe0f74
movl -0x24(%rbp), %ecx
andl $0x30, %ecx
shrl $0x4, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
leaq 0xdbab0(%rip), %rsi     # 0x1bca1d
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %ecx
andl $0x8, %ecx
shrl $0x3, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edx
leaq 0xdba9a(%rip), %rsi     # 0x1bca30
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %ecx
andl $0x4, %ecx
shrl $0x2, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edx
leaq 0xdba84(%rip), %rsi     # 0x1bca43
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %ecx
andl $0x3, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %edx
leaq 0xdba76(%rip), %rsi     # 0x1bca5b
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x15b5a0
addq $0xc0, %rsp
popq %rbp
retq
nop