// File: /workspace/github_c_makefile_star2_O1/comfies[P]custard/src/ipc/ipc.c
// Function: ipc_command_geometry
void ipc_command_geometry(vector_t *input, unsigned short *screen_update) {
    suppress_unused(screen_update);

    /*
     * Usage:
     *  custard - geometry [monitor or '*'] [label] [width]x[height] [x],[y]
     */

    char *monitor_name;
    char *label;
    char *size;
    char *position;

    char *token;
    unsigned int height;
    unsigned int width;
    unsigned int x;
    unsigned int y;

    monitor_t *monitor;
    grid_geometry_t *geometry = NULL;
    labeled_grid_geometry_t *labeled_geometry = NULL;

    // Missing geometry data
    if ((input->size - 1) % 4) return;

    while (input->remaining) {
        labeled_geometry = NULL;
        geometry = NULL;

        monitor_name = vector_iterator(input);
        label = vector_iterator(input);
        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);

        /* bullshit here */

        while ((monitor = vector_iterator(monitors))) {
            if (!strcmp(monitor_name, "*") ||
                !strcmp(monitor_name, monitor->name)) {

                if (monitor->geometries) {
                    geometry = get_geometry_from_monitor(monitor, label);
                    if (geometry) {
                        geometry->x = x;
                        geometry->y = y;
                        geometry->height = height;
                        geometry->width = width;
                        free(labeled_geometry);

                        continue;
                    }
                } else
                    monitor->geometries = construct_vector();

                labeled_geometry = create_labeled_geometry(label,
                    x, y, height, width);
                push_to_vector(monitor->geometries, labeled_geometry);
            }
        }
    }

}

// Assembly:
movl 0xc(%rdi), %eax
decl %eax
testb $0x3, %al
je 0x3c4c
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x10(%rdi)
je 0x3dc9
movq %rbx, 0x20(%rsp)
movq %rbx, %rdi
callq 0x3851
movq %rax, %r14
movq %rbx, %rdi
callq 0x3851
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x3851
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
callq 0x3851
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x440d(%rip), %rsi      # 0x80b7
callq 0x3440
movq %rax, %rdi
callq 0x479c
movl %eax, 0x4(%rsp)
movq 0x18(%rsp), %rdi
callq 0x479c
movl %eax, %r13d
leaq 0x10(%rsp), %rdi
leaq 0x43e5(%rip), %rsi      # 0x80b9
callq 0x3440
movq %rax, %rdi
callq 0x479c
movl %eax, %ebx
movq 0x10(%rsp), %rdi
callq 0x479c
movl %eax, %ebp
leaq 0x8be2(%rip), %rax      # 0xc8d8
movq (%rax), %rdi
callq 0x3851
testq %rax, %rax
je 0x3dba
movq %rax, %r12
xorl %r15d, %r15d
movq %r14, %rdi
leaq 0x43a4(%rip), %rsi      # 0x80bb
callq 0x3370
testl %eax, %eax
je 0x3d30
movq (%r12), %rsi
movq %r14, %rdi
callq 0x3370
testl %eax, %eax
jne 0x3d62
cmpq $0x0, 0x10(%r12)
je 0x3d7b
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x608a
testq %rax, %rax
je 0x3d8f
movl %ebx, (%rax)
movl %ebp, 0x4(%rax)
movl %r13d, 0x8(%rax)
movl 0x4(%rsp), %ecx
movl %ecx, 0xc(%rax)
movq %r15, %rdi
callq 0x3060
leaq 0x8b6f(%rip), %rax      # 0xc8d8
movq (%rax), %rdi
callq 0x3851
movq %rax, %r12
testq %rax, %rax
jne 0x3d0d
jmp 0x3dba
leaq 0x10(%r12), %r15
callq 0x3818
movq %rax, 0x10(%r12)
movq %r15, %r12
jmp 0x3d93
addq $0x10, %r12
movq 0x8(%rsp), %rdi
movl %ebx, %esi
movl %ebp, %edx
movl %r13d, %ecx
movl 0x4(%rsp), %r8d
callq 0x5f00
movq %rax, %r15
movq (%r12), %rdi
movq %rax, %rsi
callq 0x388c
jmp 0x3d62
movq 0x20(%rsp), %rbx
cmpl $0x0, 0x10(%rbx)
jne 0x3c6c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq