// File: /workspace/github_c_makefile_star2_O0/tudurom[P]disputils/phd.c
// Function: main
int
main(int argc, char *argv[])
{
#ifdef __OpenBSD__
	if (pledge("stdio rpath unix", NULL) == -1)
		err(1, "pledge");
#endif
	xcb_query_pointer_reply_t *pointer;

	uint16_t pointer_x;
	uint16_t pointer_y;

	xcb_randr_get_output_info_reply_t *output_info = NULL;
	xcb_randr_get_crtc_info_reply_t *output_crtc_info = NULL;
	xcb_randr_output_t output;
	const char *output_name;

	uint16_t output_w;
	uint16_t output_h;
	uint16_t output_x;
	uint16_t output_y;

	if (argc > 1)
		usage(argv[0]);
	init_xcb(&conn);
	get_screen(conn, &scrn);

	/* Get info about the pointer */
	pointer = xcb_query_pointer_reply(conn,
			xcb_query_pointer(conn, scrn->root), NULL);
	pointer_x = pointer->root_x;
	pointer_y = pointer->root_y;

	/* Iterate through outputs */
	xcb_randr_provider_t *providers;
	int p_len = get_providers(conn, scrn, &providers);

	int i = 0;
	output_name = NULL;
	while (i < p_len && output_name == NULL) {
		xcb_randr_output_t *os;
		int o_len = get_outputs(conn, providers[i], &os);

		int j = 0;
		while (j < o_len && output_name == NULL) {
			output = os[j];
			if (get_output_connection(conn, output) == 0) {
				/* Check */
				output_info = get_output_info(conn, output);
				output_crtc_info = get_output_crtc_info(conn, output_info->crtc);
				if (output_crtc_info != NULL) {
					output_w = output_crtc_info->width;
					output_h = output_crtc_info->height;
					output_x = output_crtc_info->x;
					output_y = output_crtc_info->y;

					if (pointer_x >= output_x &&
						pointer_y >= output_y &&
					  pointer_x <= output_x + output_w &&
					  pointer_y <= output_y + output_h) {

						output_name = (const char *)get_output_name(conn, output);
					}
				}
			}
			j++;
		}

		i++;
	}
	if (output_name == NULL)
		errx(1, "Cannot get output name");
	printf("%s\n", output_name);
	free(pointer);
	free(output_info);
	free(output_crtc_info);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpl $0x1, -0x8(%rbp)
jle 0x139b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1330
leaq 0x2d8e(%rip), %rdi      # 0x4130
callq 0x15f0
movq 0x2d82(%rip), %rdi      # 0x4130
leaq 0x2d83(%rip), %rsi      # 0x4138
callq 0x1670
movq 0x2d6f(%rip), %rax      # 0x4130
movq %rax, -0x78(%rbp)
movq 0x2d64(%rip), %rdi      # 0x4130
movq 0x2d65(%rip), %rax      # 0x4138
movl (%rax), %esi
callq 0x1100
movq -0x78(%rbp), %rdi
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x1110
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movw 0x10(%rax), %ax
movw %ax, -0x1a(%rbp)
movq -0x18(%rbp), %rax
movw 0x12(%rax), %ax
movw %ax, -0x1c(%rbp)
movq 0x2d20(%rip), %rdi      # 0x4130
movq 0x2d21(%rip), %rsi      # 0x4138
leaq -0x58(%rbp), %rdx
callq 0x16d0
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x60(%rbp), %ecx
xorl %eax, %eax
cmpl -0x5c(%rbp), %ecx
movb %al, -0x79(%rbp)
jge 0x144a
cmpq $0x0, -0x40(%rbp)
sete %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x1456
jmp 0x1599
movq 0x2cd3(%rip), %rdi      # 0x4130
movq -0x58(%rbp), %rax
movslq -0x60(%rbp), %rcx
movl (%rax,%rcx,4), %esi
leaq -0x68(%rbp), %rdx
callq 0x1750
movl %eax, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %ecx
xorl %eax, %eax
cmpl -0x6c(%rbp), %ecx
movb %al, -0x7a(%rbp)
jge 0x1493
cmpq $0x0, -0x40(%rbp)
sete %al
movb %al, -0x7a(%rbp)
movb -0x7a(%rbp), %al
testb $0x1, %al
jne 0x149f
jmp 0x158b
movq -0x68(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq 0x2c7c(%rip), %rdi      # 0x4130
movl -0x34(%rbp), %esi
callq 0x18e0
cmpl $0x0, %eax
jne 0x157d
movq 0x2c64(%rip), %rdi      # 0x4130
movl -0x34(%rbp), %esi
callq 0x17d0
movq %rax, -0x28(%rbp)
movq 0x2c51(%rip), %rdi      # 0x4130
movq -0x28(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x1910
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x157b
movq -0x30(%rbp), %rax
movw 0x10(%rax), %ax
movw %ax, -0x42(%rbp)
movq -0x30(%rbp), %rax
movw 0x12(%rax), %ax
movw %ax, -0x44(%rbp)
movq -0x30(%rbp), %rax
movw 0xc(%rax), %ax
movw %ax, -0x46(%rbp)
movq -0x30(%rbp), %rax
movw 0xe(%rax), %ax
movw %ax, -0x48(%rbp)
movzwl -0x1a(%rbp), %eax
movzwl -0x46(%rbp), %ecx
cmpl %ecx, %eax
jl 0x1579
movzwl -0x1c(%rbp), %eax
movzwl -0x48(%rbp), %ecx
cmpl %ecx, %eax
jl 0x1579
movzwl -0x1a(%rbp), %eax
movzwl -0x46(%rbp), %ecx
movzwl -0x42(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jg 0x1579
movzwl -0x1c(%rbp), %eax
movzwl -0x48(%rbp), %ecx
movzwl -0x44(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jg 0x1579
movq 0x2bc3(%rip), %rdi      # 0x4130
movl -0x34(%rbp), %esi
callq 0x1830
movq %rax, -0x40(%rbp)
jmp 0x157b
jmp 0x157d
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x147b
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1432
cmpq $0x0, -0x40(%rbp)
jne 0x15b3
movl $0x1, %edi
leaq 0xa64(%rip), %rsi       # 0x2010
movb $0x0, %al
callq 0x10a0
movq -0x40(%rbp), %rsi
leaq 0xa69(%rip), %rdi       # 0x2027
movb $0x0, %al
callq 0x10b0
movq -0x18(%rbp), %rdi
callq 0x1030
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x30(%rbp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)