// File: /workspace/github_c_makefile_star2_O3/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 0xeed83
movq %rax, %r15
movq (%r12), %rcx
addq %rcx, %rax
movq 0x18(%r14), %rdx
addq 0x10(%r14), %rdx
cmpq %rdx, %rax
jle 0x1f3e0
xorl %r15d, %r15d
jmp 0x1f5b1
testq %r15, %r15
jle 0x1f43f
leaq 0xf344f(%rip), %rsi     # 0x11283b
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
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 0xe8bea
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
addq 0x8(%rsp), %r15
movq %r15, %rax
leaq 0x8(%rsp), %r13
movq %rax, (%r13)
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
movq %rax, %r12
movq (%r13), %rsi
addq %rsi, %rax
movq 0x18(%r14), %rcx
addq 0x10(%r14), %rcx
cmpq %rcx, %rax
jg 0x1f5b1
movq 0x18(%rbx), %rdi
movl $0x1, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0xefc2a
movq %r15, %rdi
callq 0xf6461
movq %r15, %rdi
callq 0xf70f6
leaq 0xf33ad(%rip), %rsi     # 0x11285c
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
leaq 0x8(%rsp), %r13
addq %r12, (%r13)
movq %r15, %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
movq %rax, %r12
movq (%r13), %rsi
addq %rsi, %rax
movq 0x18(%r14), %rcx
addq 0x10(%r14), %rcx
cmpq %rcx, %rax
jg 0x1f5b1
movq 0x18(%rbx), %rdi
movl $0x1, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0xefc2a
movq %r15, %rdi
callq 0xf6461
movq %r15, %rdi
callq 0xf70f6
leaq 0xf3349(%rip), %rsi     # 0x112872
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
leaq 0x8(%rsp), %r13
addq %r12, (%r13)
movq %r15, %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
movq %rax, %r12
movq (%r13), %rsi
addq %rsi, %rax
movq 0x18(%r14), %rcx
addq 0x10(%r14), %rcx
cmpq %rcx, %rax
jg 0x1f5b1
movq 0x18(%rbx), %rdi
movl $0x1, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0xefc2a
movq %r15, %rdi
callq 0xf6461
movq %r15, %rdi
callq 0xf70f6
leaq 0xf32e0(%rip), %rsi     # 0x11287f
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq %r12, 0x8(%rsp)
movq %r15, %rdi
callq 0xf6753
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq