// File: /workspace/github_c_makefile_star2_O1/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_write_freeze_panes
STATIC void
_worksheet_write_freeze_panes(lxw_worksheet *self)
{
    struct xml_attribute_list attributes;
    struct xml_attribute *attribute;

    lxw_selection *selection;
    lxw_selection *user_selection;
    lxw_row_t row = self->panes.first_row;
    lxw_col_t col = self->panes.first_col;
    lxw_row_t top_row = self->panes.top_row;
    lxw_col_t left_col = self->panes.left_col;

    char row_cell[LXW_MAX_CELL_NAME_LENGTH];
    char col_cell[LXW_MAX_CELL_NAME_LENGTH];
    char top_left_cell[LXW_MAX_CELL_NAME_LENGTH];
    char active_pane[LXW_PANE_NAME_LENGTH];

    /* If there is a user selection we remove it from the list and use it. */
    if (!STAILQ_EMPTY(self->selections)) {
        user_selection = STAILQ_FIRST(self->selections);
        STAILQ_REMOVE_HEAD(self->selections, list_pointers);
    }
    else {
        /* or else create a new blank selection. */
        user_selection = calloc(1, sizeof(lxw_selection));
        RETURN_VOID_ON_MEM_ERROR(user_selection);
    }

    LXW_INIT_ATTRIBUTES();

    lxw_rowcol_to_cell(top_left_cell, top_row, left_col);

    /* Set the active pane. */
    if (row && col) {
        lxw_strcpy(active_pane, "bottomRight");

        lxw_rowcol_to_cell(row_cell, row, 0);
        lxw_rowcol_to_cell(col_cell, 0, col);

        selection = calloc(1, sizeof(lxw_selection));
        if (selection) {
            lxw_strcpy(selection->pane, "topRight");
            lxw_strcpy(selection->active_cell, col_cell);
            lxw_strcpy(selection->sqref, col_cell);

            STAILQ_INSERT_TAIL(self->selections, selection, list_pointers);
        }

        selection = calloc(1, sizeof(lxw_selection));
        if (selection) {
            lxw_strcpy(selection->pane, "bottomLeft");
            lxw_strcpy(selection->active_cell, row_cell);
            lxw_strcpy(selection->sqref, row_cell);

            STAILQ_INSERT_TAIL(self->selections, selection, list_pointers);
        }

        selection = calloc(1, sizeof(lxw_selection));
        if (selection) {
            lxw_strcpy(selection->pane, "bottomRight");
            lxw_strcpy(selection->active_cell, user_selection->active_cell);
            lxw_strcpy(selection->sqref, user_selection->sqref);

            STAILQ_INSERT_TAIL(self->selections, selection, list_pointers);
        }
    }
    else if (col) {
        lxw_strcpy(active_pane, "topRight");

        selection = calloc(1, sizeof(lxw_selection));
        if (selection) {
            lxw_strcpy(selection->pane, "topRight");
            lxw_strcpy(selection->active_cell, user_selection->active_cell);
            lxw_strcpy(selection->sqref, user_selection->sqref);

            STAILQ_INSERT_TAIL(self->selections, selection, list_pointers);
        }
    }
    else {
        lxw_strcpy(active_pane, "bottomLeft");

        selection = calloc(1, sizeof(lxw_selection));
        if (selection) {
            lxw_strcpy(selection->pane, "bottomLeft");
            lxw_strcpy(selection->active_cell, user_selection->active_cell);
            lxw_strcpy(selection->sqref, user_selection->sqref);

            STAILQ_INSERT_TAIL(self->selections, selection, list_pointers);
        }
    }

    if (col)
        LXW_PUSH_ATTRIBUTES_INT("xSplit", col);

    if (row)
        LXW_PUSH_ATTRIBUTES_INT("ySplit", row);

    LXW_PUSH_ATTRIBUTES_STR("topLeftCell", top_left_cell);
    LXW_PUSH_ATTRIBUTES_STR("activePane", active_pane);

    if (self->panes.type == FREEZE_PANES)
        LXW_PUSH_ATTRIBUTES_STR("state", "frozen");
    else if (self->panes.type == FREEZE_SPLIT_PANES)
        LXW_PUSH_ATTRIBUTES_STR("state", "frozenSplit");

    lxw_xml_empty_tag(self->file, "pane", &attributes);

    free(user_selection);

    LXW_FREE_ATTRIBUTES();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movl 0x244(%rdi), %r15d
movl 0x24c(%rdi), %ebp
movzwl 0x248(%rdi), %r12d
movzwl 0x250(%rdi), %r13d
movq 0x48(%rdi), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x3ded9
movq 0x48(%r14), %rcx
movq %rcx, (%rax)
testq %rcx, %rcx
jne 0x3def4
movq %rax, 0x8(%rax)
jmp 0x3def4
movl $0x1, %edi
movl $0x50, %esi
callq 0xc7f0
movq %rax, %r14
testq %rax, %rax
je 0x3e2b9
movq %rsp, %rax
movq $0x0, (%rax)
movq %rax, 0x8(%rax)
movzwl %r13w, %edx
leaq 0x1e(%rsp), %rdi
movl %ebp, %esi
callq 0xca00
testq %r15, %r15
setne %al
testw %r12w, %r12w
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3e09f
movabsq $0x69526d6f74746f62, %rax # imm = 0x69526D6F74746F62
movq %rax, 0x10(%rsp)
movl $0x746867, 0x18(%rsp)   # imm = 0x746867
leaq 0x3a(%rsp), %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0xca00
leaq 0x2c(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0xca00
movl $0x1, %edi
movl $0x50, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3dfe4
movq %rax, %r13
movabsq $0x7468676952706f74, %rax # imm = 0x7468676952706F74
movq %rax, (%r13)
movb $0x0, 0x8(%r13)
leaq 0xc(%r13), %rdi
leaq 0x8e24(%rip), %rdx      # 0x46db8
leaq 0x2c(%rsp), %rbp
movl $0x1c, %esi
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc570
leaq 0x28(%r13), %rdi
movl $0x1c, %esi
leaq 0x8e00(%rip), %rdx      # 0x46db8
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc570
movq %r13, %rax
addq $0x48, %rax
movq $0x0, 0x48(%r13)
movq 0x48(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq %r13, (%rcx)
movq 0x48(%rbx), %rcx
movq %rax, 0x8(%rcx)
movl $0x1, %edi
movl $0x50, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3e06c
movq %rax, %r13
movabsq $0x654c6d6f74746f62, %rax # imm = 0x654C6D6F74746F62
movq %rax, (%r13)
movl $0x746665, 0x7(%r13)    # imm = 0x746665
leaq 0xc(%r13), %rdi
leaq 0x8d9c(%rip), %rdx      # 0x46db8
leaq 0x3a(%rsp), %rbp
movl $0x1c, %esi
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc570
leaq 0x28(%r13), %rdi
movl $0x1c, %esi
leaq 0x8d78(%rip), %rdx      # 0x46db8
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc570
movq %r13, %rax
addq $0x48, %rax
movq $0x0, 0x48(%r13)
movq 0x48(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq %r13, (%rcx)
movq 0x48(%rbx), %rcx
movq %rax, 0x8(%rcx)
movl $0x1, %edi
movl $0x50, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3e168
movq %rax, %r13
movabsq $0x69526d6f74746f62, %rax # imm = 0x69526D6F74746F62
movq %rax, (%r13)
movl $0x746867, 0x8(%r13)    # imm = 0x746867
jmp 0x3e114
testq %r12, %r12
je 0x3e0dc
movabsq $0x7468676952706f74, %rbp # imm = 0x7468676952706F74
movq %rbp, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movl $0x1, %edi
movl $0x50, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3e168
movq %rax, %r13
movq %rbp, (%rax)
movb $0x0, 0x8(%rax)
jmp 0x3e114
movabsq $0x654c6d6f74746f62, %rbp # imm = 0x654C6D6F74746F62
movq %rbp, 0x10(%rsp)
movl $0x746665, 0x17(%rsp)   # imm = 0x746665
movl $0x1, %edi
movl $0x50, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3e168
movq %rax, %r13
movq %rbp, (%rax)
movl $0x746665, 0x7(%rax)    # imm = 0x746665
leaq 0xc(%r13), %rdi
leaq 0xc(%r14), %rcx
leaq 0x8c95(%rip), %rbp      # 0x46db8
movl $0x1c, %esi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xc570
leaq 0x28(%r13), %rdi
leaq 0x28(%r14), %rcx
movl $0x1c, %esi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xc570
leaq 0x48(%r13), %rax
movq $0x0, 0x48(%r13)
movq 0x48(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq %r13, (%rcx)
movq 0x48(%rbx), %rcx
movq %rax, 0x8(%rcx)
testq %r12, %r12
je 0x3e19b
leaq 0xa74b(%rip), %rdi      # 0x488bf
movq %r12, %rsi
callq 0xc180
leaq 0x1040(%rax), %rcx
movq $0x0, 0x1040(%rax)
movq 0x8(%rsp), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%rsp)
testq %r15, %r15
je 0x3e1ce
leaq 0xa71f(%rip), %rdi      # 0x488c6
movq %r15, %rsi
callq 0xc180
leaq 0x1040(%rax), %rcx
movq $0x0, 0x1040(%rax)
movq 0x8(%rsp), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%rsp)
leaq 0xa68b(%rip), %rdi      # 0x48860
leaq 0x1e(%rsp), %rsi
callq 0xc030
movl $0x1040, %r15d          # imm = 0x1040
leaq (%rax,%r15), %rcx
xorl %r12d, %r12d
movq %r12, 0x1040(%rax)
movq 0x8(%rsp), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%rsp)
leaq 0xa6c6(%rip), %rdi      # 0x488cd
leaq 0x10(%rsp), %rsi
callq 0xc030
addq %rax, %r15
movq %r12, 0x1040(%rax)
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq %r15, 0x8(%rsp)
movzbl 0x240(%rbx), %eax
cmpl $0x1, %eax
je 0x3e242
cmpl $0x3, %eax
jne 0x3e274
leaq 0xa69f(%rip), %rsi      # 0x488df
jmp 0x3e249
leaq 0xa68f(%rip), %rsi      # 0x488d8
leaq 0x823d(%rip), %rdi      # 0x4648d
callq 0xc030
leaq 0x1040(%rax), %rcx
movq $0x0, 0x1040(%rax)
movq 0x8(%rsp), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%rsp)
movq (%rbx), %rdi
leaq 0xa66d(%rip), %rsi      # 0x488eb
movq %rsp, %rbx
movq %rbx, %rdx
callq 0xcc00
movq %r14, %rdi
callq 0xc0c0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3e2be
movq 0x1040(%rdi), %rax
movq %rax, (%rsp)
testq %rax, %rax
jne 0x3e2ae
movq %rbx, 0x8(%rsp)
callq 0xc0c0
movq (%rsp), %rdi
jmp 0x3e294
callq 0xf891
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq