// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_arc_comp1(int, block_struct*, setup_struct*, double, double, double, double, double, double, double, double, double, double, double)
int Interp::convert_arc_comp1(int move,  //!< either G_2 (cw arc) or G_3 (ccw arc)            
                              block_pointer block,       //!< pointer to a block of RS274/NGC instructions    
                              setup_pointer settings,    //!< pointer to machine settings                     
                              double end_x,      //!< x-value at end of programmed (then actual) arc  
                              double end_y,      //!< y-value at end of programmed (then actual) arc  
                              double end_z,      //!< z-value at end of arc                           
                              double offset_x, double offset_y, 
                              double AA_end,     //!< a-value at end of arc                     
                              double BB_end,     //!< b-value at end of arc                     
                              double CC_end,     //!< c-value at end of arc                     
                              double u_end, double v_end, double w_end) //!< uvw at end of arc
{
    double center_x, center_y;
    double gamma;                 /* direction of perpendicular to arc at end */
    int side;                     /* offset side - right or left              */
    double tolerance;             /* tolerance for difference of radii        */
    double tool_radius;
    int turn;                     /* 1 for counterclockwise, -1 for clockwise */
    double cx, cy, cz; // current
    int plane = settings->plane;

    side = settings->cutter_comp_side;
    tool_radius = settings->cutter_comp_radius;   /* always is positive */
    tolerance = (settings->length_units == CANON_UNITS_INCHES) ? TOLERANCE_INCH : TOLERANCE_MM;

    comp_get_current(settings, &cx, &cy, &cz);

    CHKS((hypot((end_x - cx), (end_y - cy)) <= tool_radius),
         "Radius of cutter compensation entry arc is not greater than the tool radius");

    if (block->r_flag) {
        CHP(arc_data_comp_r(move, plane, side, tool_radius, cx, cy, end_x, end_y, 
                            block->r_number,
                            &center_x, &center_y, &turn, tolerance));
    } else {
        CHP(arc_data_comp_ijk(move, plane, side, tool_radius, cx, cy, end_x, end_y,
                              (settings->ijk_distance_mode == MODE_ABSOLUTE),
                              offset_x, offset_y,
                              &center_x, &center_y, &turn, tolerance));
    }

    inverse_time_rate_arc(cx, cy, cz, center_x, center_y,
                          turn, end_x, end_y, end_z, block, settings);


    // the tool will end up in gamma direction from the programmed arc endpoint
    if TOOL_INSIDE_ARC(side, turn) {
        // tool inside the arc: ends up toward the center
        gamma = atan2((center_y - end_y), (center_x - end_x));
    } else {
        // outside: away from the center
        gamma = atan2((end_y - center_y), (end_x - center_x));
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movsd %xmm7, -0xb8(%rbp)
movsd %xmm6, -0xb0(%rbp)
movsd %xmm5, -0xa8(%rbp)
movsd %xmm4, -0xd0(%rbp)
movsd %xmm3, -0xc8(%rbp)
movsd %xmm2, -0x90(%rbp)
movsd %xmm1, -0x70(%rbp)
movsd %xmm0, -0x30(%rbp)
movq %rdx, %r13
movl %esi, -0x98(%rbp)
movq %rdi, %r14
movl 0xc67c(%rcx), %eax
movl %eax, -0xa0(%rbp)
movl 0x624(%rcx), %eax
movl %eax, -0x88(%rbp)
movsd 0x618(%rcx), %xmm0
movsd %xmm0, -0x50(%rbp)
xorl %r15d, %r15d
cmpl $0x1, 0x1690(%rcx)
sete -0xc0(%rbp)
leaq -0xe8(%rbp), %rbx
leaq -0xe0(%rbp), %r12
leaq -0xd8(%rbp), %r8
movq %rcx, -0x40(%rbp)
movq %rcx, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0xb6b0
movsd (%rbx), %xmm1
movsd -0x30(%rbp), %xmm0
movsd %xmm1, -0x80(%rbp)
subsd %xmm1, %xmm0
movsd (%r12), %xmm2
movsd -0x70(%rbp), %xmm1
movsd %xmm2, -0x78(%rbp)
subsd %xmm2, %xmm1
callq 0xa290
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jae 0xe30d
movapd %xmm1, %xmm0
movb -0xc0(%rbp), %al
movb %al, %r15b
leaq 0x28cf9(%rip), %rax     # 0x36f20
movsd (%rax,%r15,8), %xmm7
cmpb $0x1, 0x229(%r13)
movq %r13, %rbx
movsd %xmm7, -0xc0(%rbp)
jne 0xe31c
movsd 0x230(%rbx), %xmm5
leaq -0x34(%rbp), %rax
movq %rax, (%rsp)
leaq -0x48(%rbp), %r8
leaq -0x58(%rbp), %r9
movq %r14, %r15
movq %r14, %rdi
movl -0x98(%rbp), %esi
movl -0xa0(%rbp), %edx
movl -0x88(%rbp), %r14d
movl %r14d, %ecx
movsd -0x80(%rbp), %xmm1
movsd -0x78(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movsd -0x70(%rbp), %xmm4
movaps %xmm7, %xmm6
callq 0xa120
testl %eax, %eax
movq -0x40(%rbp), %r12
je 0xe392
movl %eax, %r13d
movq 0x35cb4(%rip), %rbx     # 0x43f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0xe62c
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x29e72(%rip), %rsi     # 0x38149
movl $0x50, %edx
callq 0xa8a0
movslq 0xd670(%rbx), %rax
leaq (%rax,%rax,4), %rcx
shlq $0x4, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%rbx,%rcx)
incl %eax
movl %eax, 0xd670(%rbx)
movb %dl, 0xc720(%rbx,%rcx)
jmp 0xe62c
leaq 0x29de9(%rip), %rsi     # 0x380fd
movq %r14, %rdi
jmp 0xe5e3
xorl %r8d, %r8d
movq -0x40(%rbp), %r12
cmpl $0x0, 0x66c(%r12)
sete %r8b
leaq -0x34(%rbp), %rax
movq %rax, 0x8(%rsp)
leaq -0x58(%rbp), %rax
movq %rax, (%rsp)
leaq -0x48(%rbp), %r9
movq %r14, %r15
movq %r14, %rdi
movl -0x98(%rbp), %esi
movl -0xa0(%rbp), %edx
movl -0x88(%rbp), %r14d
movl %r14d, %ecx
movsd -0x80(%rbp), %xmm1
movsd -0x78(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movsd -0x70(%rbp), %xmm4
movsd -0xc8(%rbp), %xmm5
movsd -0xd0(%rbp), %xmm6
callq 0xb160
testl %eax, %eax
jne 0xe2a2
movsd -0xd8(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movsd -0x58(%rbp), %xmm4
movl -0x34(%rbp), %esi
movq %r15, %rdi
movsd -0x80(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
movsd %xmm2, -0x98(%rbp)
movsd -0x30(%rbp), %xmm5
movsd -0x70(%rbp), %xmm6
movsd -0x90(%rbp), %xmm7
movq %rbx, %rdx
movq %r12, %rcx
callq 0xac30
movl %r14d, %ecx
xorl $0x2, %ecx
movl -0x34(%rbp), %eax
movl %eax, %edx
xorl $0x1, %edx
orl %ecx, %edx
je 0xe3f6
xorl $0x1, %r14d
notl %eax
orl %r14d, %eax
jne 0xe40c
movsd -0x58(%rbp), %xmm0
subsd -0x70(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
subsd -0x30(%rbp), %xmm1
jmp 0xe420
movsd -0x70(%rbp), %xmm0
subsd -0x58(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
subsd -0x48(%rbp), %xmm1
callq 0xa100
movsd %xmm0, -0x40(%rbp)
movb $0x0, 0xc689(%r12)
movq %r15, %rdi
movq %r12, %rsi
movsd -0x30(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
movsd -0x90(%rbp), %xmm2
callq 0xad80
movsd -0x40(%rbp), %xmm0
callq 0xb550
mulsd -0x50(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x40(%rbp), %xmm0
callq 0xa1d0
movapd %xmm0, %xmm1
mulsd -0x50(%rbp), %xmm1
addsd -0x70(%rbp), %xmm1
movsd %xmm1, -0x50(%rbp)
movsd -0x78(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x80(%rbp), %xmm1
subsd -0x30(%rbp), %xmm1
movsd %xmm1, -0xa0(%rbp)
callq 0xa290
movsd %xmm0, -0x70(%rbp)
movsd -0x58(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
subsd -0x30(%rbp), %xmm1
callq 0xa100
movsd %xmm0, -0x40(%rbp)
movsd -0x88(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
callq 0xa100
subsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
callq 0xb550
andpd 0x26b20(%rip), %xmm0    # 0x35020
movsd 0x28358(%rip), %xmm1    # 0x36860
ucomisd %xmm0, %xmm1
jbe 0xe51a
leaq 0x26c5c(%rip), %rdi     # 0x35171
jmp 0xe5d8
movsd -0x70(%rbp), %xmm0
mulsd 0x26ae1(%rip), %xmm0    # 0x35008
movsd %xmm0, -0x70(%rbp)
movsd -0x88(%rbp), %xmm0
callq 0xb550
movsd -0x70(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x70(%rbp)
movsd -0x40(%rbp), %xmm0
callq 0xb550
mulsd -0x70(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x40(%rbp), %xmm0
callq 0xa1d0
movsd -0x70(%rbp), %xmm2
mulsd %xmm0, %xmm2
movsd -0x50(%rbp), %xmm1
addsd %xmm1, %xmm2
movsd %xmm2, -0x58(%rbp)
movsd -0x48(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
subsd %xmm1, %xmm2
movapd %xmm2, %xmm1
callq 0xa290
movapd %xmm0, -0x70(%rbp)
movsd -0x48(%rbp), %xmm0
subsd -0x80(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
subsd -0x78(%rbp), %xmm1
callq 0xa290
movapd -0x70(%rbp), %xmm1
subsd %xmm0, %xmm1
andpd 0x26a59(%rip), %xmm1    # 0x35020
ucomisd -0xc0(%rbp), %xmm1
jbe 0xe641
leaq 0x29c0a(%rip), %rdi     # 0x381e2
callq 0xa1f0
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x3596f(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0x29b40(%rip), %rsi     # 0x38149
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %r13d
movl %r13d, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x620(%r12), %eax
testl %eax, %eax
je 0xe6ca
cmpl $0x9, %eax
je 0xe6ca
movl 0x1d0(%rbx), %esi
movsd 0x20(%rbp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%rbp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rbp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, (%rsp)
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
movq %r12, %rdi
movsd -0x80(%rbp), %xmm3
movsd -0x78(%rbp), %xmm4
movsd -0x98(%rbp), %xmm5
movsd -0xa8(%rbp), %xmm6
movsd -0xb0(%rbp), %xmm7
callq 0xb6e0
movsd -0x80(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
callq 0xa9b0
movl 0x1d0(%rbx), %ebx
movsd -0x48(%rbp), %xmm2
movsd -0x58(%rbp), %xmm3
movl -0x34(%rbp), %esi
movq %r15, %rdi
movsd -0x80(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
movsd -0x30(%rbp), %xmm4
movsd -0x50(%rbp), %xmm5
callq 0xab90
movsd -0x48(%rbp), %xmm3
movsd -0x58(%rbp), %xmm4
movl -0x34(%rbp), %edx
movsd 0x20(%rbp), %xmm1
movsd %xmm1, 0x18(%rsp)
movsd 0x18(%rbp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x10(%rbp), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd -0xb8(%rbp), %xmm1
movsd %xmm1, (%rsp)
movq %r12, %rdi
movl %ebx, %esi
movsd -0x30(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
movsd -0x90(%rbp), %xmm5
movsd -0xa8(%rbp), %xmm6
movsd -0xb0(%rbp), %xmm7
callq 0xa3b0
movq %r15, %rdi
movq %r12, %rsi
movsd -0x30(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
movsd -0x90(%rbp), %xmm2
callq 0xb170
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, 0x8(%r12)
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, 0x20(%r12)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, 0x38(%r12)
movsd 0x10(%rbp), %xmm0
movsd %xmm0, 0x50(%r12)
movsd 0x18(%rbp), %xmm0
movsd %xmm0, 0x68(%r12)
movsd 0x20(%rbp), %xmm0
movsd %xmm0, 0x80(%r12)
xorl %r13d, %r13d
jmp 0xe62c
nop