// File: /workspace/github_c_makefile_star2_O3/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 0x3e0ba
movq 0x48(%r14), %rcx
movq %rcx, (%rax)
testq %rcx, %rcx
jne 0x3e0d5
movq %rax, 0x8(%rax)
jmp 0x3e0d5
movl $0x1, %edi
movl $0x50, %esi
callq 0xc7f0
movq %rax, %r14
testq %rax, %rax
je 0x3e4f9
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 0x3e280
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 0x3e1c5
movq %rax, %r13
movabsq $0x7468676952706f74, %rax # imm = 0x7468676952706F74
movq %rax, (%r13)
movb $0x0, 0x8(%r13)
leaq 0xc(%r13), %rdi
leaq 0x8d2f(%rip), %rdx      # 0x46ea4
leaq 0x2c(%rsp), %rbp
movl $0x1c, %esi
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc570
leaq 0x28(%r13), %rdi
movl $0x1c, %esi
leaq 0x8d0b(%rip), %rdx      # 0x46ea4
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 0x3e24d
movq %rax, %r13
movabsq $0x654c6d6f74746f62, %rax # imm = 0x654C6D6F74746F62
movq %rax, (%r13)
movl $0x746665, 0x7(%r13)    # imm = 0x746665
leaq 0xc(%r13), %rdi
leaq 0x8ca7(%rip), %rdx      # 0x46ea4
leaq 0x3a(%rsp), %rbp
movl $0x1c, %esi
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc570
leaq 0x28(%r13), %rdi
movl $0x1c, %esi
leaq 0x8c83(%rip), %rdx      # 0x46ea4
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 0x3e30f
movq %rax, %r13
movabsq $0x69526d6f74746f62, %rax # imm = 0x69526D6F74746F62
movq %rax, (%r13)
movl $0x746867, 0x8(%r13)    # imm = 0x746867
jmp 0x3e2bb
testq %r12, %r12
je 0x3e45f
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 0x3e30f
movq %rax, %r13
movq %rbp, (%rax)
movb $0x0, 0x8(%rax)
leaq 0xc(%r13), %rdi
leaq 0xc(%r14), %rcx
leaq 0x8bda(%rip), %rbp      # 0x46ea4
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)
leaq 0xa692(%rip), %rdi      # 0x489a8
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 0x3e370
leaq 0xa666(%rip), %rdi      # 0x489af
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 0xa5d2(%rip), %rdi      # 0x48949
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 0xa60d(%rip), %rdi      # 0x489b6
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 0x3e3e4
cmpl $0x3, %eax
jne 0x3e416
leaq 0xa5e6(%rip), %rsi      # 0x489c8
jmp 0x3e3eb
leaq 0xa5d6(%rip), %rsi      # 0x489c1
leaq 0x80ab(%rip), %rdi      # 0x4649d
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 0xa5b4(%rip), %rsi      # 0x489d4
movq %rsp, %rbx
movq %rbx, %rdx
callq 0xcc00
movq %r14, %rdi
callq 0xc0c0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3e4fe
movq 0x1040(%rdi), %rax
movq %rax, (%rsp)
testq %rax, %rax
jne 0x3e454
movq %rbx, 0x8(%rsp)
callq 0xc0c0
movq (%rsp), %rdi
jmp 0x3e436
movabsq $0x654c6d6f74746f62, %r13 # imm = 0x654C6D6F74746F62
movq %r13, 0x10(%rsp)
movl $0x746665, 0x17(%rsp)   # imm = 0x746665
movl $0x1, %edi
movl $0x50, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3e33d
movq %rax, %r12
movq %r13, (%rax)
movl $0x746665, 0x7(%rax)    # imm = 0x746665
leaq 0xc(%rax), %rdi
leaq 0xc(%r14), %rcx
leaq 0x89fa(%rip), %r13      # 0x46ea4
movl $0x1c, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0xc570
leaq 0x28(%r12), %rdi
leaq 0x28(%r14), %rcx
movl $0x1c, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0xc570
movq %r12, %rax
addq $0x48, %rax
movq $0x0, 0x48(%r12)
movq 0x48(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq %r12, (%rcx)
movq 0x48(%rbx), %rcx
movq %rax, 0x8(%rcx)
jmp 0x3e33d
callq 0xfc74
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq