// File: /workspace/github_c_makefile_star2_O0/sguerrini97[P]ps3linux-ps3vuart-tools/ps3dm/um/cmd_um_read_eprom.c
// Function: cmd_um_read_eprom_exec
int
cmd_um_read_eprom_exec(int cmdc, struct cmd **cmdv, int argc, char **argv)
{
	struct ps3dm_um_read_eprom read_eprom;
	uint32_t offset;
	char *endptr;
	uint64_t laid, paid;
	int len;
	int ret;

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

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

	ps3dm_init_header(&read_eprom.dm_hdr, 1, PS3DM_FID_UM,
	    sizeof(read_eprom) - sizeof(struct ps3dm_header),
	    sizeof(read_eprom) - sizeof(struct ps3dm_header));
	ps3dm_init_ss_header(&read_eprom.ss_hdr, PS3DM_PID_UM_READ_EPROM,
	    laid, paid);
	read_eprom.offset = offset;

	len = sizeof(read_eprom);

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

	ret = dev_read(&read_eprom, sizeof(read_eprom));
	if (ret != sizeof(read_eprom))
		return (CMD_EIO);

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

	if (read_eprom.ss_hdr.status)
		return (CMD_EIO);

	fprintf(stdout, "%02x\n", read_eprom.data);

	return (CMD_EOK);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x78(%rbp), %rsi
xorl %edx, %edx
callq 0x2110
movl %eax, -0x6c(%rbp)
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x4ad6
movl $0x2, -0x4(%rbp)
jmp 0x4c54
leaq 0x45e3(%rip), %rax      # 0x90c0
cmpl $0x0, 0x20(%rax)
je 0x4af7
leaq 0x45d6(%rip), %rax      # 0x90c0
movq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0x4b0a
movabsq $0x1070000002000001, %rax # imm = 0x1070000002000001
movq %rax, -0x98(%rbp)
jmp 0x4b0a
movq -0x98(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq 0x45a4(%rip), %rax      # 0x90c0
cmpl $0x0, 0x30(%rax)
je 0x4b36
leaq 0x4597(%rip), %rax      # 0x90c0
movq 0x28(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0x4b49
movabsq $0x10700003ff000001, %rax # imm = 0x10700003FF000001
movq %rax, -0xa0(%rbp)
jmp 0x4b49
movq -0xa0(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x68(%rbp), %rdi
movl $0x1, %esi
movl $0x6000, %edx           # imm = 0x6000
movl $0x38, %r8d
movl %r8d, %ecx
callq 0x4c60
leaq -0x68(%rbp), %rdi
addq $0x10, %rdi
movq -0x80(%rbp), %rdx
movq -0x88(%rbp), %rcx
movl $0x600b, %esi           # imm = 0x600B
callq 0x4ca0
movl -0x6c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl $0x48, -0x8c(%rbp)
movslq -0x8c(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x2620
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x8c(%rbp), %eax
je 0x4bd0
movl $0x3, -0x4(%rbp)
jmp 0x4c54
leaq -0x68(%rbp), %rdi
movl $0x48, %esi
callq 0x2670
movl %eax, -0x90(%rbp)
movslq -0x90(%rbp), %rax
cmpq $0x48, %rax
je 0x4bfa
movl $0x3, -0x4(%rbp)
jmp 0x4c54
leaq 0x44bf(%rip), %rax      # 0x90c0
cmpl $0x0, 0x8(%rax)
jle 0x4c22
movq 0x43ea(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movl -0x48(%rbp), %edx
leaq 0x1609(%rip), %rsi      # 0x6224
movb $0x0, %al
callq 0x20c0
cmpl $0x0, -0x48(%rbp)
je 0x4c31
movl $0x3, -0x4(%rbp)
jmp 0x4c54
movq 0x4390(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
movzbl -0x28(%rbp), %edx
leaq 0x18ee(%rip), %rsi      # 0x6534
movb $0x0, %al
callq 0x20c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq