// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movl %edx, %r12d
movl %esi, %r15d
movq %rdi, %r14
movl %esi, %r13d
movq %rsp, %rcx
leaq 0xf(,%r13,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, %rsp
testl %esi, %esi
movq %rcx, -0x58(%rbp)
jle 0x61b0
xorl %ebx, %ebx
movq 0x6223(%rip), %rdi      # 0xc3b8
movl (%r14,%rbx,4), %esi
movl %r12d, %edx
callq 0x3440
movq -0x58(%rbp), %rcx
movl %eax, (%rcx,%rbx,4)
incq %rbx
cmpq %rbx, %r13
jne 0x618e
movq %r13, -0x60(%rbp)
movq %r14, -0x40(%rbp)
testl %r15d, %r15d
jle 0x6454
xorl %r14d, %r14d
movl %r12d, -0x34(%rbp)
movq 0x61e9(%rip), %rdi      # 0xc3b8
movl (%rcx,%r14,4), %esi
xorl %edx, %edx
callq 0x3220
movq %rax, -0x50(%rbp)
testq %rax, %rax
je 0x6443
movq -0x50(%rbp), %r13
movq %r13, %rdi
callq 0x3320
movl %eax, %ebx
cmpl $0x10, %eax
movl $0x10, %eax
cmovgel %eax, %ebx
leal 0x1(%rbx), %eax
movslq %eax, %r15
movq %r15, %rdi
callq 0x31b0
movq %rax, %r12
movq %r13, %rdi
callq 0x33e0
movq %r12, -0x48(%rbp)
movq %r12, %rdi
movq %r15, %rsi
leaq 0x30e5(%rip), %rdx      # 0x930f
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x30b0
movl 0xc(%r13), %esi
testl %esi, %esi
je 0x6317
movq 0x616f(%rip), %rdi      # 0xc3b8
movl -0x34(%rbp), %edx
callq 0x32a0
movq 0x6160(%rip), %rdi      # 0xc3b8
movl %eax, %esi
xorl %edx, %edx
callq 0x33a0
testq %rax, %rax
je 0x6454
movq %rax, %r15
movq -0x40(%rbp), %rax
movl (%rax,%r14,4), %r13d
movzwl 0xc(%r15), %ebx
movzwl 0xe(%r15), %esi
movq 0x658a(%rip), %rax      # 0xc810
testq %rax, %rax
je 0x62c5
movq %rax, %rcx
movq (%rcx), %rdx
cmpl %r13d, (%rdx)
je 0x62a6
cmpw %bx, 0x10(%rdx)
jne 0x62a6
cmpw %si, 0x12(%rdx)
je 0x6443
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
jne 0x628e
jmp 0x62b5
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x62c5
movq (%rax), %r12
cmpl %r13d, (%r12)
jne 0x62b1
jmp 0x62c8
xorl %r12d, %r12d
testq %r12, %r12
je 0x63ad
movw %bx, 0x10(%r12)
movw %si, 0x12(%r12)
movzwl 0x10(%r15), %eax
movw %ax, 0x14(%r12)
movzwl 0x12(%r15), %eax
movw %ax, 0x16(%r12)
movq 0x60ce(%rip), %rbx      # 0xc3c8
testq %rbx, %rbx
je 0x6429
movq (%rbx), %rdi
cmpq %r12, 0x40(%rdi)
jne 0x6311
callq 0x4bf6
movq 0x10(%rbx), %rbx
jmp 0x62fa
movq 0x64f2(%rip), %rax      # 0xc810
testq %rax, %rax
je 0x633c
movq -0x40(%rbp), %rcx
movl (%rcx,%r14,4), %ecx
movq (%rax), %r15
cmpl %ecx, (%r15)
je 0x633f
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x632b
xorl %r15d, %r15d
testq %r15, %r15
je 0x6431
movq 0x6079(%rip), %rbx      # 0xc3c8
testq %rbx, %rbx
je 0x638d
movq (%rbx), %rdi
movq 0x40(%rdi), %rax
cmpq %r15, %rax
jne 0x6387
movq 0x18(%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x6382
movq 0x649e(%rip), %rax      # 0xc810
testq %rax, %rax
je 0x637c
movq (%rax), %rax
jmp 0x637e
xorl %eax, %eax
movq %rax, 0x40(%rdi)
callq 0x4bf6
movq 0x10(%rbx), %rbx
jmp 0x634f
movq 0x18(%r15), %rbx
movq %r15, %rdi
callq 0x32d0
leaq 0x6470(%rip), %rdi      # 0xc810
movq %rbx, %rsi
callq 0x8615
jmp 0x6431
movw %si, -0x2a(%rbp)
movzwl 0x10(%r15), %eax
movw %ax, -0x2e(%rbp)
movzwl 0x12(%r15), %eax
movw %ax, -0x2c(%rbp)
movl $0x20, %edi
callq 0x31b0
testq %rax, %rax
je 0x6429
movq %rax, %r12
leaq 0x6434(%rip), %rdi      # 0xc810
callq 0x85d2
testq %rax, %rax
je 0x6421
movq %r12, (%rax)
movq %rax, 0x18(%r12)
movl %r13d, (%r12)
movq -0x48(%rbp), %rax
movq %rax, 0x8(%r12)
movw %bx, 0x10(%r12)
movzwl -0x2a(%rbp), %eax
movw %ax, 0x12(%r12)
movzwl -0x2e(%rbp), %eax
movw %ax, 0x14(%r12)
movzwl -0x2c(%rbp), %eax
movw %ax, 0x16(%r12)
jmp 0x6429
movq %r12, %rdi
callq 0x32d0
movq %r15, %rdi
callq 0x32d0
movq -0x50(%rbp), %rdi
callq 0x32d0
movq -0x48(%rbp), %rdi
callq 0x32d0
incq %r14
cmpq -0x60(%rbp), %r14
movq -0x58(%rbp), %rcx
jne 0x61c8
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq