// File: /workspace/github_c_makefile_star2_O3/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 0x3c34
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x10(%rdi)
je 0x3da8
movq %rbx, 0x20(%rsp)
movq %rbx, %rdi
callq 0x3849
movq %rax, %rbp
movq %rbx, %rdi
callq 0x3849
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x3849
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
callq 0x3849
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x4423(%rip), %rsi      # 0x80b5
callq 0x3440
movq %rax, %rdi
callq 0x4770
movl %eax, 0x4(%rsp)
movq 0x18(%rsp), %rdi
callq 0x4770
movl %eax, %r12d
leaq 0x10(%rsp), %rdi
leaq 0x43fb(%rip), %rsi      # 0x80b7
callq 0x3440
movq %rax, %rdi
callq 0x4770
movl %eax, %r13d
movq 0x10(%rsp), %rdi
callq 0x4770
movl %eax, %ebx
leaq 0x8bf9(%rip), %rax      # 0xc8d8
movq (%rax), %rdi
callq 0x3849
testq %rax, %rax
je 0x3d99
movq %rax, %r15
xorl %r14d, %r14d
cmpb $0x2a, (%rbp)
jne 0x3d02
cmpb $0x0, 0x1(%rbp)
je 0x3d11
movq (%r15), %rsi
movq %rbp, %rdi
callq 0x3370
testl %eax, %eax
jne 0x3d43
cmpq $0x0, 0x10(%r15)
je 0x3d5c
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x6099
testq %rax, %rax
je 0x3d6e
movl %r13d, (%rax)
movl %ebx, 0x4(%rax)
movl %r12d, 0x8(%rax)
movl 0x4(%rsp), %ecx
movl %ecx, 0xc(%rax)
movq %r14, %rdi
callq 0x3060
leaq 0x8b8e(%rip), %rax      # 0xc8d8
movq (%rax), %rdi
callq 0x3849
movq %rax, %r15
testq %rax, %rax
jne 0x3cf6
jmp 0x3d99
leaq 0x10(%r15), %r14
callq 0x3818
movq %rax, 0x10(%r15)
movq %r14, %r15
jmp 0x3d72
addq $0x10, %r15
movq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebx, %edx
movl %r12d, %ecx
movl 0x4(%rsp), %r8d
callq 0x5ed0
movq %rax, %r14
movq (%r15), %rdi
movq %rax, %rsi
callq 0x3884
jmp 0x3d43
movq 0x20(%rsp), %rbx
cmpl $0x0, 0x10(%rbx)
jne 0x3c54
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq