// File: /workspace/github_c_makefile_star2_O2/tudurom[P]windowchef/wm.c
// Function: get_outputs
static void
get_outputs(xcb_randr_output_t *outputs, int len, xcb_timestamp_t timestamp)
{
	int name_len;
	char *name;
	xcb_randr_get_crtc_info_cookie_t info_c;
	xcb_randr_get_crtc_info_reply_t *crtc;
	xcb_randr_get_output_info_reply_t *output;
	struct monitor *mon, *clonemon;
	struct list_item *item;
	xcb_randr_get_output_info_cookie_t out_cookie[len];

	for (int i = 0; i < len; i++)
		out_cookie[i] = xcb_randr_get_output_info(conn, outputs[i],
				timestamp);

	for (int i = 0; i < len; i++) {
		output = xcb_randr_get_output_info_reply(conn, out_cookie[i], NULL);
		if (output == NULL)
			continue;

		name_len = xcb_randr_get_output_info_name_length(output);
		if (16 < name_len)
			name_len = 16;

		/* +1 for the null character */
		name = malloc(name_len + 1);
		/* make sure the name is at most name_len + 1 length
		 * or we may run into problems. */
		snprintf(name, name_len + 1, "%.*s", name_len,
				xcb_randr_get_output_info_name(output));

		if (output->crtc != XCB_NONE) {
			info_c = xcb_randr_get_crtc_info(conn, output->crtc,
					timestamp);
			crtc = xcb_randr_get_crtc_info_reply(conn, info_c, NULL);

			if (crtc == NULL)
				return;

			clonemon = find_clones(outputs[i], crtc->x, crtc->y);
			if (clonemon != NULL)
				continue;

			mon = find_monitor(outputs[i]);
			if (mon == NULL) {
				add_monitor(outputs[i], name, crtc->x, crtc->y,
						crtc->width, crtc->height);
			} else {
				mon->x = crtc->x;
				mon->y = crtc->y;
				mon->width = crtc->width;
				mon->height = crtc->height;

				arrange_by_monitor(mon);
			}

			free(crtc);
		} else {
			/* Check if the monitor was used before
			 * becoming disabled. */
			mon = find_monitor(outputs[i]);
			if (mon) {
				struct client *client;
				for (item = win_list; item != NULL; item = item->next) {
					/* Move window from this monitor to
					 * either the next one or the first one. */
					client = item->data;

					if (client->monitor == mon) {
						if (client->monitor->item->next)
							/* If at end, take from the beginning */
							if (mon_list == NULL)
								client->monitor = NULL;
							else
								client->monitor = mon_list->data;
						else
							client->monitor = client->monitor->item->next->data;
						fit_on_screen(client);
					}
				}

				/* Monitor not active. Delete it. */
				free_monitor(mon);
			}
		}

		if (output != NULL)
			free(output);
		free(name);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r12d
movl %esi, %r14d
movq %rdi, -0x30(%rbp)
movl %esi, %eax
movq %rsp, %rcx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x58(%rbp)
movq %rcx, %rsp
xorl %ebx, %ebx
testl %esi, %esi
cmovlel %ebx, %r14d
cmpq %rbx, %r14
je 0x5efc
movq 0x64d7(%rip), %rdi      # 0xc3b8
movq -0x30(%rbp), %rax
movl (%rax,%rbx,4), %esi
movl %r12d, %edx
callq 0x3430
movq -0x58(%rbp), %rcx
movl %eax, (%rcx,%rbx,4)
incq %rbx
jmp 0x5ed5
xorl %ecx, %ecx
movl %r12d, -0x3c(%rbp)
movq %r14, -0x60(%rbp)
cmpq %r14, %rcx
je 0x615d
movq 0x64a2(%rip), %rdi      # 0xc3b8
movq -0x58(%rbp), %rax
movq %rcx, -0x38(%rbp)
movl (%rax,%rcx,4), %esi
xorl %edx, %edx
callq 0x3210
movq %rax, -0x50(%rbp)
testq %rax, %rax
je 0x614d
movq -0x50(%rbp), %r14
movq %r14, %rdi
callq 0x3310
movl %eax, %ebx
cmpl $0x10, %eax
pushq $0x10
popq %rax
cmovgel %eax, %ebx
leal 0x1(%rbx), %eax
movslq %eax, %r15
movq %r15, %rdi
callq 0x31a0
movq %rax, %r13
movq %r14, %rdi
callq 0x33d0
movq %r13, %rdi
movq %r15, %rsi
leaq 0x33dd(%rip), %rdx      # 0x934f
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x30a0
movl 0xc(%r14), %esi
testl %esi, %esi
je 0x604b
movq 0x6427(%rip), %rdi      # 0xc3b8
movl %r12d, %edx
callq 0x3290
movq 0x6418(%rip), %rdi      # 0xc3b8
movl %eax, %esi
xorl %edx, %edx
callq 0x3390
testq %rax, %rax
movq -0x38(%rbp), %rcx
je 0x615d
movq %rax, %rbx
movq %r13, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl (%rax,%rcx,4), %r15d
movzwl 0xc(%rbx), %r13d
movzwl 0xe(%rbx), %r14d
leaq 0x683a(%rip), %rax      # 0xc810
movq (%rax), %rax
testq %rax, %rax
je 0x5ffe
movq (%rax), %rcx
cmpl %r15d, (%rcx)
je 0x5ff8
cmpw %r13w, 0x10(%rcx)
jne 0x5ff8
cmpw %r14w, 0x12(%rcx)
je 0x614d
addq $0x10, %rax
jmp 0x5fd6
movl %r15d, %edi
callq 0x616c
testq %rax, %rax
je 0x60cc
movq %rax, %r12
movw %r13w, 0x10(%rax)
movw %r14w, 0x12(%rax)
movl 0x10(%rbx), %eax
movl %eax, 0x14(%r12)
leaq 0x639d(%rip), %r14      # 0xc3c8
movq (%r14), %r14
testq %r14, %r14
je 0x612c
movq (%r14), %rdi
cmpq %r12, 0x40(%rdi)
jne 0x6045
callq 0x4a0a
addq $0x10, %r14
jmp 0x602b
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x616c
testq %rax, %rax
je 0x613c
movq %rax, %rbx
leaq 0x635a(%rip), %r14      # 0xc3c8
movq (%r14), %r14
testq %r14, %r14
je 0x60af
movq (%r14), %rdi
movq 0x40(%rdi), %rax
cmpq %rbx, %rax
jne 0x60a9
movq 0x18(%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x60a4
movq 0x677c(%rip), %rax      # 0xc810
testq %rax, %rax
je 0x609e
movq (%rax), %rax
jmp 0x60a0
xorl %eax, %eax
movq %rax, 0x40(%rdi)
callq 0x4a0a
addq $0x10, %r14
jmp 0x606e
movq 0x18(%rbx), %r15
movq %rbx, %rdi
callq 0x32c0
leaq 0x674e(%rip), %rdi      # 0xc810
movq %r15, %rsi
callq 0x7f9c
jmp 0x613c
movss 0x10(%rbx), %xmm0
movaps %xmm0, -0x70(%rbp)
pushq $0x20
popq %rdi
callq 0x31a0
testq %rax, %rax
je 0x612c
movq %rax, %r12
leaq 0x6724(%rip), %rdi      # 0xc810
callq 0x7f71
testq %rax, %rax
je 0x6124
movq %r12, (%rax)
movq %rax, 0x18(%r12)
movl %r15d, (%r12)
movq -0x48(%rbp), %rax
movq %rax, 0x8(%r12)
movw %r13w, 0x10(%r12)
movw %r14w, 0x12(%r12)
movaps -0x70(%rbp), %xmm0
movss %xmm0, 0x14(%r12)
jmp 0x612c
movq %r12, %rdi
callq 0x32c0
movq %rbx, %rdi
callq 0x32c0
movl -0x3c(%rbp), %r12d
movq -0x48(%rbp), %r13
movq -0x50(%rbp), %rdi
callq 0x32c0
movq %r13, %rdi
callq 0x32c0
movq -0x38(%rbp), %rcx
incq %rcx
movq -0x60(%rbp), %r14
jmp 0x5f06
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq