// File: /workspace/github_c_makefile_star2_O0/comfies[P]custard/src/ipc/ipc.c
// Function: ipc_command_window
void ipc_command_window(vector_t *input, unsigned short *screen_update) {
    // Missing input
    if (input->size < 2) return;
    char *variable = vector_iterator(input);

    /*
     * Usage:
     * custard - window close
     *  custard - window geometry [label]
     */

    window_t *window = NULL;
    if (focused_window == XCB_WINDOW_NONE)
        return;
    if (window_is_managed(focused_window))
        window = get_window_by_id(focused_window);

    if (!strcmp(variable, "close")) {
        close_window(focused_window);
    } else if (!strcmp(variable, "raise")) {

        if (window)
            raise_window(window->parent);
        else
            raise_window(focused_window);

    } else if (!strcmp(variable, "expand")) {

        if (!window || window->floating)
            return;

        char *cardinal = vector_iterator(input);
        grid_geometry_t *geometry = (grid_geometry_t*)window->geometry;

        if (!strcmp(cardinal, "north")) {
            if (geometry->y == 0)
                return;
            geometry->y--;
            geometry->height++;
        } else if (!strcmp(cardinal, "south"))
            geometry->height++;
        else if (!strcmp(cardinal, "east"))
            geometry->width++;
        else if (!strcmp(cardinal, "west")) {
            if (geometry->x == 0)
                return;
            geometry->x--;
            geometry->width++;
        } else return;

        set_window_geometry(window, geometry);
        decorate(window);

    } else if (!strcmp(variable, "contract")) {

        if (!window || window->floating)
            return;

        char *cardinal = vector_iterator(input);
        grid_geometry_t *geometry = (grid_geometry_t*)window->geometry;

        if (!strcmp(cardinal, "north")) {
            if (geometry->height == 1)
                return;
            geometry->y++;
            geometry->height--;
        } else if (!strcmp(cardinal, "south")) {
            if (geometry->height == 1)
                return;
            geometry->height--;
        } else if (!strcmp(cardinal, "east")) {
            if (geometry->width == 1)
                return;
            geometry->width--;
        } else if (!strcmp(cardinal, "west")) {
            if (geometry->width == 1)
                return;
            geometry->x++;
            geometry->width--;
        } else return;

        set_window_geometry(window, geometry);
        decorate(window);

    } else if (!strcmp(variable, "move")) {

        if (!window || window->floating)
            return;

        char *cardinal = vector_iterator(input);
        grid_geometry_t *geometry = (grid_geometry_t*)window->geometry;

        if (!strcmp(cardinal, "north")) {
            if (geometry->y == 0)
                return;
            geometry->y--;
        } else if (!strcmp(cardinal, "south"))
            geometry->y++;
        else if (!strcmp(cardinal, "east"))
            geometry->x++;
        else if (!strcmp(cardinal, "west")) {
            if (geometry->x == 0)
                return;
            geometry->x--;
        } else return;

        set_window_geometry(window, geometry);
        decorate(window);


    } else if (!strcmp(variable, "lower")) {

        if (window)
            lower_window(window->parent);
        else
            lower_window(focused_window);

    } else if (!strcmp(variable, "workspace")) {

        unsigned int workspace = string_to_integer(vector_iterator(input));

        if (window) {
            if (window->workspace == workspace)
                return;

            window->workspace = workspace;

            monitor_t *monitor = monitor_with_cursor_residence();
            if (monitor->workspace != window->workspace)
                unmap_window(window->parent);
        }

    } else if (!strcmp(variable, "geometry")) {
        char *label = vector_iterator(input);

        grid_geometry_t *geometry = (grid_geometry_t *)calloc(1,
            sizeof(grid_geometry_t));
        monitor_t *monitor = monitor_with_cursor_residence();

        log_debug("Looking for geometry(%s) in monitor(%s)",
            label, monitor->name);

        memcpy(geometry,
            get_geometry_from_monitor(monitor, label),
            sizeof(grid_geometry_t));

        if (!geometry)
            return;

        window_t *window = get_window_by_id(focused_window);
        if (window) {
            window->floating = 0;

            free(window->geometry);
            set_window_geometry(window, geometry);
            decorate(window);
        }

    } else if (!strcmp(variable, "float")) {
        char *token;
        char *size;
        char *position;
        unsigned int height;
        unsigned int width;
        unsigned int x;
        unsigned int y;

        size = vector_iterator(input);
        position = vector_iterator(input);

        token = strsep(&size, "x");

        width = string_to_integer(token);
        height = string_to_integer(size);

        token = strsep(&position, ",");

        x = string_to_integer(token);
        y = string_to_integer(position);

        window_t *window = get_window_by_id(focused_window);
        if (window) {
            window->floating = 1;
            screen_geometry_t *geometry = create_screen_geometry(x, y, height,
                width);

            free(window->geometry);
            set_window_geometry(window, geometry);
            decorate(window);
        }
    }

    *screen_update = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x2, 0xc(%rax)
jae 0x4132
jmp 0x4892
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
leaq 0x97a2(%rip), %rax      # 0xd8f0
cmpl $0x0, (%rax)
jne 0x4158
jmp 0x4892
leaq 0x9791(%rip), %rax      # 0xd8f0
movl (%rax), %edi
callq 0x8050
cmpw $0x0, %ax
je 0x417e
leaq 0x977d(%rip), %rax      # 0xd8f0
movl (%rax), %edi
callq 0x8090
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x5f34(%rip), %rsi      # 0xa0bd
callq 0x3380
cmpl $0x0, %eax
jne 0x41a6
leaq 0x9756(%rip), %rax      # 0xd8f0
movl (%rax), %edi
callq 0x9100
jmp 0x4889
movq -0x18(%rbp), %rdi
leaq 0x5f12(%rip), %rsi      # 0xa0c3
callq 0x3380
cmpl $0x0, %eax
jne 0x41e3
cmpq $0x0, -0x20(%rbp)
je 0x41d0
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x9030
jmp 0x41de
leaq 0x9719(%rip), %rax      # 0xd8f0
movl (%rax), %edi
callq 0x9030
jmp 0x4887
movq -0x18(%rbp), %rdi
leaq 0x5edb(%rip), %rsi      # 0xa0c9
callq 0x3380
cmpl $0x0, %eax
jne 0x431c
cmpq $0x0, -0x20(%rbp)
je 0x4210
movq -0x20(%rbp), %rax
movzwl 0x22(%rax), %eax
cmpl $0x0, %eax
je 0x4215
jmp 0x4892
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x5e97(%rip), %rsi      # 0xa0d0
callq 0x3380
cmpl $0x0, %eax
jne 0x4271
movq -0x30(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x4252
jmp 0x4892
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x4301
movq -0x28(%rbp), %rdi
leaq 0x5e5a(%rip), %rsi      # 0xa0d6
callq 0x3380
cmpl $0x0, %eax
jne 0x4295
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x42ff
movq -0x28(%rbp), %rdi
leaq 0x5e3c(%rip), %rsi      # 0xa0dc
callq 0x3380
cmpl $0x0, %eax
jne 0x42b9
movq -0x30(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x42fd
movq -0x28(%rbp), %rdi
leaq 0x5e1d(%rip), %rsi      # 0xa0e1
callq 0x3380
cmpl $0x0, %eax
jne 0x42f6
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x42dc
jmp 0x4892
movq -0x30(%rbp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x42fb
jmp 0x4892
jmp 0x42fd
jmp 0x42ff
jmp 0x4301
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x8520
movq -0x20(%rbp), %rdi
callq 0x6430
jmp 0x4885
movq -0x18(%rbp), %rdi
leaq 0x5dbf(%rip), %rsi      # 0xa0e6
callq 0x3380
cmpl $0x0, %eax
jne 0x4474
cmpq $0x0, -0x20(%rbp)
je 0x4349
movq -0x20(%rbp), %rax
movzwl 0x22(%rax), %eax
cmpl $0x0, %eax
je 0x434e
jmp 0x4892
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
leaq 0x5d5e(%rip), %rsi      # 0xa0d0
callq 0x3380
cmpl $0x0, %eax
jne 0x43aa
movq -0x40(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x438b
jmp 0x4892
movq -0x40(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x4459
movq -0x38(%rbp), %rdi
leaq 0x5d21(%rip), %rsi      # 0xa0d6
callq 0x3380
cmpl $0x0, %eax
jne 0x43dd
movq -0x40(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x43ce
jmp 0x4892
movq -0x40(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x4457
movq -0x38(%rbp), %rdi
leaq 0x5cf4(%rip), %rsi      # 0xa0dc
callq 0x3380
cmpl $0x0, %eax
jne 0x4410
movq -0x40(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jne 0x4401
jmp 0x4892
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x4455
movq -0x38(%rbp), %rdi
leaq 0x5cc6(%rip), %rsi      # 0xa0e1
callq 0x3380
cmpl $0x0, %eax
jne 0x444e
movq -0x40(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jne 0x4434
jmp 0x4892
movq -0x40(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x4453
jmp 0x4892
jmp 0x4455
jmp 0x4457
jmp 0x4459
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x8520
movq -0x20(%rbp), %rdi
callq 0x6430
jmp 0x4883
movq -0x18(%rbp), %rdi
leaq 0x5c70(%rip), %rsi      # 0xa0ef
callq 0x3380
cmpl $0x0, %eax
jne 0x4591
cmpq $0x0, -0x20(%rbp)
je 0x44a1
movq -0x20(%rbp), %rax
movzwl 0x22(%rax), %eax
cmpl $0x0, %eax
je 0x44a6
jmp 0x4892
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x5c06(%rip), %rsi      # 0xa0d0
callq 0x3380
cmpl $0x0, %eax
jne 0x44f5
movq -0x50(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x44e3
jmp 0x4892
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
jmp 0x4576
movq -0x48(%rbp), %rdi
leaq 0x5bd6(%rip), %rsi      # 0xa0d6
callq 0x3380
cmpl $0x0, %eax
jne 0x4519
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
jmp 0x4574
movq -0x48(%rbp), %rdi
leaq 0x5bb8(%rip), %rsi      # 0xa0dc
callq 0x3380
cmpl $0x0, %eax
jne 0x453b
movq -0x50(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x4572
movq -0x48(%rbp), %rdi
leaq 0x5b9b(%rip), %rsi      # 0xa0e1
callq 0x3380
cmpl $0x0, %eax
jne 0x456b
movq -0x50(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x455e
jmp 0x4892
movq -0x50(%rbp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
jmp 0x4570
jmp 0x4892
jmp 0x4572
jmp 0x4574
jmp 0x4576
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x8520
movq -0x20(%rbp), %rdi
callq 0x6430
jmp 0x4881
movq -0x18(%rbp), %rdi
leaq 0x5b58(%rip), %rsi      # 0xa0f4
callq 0x3380
cmpl $0x0, %eax
jne 0x45ce
cmpq $0x0, -0x20(%rbp)
je 0x45bb
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x90a0
jmp 0x45c9
leaq 0x932e(%rip), %rax      # 0xd8f0
movl (%rax), %edi
callq 0x90a0
jmp 0x487f
movq -0x18(%rbp), %rdi
leaq 0x5a74(%rip), %rsi      # 0xa04d
callq 0x3380
cmpl $0x0, %eax
jne 0x4645
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, %rdi
callq 0x4e90
movl %eax, -0x54(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4640
movq -0x20(%rbp), %rax
movl 0x24(%rax), %eax
cmpl -0x54(%rbp), %eax
jne 0x460f
jmp 0x4892
movl -0x54(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
callq 0x7b10
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x24(%rcx), %eax
je 0x463e
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x8f10
jmp 0x4640
jmp 0x487d
movq -0x18(%rbp), %rdi
leaq 0x6337(%rip), %rsi      # 0xa987
callq 0x3380
cmpl $0x0, %eax
jne 0x4743
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x68(%rbp)
movl $0x1, %edi
movl $0x10, %esi
callq 0x3350
movq %rax, -0x70(%rbp)
callq 0x7b10
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %r9
movq -0x78(%rbp), %rax
movq (%rax), %rax
movl $0x3, %edi
leaq 0x5a5c(%rip), %rsi      # 0xa0fa
leaq 0x5a63(%rip), %rdx      # 0xa108
movl $0x156, %ecx            # imm = 0x156
leaq 0x5a6a(%rip), %r8       # 0xa11b
movq %rax, (%rsp)
movb $0x0, %al
callq 0x5bf0
movq -0x70(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x78(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x6d40
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x70(%rbp)
jne 0x46f8
jmp 0x4892
leaq 0x91f1(%rip), %rax      # 0xd8f0
movl (%rax), %edi
callq 0x8090
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x473e
movq -0x80(%rbp), %rax
movw $0x0, 0x22(%rax)
movq -0x80(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3060
movq -0x80(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x8520
movq -0x80(%rbp), %rdi
callq 0x6430
jmp 0x487b
movq -0x18(%rbp), %rdi
leaq 0x59f5(%rip), %rsi      # 0xa143
callq 0x3380
cmpl $0x0, %eax
jne 0x4879
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq 0x592d(%rip), %rsi      # 0xa0b7
callq 0x3450
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x4e90
movl %eax, -0xa0(%rbp)
movq -0x90(%rbp), %rdi
callq 0x4e90
movl %eax, -0x9c(%rbp)
leaq -0x98(%rbp), %rdi
leaq 0x58f1(%rip), %rsi      # 0xa0b9
callq 0x3450
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x4e90
movl %eax, -0xa4(%rbp)
movq -0x98(%rbp), %rdi
callq 0x4e90
movl %eax, -0xa8(%rbp)
leaq 0x90f1(%rip), %rax      # 0xd8f0
movl (%rax), %edi
callq 0x8090
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0x4877
movq -0xb0(%rbp), %rax
movw $0x1, 0x22(%rax)
movl -0xa4(%rbp), %edi
movl -0xa8(%rbp), %esi
movl -0x9c(%rbp), %edx
movl -0xa0(%rbp), %ecx
callq 0x6c30
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3060
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x8520
movq -0xb0(%rbp), %rdi
callq 0x6430
jmp 0x4879
jmp 0x487b
jmp 0x487d
jmp 0x487f
jmp 0x4881
jmp 0x4883
jmp 0x4885
jmp 0x4887
jmp 0x4889
movq -0x10(%rbp), %rax
movw $0x1, (%rax)
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax,%rax)