// File: /workspace/github_c_makefile_star2_O2/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 $0x68, %rsp
movq %rdi, %r14
movl 0x244(%rdi), %r13d
movl 0x24c(%rdi), %ebp
movzwl 0x248(%rdi), %eax
movq %rax, 0x28(%rsp)
movzwl 0x250(%rdi), %r12d
movq 0x48(%rdi), %rax
movq (%rax), %rbx
testq %rbx, %rbx
je 0x3b208
movq 0x48(%rbx), %rcx
movq %rcx, (%rax)
testq %rcx, %rcx
jne 0x3b21f
movq %rax, 0x8(%rax)
jmp 0x3b21f
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0xc850
movq %rax, %rbx
testq %rax, %rax
je 0x3b61f
leaq 0x8(%rsp), %r15
andq $0x0, (%r15)
movq %r15, 0x8(%r15)
movzwl %r12w, %edx
leaq 0x5a(%rsp), %rdi
movl %ebp, %esi
callq 0xca60
testq %r13, %r13
setne %al
movq 0x28(%rsp), %r12
testw %r12w, %r12w
setne %cl
andb %al, %cl
cmpb $0x1, %cl
movq %r13, 0x30(%rsp)
jne 0x3b3ba
movq %r13, %rsi
movabsq $0x69526d6f74746f62, %r13 # imm = 0x69526D6F74746F62
movq %r13, 0x18(%rsp)
movl $0x746867, 0x20(%rsp)   # imm = 0x746867
leaq 0x4c(%rsp), %rdi
xorl %edx, %edx
callq 0xca60
leaq 0x3e(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0xca60
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x3b318
movq %rax, %rbp
movabsq $0x7468676952706f74, %rax # imm = 0x7468676952706F74
movq %rax, (%rbp)
movb $0x0, 0x8(%rbp)
leaq 0xc(%rbp), %rdi
leaq 0x8bcd(%rip), %r13      # 0x43e90
pushq $0x1c
popq %r12
leaq 0x3e(%rsp), %rcx
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0xc5b0
leaq 0x28(%rbp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movabsq $0x69526d6f74746f62, %r13 # imm = 0x69526D6F74746F62
leaq 0x3e(%rsp), %rcx
xorl %eax, %eax
callq 0xc5b0
movq %rbp, %rax
addq $0x48, %rax
andq $0x0, 0x48(%rbp)
movq 0x48(%r14), %rcx
movq 0x8(%rcx), %rcx
movq %rbp, (%rcx)
movq 0x48(%r14), %rcx
movq %rax, 0x8(%rcx)
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x3b397
movq %rax, %rbp
movabsq $0x654c6d6f74746f62, %rax # imm = 0x654C6D6F74746F62
movq %rax, (%rbp)
movl $0x746665, 0x7(%rbp)    # imm = 0x746665
leaq 0xc(%rbp), %rdi
leaq 0x8b45(%rip), %rdx      # 0x43e90
pushq $0x1c
popq %r12
leaq 0x4c(%rsp), %rcx
movq %r12, %rsi
xorl %eax, %eax
callq 0xc5b0
leaq 0x28(%rbp), %rdi
movq %r12, %rsi
leaq 0x8b24(%rip), %rdx      # 0x43e90
leaq 0x4c(%rsp), %rcx
xorl %eax, %eax
callq 0xc5b0
movq %rbp, %rax
addq $0x48, %rax
andq $0x0, 0x48(%rbp)
movq 0x48(%r14), %rcx
movq 0x8(%rcx), %rcx
movq %rbp, (%rcx)
movq 0x48(%r14), %rcx
movq %rax, 0x8(%rcx)
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x3b442
movq %rax, %rbp
movq %r13, (%rax)
movl $0x746867, 0x8(%rax)    # imm = 0x746867
jmp 0x3b3f1
testq %r12, %r12
je 0x3b58f
movabsq $0x7468676952706f74, %r12 # imm = 0x7468676952706F74
movq %r12, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x3b442
movq %rax, %rbp
movq %r12, (%rax)
movb $0x0, 0x8(%rax)
leaq 0xc(%rbp), %rdi
leaq 0xc(%rbx), %rcx
leaq 0x8a90(%rip), %r12      # 0x43e90
pushq $0x1c
popq %r13
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0xc5b0
leaq 0x28(%rbp), %rdi
leaq 0x28(%rbx), %rcx
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0xc5b0
leaq 0x48(%rbp), %rax
andq $0x0, 0x48(%rbp)
movq 0x48(%r14), %rcx
movq 0x8(%rcx), %rcx
movq %rbp, (%rcx)
movq 0x48(%r14), %rcx
movq %rax, 0x8(%rcx)
leaq 0xa54b(%rip), %rdi      # 0x45994
movq 0x28(%rsp), %rsi
callq 0xc1a0
andq $0x0, 0x1040(%rax)
leaq 0x1040(%rax), %rcx
movq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movq %rcx, 0x10(%rsp)
movq 0x30(%rsp), %rsi
testq %rsi, %rsi
je 0x3b4a1
leaq 0xa51b(%rip), %rdi      # 0x4599b
callq 0xc1a0
andq $0x0, 0x1040(%rax)
leaq 0x1040(%rax), %rcx
movq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movq %rcx, 0x10(%rsp)
leaq 0xa48d(%rip), %rdi      # 0x45935
leaq 0x5a(%rsp), %rsi
callq 0xc030
movl $0x1040, %r12d          # imm = 0x1040
andq $0x0, 0x1040(%rax)
leaq (%rax,%r12), %rcx
movq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movq %rcx, 0x10(%rsp)
leaq 0xa4ca(%rip), %rdi      # 0x459a2
leaq 0x18(%rsp), %rsi
callq 0xc030
addq %rax, %r12
andq $0x0, 0x1040(%rax)
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq %r12, 0x10(%rsp)
movzbl 0x240(%r14), %eax
cmpl $0x1, %eax
je 0x3b515
cmpl $0x3, %eax
jne 0x3b544
leaq 0xa4a1(%rip), %rsi      # 0x459b4
jmp 0x3b51c
leaq 0xa491(%rip), %rsi      # 0x459ad
leaq 0x7f5a(%rip), %rdi      # 0x4347d
callq 0xc030
andq $0x0, 0x1040(%rax)
leaq 0x1040(%rax), %rcx
movq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movq %rcx, 0x10(%rsp)
movq (%r14), %rdi
leaq 0xa472(%rip), %rsi      # 0x459c0
movq %r15, %rdx
callq 0xcc70
movq %rbx, %rdi
callq 0xc0d0
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
je 0x3b580
movq 0x1040(%rbx), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x3b556
movq %r15, 0x10(%rsp)
jmp 0x3b556
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movabsq $0x654c6d6f74746f62, %r12 # imm = 0x654C6D6F74746F62
movq %r12, 0x18(%rsp)
movl $0x746665, 0x1f(%rsp)   # imm = 0x746665
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x3b46f
movq %rax, %r13
movq %r12, (%rax)
movl $0x746665, 0x7(%rax)    # imm = 0x746665
leaq 0xc(%rax), %rdi
leaq 0xc(%rbx), %rcx
leaq 0x88ba(%rip), %r12      # 0x43e90
pushq $0x1c
popq %rbp
movq %rbp, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0xc5b0
leaq 0x28(%r13), %rdi
leaq 0x28(%rbx), %rcx
movq %rbp, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0xc5b0
movq %r13, %rax
addq $0x48, %rax
andq $0x0, 0x48(%r13)
movq 0x48(%r14), %rcx
movq 0x8(%rcx), %rcx
movq %r13, (%rcx)
movq 0x48(%r14), %rcx
movq %rax, 0x8(%rcx)
jmp 0x3b46f
movq 0x179d2(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x1ab0(%rip), %rsi      # 0x3d0e0
leaq 0x83a9(%rip), %rdx      # 0x439e0
movl $0x818, %ecx            # imm = 0x818
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc8d0