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

	uint16_t window_x;
	uint16_t window_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;

	char *argv0;

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

	f_window = get_focused_window(conn);
	/* Get info about the focused window */
	ARGBEGIN {
		case 'w':
			f_window = strtoul(EARGF(usage(argv0)), NULL, 16);
	} ARGEND

	if (!window_exists(f_window))
		errx(1, "Window does not exist");
	window_geometry = get_window_geometry(conn, f_window);
	window_x = window_geometry->x;
	window_y = window_geometry->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 (window_x >= output_x &&
						window_y >= output_y &&
					  window_x < output_x + output_w &&
					  window_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(window_geometry);
	free(output_info);
	free(output_crtc_info);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq 0x2d48(%rip), %rdi      # 0x4130
callq 0x1860
movq 0x2d3c(%rip), %rdi      # 0x4130
leaq 0x2d3d(%rip), %rsi      # 0x4138
callq 0x18e0
movq 0x2d29(%rip), %rdi      # 0x4130
callq 0x1bd0
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0x91(%rbp)
je 0x146f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl 0x1(%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x91(%rbp)
je 0x146f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
sete %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x147e
jmp 0x1600
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0x14b8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x14b8
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x1600
movl $0x0, -0x6c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x92(%rbp)
je 0x14fb
cmpl $0x0, -0x6c(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x92(%rbp)
movb -0x92(%rbp), %al
testb $0x1, %al
jne 0x150a
jmp 0x15e4
movq -0x68(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x1519
jmp 0x15e4
movq -0x10(%rbp), %rax
movq (%rax), %rax
movb (%rax), %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
subb $0x77, %al
jne 0x15cf
jmp 0x1532
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x155b
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x155b
movq -0x58(%rbp), %rdi
callq 0x1330
callq 0x1040
movl $0x1, -0x6c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0x1586
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x15a9
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x11c0
movl %eax, -0x14(%rbp)
jmp 0x15d1
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x14d5
jmp 0x15e6
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x142f
movl -0x14(%rbp), %edi
callq 0x1360
testb $0x1, %al
jne 0x161f
movl $0x1, %edi
leaq 0xa00(%rip), %rsi       # 0x2018
movb $0x0, %al
callq 0x10b0
movq 0x2b0a(%rip), %rdi      # 0x4130
movl -0x14(%rbp), %esi
callq 0x1c40
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movw 0xc(%rax), %ax
movw %ax, -0x22(%rbp)
movq -0x20(%rbp), %rax
movw 0xe(%rax), %ax
movw %ax, -0x24(%rbp)
movq 0x2adf(%rip), %rdi      # 0x4130
movq 0x2ae0(%rip), %rsi      # 0x4138
leaq -0x78(%rbp), %rdx
callq 0x1940
movl %eax, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movq $0x0, -0x48(%rbp)
movl -0x80(%rbp), %ecx
xorl %eax, %eax
cmpl -0x7c(%rbp), %ecx
movb %al, -0xa9(%rbp)
jge 0x1691
cmpq $0x0, -0x48(%rbp)
sete %al
movb %al, -0xa9(%rbp)
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x16a0
jmp 0x1807
movq 0x2a89(%rip), %rdi      # 0x4130
movq -0x78(%rbp), %rax
movslq -0x80(%rbp), %rcx
movl (%rax,%rcx,4), %esi
leaq -0x88(%rbp), %rdx
callq 0x19c0
movl %eax, -0x8c(%rbp)
movl $0x0, -0x90(%rbp)
movl -0x90(%rbp), %ecx
xorl %eax, %eax
cmpl -0x8c(%rbp), %ecx
movb %al, -0xaa(%rbp)
jge 0x16f2
cmpq $0x0, -0x48(%rbp)
sete %al
movb %al, -0xaa(%rbp)
movb -0xaa(%rbp), %al
testb $0x1, %al
jne 0x1701
jmp 0x17f9
movq -0x88(%rbp), %rax
movslq -0x90(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movq 0x2a14(%rip), %rdi      # 0x4130
movl -0x3c(%rbp), %esi
callq 0x1b50
cmpl $0x0, %eax
jne 0x17e5
movq 0x29fc(%rip), %rdi      # 0x4130
movl -0x3c(%rbp), %esi
callq 0x1a40
movq %rax, -0x30(%rbp)
movq 0x29e9(%rip), %rdi      # 0x4130
movq -0x30(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x1b80
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x17e3
movq -0x38(%rbp), %rax
movw 0x10(%rax), %ax
movw %ax, -0x4a(%rbp)
movq -0x38(%rbp), %rax
movw 0x12(%rax), %ax
movw %ax, -0x4c(%rbp)
movq -0x38(%rbp), %rax
movw 0xc(%rax), %ax
movw %ax, -0x4e(%rbp)
movq -0x38(%rbp), %rax
movw 0xe(%rax), %ax
movw %ax, -0x50(%rbp)
movzwl -0x22(%rbp), %eax
movzwl -0x4e(%rbp), %ecx
cmpl %ecx, %eax
jl 0x17e1
movzwl -0x24(%rbp), %eax
movzwl -0x50(%rbp), %ecx
cmpl %ecx, %eax
jl 0x17e1
movzwl -0x22(%rbp), %eax
movzwl -0x4e(%rbp), %ecx
movzwl -0x4a(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x17e1
movzwl -0x24(%rbp), %eax
movzwl -0x50(%rbp), %ecx
movzwl -0x4c(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x17e1
movq 0x295b(%rip), %rdi      # 0x4130
movl -0x3c(%rbp), %esi
callq 0x1aa0
movq %rax, -0x48(%rbp)
jmp 0x17e3
jmp 0x17e5
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x16ce
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x1673
cmpq $0x0, -0x48(%rbp)
jne 0x1821
movl $0x1, %edi
leaq 0x814(%rip), %rsi       # 0x202e
movb $0x0, %al
callq 0x10b0
movq -0x48(%rbp), %rsi
leaq 0x819(%rip), %rdi       # 0x2045
movb $0x0, %al
callq 0x10c0
movq -0x20(%rbp), %rdi
callq 0x1030
movq -0x30(%rbp), %rdi
callq 0x1030
movq -0x38(%rbp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)