// File: /workspace/github_c_makefile_star2_O3/tudurom[P]disputils/dattr.c
// Function: main
int
main(int argc, char *argv[])
{
#ifdef __OpenBSD__
	if (pledge("stdio rpath unix", NULL) == -1)
		err(1, "pledge");
#endif
	xcb_randr_output_t output = -1;
	xcb_randr_get_output_info_reply_t *output_info = NULL;
	xcb_randr_crtc_t screen_crtc;
	xcb_randr_get_crtc_info_reply_t *screen_crtc_info = NULL;
	char *output_name;

	if (argc == 2)
		output_name = argv[1];
	else if (argc == 3)
		output_name = argv[2];
	else
		usage(argv[0]);

	init_xcb(&conn);
	get_screen(conn, &scrn);

	xcb_randr_provider_t *providers;
	int p_len = get_providers(conn, scrn, &providers);

	/* get the id of the output */
	int i = 0;
	while (i < p_len && output == -1) {
		xcb_randr_output_t *os;
		int o_len = get_outputs(conn, providers[i], &os);

		int j = 0;
		while (j < o_len && output == -1) {
			if (strcmp(output_name,
						(const char *)get_output_name(conn, os[j])) == 0)
				output = os[j];

			j++;
		}

		i++;
	}

	if (output == -1) {
		errx(1, "Output not found");
	}
	output_info = get_output_info(conn, output);

	/* get info about output */
	screen_crtc = output_info->crtc;
	screen_crtc_info = get_output_crtc_info(conn, screen_crtc);
	if (screen_crtc_info == '\0')
		errx(1, "Output not in use");

	if (argc == 3) {
		/* print info */
		for (i = 0; i < strlen(argv[1]); i++) {
			switch (argv[1][i]) {
			case 'w':
				printf("%d\n", screen_crtc_info->width);
				break;
			case 'h':
				printf("%d\n", screen_crtc_info->height);
				break;
			case 'x':
				printf("%d\n", screen_crtc_info->x);
				break;
			case 'y':
				printf("%d\n", screen_crtc_info->y);
				break;
			default:
				usage(argv[0]);
			}
		}
	}

	free(output_info);
	free(screen_crtc_info);
	kill_xcb(&conn);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0x8, %eax
cmpl $0x2, %edi
je 0x136b
cmpl $0x3, %edi
jne 0x1543
movl $0x10, %eax
movl %edi, 0xc(%rsp)
movq %rsi, 0x18(%rsp)
movq (%rsi,%rax), %r14
leaq 0x2db1(%rip), %rdi      # 0x4130
callq 0x1548
movq 0x2da5(%rip), %rdi      # 0x4130
leaq 0x2da6(%rip), %rsi      # 0x4138
callq 0x1586
movq 0x2d92(%rip), %rdi      # 0x4130
movq 0x2d93(%rip), %rsi      # 0x4138
leaq 0x20(%rsp), %rdx
callq 0x15b4
testl %eax, %eax
jle 0x1527
movl %eax, %r12d
xorl %r13d, %r13d
leaq 0x10(%rsp), %r15
movq 0x2d67(%rip), %rdi      # 0x4130
movq 0x20(%rsp), %rax
movl (%rax,%r13,4), %esi
movq %r15, %rdx
callq 0x1606
testl %eax, %eax
jle 0x1426
movl %eax, %ebp
movl $0x1, %ebx
movq 0x2d44(%rip), %rdi      # 0x4130
movq 0x10(%rsp), %rax
movl -0x4(%rax,%rbx,4), %esi
callq 0x1689
movq %r14, %rdi
movq %rax, %rsi
callq 0x1110
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x1417
movq 0x10(%rsp), %rax
movl -0x4(%rax,%rbx,4), %esi
cmpq %rbp, %rbx
jae 0x142b
incq %rbx
cmpl $-0x1, %esi
je 0x13e5
jmp 0x142b
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
incq %r13
cmpq %r12, %r13
jae 0x1438
cmpl $-0x1, %esi
je 0x13c2
cmpl $-0x1, %esi
je 0x1527
movq 0x2ce8(%rip), %rdi      # 0x4130
callq 0x1658
movq %rax, %r14
movl 0xc(%rax), %esi
movq 0x2cd6(%rip), %rdi      # 0x4130
callq 0x1704
testq %rax, %rax
movq 0x18(%rsp), %rbx
je 0x1530
movq %rax, %r15
cmpl $0x3, 0xc(%rsp)
jne 0x14e2
movq 0x8(%rbx), %r13
cmpb $0x0, (%r13)
je 0x14e2
leaq 0xbbe(%rip), %r12       # 0x2047
xorl %ebp, %ebp
movzbl (%r13,%rbp), %eax
cmpl $0x77, %eax
jg 0x14a7
cmpl $0x68, %eax
je 0x14b8
cmpl $0x77, %eax
jne 0x150f
movzwl 0x10(%r15), %esi
jmp 0x14c4
cmpl $0x78, %eax
je 0x14bf
cmpl $0x79, %eax
jne 0x150f
movswl 0xe(%r15), %esi
jmp 0x14c4
movzwl 0x12(%r15), %esi
jmp 0x14c4
movswl 0xc(%r15), %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x10c0
incq %rbp
movq 0x8(%rbx), %r13
movq %r13, %rdi
callq 0x10a0
cmpq %rbp, %rax
ja 0x148b
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
leaq 0x2c37(%rip), %rdi      # 0x4130
callq 0x1579
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rsi
leaq 0xaeb(%rip), %rdi       # 0x2004
xorl %eax, %eax
callq 0x10c0
xorl %edi, %edi
callq 0x11f0
leaq 0xaf6(%rip), %rsi       # 0x2024
jmp 0x1537
leaq 0xafe(%rip), %rsi       # 0x2035
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
movq (%rsi), %rsi
jmp 0x1512