// File: /workspace/github_c_makefile_star2_O0/tkln[P]mcwm/mcwm.c
// Function: getoutputs
void getoutputs(xcb_randr_output_t *outputs, int len, xcb_timestamp_t timestamp)
{
    char *name;
    xcb_randr_get_crtc_info_cookie_t icookie;
    xcb_randr_get_crtc_info_reply_t *crtc = NULL;
    xcb_randr_get_output_info_reply_t *output;
    struct monitor *mon;
    struct monitor *clonemon;
    xcb_randr_get_output_info_cookie_t ocookie[len];
    int i;
    
    for (i = 0; i < len; i++)
    {
        ocookie[i] = xcb_randr_get_output_info(conn, outputs[i], timestamp);
    }

    /* Loop through all outputs. */
    for (i = 0; i < len; i ++)
    {
        output = xcb_randr_get_output_info_reply(conn, ocookie[i], NULL);
        
        if (output == NULL)
        {
            continue;
        }

        asprintf(&name, "%.*s",
                 xcb_randr_get_output_info_name_length(output),
                 xcb_randr_get_output_info_name(output));

        PDEBUG("Name: %s\n", name);
        PDEBUG("id: %d\n" , outputs[i]);
        PDEBUG("Size: %d x %d mm.\n", output->mm_width, output->mm_height);

        if (XCB_NONE != output->crtc)
        {
            icookie = xcb_randr_get_crtc_info(conn, output->crtc, timestamp);
            crtc = xcb_randr_get_crtc_info_reply(conn, icookie, NULL);
            if (NULL == crtc)
            {
                return;
            }
            
            PDEBUG("CRTC: at %d, %d, size: %d x %d.\n", crtc->x, crtc->y,
                   crtc->width, crtc->height);

            /* Check if it's a clone. */
            clonemon = findclones(outputs[i], crtc->x, crtc->y);
            if (NULL != clonemon)
            {
                PDEBUG("Monitor %s, id %d is a clone of %s, id %d. Skipping.\n",
                       name, outputs[i],
                       clonemon->name, clonemon->id);
                continue;
            }

            /* Do we know this monitor already? */
            if (NULL == (mon = findmonitor(outputs[i])))
            {
                PDEBUG("Monitor not known, adding to list.\n");
                addmonitor(outputs[i], name, crtc->x, crtc->y, crtc->width,
                           crtc->height);
            }
            else
            {
                bool changed = false;
                
                /*
                 * We know this monitor. Update information. If it's
                 * smaller than before, rearrange windows.
                 */
                PDEBUG("Known monitor. Updating info.\n");

                if (crtc->x != mon->x)
                {
                    mon->x = crtc->x;
                    changed = true;
                }
                if (crtc->y != mon->y)
                {
                    mon->y = crtc->y;
                    changed = true;
                }

                if (crtc->width != mon->width)
                {
                    mon->width = crtc->width;                    
                    changed = true;
                }
                if (crtc->height != mon->height)
                {
                    mon->height = crtc->height;                    
                    changed = true;
                }
                
                if (changed)
                {
                    arrbymon(mon);
                }
            }

            free(crtc);
        }
        else
        {
            PDEBUG("Monitor not used at the moment.\n");
            /*
             * Check if it was used before. If it was, do something.
             */
            if ((mon = findmonitor(outputs[i])))
            {
                struct item *item;
                struct client *client;

                /* Check all windows on this monitor and move them to
                 * the next or to the first monitor if there is no
                 * next.
                 *
                 * FIXME: Use per monitor workspace list instead of
                 * global window list.
                 */
                for (item = winlist; item != NULL; item = item->next)
                {
                    client = item->data;
                    if (client->monitor == mon)
                    {
                        if (NULL == client->monitor->item->next)
                        {
                            if (NULL == monlist)
                            {
                                client->monitor = NULL;
                            }
                            else
                            {
                                client->monitor = monlist->data;
                            }
                        }
                        else
                        {
                            client->monitor =
                                client->monitor->item->next->data;
                        }

                        fitonscreen(client);
                    }
                } /* for */
                
                /* It's not active anymore. Forget about it. */
                delmonitor(mon);
            }
        }

        free(output);
    } /* for */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movl -0xc(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x48(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x80(%rbp)
movq %rcx, %rsp
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x7a99
movslq -0x54(%rbp), %rax
movq %rax, -0x88(%rbp)
movq 0x5f13(%rip), %rdi      # 0xd978
movq -0x8(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movl -0x10(%rbp), %edx
callq 0x3570
movq -0x88(%rbp), %rcx
movl %eax, %edx
movq -0x80(%rbp), %rax
movl %edx, -0x58(%rbp)
movl -0x58(%rbp), %edx
movl %edx, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x7a4b
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x7da3
movq -0x80(%rbp), %rax
movq 0x5ec1(%rip), %rdi      # 0xd978
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x34f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x7ad7
jmp 0x7d95
movq -0x30(%rbp), %rdi
callq 0x30d0
movl %eax, -0x8c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3360
movl -0x8c(%rbp), %edx
movq %rax, %rcx
leaq -0x18(%rbp), %rdi
leaq 0x2981(%rip), %rsi      # 0xa484
movb $0x0, %al
callq 0x33e0
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x7cbc
movq 0x5e53(%rip), %rdi      # 0xd978
movq -0x30(%rbp), %rax
movl 0xc(%rax), %esi
movl -0x10(%rbp), %edx
callq 0x3340
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq 0x5e34(%rip), %rdi      # 0xd978
movl -0x1c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x34a0
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq -0x28(%rbp), %rax
jne 0x7b68
movl $0x1, -0x60(%rbp)
jmp 0x7daa
movq -0x8(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x28(%rbp), %rax
movw 0xc(%rax), %cx
movq -0x28(%rbp), %rax
movswl %cx, %esi
movswl 0xe(%rax), %edx
callq 0x7dc0
movq %rax, -0x40(%rbp)
xorl %eax, %eax
cmpq -0x40(%rbp), %rax
je 0x7b9c
jmp 0x7d95
movq -0x8(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x7e50
movq %rax, %rcx
movq %rcx, -0x38(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x7bf9
movq -0x8(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rax
movswl 0xc(%rax), %edx
movq -0x28(%rbp), %rax
movswl 0xe(%rax), %ecx
movq -0x28(%rbp), %rax
movw 0x10(%rax), %r8w
movq -0x28(%rbp), %rax
movzwl %r8w, %r8d
movzwl 0x12(%rax), %r9d
callq 0x7eb0
jmp 0x7cae
movb $0x0, -0x61(%rbp)
movq -0x28(%rbp), %rax
movswl 0xc(%rax), %eax
movq -0x38(%rbp), %rcx
movswl 0x10(%rcx), %ecx
cmpl %ecx, %eax
je 0x7c25
movq -0x28(%rbp), %rax
movw 0xc(%rax), %cx
movq -0x38(%rbp), %rax
movw %cx, 0x10(%rax)
movb $0x1, -0x61(%rbp)
movq -0x28(%rbp), %rax
movswl 0xe(%rax), %eax
movq -0x38(%rbp), %rcx
movswl 0x12(%rcx), %ecx
cmpl %ecx, %eax
je 0x7c4d
movq -0x28(%rbp), %rax
movw 0xe(%rax), %cx
movq -0x38(%rbp), %rax
movw %cx, 0x12(%rax)
movb $0x1, -0x61(%rbp)
movq -0x28(%rbp), %rax
movzwl 0x10(%rax), %eax
movq -0x38(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
cmpl %ecx, %eax
je 0x7c75
movq -0x28(%rbp), %rax
movw 0x10(%rax), %cx
movq -0x38(%rbp), %rax
movw %cx, 0x14(%rax)
movb $0x1, -0x61(%rbp)
movq -0x28(%rbp), %rax
movzwl 0x12(%rax), %eax
movq -0x38(%rbp), %rcx
movzwl 0x16(%rcx), %ecx
cmpl %ecx, %eax
je 0x7c9d
movq -0x28(%rbp), %rax
movw 0x12(%rax), %cx
movq -0x38(%rbp), %rax
movw %cx, 0x16(%rax)
movb $0x1, -0x61(%rbp)
testb $0x1, -0x61(%rbp)
je 0x7cac
movq -0x38(%rbp), %rdi
callq 0x4a60
jmp 0x7cae
movq -0x28(%rbp), %rdi
callq 0x3040
jmp 0x7d8c
movq -0x8(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x7e50
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x7d8a
movq 0x5be7(%rip), %rax      # 0xd8c8
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x7d81
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq 0x38(%rax), %rax
cmpq -0x38(%rbp), %rax
jne 0x7d6e
movq -0x78(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x18(%rax), %rcx
xorl %eax, %eax
cmpq 0x10(%rcx), %rax
jne 0x7d4a
xorl %eax, %eax
cmpq 0x5baa(%rip), %rax      # 0xd8d0
jne 0x7d36
movq -0x78(%rbp), %rax
movq $0x0, 0x38(%rax)
jmp 0x7d48
movq 0x5b93(%rip), %rax      # 0xd8d0
movq (%rax), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0x7d65
movq -0x78(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x78(%rbp), %rdi
callq 0x4ac0
jmp 0x7d70
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x7ce5
movq -0x38(%rbp), %rdi
callq 0x7fe0
jmp 0x7d8c
movq -0x30(%rbp), %rdi
callq 0x3040
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x7aa0
movl $0x0, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)