// File: /workspace/github_c_makefile_star2_O2/sguerrini97[P]ps3linux-ps3vuart-tools/ps3av/cmd/cmd_av_get_monitor_info.c
// Function: cmd_av_get_monitor_info_exec
int
cmd_av_get_monitor_info_exec(int cmdc, struct cmd **cmdv, int argc, char **argv)
{
	struct ps3av_av_get_monitor_info av_get_monitor_info_req;
	struct ps3av_av_get_monitor_info_reply av_get_monitor_info_reply;
	char *endptr;
	unsigned int port;
	int ret;

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

	ps3av_init_request(PS3AV_REQ(&av_get_monitor_info_req),
	    sizeof(av_get_monitor_info_req) - sizeof(struct ps3av_header),
	    PS3AV_CMD_AV_GET_MONITOR_INFO);

	av_get_monitor_info_req.port = port;

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

	ret = dev_read(&av_get_monitor_info_reply, sizeof(av_get_monitor_info_reply));
	if (ret < sizeof(struct ps3av_reply))
		return (CMD_EIO);

	if (opts.do_verbose)
		fprintf(stderr, "status %d\n", av_get_monitor_info_reply.reply.status);

	if (av_get_monitor_info_reply.reply.status != PS3AV_STATUS_SUCCESS)
		return (CMD_EIO);

	fprintf(stdout, "type: %d\n", av_get_monitor_info_reply.monitor.type);
	fprintf(stdout, "name: %s\n", av_get_monitor_info_reply.monitor.name);
	fprintf(stdout, "res_60: %08x %08x\n", av_get_monitor_info_reply.monitor.res_60.bits,
	    av_get_monitor_info_reply.monitor.res_60.native);
	fprintf(stdout, "res_50: %08x %08x\n", av_get_monitor_info_reply.monitor.res_50.bits,
	    av_get_monitor_info_reply.monitor.res_50.native);
	fprintf(stdout, "res_other: %08x %08x\n", av_get_monitor_info_reply.monitor.res_other.bits,
	    av_get_monitor_info_reply.monitor.res_other.native);
	fprintf(stdout, "res_vesa: %08x %08x\n", av_get_monitor_info_reply.monitor.res_vesa.bits,
	    av_get_monitor_info_reply.monitor.res_vesa.native);

	return (CMD_EOK);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq (%rcx), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
xorl %edx, %edx
callq 0x10d0
movq (%rbx), %rcx
cmpb $0x0, (%rcx)
je 0x1578
pushq $0x2
popq %rbx
jmp 0x1672
movabsq $0x400080205, %rcx      # imm = 0x400080205
leaq 0x8(%rsp), %rdi
movq %rcx, (%rdi)
movw %ax, 0x8(%rdi)
pushq $0xc
popq %rsi
callq 0x13aa
pushq $0x3
popq %rbx
cmpl $0xc, %eax
jne 0x1672
leaq 0x14(%rsp), %rdi
movl $0x10c, %esi            # imm = 0x10C
callq 0x13c9
cmpl $0xc, %eax
jb 0x1672
leaq 0x2acf(%rip), %rax      # 0x4090
cmpl $0x0, 0x8(%rax)
jne 0x1681
cmpl $0x0, 0x1c(%rsp)
jne 0x1672
movq 0x29eb(%rip), %r15      # 0x3fc8
movq (%r15), %rdi
leaq 0x2c(%rsp), %r14
movzbl -0x1(%r14), %edx
leaq 0xb76(%rip), %rsi       # 0x2167
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1090
movq (%r15), %rdi
leaq 0xb6d(%rip), %rsi       # 0x2171
movq %r14, %rdx
xorl %eax, %eax
callq 0x1090
movq (%r15), %rdi
movl 0x10(%r14), %edx
movl 0x14(%r14), %ecx
leaq 0xb5b(%rip), %rsi       # 0x217b
xorl %eax, %eax
callq 0x1090
movq (%r15), %rdi
movl 0x18(%r14), %edx
movl 0x1c(%r14), %ecx
leaq 0xb55(%rip), %rsi       # 0x218e
xorl %eax, %eax
callq 0x1090
movq (%r15), %rdi
movl 0x20(%r14), %edx
movl 0x24(%r14), %ecx
leaq 0xb4f(%rip), %rsi       # 0x21a1
xorl %eax, %eax
callq 0x1090
movq (%r15), %rdi
movl 0x28(%r14), %edx
movl 0x2c(%r14), %ecx
leaq 0xb4c(%rip), %rsi       # 0x21b7
xorl %eax, %eax
callq 0x1090
movl %ebx, %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r14
popq %r15
retq
movq 0x2970(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movl 0x1c(%rsp), %edx
leaq 0xac6(%rip), %rsi       # 0x215c
xorl %eax, %eax
callq 0x1090
jmp 0x15cb
nop