// File: /workspace/github_c_makefile_star2_O1/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
movq %rsi, 0x8(%rsp)
movl $0x8, %eax
cmpl $0x2, %edi
je 0x1370
cmpl $0x3, %edi
jne 0x1527
movl $0x10, %eax
movl %edi, 0x14(%rsp)
movq 0x8(%rsp), %rcx
movq (%rcx,%rax), %r14
leaq 0x2dac(%rip), %rdi      # 0x4130
callq 0x1560
movq 0x2da0(%rip), %rdi      # 0x4130
leaq 0x2da1(%rip), %rsi      # 0x4138
callq 0x159e
movq 0x2d8d(%rip), %rdi      # 0x4130
movq 0x2d8e(%rip), %rsi      # 0x4138
leaq 0x20(%rsp), %rdx
callq 0x15cc
testl %eax, %eax
jle 0x1445
movl %eax, %r12d
xorl %r13d, %r13d
leaq 0x18(%rsp), %r15
movq 0x2d62(%rip), %rdi      # 0x4130
movq 0x20(%rsp), %rax
movl (%rax,%r13,4), %esi
movq %r15, %rdx
callq 0x161e
testl %eax, %eax
jle 0x142b
movl %eax, %ebp
movl $0x1, %ebx
movq 0x2d3f(%rip), %rdi      # 0x4130
movq 0x18(%rsp), %rax
movl -0x4(%rax,%rbx,4), %esi
callq 0x16a1
movq %r14, %rdi
movq %rax, %rsi
callq 0x1110
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x141c
movq 0x18(%rsp), %rax
movl -0x4(%rax,%rbx,4), %esi
cmpq %rbp, %rbx
jae 0x1430
incq %rbx
cmpl $-0x1, %esi
je 0x13ea
jmp 0x1430
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
incq %r13
cmpl $-0x1, %esi
sete %al
cmpq %r12, %r13
jae 0x144c
cmpl $-0x1, %esi
je 0x13c7
jmp 0x144c
movb $0x1, %al
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
testb %al, %al
jne 0x1544
movq 0x2cd5(%rip), %rdi      # 0x4130
callq 0x1670
movq %rax, %r14
movl 0xc(%rax), %esi
movq 0x2cc3(%rip), %rdi      # 0x4130
callq 0x171c
testq %rax, %rax
je 0x154d
movq %rax, %r15
cmpl $0x3, 0x14(%rsp)
jne 0x14fa
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r13
cmpb $0x0, (%r13)
je 0x14fa
leaq 0xbab(%rip), %r12       # 0x2047
xorl %ebp, %ebp
movzbl (%r13,%rbp), %eax
cmpl $0x77, %eax
jg 0x14ba
cmpl $0x68, %eax
je 0x14cb
cmpl $0x77, %eax
jne 0x1527
movzwl 0x10(%r15), %esi
jmp 0x14d7
cmpl $0x78, %eax
je 0x14d2
cmpl $0x79, %eax
jne 0x1527
movswl 0xe(%r15), %esi
jmp 0x14d7
movzwl 0x12(%r15), %esi
jmp 0x14d7
movswl 0xc(%r15), %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x10c0
incq %rbp
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r13
movq %r13, %rdi
callq 0x10a0
cmpq %rbp, %rax
ja 0x149e
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
leaq 0x2c1f(%rip), %rdi      # 0x4130
callq 0x1591
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0xace(%rip), %rdi       # 0x2004
xorl %eax, %eax
callq 0x10c0
xorl %edi, %edi
callq 0x11f0
leaq 0xad9(%rip), %rsi       # 0x2024
jmp 0x1554
leaq 0xae1(%rip), %rsi       # 0x2035
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0