// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/asf.c
// Function: handler_ContentEncr
static void handler_ContentEncr(deark *c, lctx *d, struct handler_params *hp)
{
	i64 pos = hp->dpos;
	i64 xlen;
	de_ucstring *s = NULL;

	xlen = de_getu32le_p(&pos);
	if(pos+xlen > hp->dpos+hp->dlen) goto done;
	if(xlen>0) {
		de_dbg(c, "[%d bytes of secret data at %"I64_FMT"]", (int)xlen, pos);
		de_dbg_indent(c, 1);
		de_dbg_hexdump(c, c->infile, pos, xlen, 256, NULL, 0x0);
		de_dbg_indent(c, -1);
	}
	pos += xlen;

	s = ucstring_create(c);
	xlen = de_getu32le_p(&pos);
	if(pos+xlen > hp->dpos+hp->dlen) goto done;
	dbuf_read_to_ucstring_n(c->infile, pos, xlen, DE_DBG_MAX_STRLEN, s,
			0, DE_ENCODING_ASCII);
	ucstring_truncate_at_NUL(s);
	de_dbg(c, "protection type: \"%s\"", ucstring_getpsz_d(s));
	// TODO: What should we do if this is not "DRM"?
	pos += xlen;

	ucstring_empty(s);
	xlen = de_getu32le_p(&pos);
	if(pos+xlen > hp->dpos+hp->dlen) goto done;
	dbuf_read_to_ucstring_n(c->infile, pos, xlen, DE_DBG_MAX_STRLEN, s,
			0, DE_ENCODING_ASCII);
	ucstring_truncate_at_NUL(s);
	de_dbg(c, "key id: \"%s\"", ucstring_getpsz_d(s));
	pos += xlen;

	ucstring_empty(s);
	xlen = de_getu32le_p(&pos);
	if(pos+xlen > hp->dpos+hp->dlen) goto done;
	dbuf_read_to_ucstring_n(c->infile, pos, xlen, DE_DBG_MAX_STRLEN, s,
			0, DE_ENCODING_ASCII);
	ucstring_truncate_at_NUL(s);
	de_dbg(c, "license url: \"%s\"", ucstring_getpsz_d(s));
	pos += xlen;

done:
	ucstring_destroy(s);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rdi, %rbx
movq 0x10(%rdx), %rax
leaq 0x8(%rsp), %r12
movq %rax, (%r12)
movq 0x18(%rdi), %rdi
movq %r12, %rsi
callq 0xef3a0
movq %rax, %r15
movq (%r12), %rcx
addq %rcx, %rax
movq 0x18(%r14), %rdx
addq 0x10(%r14), %rdx
cmpq %rdx, %rax
jle 0x1f2ef
xorl %r15d, %r15d
jmp 0x1f4b8
testq %r15, %r15
jle 0x1f346
leaq 0xf3530(%rip), %rsi     # 0x11282b
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rsi
movq 0x8(%rsp), %rdx
movl $0x0, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %rbx, %rdi
movq %r15, %rcx
xorl %r9d, %r9d
callq 0xe975a
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
leaq 0x8(%rsp), %r13
addq %r15, (%r13)
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
movq %rax, %r12
movq (%r13), %rsi
addq %rsi, %rax
movq 0x18(%r14), %rcx
addq 0x10(%r14), %rcx
cmpq %rcx, %rax
jg 0x1f4b8
movq 0x18(%rbx), %rdi
movl $0x1, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0xf0203
movq %r15, %rdi
callq 0xf68c1
movq %r15, %rdi
callq 0xf7557
leaq 0xf3496(%rip), %rsi     # 0x11284c
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
leaq 0x8(%rsp), %r13
addq %r12, (%r13)
movq %r15, %rdi
callq 0xf6883
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
movq %rax, %r12
movq (%r13), %rsi
addq %rsi, %rax
movq 0x18(%r14), %rcx
addq 0x10(%r14), %rcx
cmpq %rcx, %rax
jg 0x1f4b8
movq 0x18(%rbx), %rdi
movl $0x1, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0xf0203
movq %r15, %rdi
callq 0xf68c1
movq %r15, %rdi
callq 0xf7557
leaq 0xf3432(%rip), %rsi     # 0x112862
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
leaq 0x8(%rsp), %r13
addq %r12, (%r13)
movq %r15, %rdi
callq 0xf6883
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
movq %rax, %r12
movq (%r13), %rsi
addq %rsi, %rax
movq 0x18(%r14), %rcx
addq 0x10(%r14), %rcx
cmpq %rcx, %rax
jg 0x1f4b8
movq 0x18(%rbx), %rdi
movl $0x1, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0xf0203
movq %r15, %rdi
callq 0xf68c1
movq %r15, %rdi
callq 0xf7557
leaq 0xf33c9(%rip), %rsi     # 0x11286f
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq %r12, 0x8(%rsp)
movq %r15, %rdi
callq 0xf6bb0
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq