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

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

	data = strtoul(argv[1], &endptr, 0);
	if (*endptr != '\0' || data > 0xff)
		return (CMD_EINVAL);

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

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

	len = sizeof(write_eprom);

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

	ret = dev_write(&write_eprom, sizeof(write_eprom));
	if (ret != sizeof(write_eprom))
		return (CMD_EIO);

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

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

	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 0x4d36
movl $0x2, -0x4(%rbp)
jmp 0x4ed2
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x78(%rbp), %rsi
xorl %edx, %edx
callq 0x2110
movl %eax, -0x70(%rbp)
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4d61
cmpl $0xff, -0x70(%rbp)
jbe 0x4d6d
movl $0x2, -0x4(%rbp)
jmp 0x4ed2
leaq 0x434c(%rip), %rax      # 0x90c0
cmpl $0x0, 0x20(%rax)
je 0x4d8e
leaq 0x433f(%rip), %rax      # 0x90c0
movq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0x4da1
movabsq $0x1070000002000001, %rax # imm = 0x1070000002000001
movq %rax, -0x98(%rbp)
jmp 0x4da1
movq -0x98(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq 0x430d(%rip), %rax      # 0x90c0
cmpl $0x0, 0x30(%rax)
je 0x4dcd
leaq 0x4300(%rip), %rax      # 0x90c0
movq 0x28(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0x4de0
movabsq $0x10700003ff000001, %rax # imm = 0x10700003FF000001
movq %rax, -0xa0(%rbp)
jmp 0x4de0
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 0x4ee0
leaq -0x68(%rbp), %rdi
addq $0x10, %rdi
movq -0x80(%rbp), %rdx
movq -0x88(%rbp), %rcx
movl $0x600c, %esi           # imm = 0x600C
callq 0x4f20
movl -0x6c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x70(%rbp), %eax
movb %al, -0x28(%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 0x4e6a
movl $0x3, -0x4(%rbp)
jmp 0x4ed2
leaq -0x68(%rbp), %rdi
movl $0x48, %esi
callq 0x2620
movl %eax, -0x90(%rbp)
movslq -0x90(%rbp), %rax
cmpq $0x48, %rax
je 0x4e94
movl $0x3, -0x4(%rbp)
jmp 0x4ed2
leaq 0x4225(%rip), %rax      # 0x90c0
cmpl $0x0, 0x8(%rax)
jle 0x4ebc
movq 0x4150(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movl -0x48(%rbp), %edx
leaq 0x136f(%rip), %rsi      # 0x6224
movb $0x0, %al
callq 0x20c0
cmpl $0x0, -0x48(%rbp)
je 0x4ecb
movl $0x3, -0x4(%rbp)
jmp 0x4ed2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nop