// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
subl $0x1, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x3f07
jmp 0x409d
jmp 0x3f09
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x409d
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x38c0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq 0x6151(%rip), %rsi      # 0xa0b7
callq 0x3450
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x4e90
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
callq 0x4e90
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
leaq 0x6127(%rip), %rsi      # 0xa0b9
callq 0x3450
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x4e90
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rdi
callq 0x4e90
movl %eax, -0x48(%rbp)
leaq 0x991e(%rip), %rax      # 0xd8d8
movq (%rax), %rdi
callq 0x38c0
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x4098
movq -0x18(%rbp), %rdi
leaq 0x60e0(%rip), %rsi      # 0xa0bb
callq 0x3380
cmpl $0x0, %eax
je 0x3ffe
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rsi
callq 0x3380
cmpl $0x0, %eax
jne 0x4093
movq -0x50(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x4058
movq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x6d40
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x4056
movl -0x44(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, (%rax)
movl -0x48(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x3c(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x40(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x60(%rbp), %rdi
callq 0x3060
jmp 0x3fb3
jmp 0x4068
callq 0x3860
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x48(%rbp), %edx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
callq 0x6b80
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x60(%rbp), %rsi
callq 0x3990
jmp 0x3fb3
jmp 0x3f09
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)