// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0xac0, %rsp            # imm = 0xAC0
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0xa88(%rbp), %rsi
xorl %edx, %edx
callq 0x20a0
movq %rax, -0xa80(%rbp)
movq -0xa88(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x40c0
movl $0x2, -0x4(%rbp)
jmp 0x42dc
leaq 0x4ff9(%rip), %rax      # 0x90c0
cmpl $0x0, 0x20(%rax)
je 0x40e1
leaq 0x4fec(%rip), %rax      # 0x90c0
movq 0x18(%rax), %rax
movq %rax, -0xab8(%rbp)
jmp 0x40f4
movabsq $0x1070000002000001, %rax # imm = 0x1070000002000001
movq %rax, -0xab8(%rbp)
jmp 0x40f4
movq -0xab8(%rbp), %rax
movq %rax, -0xa90(%rbp)
leaq 0x4fb7(%rip), %rax      # 0x90c0
cmpl $0x0, 0x30(%rax)
je 0x4123
leaq 0x4faa(%rip), %rax      # 0x90c0
movq 0x28(%rax), %rax
movq %rax, -0xac0(%rbp)
jmp 0x4136
movabsq $0x1070000300000001, %rax # imm = 0x1070000300000001
movq %rax, -0xac0(%rbp)
jmp 0x4136
movq -0xac0(%rbp), %rax
movq %rax, -0xa98(%rbp)
leaq -0xa70(%rbp), %rax
movq %rax, -0xa78(%rbp)
movq -0xa78(%rbp), %rdi
movl $0x1, %esi
movl $0x17000, %edx          # imm = 0x17000
movl $0xa40, %r8d            # imm = 0xA40
movl %r8d, %ecx
callq 0x42f0
movq -0xa78(%rbp), %rdi
addq $0x10, %rdi
movq -0xa90(%rbp), %rdx
movq -0xa98(%rbp), %rcx
movl $0x17002, %esi          # imm = 0x17002
callq 0x4330
movq -0xa80(%rbp), %rcx
movq -0xa78(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0xa78(%rbp), %rax
movq $0xa00, 0x40(%rax)      # imm = 0xA00
movl $0xa50, -0xaa8(%rbp)    # imm = 0xA50
movq -0xa78(%rbp), %rdi
movslq -0xaa8(%rbp), %rsi
callq 0x2620
movl %eax, -0xaac(%rbp)
movl -0xaac(%rbp), %eax
cmpl -0xaa8(%rbp), %eax
je 0x41f2
movl $0x3, -0x4(%rbp)
jmp 0x42dc
movl $0xa50, -0xaa8(%rbp)    # imm = 0xA50
movq -0xa78(%rbp), %rdi
movslq -0xaa8(%rbp), %rsi
callq 0x2670
movl %eax, -0xaac(%rbp)
movl -0xaac(%rbp), %eax
cmpl -0xaa8(%rbp), %eax
je 0x422f
movl $0x3, -0x4(%rbp)
jmp 0x42dc
leaq 0x4e8a(%rip), %rax      # 0x90c0
cmpl $0x0, 0x8(%rax)
jle 0x425e
movq 0x4db5(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movq -0xa78(%rbp), %rax
movl 0x20(%rax), %edx
leaq 0x1fcd(%rip), %rsi      # 0x6224
movb $0x0, %al
callq 0x20c0
movq -0xa78(%rbp), %rax
cmpl $0x0, 0x20(%rax)
je 0x4274
movl $0x3, -0x4(%rbp)
jmp 0x42dc
movq -0x28(%rbp), %rax
movq %rax, -0xaa0(%rbp)
movl $0x0, -0xaa4(%rbp)
movslq -0xaa4(%rbp), %rax
cmpq -0xaa0(%rbp), %rax
jae 0x42d5
movq 0x4d28(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
movq -0xa78(%rbp), %rax
movslq -0xaa4(%rbp), %rcx
movzbl 0x48(%rax,%rcx), %edx
leaq 0x21ae(%rip), %rsi      # 0x646b
movb $0x0, %al
callq 0x20c0
movl -0xaa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xaa4(%rbp)
jmp 0x4289
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xac0, %rsp            # imm = 0xAC0
popq %rbp
retq
nopl (%rax,%rax)