// File: /workspace/github_c_makefile_star2_O3/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, 0x18(%rsp)
movq %rdx, 0x50(%rsp)
movb 0x1(%rdx), %al
movb %al, 0x30(%rsp)
movzwl 0x1c(%rsi), %ebp
movl 0x18(%rsi), %ebx
movl (%rsi), %eax
movl 0x4(%rsi), %r15d
movsd 0x68(%rsi), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x70(%rsi), %xmm0
testl %eax, %eax
sets %dl
testw %bp, %bp
setne %cl
andb %dl, %cl
cmpb $0x1, %cl
movsd %xmm0, 0x20(%rsp)
jne 0x30dbe
decl %ebp
movl %eax, %r14d
movzwl %bp, %ebp
movq 0x18(%rsp), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x3ddba
addw $-0x1, %bp
setb %cl
addl %r14d, %eax
jns 0x30dbc
testb %cl, %cl
jne 0x30d98
incl %ebp
testl %r15d, %r15d
sets %dl
testl %ebx, %ebx
setne %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x30e3a
movq 0x18(%rsp), %rcx
movq 0x20(%rcx), %rdx
movq (%rdx), %rdi
addq $0x198, %rcx            # imm = 0x198
movsd 0x14505(%rip), %xmm0    # 0x452f0
decl %ebx
movq %rcx, %rdx
testq %rdi, %rdi
je 0x30e14
movq %rdi, %rdx
movl $0x28, %esi
cmpl %ebx, (%rdx)
ja 0x30e08
movl $0x30, %esi
je 0x30e2c
movq (%rdx,%rsi), %rdx
testq %rdx, %rdx
jne 0x30df8
movq %rcx, %rdx
movsd (%rdx), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %rsi
addl %esi, %r15d
jns 0x30e3a
testl %ebx, %ebx
jne 0x30deb
jmp 0x30e3a
xorl %esi, %esi
cmpb $0x0, 0x18(%rdx)
jne 0x30e21
addq $0x8, %rdx
jmp 0x30e14
movzwl %bp, %r9d
xorl %r14d, %r14d
testl %eax, %eax
cmovlel %r14d, %eax
movl %eax, 0x3c(%rsp)
testl %r15d, %r15d
cmovlel %r14d, %r15d
movl %r15d, 0xc(%rsp)
movq 0x18(%rsp), %r12
cmpb $0x0, 0x11a(%r12)
je 0x30e93
testw %bp, %bp
je 0x30e9f
xorl %r15d, %r15d
xorl %r14d, %r14d
movzwl %r15w, %esi
movq %r12, %rdi
xorl %edx, %edx
movl %r9d, %r13d
callq 0x3ddba
movl %r13d, %r9d
addl %eax, %r14d
incl %r15d
cmpl %r15d, %r13d
jne 0x30e72
jmp 0x30e9f
movl 0x1a4(%r12), %r14d
imull %r9d, %r14d
cmpb $0x0, 0x11b(%r12)
movq %r14, 0x48(%rsp)
je 0x30f2e
testl %ebx, %ebx
je 0x30f3c
movq 0x18(%rsp), %rcx
movq 0x20(%rcx), %rax
movq (%rax), %rax
addq $0x198, %rcx            # imm = 0x198
xorl %edx, %edx
movsd 0x1441c(%rip), %xmm0    # 0x452f0
xorl %r8d, %r8d
movl 0xc(%rsp), %r15d
movl 0x3c(%rsp), %r12d
movq %rcx, %rsi
testq %rax, %rax
je 0x30f08
movq %rax, %rsi
movl $0x28, %edi
cmpl %edx, (%rsi)
ja 0x30efc
movl $0x30, %edi
je 0x30f20
movq (%rsi,%rdi), %rsi
testq %rsi, %rsi
jne 0x30eec
movq %rcx, %rsi
movsd (%rsi), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %rdi
addl %edi, %r8d
incl %edx
cmpl %ebx, %edx
jne 0x30ee1
jmp 0x30f49
xorl %edi, %edi
cmpb $0x0, 0x18(%rsi)
jne 0x30f15
addq $0x8, %rsi
jmp 0x30f08
movl 0x1a0(%r12), %r8d
imull %ebx, %r8d
jmp 0x30f3f
xorl %r8d, %r8d
movl 0xc(%rsp), %r15d
movl 0x3c(%rsp), %r12d
movq %r8, 0x40(%rsp)
movzbl 0x30(%rsp), %edx
movq 0x18(%rsp), %r13
movq %r13, %rdi
movl %r9d, %esi
movl %edx, 0x10(%rsp)
callq 0x3ddba
cmpl %eax, %r12d
jge 0x30f76
movb $0x1, 0xb(%rsp)
movl %r12d, %r14d
jmp 0x30fb1
movl %r12d, %r14d
movl 0x10(%rsp), %r15d
movzwl %bp, %ebp
movq %r13, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x3ddba
subl %eax, %r14d
incl %ebp
movzwl %bp, %esi
movq %r13, %rdi
movl %r15d, %edx
callq 0x3ddba
cmpl %eax, %r14d
jge 0x30f7e
testl %eax, %eax
setg 0xb(%rsp)
movl 0xc(%rsp), %r15d
movq %r13, %rdi
movl %ebx, %esi
movl 0x10(%rsp), %edx
callq 0x3de46
cmpl %eax, %r15d
jge 0x3100b
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
cmpb $0x0, 0xb(%rsp)
movsd 0x28(%rsp), %xmm0
je 0x30fe3
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x10(%rsp), %r14d
movsd %xmm1, 0x30(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
movsd 0x20(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
addsd %xmm1, %xmm0
jmp 0x310cf
movq 0x20(%r13), %rax
movq %r13, %rcx
movq (%rax), %r13
leaq 0x198(%rcx), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
testq %r13, %r13
je 0x3104c
movq %r13, %rax
movl $0x28, %ecx
cmpl %ebx, (%rax)
ja 0x3103e
movl $0x30, %ecx
je 0x3107f
movq (%rax,%rcx), %rax
testq %rax, %rax
jne 0x3102e
movq 0x30(%rsp), %rax
movsd (%rax), %xmm0
divsd 0x14298(%rip), %xmm0    # 0x452f0
cvttsd2si %xmm0, %rcx
subl %ecx, %r15d
incl %ebx
movq 0x18(%rsp), %rdi
movl %ebx, %esi
movl 0x10(%rsp), %edx
callq 0x3de46
movsd 0x28(%rsp), %xmm0
cmpl %eax, %r15d
jge 0x31021
jmp 0x3108d
xorl %ecx, %ecx
cmpb $0x0, 0x18(%rax)
jne 0x3105d
addq $0x8, %rax
jmp 0x3104c
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
cmpb $0x0, 0xb(%rsp)
je 0x310a0
addsd %xmm1, %xmm0
movq 0x18(%rsp), %r13
movl 0x10(%rsp), %r14d
movsd %xmm0, 0x28(%rsp)
cvtsi2sd %r15d, %xmm2
testl %eax, %eax
movsd %xmm1, 0x30(%rsp)
movsd %xmm2, 0x10(%rsp)
jle 0x310d5
movsd 0x20(%rsp), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, 0x20(%rsp)
movzwl %bp, %esi
movq %r13, %rdi
movl %esi, 0x18(%rsp)
movl %r14d, %edx
callq 0x3ddba
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x31123
subsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
incl %ebp
movzwl %bp, %esi
movq %r13, %rdi
movl %r14d, %edx
callq 0x3ddba
movsd 0x28(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
jmp 0x310f4
movsd %xmm1, 0x28(%rsp)
movq %r13, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x3de46
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0x31154
movl %ebx, %r14d
movsd 0x20(%rsp), %xmm1
jmp 0x3118e
movl %r14d, %r15d
movl %ebx, %r14d
movsd 0x20(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
incl %r14d
movq %r13, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x3de46
movsd 0x20(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
ucomisd %xmm0, %xmm1
jae 0x31160
movq 0x40(%rsp), %rsi
addl 0xc(%rsp), %esi
movq 0x48(%rsp), %rdx
addl %r12d, %edx
movq 0x50(%rsp), %rcx
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rcx)
movl %ebx, 0xc(%rcx)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x10(%rcx)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rcx)
movzwl %bp, %eax
movl %eax, 0x20(%rcx)
movl %r14d, 0x24(%rcx)
movsd 0x28(%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