// File: /workspace/github_c_makefile_star2_O2/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)
cmpl $0x2, %edi
movl %edi, 0x14(%rsp)
je 0x136e
cmpl $0x3, %edi
jne 0x14f6
pushq $0x10
jmp 0x1370
pushq $0x8
popq %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax), %r14
leaq 0x2daf(%rip), %rdi      # 0x4130
callq 0x1520
movq 0x2da3(%rip), %rdi      # 0x4130
leaq 0x2da4(%rip), %rsi      # 0x4138
callq 0x155c
movq 0x2d90(%rip), %rdi      # 0x4130
movq 0x2d91(%rip), %rsi      # 0x4138
leaq 0x20(%rsp), %rdx
callq 0x1588
movslq %eax, %r12
pushq $-0x1
popq %r13
xorl %ebp, %ebp
movl %r13d, %esi
cmpq %r12, %rbp
jge 0x142d
cmpl $-0x1, %esi
jne 0x142d
movq 0x2d62(%rip), %rdi      # 0x4130
movq 0x20(%rsp), %rax
movl (%rax,%rbp,4), %esi
leaq 0x18(%rsp), %rdx
callq 0x15d8
movslq %eax, %rbx
xorl %r15d, %r15d
movl %r13d, %esi
cmpq %rbx, %r15
jge 0x1428
cmpl $-0x1, %esi
jne 0x1428
movq 0x2d36(%rip), %rdi      # 0x4130
movq 0x18(%rsp), %rax
movl (%rax,%r15,4), %esi
callq 0x1657
movq %r14, %rdi
movq %rax, %rsi
callq 0x1110
movl %r13d, %esi
testl %eax, %eax
jne 0x1423
movq 0x18(%rsp), %rax
movl (%rax,%r15,4), %esi
incq %r15
jmp 0x13e9
incq %rbp
jmp 0x13bd
cmpl $-0x1, %esi
je 0x1503
movq 0x2cf3(%rip), %rdi      # 0x4130
callq 0x1628
movq %rax, %r14
movl 0xc(%rax), %esi
movq 0x2ce1(%rip), %rdi      # 0x4130
callq 0x16c8
testq %rax, %rax
je 0x150c
movq %rax, %r15
cmpl $0x3, 0x14(%rsp)
jne 0x14c9
leaq 0xbd9(%rip), %r12       # 0x2047
xorl %ebp, %ebp
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r13
movq %r13, %rdi
callq 0x10a0
cmpq %rbp, %rax
jbe 0x14c9
movzbl (%r13,%rbp), %eax
cmpl $0x68, %eax
je 0x14ae
cmpl $0x79, %eax
je 0x14b5
cmpl $0x78, %eax
je 0x14a7
cmpl $0x77, %eax
jne 0x14f6
movzwl 0x10(%r15), %esi
jmp 0x14ba
movswl 0xc(%r15), %esi
jmp 0x14ba
movzwl 0x12(%r15), %esi
jmp 0x14ba
movswl 0xe(%r15), %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x10c0
incq %rbp
jmp 0x1470
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
leaq 0x2c50(%rip), %rdi      # 0x4130
callq 0x154f
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), %rdi
callq 0x132c
leaq 0xb1a(%rip), %rsi       # 0x2024
jmp 0x1513
leaq 0xb22(%rip), %rsi       # 0x2035
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x10b0
nopl (%rax)