// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %rdi, %r13
movq %rdx, 0x50(%rsp)
movb 0x1(%rdx), %al
movb %al, 0x40(%rsp)
movzwl 0x1c(%rsi), %ebp
movl 0x18(%rsi), %ebx
movl (%rsi), %r12d
movl 0x4(%rsi), %r15d
movsd 0x68(%rsi), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x70(%rsi), %xmm0
movsd %xmm0, 0x28(%rsp)
testl %r12d, %r12d
sets %al
testw %bp, %bp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x30c5f
decl %ebp
movl %r12d, %r14d
movzwl %bp, %ebp
movq %r13, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x3dbcb
movl %eax, %r12d
addw $-0x1, %bp
setb %al
addl %r14d, %r12d
jns 0x30c5d
testb %al, %al
jne 0x30c38
incl %ebp
testl %r15d, %r15d
sets %al
testl %ebx, %ebx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x30c96
decl %ebx
movl %r15d, %r14d
movq %r13, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x3dc5b
movl %eax, %r15d
addl $-0x1, %ebx
setb %al
addl %r14d, %r15d
jns 0x30c94
testb %al, %al
jne 0x30c73
incl %ebx
movzwl %bp, %eax
xorl %ecx, %ecx
testl %r12d, %r12d
cmovlel %ecx, %r12d
testl %r15d, %r15d
cmovlel %ecx, %r15d
cmpb $0x0, 0x11a(%r13)
movq %r13, 0x10(%rsp)
movl %eax, 0x18(%rsp)
je 0x30ced
testw %bp, %bp
je 0x30cf7
xorl %r14d, %r14d
xorl %ecx, %ecx
movzwl %r14w, %esi
movq %r13, %rdi
movq %rcx, %r13
xorl %edx, %edx
callq 0x3dbcb
movq %r13, %rcx
movq 0x10(%rsp), %r13
addl %eax, %ecx
incl %r14d
cmpl %r14d, 0x18(%rsp)
jne 0x30cc6
jmp 0x30cf7
movl 0x1a4(%r13), %ecx
imull %eax, %ecx
cmpb $0x0, 0x11b(%r13)
movq %rcx, 0x48(%rsp)
movl %r15d, 0x34(%rsp)
je 0x30d34
testl %ebx, %ebx
je 0x30d44
xorl %r14d, %r14d
xorl %r13d, %r13d
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x3dc5b
addl %eax, %r13d
incl %r14d
cmpl %r14d, %ebx
jne 0x30d1a
jmp 0x30d4c
movq %r13, %r15
movl 0x1a0(%r13), %r13d
imull %ebx, %r13d
jmp 0x30d4c
xorl %r13d, %r13d
movq 0x10(%rsp), %r15
movzbl 0x40(%rsp), %edx
movq %r15, %rdi
movl 0x18(%rsp), %esi
movl %edx, 0x18(%rsp)
callq 0x3dbcb
movb $0x1, %r15b
movl %r12d, %r14d
cmpl %eax, %r12d
jge 0x30d73
movb $0x1, 0xf(%rsp)
jmp 0x30daa
movq 0x10(%rsp), %r15
movzwl %bp, %ebp
movq %r15, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x3dbcb
subl %eax, %r14d
incl %ebp
movzwl %bp, %esi
movq %r15, %rdi
movl 0x18(%rsp), %edx
callq 0x3dbcb
cmpl %eax, %r14d
jge 0x30d78
testl %eax, %eax
setg 0xf(%rsp)
movb $0x1, %r15b
movq %r13, 0x40(%rsp)
movq 0x10(%rsp), %rdi
movl %ebx, %esi
movl 0x18(%rsp), %edx
callq 0x3dc5b
movl 0x34(%rsp), %r13d
cmpl %eax, %r13d
jl 0x30e06
movl %r12d, 0x38(%rsp)
movq 0x10(%rsp), %r12
movl 0x18(%rsp), %r15d
movq %r12, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x3dc5b
subl %eax, %r13d
incl %ebx
movq %r12, %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0x3dc5b
cmpl %eax, %r13d
jge 0x30dd8
testl %eax, %eax
setg %r15b
movl 0x38(%rsp), %r12d
cvtsi2sd %r14d, %xmm2
cmpb $0x0, 0xf(%rsp)
movsd 0x28(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
je 0x30e22
addsd %xmm2, %xmm1
movl 0x18(%rsp), %r14d
cvtsi2sd %r13d, %xmm3
testb %r15b, %r15b
movsd %xmm1, 0x20(%rsp)
movsd %xmm2, 0x38(%rsp)
movsd %xmm3, 0x18(%rsp)
je 0x30e4d
addsd %xmm3, %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x10(%rsp), %r13
movzwl %bp, %esi
movq %r13, %rdi
movl %esi, 0x10(%rsp)
movl %r14d, %edx
callq 0x3dbcb
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x30ea0
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
incl %ebp
movzwl %bp, %esi
movq %r13, %rdi
movl %r14d, %edx
callq 0x3dbcb
movsd 0x20(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
jmp 0x30e71
movsd %xmm1, 0x20(%rsp)
movq %r13, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x3dc5b
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0x30ecb
movl %ebx, %r14d
jmp 0x30eff
movl %r14d, %r15d
movl %ebx, %r14d
subsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
incl %r14d
movq %r13, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x3dc5b
movsd 0x28(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
ucomisd %xmm0, %xmm1
jae 0x30ed1
movq 0x40(%rsp), %rsi
addl 0x34(%rsp), %esi
movq 0x48(%rsp), %rdx
addl %r12d, %edx
movq 0x50(%rsp), %rcx
movl 0x10(%rsp), %eax
movl %eax, 0x8(%rcx)
movl %ebx, 0xc(%rcx)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x10(%rcx)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rcx)
movzwl %bp, %eax
movl %eax, 0x20(%rcx)
movl %r14d, 0x24(%rcx)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rcx)
movsd %xmm1, 0x30(%rcx)
movq %rdx, 0x38(%rcx)
movq %rsi, 0x40(%rcx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq