// File: /workspace/github_c_makefile_star2_O2/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_position_object_pixels
STATIC void
_worksheet_position_object_pixels(lxw_worksheet *self,
                                  lxw_object_properties *object_props,
                                  lxw_drawing_object *drawing_object)
{
    lxw_col_t col_start;        /* Column containing upper left corner.  */
    int32_t x1;                 /* Distance to left side of object.      */

    lxw_row_t row_start;        /* Row containing top left corner.       */
    int32_t y1;                 /* Distance to top of object.            */

    lxw_col_t col_end;          /* Column containing lower right corner. */
    double x2;                  /* Distance to right side of object.     */

    lxw_row_t row_end;          /* Row containing bottom right corner.   */
    double y2;                  /* Distance to bottom of object.         */

    double width;               /* Width of object frame.                */
    double height;              /* Height of object frame.               */

    uint32_t x_abs = 0;         /* Abs. distance to left side of object. */
    uint32_t y_abs = 0;         /* Abs. distance to top  side of object. */

    uint32_t i;
    uint8_t anchor = drawing_object->anchor;
    uint8_t ignore_anchor = LXW_OBJECT_POSITION_DEFAULT;

    col_start = object_props->col;
    row_start = object_props->row;
    x1 = object_props->x_offset;
    y1 = object_props->y_offset;
    width = object_props->width;
    height = object_props->height;

    /* Adjust start column for negative offsets. */
    while (x1 < 0 && col_start > 0) {
        x1 += _worksheet_size_col(self, col_start - 1, ignore_anchor);
        col_start--;
    }

    /* Adjust start row for negative offsets. */
    while (y1 < 0 && row_start > 0) {
        y1 += _worksheet_size_row(self, row_start - 1, ignore_anchor);
        row_start--;
    }

    /* Ensure that the image isn't shifted off the page at top left. */
    if (x1 < 0)
        x1 = 0;

    if (y1 < 0)
        y1 = 0;

    /* Calculate the absolute x offset of the top-left vertex. */
    if (self->col_size_changed) {
        for (i = 0; i < col_start; i++)
            x_abs += _worksheet_size_col(self, i, ignore_anchor);
    }
    else {
        /* Optimization for when the column widths haven't changed. */
        x_abs += self->default_col_pixels * col_start;
    }

    x_abs += x1;

    /* Calculate the absolute y offset of the top-left vertex. */
    /* Store the column change to allow optimizations. */
    if (self->row_size_changed) {
        for (i = 0; i < row_start; i++)
            y_abs += _worksheet_size_row(self, i, ignore_anchor);
    }
    else {
        /* Optimization for when the row heights haven"t changed. */
        y_abs += self->default_row_pixels * row_start;
    }

    y_abs += y1;

    /* Adjust start col for offsets that are greater than the col width. */
    while (x1 >= _worksheet_size_col(self, col_start, anchor)) {
        x1 -= _worksheet_size_col(self, col_start, ignore_anchor);
        col_start++;
    }

    /* Adjust start row for offsets that are greater than the row height. */
    while (y1 >= _worksheet_size_row(self, row_start, anchor)) {
        y1 -= _worksheet_size_row(self, row_start, ignore_anchor);
        row_start++;
    }

    /* Initialize end cell to the same as the start cell. */
    col_end = col_start;
    row_end = row_start;

    /* Only offset the image in the cell if the row/col is hidden. */
    if (_worksheet_size_col(self, col_start, anchor) > 0)
        width = width + x1;
    if (_worksheet_size_row(self, row_start, anchor) > 0)
        height = height + y1;

    /* Subtract the underlying cell widths to find the end cell. */
    while (width >= _worksheet_size_col(self, col_end, anchor)) {
        width -= _worksheet_size_col(self, col_end, anchor);
        col_end++;
    }

    /* Subtract the underlying cell heights to find the end cell. */
    while (height >= _worksheet_size_row(self, row_end, anchor)) {
        height -= _worksheet_size_row(self, row_end, anchor);
        row_end++;
    }

    /* The end vertices are whatever is left from the width and height. */
    x2 = width;
    y2 = height;

    /* Add the dimensions to the drawing object. */
    drawing_object->from.col = col_start;
    drawing_object->from.row = row_start;
    drawing_object->from.col_offset = x1;
    drawing_object->from.row_offset = y1;
    drawing_object->to.col = col_end;
    drawing_object->to.row = row_end;
    drawing_object->to.col_offset = x2;
    drawing_object->to.row_offset = y2;
    drawing_object->col_absolute = x_abs;
    drawing_object->row_absolute = y_abs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbp
movq %rdx, 0x60(%rsp)
movb 0x1(%rdx), %r12b
movzwl 0x1c(%rsi), %r13d
movl 0x18(%rsi), %ebx
movl (%rsi), %r15d
movl 0x4(%rsi), %r14d
movsd 0x68(%rsi), %xmm0
movsd 0x70(%rsi), %xmm1
movsd %xmm1, 0x50(%rsp)
movsd %xmm0, 0x18(%rsp)
testl %r15d, %r15d
jns 0x2dbf3
testw %r13w, %r13w
je 0x2dbf3
decl %r13d
movzwl %r13w, %esi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x3af5a
addl %eax, %r15d
jmp 0x2dbbd
testl %ebx, %ebx
je 0x2dbf8
decl %ebx
movq %rbp, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x3afe2
addl %eax, %r14d
testl %r14d, %r14d
js 0x2dbde
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
testl %r14d, %r14d
cmovlel %eax, %r14d
cmpb $0x0, 0x11a(%rbp)
movq %rbp, 0x20(%rsp)
je 0x2dc50
movq $0x0, 0x38(%rsp)
movl %ebx, %ebp
xorl %ebx, %ebx
cmpl %ebx, %r13d
je 0x2dc47
movzwl %bx, %esi
movq 0x20(%rsp), %rdi
xorl %edx, %edx
callq 0x3af5a
movq 0x38(%rsp), %rcx
addl %eax, %ecx
movq %rcx, 0x38(%rsp)
incl %ebx
jmp 0x2dc23
movl %ebp, %ebx
movq 0x20(%rsp), %rbp
jmp 0x2dc5f
movl 0x1a4(%rbp), %eax
imull %r13d, %eax
movq %rax, 0x38(%rsp)
cmpb $0x0, 0x11b(%rbp)
movl %r14d, 0x28(%rsp)
je 0x2dca5
movl %ebx, %ebp
movq $0x0, 0x30(%rsp)
xorl %ebx, %ebx
cmpl %ebx, %ebp
je 0x2dc9c
movq 0x20(%rsp), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x3afe2
movq 0x30(%rsp), %rcx
addl %eax, %ecx
movq %rcx, 0x30(%rsp)
incl %ebx
jmp 0x2dc7a
movl %ebp, %ebx
movq 0x20(%rsp), %rbp
jmp 0x2dcb3
movl 0x1a0(%rbp), %eax
imull %ebx, %eax
movq %rax, 0x30(%rsp)
movzbl %r12b, %eax
movl %eax, 0xc(%rsp)
movl %r15d, %r14d
movzwl %r13w, %r12d
movq %rbp, %rdi
movl %r12d, %esi
movl 0xc(%rsp), %edx
callq 0x3af5a
cmpl %eax, %r14d
jl 0x2dcee
movq %rbp, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x3af5a
subl %eax, %r14d
incl %r12d
movl %r12d, %r13d
jmp 0x2dcbe
movl %r13d, %ecx
movl %eax, %r13d
movl %r14d, 0x40(%rsp)
movl %ecx, 0x10(%rsp)
movl %r15d, 0x4c(%rsp)
movl 0x28(%rsp), %r14d
movq %rbp, %rdi
movl %ebx, %esi
movl 0xc(%rsp), %edx
callq 0x3afe2
cmpl %eax, %r14d
jl 0x2dd2d
movq %rbp, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x3afe2
subl %eax, %r14d
incl %ebx
jmp 0x2dd07
movl %eax, %r15d
movl %ebx, 0x2c(%rsp)
cvtsi2sdl 0x40(%rsp), %xmm1
testl %r13d, %r13d
movsd %xmm1, 0x40(%rsp)
jg 0x2dd4d
movsd 0x18(%rsp), %xmm0
jmp 0x2dd57
movsd 0x18(%rsp), %xmm0
addsd %xmm1, %xmm0
movl 0x10(%rsp), %ebx
movsd %xmm0, 0x18(%rsp)
cvtsi2sd %r14d, %xmm2
movsd 0x50(%rsp), %xmm1
movsd %xmm2, 0x58(%rsp)
addsd %xmm2, %xmm1
movsd %xmm1, 0x10(%rsp)
movl 0x4c(%rsp), %r14d
movzwl %bx, %r13d
movq 0x20(%rsp), %rdi
movl %r13d, %esi
movl 0xc(%rsp), %edx
callq 0x3af5a
cvtsi2sd %eax, %xmm0
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x2ddb4
subsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
incl %ebx
jmp 0x2dd81
testl %r15d, %r15d
jg 0x2ddc5
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x2c(%rsp), %ebx
movq 0x20(%rsp), %r15
movq %r15, %rdi
movl %ebx, %esi
movl 0xc(%rsp), %edx
callq 0x3afe2
cvtsi2sd %eax, %xmm0
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x2ddfa
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
incl %ebx
jmp 0x2ddce
movq 0x30(%rsp), %rsi
addl 0x28(%rsp), %esi
movq 0x38(%rsp), %rdx
addl %r14d, %edx
movq 0x60(%rsp), %rax
movl %r12d, 0x8(%rax)
movl 0x2c(%rsp), %ecx
movl %ecx, 0xc(%rax)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x18(%rax)
movl %r13d, 0x20(%rax)
movl %ebx, 0x24(%rax)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x28(%rax)
movsd %xmm1, 0x30(%rax)
movq %rdx, 0x38(%rax)
movq %rsi, 0x40(%rax)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq