// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/asf.c
// Function: handler_ESP
static void handler_ESP(deark *c, lctx *d, struct handler_params *hp)
{
	i64 pos = hp->dpos;
	i64 name_count, pes_count;
	i64 k;
	i64 x, xlen;
	i64 bytes_remaining;
	int saved_indent_level;
	u8 guid_raw[16];
	char guid_string[50];

	de_dbg_indent_save(c, &saved_indent_level);
	if(hp->dlen<64) goto done;

	x = de_geti64le(pos);
	de_dbg(c, "start time: %"I64_FMT, x);
	pos += 8;
	x = de_geti64le(pos);
	de_dbg(c, "end time: %"I64_FMT, x);
	pos += 8;

	x = de_getu32le_p(&pos);
	de_dbg(c, "data bitrate: %u", (unsigned int)x);
	x = de_getu32le_p(&pos);
	de_dbg(c, "buffer size: %u", (unsigned int)x);
	x = de_getu32le_p(&pos);
	de_dbg(c, "initial buffer fullness: %u", (unsigned int)x);
	x = de_getu32le_p(&pos);
	de_dbg(c, "alt data bitrate: %u", (unsigned int)x);
	x = de_getu32le_p(&pos);
	de_dbg(c, "alt buffer size: %u", (unsigned int)x);
	x = de_getu32le_p(&pos);
	de_dbg(c, "alt initial buffer fullness: %u", (unsigned int)x);
	x = de_getu32le_p(&pos);
	de_dbg(c, "max object size: %u", (unsigned int)x);
	x = de_getu32le_p(&pos);
	de_dbg(c, "flags: 0x%08x", (unsigned int)x);

	x = de_getu16le_p(&pos);
	de_dbg(c, "stream number: %d", (int)x);
	x = de_getu16le_p(&pos);
	de_dbg(c, "language id index: %d", (int)x);
	x = de_geti64le(pos);
	de_dbg(c, "average time per frame: %"I64_FMT, x);
	pos += 8;

	name_count = de_getu16le_p(&pos);
	de_dbg(c, "name count: %d", (int)name_count);
	pes_count = de_getu16le_p(&pos);
	de_dbg(c, "payload ext. system count: %d", (int)pes_count);

	// Stream names (TODO)
	for(k=0; k<name_count; k++) {
		if(pos+4 > hp->dpos+hp->dlen) goto done;
		de_dbg(c, "name[%d] at %"I64_FMT, (int)k, pos);
		pos += 2; // language id index
		xlen = de_getu16le_p(&pos);
		pos += xlen;
	}

	// Payload extension systems
	for(k=0; k<pes_count; k++) {
		if(pos+22 > hp->dpos+hp->dlen) {
			goto done;
		}
		de_dbg(c, "payload ext. system[%d] at %"I64_FMT, (int)k, pos);
		de_dbg_indent(c, 1);

		read_and_render_guid(c->infile, guid_raw, pos, guid_string, sizeof(guid_string));
		de_dbg(c, "ext. system id: {%s} (%s)", guid_string, get_uuid_name(guid_raw));
		pos += 16;

		x = de_getu16le_p(&pos);
		de_dbg(c, "ext. data size: %d", (int)x);

		xlen = de_getu32le_p(&pos);
		de_dbg(c, "payload ext. system info length: %d", (int)xlen);

		if(pos+xlen > hp->dpos+hp->dlen) {
			goto done;
		}
		if(xlen>0) {
			de_dbg(c, "[%d bytes of payload ext. system info at %"I64_FMT, (int)xlen, pos);
			de_dbg_indent(c, 1);
			de_dbg_hexdump(c, c->infile, pos, xlen, 256, NULL, 0x1);
			de_dbg_indent(c, -1);
		}
		pos += xlen;
		de_dbg_indent(c, -1);
	}

	bytes_remaining = hp->dpos + hp->dlen - pos;
	// There is an optional Stream Properties object here, but the spec seems
	// less than clear about how to tell whether it is present.
	if(bytes_remaining>24+54) {
		do_object_sequence(c, d, pos, bytes_remaining, hp->level+1, 1, 1);
	}

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x15b580
movq -0x18(%rbp), %rax
cmpq $0x40, 0x18(%rax)
jge 0x24100
jmp 0x24681
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x1657e0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq 0x17a82d(%rip), %rsi    # 0x19e951
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x1657e0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq 0x17a806(%rip), %rsi    # 0x19e961
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a7df(%rip), %rsi    # 0x19e973
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a7c7(%rip), %rsi    # 0x19e988
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a7ae(%rip), %rsi    # 0x19e99c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a754(%rip), %rsi    # 0x19e96f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a73c(%rip), %rsi    # 0x19e984
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a723(%rip), %rsi    # 0x19e998
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a716(%rip), %rsi    # 0x19e9b8
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x18ddaf(%rip), %rsi    # 0x1b207e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a5ed(%rip), %rsi    # 0x19e8e9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a6a3(%rip), %rsi    # 0x19e9cc
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x1657e0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq 0x17a68e(%rip), %rsi    # 0x19e9e2
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0x17a671(%rip), %rsi    # 0x19e9fe
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
leaq 0x17a653(%rip), %rsi    # 0x19ea0d
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0x2444f
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
addq 0x18(%rdx), %rcx
cmpq %rcx, %rax
jle 0x243f5
jmp 0x24681
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
movq -0x20(%rbp), %rcx
leaq 0x17a621(%rip), %rsi    # 0x19ea2b
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x243c9
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x24631
movq -0x20(%rbp), %rax
addq $0x16, %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
addq 0x18(%rdx), %rcx
cmpq %rcx, %rax
jle 0x24487
jmp 0x24681
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
movq -0x20(%rbp), %rcx
leaq 0x17a59f(%rip), %rsi    # 0x19ea3b
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0xb0(%rbp), %rcx
movl $0x32, %r8d
callq 0x22de0
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xb0(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x248e0
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
movq %rax, %rcx
leaq 0x17a54d(%rip), %rsi    # 0x19ea5a
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x17a52e(%rip), %rsi    # 0x19ea74
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movl %eax, %edx
leaq 0x17a514(%rip), %rsi    # 0x19ea87
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
addq -0x48(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
addq 0x18(%rdx), %rcx
cmpq %rcx, %rax
jle 0x2459c
jmp 0x24681
cmpq $0x0, -0x48(%rbp)
jle 0x24606
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movl %eax, %edx
movq -0x20(%rbp), %rcx
leaq 0x17a4f3(%rip), %rsi    # 0x19eaab
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x100, %r8d            # imm = 0x100
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, (%rsp)
callq 0x15b840
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x48(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x24457
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x18(%rcx), %rax
subq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x4e, -0x50(%rbp)
jle 0x2467f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movl 0x20(%rax), %r8d
addl $0x1, %r8d
movl $0x1, %r9d
movq $0x1, (%rsp)
callq 0x229c0
jmp 0x24681
movq -0x8(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x15b5a0
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)