// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
cmpl $0x2, -0x8(%rbp)
jne 0x13a4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x13c6
cmpl $0x3, -0x8(%rbp)
jne 0x13b8
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x13c4
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1330
jmp 0x13c6
leaq 0x2d63(%rip), %rdi      # 0x4130
callq 0x1640
movq 0x2d57(%rip), %rdi      # 0x4130
leaq 0x2d58(%rip), %rsi      # 0x4138
callq 0x16c0
movq 0x2d44(%rip), %rdi      # 0x4130
movq 0x2d45(%rip), %rsi      # 0x4138
leaq -0x40(%rbp), %rdx
callq 0x1720
movl %eax, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %ecx
xorl %eax, %eax
cmpl -0x44(%rbp), %ecx
movb %al, -0x59(%rbp)
jge 0x141d
cmpl $-0x1, -0x14(%rbp)
sete %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x1429
jmp 0x14c5
movq 0x2d00(%rip), %rdi      # 0x4130
movq -0x40(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %esi
leaq -0x50(%rbp), %rdx
callq 0x17a0
movl %eax, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %ecx
xorl %eax, %eax
cmpl -0x54(%rbp), %ecx
movb %al, -0x5a(%rbp)
jge 0x1465
cmpl $-0x1, -0x14(%rbp)
sete %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
testb $0x1, %al
jne 0x146e
jmp 0x14b7
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x2cb3(%rip), %rdi      # 0x4130
movq -0x50(%rbp), %rax
movslq -0x58(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x1880
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x1110
cmpl $0x0, %eax
jne 0x14ac
movq -0x50(%rbp), %rax
movslq -0x58(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x14(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x144e
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1406
cmpl $-0x1, -0x14(%rbp)
jne 0x14de
movl $0x1, %edi
leaq 0xb95(%rip), %rsi       # 0x206c
movb $0x0, %al
callq 0x10b0
movq 0x2c4b(%rip), %rdi      # 0x4130
movl -0x14(%rbp), %esi
callq 0x1820
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x24(%rbp)
movq 0x2c2e(%rip), %rdi      # 0x4130
movl -0x24(%rbp), %esi
callq 0x1960
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x1528
movl $0x1, %edi
leaq 0xb5c(%rip), %rsi       # 0x207d
movb $0x0, %al
callq 0x10b0
cmpl $0x3, -0x8(%rbp)
jne 0x160e
movl $0x0, -0x48(%rbp)
movslq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10a0
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq %rcx, %rax
jae 0x160c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x48(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $-0x68, %eax
movl %eax, %ecx
movq %rcx, -0x78(%rbp)
subl $0x11, %eax
ja 0x15f0
movq -0x78(%rbp), %rax
leaq 0xa7d(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rax
movzwl 0x10(%rax), %esi
leaq 0xaf0(%rip), %rdi       # 0x208f
movb $0x0, %al
callq 0x10c0
jmp 0x15fc
movq -0x30(%rbp), %rax
movzwl 0x12(%rax), %esi
leaq 0xad8(%rip), %rdi       # 0x208f
movb $0x0, %al
callq 0x10c0
jmp 0x15fc
movq -0x30(%rbp), %rax
movswl 0xc(%rax), %esi
leaq 0xac0(%rip), %rdi       # 0x208f
movb $0x0, %al
callq 0x10c0
jmp 0x15fc
movq -0x30(%rbp), %rax
movswl 0xe(%rax), %esi
leaq 0xaa8(%rip), %rdi       # 0x208f
movb $0x0, %al
callq 0x10c0
jmp 0x15fc
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1330
jmp 0x15fe
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1539
jmp 0x160e
movq -0x20(%rbp), %rdi
callq 0x1030
movq -0x30(%rbp), %rdi
callq 0x1030
leaq 0x2b09(%rip), %rdi      # 0x4130
callq 0x1690
xorl %eax, %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)