// File: /workspace/github_c_makefile_star2_O2/sguerrini97[P]ps3linux-ps3vuart-tools/ps3dm/iim/cmd_iim_get_data.c
// Function: cmd_iim_get_data_exec
int
cmd_iim_get_data_exec(int cmdc, struct cmd **cmdv, int argc, char **argv)
{
#define BUFSIZE	0xa00

	char buf[sizeof(struct ps3dm_iim_get_data) + BUFSIZE + sizeof(uint64_t)];
	struct ps3dm_iim_get_data *get_data;
	uint64_t index;
	char *endptr;
	uint64_t laid, paid, data_size;
	int i, len;
	int ret;

	index = strtoull(argv[0], &endptr, 0);
	if (*endptr != '\0')
		return (CMD_EINVAL);

	laid = opts.laid_valid ? opts.laid : 0x1070000002000001ull;
	paid = opts.paid_valid ? opts.paid : 0x1070000300000001ull;

	get_data = (struct ps3dm_iim_get_data *) buf;
	ps3dm_init_header(&get_data->dm_hdr, 1, PS3DM_FID_IIM,
	    sizeof(*get_data) + BUFSIZE + sizeof(uint64_t) - sizeof(struct ps3dm_header),
	    sizeof(*get_data) + BUFSIZE + sizeof(uint64_t) - sizeof(struct ps3dm_header));
	ps3dm_init_ss_header(&get_data->ss_hdr, PS3DM_PID_IIM_GET_DATA,
	    laid, paid);
	get_data->index = index;
	get_data->buf_size = BUFSIZE;

	len = sizeof(*get_data) + BUFSIZE + sizeof(uint64_t);

	ret = dev_write(get_data, len);
	if (ret != len)
		return (CMD_EIO);

	len = sizeof(*get_data) + BUFSIZE + sizeof(uint64_t);

	ret = dev_read(get_data, len);
	if (ret != len)
		return (CMD_EIO);

	if (opts.do_verbose > 0)
		fprintf(stderr, "ss status %d\n", get_data->ss_hdr.status);

	if (get_data->ss_hdr.status)
		return (CMD_EIO);

	data_size = *(uint64_t *) (buf + sizeof(*get_data) + BUFSIZE);

	for (i = 0; i < data_size; i++)
		fprintf(stdout, "%c", get_data->buf[i]);

	return (CMD_EOK);

#undef BUFSIZE
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa68, %rsp            # imm = 0xA68
movq (%rcx), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
xorl %edx, %edx
callq 0x20b0
movq (%rbx), %rcx
cmpb $0x0, (%rcx)
je 0x3004
pushq $0x2
popq %rbx
jmp 0x30a4
leaq 0x40b5(%rip), %r14      # 0x70c0
cmpl $0x0, 0x20(%r14)
je 0x3018
movq 0x18(%r14), %rcx
jmp 0x3022
movabsq $0x1070000002000001, %rcx # imm = 0x1070000002000001
cmpl $0x0, 0x30(%r14)
je 0x302f
movq 0x28(%r14), %rdx
jmp 0x3039
movabsq $0x1070000300000001, %rdx # imm = 0x1070000300000001
movaps 0x1450(%rip), %xmm0     # 0x4490
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x17002, 0x10(%rdi)    # imm = 0x17002
movq $0x17000, 0x18(%rdi)    # imm = 0x17000
movq %rcx, 0x28(%rdi)
movq %rdx, 0x30(%rdi)
movq %rax, 0x38(%rdi)
movq $0xa00, 0x40(%rdi)      # imm = 0xA00
movl $0xa50, %esi            # imm = 0xA50
callq 0x24a2
pushq $0x3
popq %rbx
cmpl $0xa50, %eax            # imm = 0xA50
jne 0x30a4
leaq 0x10(%rsp), %rdi
movl $0xa50, %esi            # imm = 0xA50
callq 0x24c1
cmpl $0xa50, %eax            # imm = 0xA50
jne 0x30a4
cmpl $0x0, 0x8(%r14)
jg 0x30e1
cmpl $0x0, 0x30(%rsp)
je 0x30b5
movl %ebx, %eax
addq $0xa68, %rsp            # imm = 0xA68
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xa58(%rsp), %r14
xorl %ebx, %ebx
movq 0x3f02(%rip), %r15      # 0x6fc8
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x30a4
movq (%r15), %rsi
movzbl 0x58(%rsp,%r12), %edi
callq 0x2090
incq %r12
jmp 0x30c9
movq 0x3f10(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movl 0x30(%rsp), %edx
leaq 0x108a(%rip), %rsi      # 0x4180
xorl %eax, %eax
callq 0x20d0
jmp 0x309d
nop