// File: /workspace/github_c_makefile_star2_O3/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, -0x2c(%rbp)
movq %rdi, -0x48(%rbp)
movl %esi, %eax
movq %rsp, %r15
movq %rax, -0x60(%rbp)
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
testl %esi, %esi
jle 0x639d
movl %esi, -0x40(%rbp)
xorl %ebx, %ebx
movl -0x2c(%rbp), %r14d
movq -0x48(%rbp), %r12
movq -0x60(%rbp), %r13
movq 0x62c0(%rip), %rdi      # 0xc3b8
movl (%r12,%rbx,4), %esi
movl %r14d, %edx
callq 0x3440
movl %eax, (%r15,%rbx,4)
incq %rbx
cmpq %rbx, %r13
jne 0x60f1
cmpl $0x0, -0x40(%rbp)
jle 0x639d
movq %r15, %r12
xorl %ebx, %ebx
movq %r15, -0x38(%rbp)
movq 0x628e(%rip), %rdi      # 0xc3b8
movl (%r12,%rbx,4), %esi
xorl %edx, %edx
callq 0x3220
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x6390
movq -0x40(%rbp), %r14
movq %r14, %rdi
callq 0x3320
movl %eax, %r15d
cmpl $0x10, %eax
movl $0x10, %eax
cmovgel %eax, %r15d
leal 0x1(%r15), %eax
movslq %eax, %r12
movq %r12, %rdi
callq 0x31b0
movq %rax, %r13
movq %r14, %rdi
callq 0x33e0
movq %r13, %rdi
movq %r12, %rsi
leaq 0x31b3(%rip), %rdx      # 0x9337
movl %r15d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x30b0
movl 0xc(%r14), %esi
testl %esi, %esi
je 0x6293
movq 0x6214(%rip), %rdi      # 0xc3b8
movl -0x2c(%rbp), %edx
callq 0x32a0
movq 0x6205(%rip), %rdi      # 0xc3b8
movl %eax, %esi
xorl %edx, %edx
callq 0x33a0
testq %rax, %rax
je 0x639d
movq %rax, %rsi
movq %r13, -0x58(%rbp)
movq -0x48(%rbp), %rax
movl (%rax,%rbx,4), %r15d
movzwl 0xc(%rsi), %r13d
movzwl 0xe(%rsi), %r14d
movq 0x662b(%rip), %rax      # 0xc810
testq %rax, %rax
je 0x622a
movq %rax, %rcx
movq -0x38(%rbp), %r12
movq (%rcx), %rdx
cmpl %r15d, (%rdx)
je 0x620b
cmpw %r13w, 0x10(%rdx)
jne 0x620b
cmpw %r14w, 0x12(%rdx)
je 0x6390
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
jne 0x61f1
movq (%rax), %r12
cmpl %r15d, (%r12)
je 0x62c4
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x6214
movq %rsi, -0x50(%rbp)
movss 0x10(%rsi), %xmm0
movaps %xmm0, -0x70(%rbp)
movl $0x20, %edi
callq 0x31b0
testq %rax, %rax
je 0x636e
movq %rax, %r12
leaq 0x65bc(%rip), %rdi      # 0xc810
callq 0x85d2
testq %rax, %rax
je 0x6366
movq %r12, (%rax)
movq %rax, 0x18(%r12)
movl %r15d, (%r12)
movq -0x58(%rbp), %rax
movq %rax, 0x8(%r12)
movw %r13w, 0x10(%r12)
movw %r14w, 0x12(%r12)
movaps -0x70(%rbp), %xmm0
movss %xmm0, 0x14(%r12)
jmp 0x636e
movq 0x6576(%rip), %rax      # 0xc810
testq %rax, %rax
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %r12
je 0x637f
movl (%rcx,%rbx,4), %ecx
movq (%rax), %r15
cmpl %ecx, (%r15)
je 0x6300
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x62ae
jmp 0x637f
movw %r13w, 0x10(%r12)
movw %r14w, 0x12(%r12)
movq %rsi, -0x50(%rbp)
movl 0x10(%rsi), %eax
movl %eax, 0x14(%r12)
movq 0x60e5(%rip), %r14      # 0xc3c8
testq %r14, %r14
je 0x636e
movq (%r14), %rdi
cmpq %r12, 0x40(%rdi)
jne 0x62fa
callq 0x4b33
movq 0x10(%r14), %r14
jmp 0x62e3
movq 0x60c1(%rip), %r14      # 0xc3c8
testq %r14, %r14
je 0x6345
movq (%r14), %rdi
movq 0x40(%rdi), %rax
cmpq %r15, %rax
jne 0x633f
movq 0x18(%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x633a
movq 0x64e6(%rip), %rax      # 0xc810
testq %rax, %rax
je 0x6334
movq (%rax), %rax
jmp 0x6336
xorl %eax, %eax
movq %rax, 0x40(%rdi)
callq 0x4b33
movq 0x10(%r14), %r14
jmp 0x6307
movq 0x18(%r15), %r12
movq %r15, %rdi
callq 0x32d0
leaq 0x64b8(%rip), %rdi      # 0xc810
movq %r12, %rsi
callq 0x8602
movq -0x38(%rbp), %r12
jmp 0x637f
movq %r12, %rdi
callq 0x32d0
movq -0x50(%rbp), %rdi
callq 0x32d0
movq -0x38(%rbp), %r12
movq -0x58(%rbp), %r13
movq -0x40(%rbp), %rdi
callq 0x32d0
movq %r13, %rdi
callq 0x32d0
incq %rbx
cmpq -0x60(%rbp), %rbx
jne 0x6123
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq