// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_set_selection
void
worksheet_set_selection(lxw_worksheet *self,
                        lxw_row_t first_row, lxw_col_t first_col,
                        lxw_row_t last_row, lxw_col_t last_col)
{
    lxw_selection *selection;
    lxw_row_t tmp_row;
    lxw_col_t tmp_col;
    char active_cell[LXW_MAX_CELL_RANGE_LENGTH];
    char sqref[LXW_MAX_CELL_RANGE_LENGTH];

    /* Only allow selection to be set once to avoid freeing/re-creating it. */
    if (!STAILQ_EMPTY(self->selections))
        return;

    /* Excel doesn't set a selection for cell A1 since it is the default. */
    if (first_row == 0 && first_col == 0 && last_row == 0 && last_col == 0)
        return;

    selection = calloc(1, sizeof(lxw_selection));
    RETURN_VOID_ON_MEM_ERROR(selection);

    /* Set the cell range selection. Do this before swapping max/min to  */
    /* allow the selection direction to be reversed. */
    lxw_rowcol_to_cell(active_cell, first_row, first_col);

    /* Swap last row/col for first row/col if necessary. */
    if (first_row > last_row) {
        tmp_row = first_row;
        first_row = last_row;
        last_row = tmp_row;
    }

    if (first_col > last_col) {
        tmp_col = first_col;
        first_col = last_col;
        last_col = tmp_col;
    }

    /* If the first and last cell are the same write a single cell. */
    if ((first_row == last_row) && (first_col == last_col))
        lxw_rowcol_to_cell(sqref, first_row, first_col);
    else
        lxw_rowcol_to_range(sqref, first_row, first_col, last_row, last_col);

    lxw_strcpy(selection->pane, "");
    lxw_strcpy(selection->active_cell, active_cell);
    lxw_strcpy(selection->sqref, sqref);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movw %r8w, %ax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movw %dx, -0xe(%rbp)
movl %ecx, -0x14(%rbp)
movw %ax, -0x16(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, (%rax)
je 0x53b61
jmp 0x53ce7
cmpl $0x0, -0xc(%rbp)
jne 0x53b84
movzwl -0xe(%rbp), %eax
cmpl $0x0, %eax
jne 0x53b84
cmpl $0x0, -0x14(%rbp)
jne 0x53b84
movzwl -0x16(%rbp), %eax
cmpl $0x0, %eax
jne 0x53b84
jmp 0x53ce7
movl $0x1, %edi
movl $0x50, %esi
callq 0xc870
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x53bc7
movq 0x29453(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x12521(%rip), %rsi     # 0x660d0
leaq 0x1883e(%rip), %rdx     # 0x6c3f4
movl $0x24f0, %ecx           # imm = 0x24F0
movb $0x0, %al
callq 0xc8f0
jmp 0x53ce7
jmp 0x53bc9
leaq -0x50(%rbp), %rdi
movl -0xc(%rbp), %esi
movzwl -0xe(%rbp), %edx
callq 0xca90
movl -0xc(%rbp), %eax
cmpl -0x14(%rbp), %eax
jbe 0x53bf3
movl -0xc(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x14(%rbp)
movzwl -0xe(%rbp), %eax
movzwl -0x16(%rbp), %ecx
cmpl %ecx, %eax
jle 0x53c17
movw -0xe(%rbp), %ax
movw %ax, -0x26(%rbp)
movw -0x16(%rbp), %ax
movw %ax, -0xe(%rbp)
movw -0x26(%rbp), %ax
movw %ax, -0x16(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x53c3d
movzwl -0xe(%rbp), %eax
movzwl -0x16(%rbp), %ecx
cmpl %ecx, %eax
jne 0x53c3d
leaq -0x70(%rbp), %rdi
movl -0xc(%rbp), %esi
movzwl -0xe(%rbp), %edx
callq 0xca90
jmp 0x53c58
leaq -0x70(%rbp), %rdi
movl -0xc(%rbp), %esi
movw -0xe(%rbp), %ax
movl -0x14(%rbp), %ecx
movzwl %ax, %edx
movzwl -0x16(%rbp), %r8d
callq 0xcdc0
movq -0x20(%rbp), %rdi
movl $0xc, %esi
leaq 0x18c3c(%rip), %rdx     # 0x6c8a4
leaq 0x1b644(%rip), %rcx     # 0x6f2b3
movb $0x0, %al
callq 0xc5d0
movq -0x20(%rbp), %rdi
addq $0xc, %rdi
leaq -0x50(%rbp), %rcx
movl $0x1c, %esi
leaq 0x18c16(%rip), %rdx     # 0x6c8a4
movb $0x0, %al
callq 0xc5d0
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
leaq -0x70(%rbp), %rcx
movl $0x1c, %esi
leaq 0x18bf7(%rip), %rdx     # 0x6c8a4
movb $0x0, %al
callq 0xc5d0
movq -0x20(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
addq $0x48, %rcx
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0x8(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)