// File: sundale[P]gcode/rs274ngc/interp_queue.cc
// Function: Interp::move_endpoint_and_flush(setup_struct*, double, double)
int Interp::move_endpoint_and_flush(setup_pointer settings, double x, double y) {
    double x1;
    double y1;
    double x2;
    double y2;
    double dot;

    if(qc().empty()) return 0;
    
    for(unsigned int i = 0; i<qc().size(); i++) {
        // there may be several moves in the queue, and we need to
        // change all of them.  consider moving into a concave corner,
        // then up and back down, then continuing on.  there will be
        // three moves to change.

        queued_canon &q = qc()[i];

        switch(q.type) {
        case QARC_FEED:
            double r1, r2, l1, l2;
            r1 = hypot(q.data.arc_feed.end1 - q.data.arc_feed.center1,
                       q.data.arc_feed.end2 - q.data.arc_feed.center2);
            l1 = q.data.arc_feed.original_turns;
            q.data.arc_feed.end1 = x;
            q.data.arc_feed.end2 = y;
            r2 = hypot(x - q.data.arc_feed.center1,
                       y - q.data.arc_feed.center2);
            l2 = find_turn(endpoint[0], endpoint[1],
                           q.data.arc_feed.center1, q.data.arc_feed.center2,
                           q.data.arc_feed.turn,
                           x, y);
            if(debug_qc) printf("moving endpoint of arc lineno %d old sweep %f new speed %f\n", q.data.arc_feed.line_number, l1, l2);

            if(fabs(r1-r2) > .01) 
                ERS(_("BUG: cutter compensation has generated an invalid arc with mismatched radii r1 %f r2 %f\n"), r1, r2);
            if(l1 && endpoint_valid && fabs(l2) > fabs(l1) + (settings->length_units == CANON_UNITS_MM? .0254 : .001)) {
                ERS(_("Arc move in concave corner cannot be reached by the tool without gouging"));
            }
            q.data.arc_feed.end1 = x;
            q.data.arc_feed.end2 = y;
            break;
        case QSTRAIGHT_TRAVERSE:
            switch(settings->plane) {
            case CANON_PLANE_XY:
                x1 = q.data.straight_traverse.dx; // direction of original motion
                y1 = q.data.straight_traverse.dy;                
                x2 = x - endpoint[0];         // new direction after clipping
                y2 = y - endpoint[1];
                break;
            case CANON_PLANE_XZ:
                x1 = q.data.straight_traverse.dz; // direction of original motion
                y1 = q.data.straight_traverse.dx;                
                x2 = x - endpoint[0];         // new direction after clipping
                y2 = y - endpoint[1];
                break;
            default:
                ERS(_("BUG: Unsupported plane in cutter compensation"));
            }
            
            dot = x1 * x2 + y1 * y2; // not normalized; we only care about the angle
            if(debug_qc) printf("moving endpoint of traverse old dir %f new dir %f dot %f endpoint_valid %d\n", atan2(y1,x1), atan2(y2,x2), dot, endpoint_valid);

            if(endpoint_valid && dot<0) {
                // oops, the move is the wrong way.  this means the
                // path has crossed because we backed up further
                // than the line is long.  this will gouge.
                ERS(_("Straight traverse in concave corner cannot be reached by the tool without gouging"));
            }
            switch(settings->plane) {
            case CANON_PLANE_XY:
                q.data.straight_traverse.x = x;
                q.data.straight_traverse.y = y;
                break;
            case CANON_PLANE_XZ:
                q.data.straight_traverse.z = x;
                q.data.straight_traverse.x = y;
                break;
            }
            break;
        case QSTRAIGHT_FEED: 
            switch(settings->plane) {
            case CANON_PLANE_XY:
                x1 = q.data.straight_feed.dx; // direction of original motion
                y1 = q.data.straight_feed.dy;                
                x2 = x - endpoint[0];         // new direction after clipping
                y2 = y - endpoint[1];
                break;
            case CANON_PLANE_XZ:
                x1 = q.data.straight_feed.dz; // direction of original motion
                y1 = q.data.straight_feed.dx;                
                x2 = x - endpoint[0];         // new direction after clipping
                y2 = y - endpoint[1];
                break;
            default:
                ERS(_("BUG: Unsupported plane [%d] in cutter compensation"),
			settings->plane);
            }

            dot = x1 * x2 + y1 * y2;
            if(debug_qc) printf("moving endpoint of feed old dir %f new dir %f dot %f endpoint_valid %d\n", atan2(y1,x1), atan2(y2,x2), dot, endpoint_valid);

            if(endpoint_valid && dot<0) {
                // oops, the move is the wrong way.  this means the
                // path has crossed because we backed up further
                // than the line is long.  this will gouge.
                ERS(_("Straight feed in concave corner cannot be reached by the tool without gouging"));
            }
            switch(settings->plane) {
            case CANON_PLANE_XY:
                q.data.straight_feed.x = x;
                q.data.straight_feed.y = y;
                break;
            case CANON_PLANE_XZ:
                q.data.straight_feed.z = x;
                q.data.straight_feed.x = y;
                break;
            }
            break;
        default:
            // other things are not moves - we don't have to mess with them.
            ;
        }
    }
    dequeue_canons(settings);
    set_endpoint(x, y);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
callq 0x103d0
movq %rax, %rdi
callq 0x11220
testb $0x1, %al
jne 0x35b3b
jmp 0x35b47
movl $0x0, -0x4(%rbp)
jmp 0x36647
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq %rax, -0x90(%rbp)
callq 0x103d0
movq %rax, %rdi
callq 0x12150
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
jae 0x36628
callq 0x103d0
movq %rax, %rdi
movl -0x54(%rbp), %eax
movl %eax, %esi
callq 0x122b0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x94(%rbp)
testl %eax, %eax
je 0x35f69
jmp 0x35ba4
movl -0x94(%rbp), %eax
subl $0x1, %eax
je 0x362bc
jmp 0x35bb5
movl -0x94(%rbp), %eax
subl $0x2, %eax
jne 0x36616
jmp 0x35bc6
movq -0x60(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x60(%rbp), %rax
subsd 0x28(%rax), %xmm0
movq -0x60(%rbp), %rax
movsd 0x20(%rax), %xmm1
movq -0x60(%rbp), %rax
subsd 0x30(%rax), %xmm1
callq 0x10460
movsd %xmm0, -0x68(%rbp)
movq -0x60(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x20(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movsd -0x20(%rbp), %xmm0
movq -0x60(%rbp), %rax
subsd 0x28(%rax), %xmm0
movsd -0x28(%rbp), %xmm1
movq -0x60(%rbp), %rax
subsd 0x30(%rax), %xmm1
callq 0x10460
movq -0x88(%rbp), %rdi
movsd %xmm0, -0x70(%rbp)
movsd 0x70dcd(%rip), %xmm0    # 0xa6a20
movsd 0x70dcd(%rip), %xmm1    # 0xa6a28
movq -0x60(%rbp), %rax
movsd 0x28(%rax), %xmm2
movq -0x60(%rbp), %rax
movsd 0x30(%rax), %xmm3
movq -0x60(%rbp), %rax
movl 0x38(%rax), %esi
movsd -0x20(%rbp), %xmm4
movsd -0x28(%rbp), %xmm5
callq 0x112d0
movsd %xmm0, -0x80(%rbp)
cmpl $0x0, 0x70d81(%rip)     # 0xa6a10
je 0x35cb0
movq -0x60(%rbp), %rax
movl 0x8(%rax), %esi
movsd -0x78(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
leaq 0x45e1b(%rip), %rdi     # 0x7bac4
movb $0x2, %al
callq 0x10060
movsd -0x68(%rbp), %xmm0
subsd -0x70(%rbp), %xmm0
movaps 0x4135f(%rip), %xmm1    # 0x77020
pand %xmm1, %xmm0
movsd 0x4586b(%rip), %xmm1    # 0x7b538
ucomisd %xmm1, %xmm0
jbe 0x35db9
jmp 0x35cd9
leaq 0x45e20(%rip), %rdi     # 0x7bb00
callq 0x10380
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movsd -0x68(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
movb $0x2, %al
callq 0x10df0
movq 0x51259(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x51248(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x5123a(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x45e1e(%rip), %rsi     # 0x7bb59
movl $0x50, %edx
callq 0x10840
movq 0x51214(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x51206(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x511ee(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x511de(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x511d1(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x511c3(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x36647
movsd -0x78(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x35dce
jp 0x35dce
jmp 0x35f48
cmpl $0x0, 0x70c3f(%rip)     # 0xa6a14
je 0x35f48
movsd -0x80(%rbp), %xmm0
movaps 0x41239(%rip), %xmm1    # 0x77020
pand %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x78(%rbp), %xmm0
movaps 0x41221(%rip), %xmm1    # 0x77020
pand %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movl 0x1690(%rax), %eax
movsd 0x45723(%rip), %xmm0    # 0x7b540
movsd 0x45723(%rip), %xmm1    # 0x7b548
movsd %xmm1, -0xa8(%rbp)
cmpl $0x2, %eax
movsd %xmm0, -0xa0(%rbp)
je 0x35e4a
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm1
movsd -0xa0(%rbp), %xmm2
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x35f48
jmp 0x35e72
leaq 0x43ab2(%rip), %rdi     # 0x7992b
callq 0x10380
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x510ca(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x510b9(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x510ab(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x45c8f(%rip), %rsi     # 0x7bb59
movl $0x50, %edx
callq 0x10840
movq 0x51085(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x51077(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x5105f(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x5104f(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x51042(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x51034(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x36647
movsd -0x20(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x20(%rax)
jmp 0x36618
movq -0x18(%rbp), %rax
movl 0xc67c(%rax), %eax
movl %eax, -0xbc(%rbp)
subl $0x1, %eax
je 0x35f90
jmp 0x35f80
movl -0xbc(%rbp), %eax
subl $0x3, %eax
je 0x35fd5
jmp 0x3601a
movq -0x60(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x60(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x20(%rbp), %xmm0
subsd 0x70a67(%rip), %xmm0    # 0xa6a20
movsd %xmm0, -0x40(%rbp)
movsd -0x28(%rbp), %xmm0
subsd 0x70a5d(%rip), %xmm0    # 0xa6a28
movsd %xmm0, -0x48(%rbp)
jmp 0x360f2
movq -0x60(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x60(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x20(%rbp), %xmm0
subsd 0x70a22(%rip), %xmm0    # 0xa6a20
movsd %xmm0, -0x40(%rbp)
movsd -0x28(%rbp), %xmm0
subsd 0x70a18(%rip), %xmm0    # 0xa6a28
movsd %xmm0, -0x48(%rbp)
jmp 0x360f2
jmp 0x3601c
leaq 0x45b79(%rip), %rdi     # 0x7bb9c
callq 0x10380
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x50f20(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x50f0f(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x50f01(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x45ae5(%rip), %rsi     # 0x7bb59
movl $0x50, %edx
callq 0x10840
movq 0x50edb(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x50ecd(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x50eb5(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x50ea5(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x50e98(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x50e8a(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x36647
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm2
movsd -0x38(%rbp), %xmm1
mulsd -0x48(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
cmpl $0x0, 0x708f6(%rip)     # 0xa6a10
je 0x36166
movsd -0x38(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x101d0
movsd %xmm0, -0xc8(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x101d0
movaps %xmm0, %xmm1
movsd -0xc8(%rbp), %xmm0
movsd -0x50(%rbp), %xmm2
movl 0x708bc(%rip), %esi     # 0xa6a14
leaq 0x45a6b(%rip), %rdi     # 0x7bbca
movb $0x3, %al
callq 0x10060
cmpl $0x0, 0x708a7(%rip)     # 0xa6a14
je 0x36259
xorps %xmm0, %xmm0
ucomisd -0x50(%rbp), %xmm0
jbe 0x36259
jmp 0x36183
leaq 0x45a8c(%rip), %rdi     # 0x7bc16
callq 0x10380
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x50db9(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x50da8(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x50d9a(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x4597e(%rip), %rsi     # 0x7bb59
movl $0x50, %edx
callq 0x10840
movq 0x50d74(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x50d66(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x50d4e(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x50d3e(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x50d31(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x50d23(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x36647
movq -0x18(%rbp), %rax
movl 0xc67c(%rax), %eax
movl %eax, -0xcc(%rbp)
subl $0x1, %eax
je 0x3627d
jmp 0x36270
movl -0xcc(%rbp), %eax
subl $0x3, %eax
je 0x3629b
jmp 0x362b7
movsd -0x20(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x30(%rax)
jmp 0x362b7
movsd -0x20(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x28(%rax)
jmp 0x36618
movq -0x18(%rbp), %rax
movl 0xc67c(%rax), %eax
movl %eax, -0xd0(%rbp)
subl $0x1, %eax
je 0x362e3
jmp 0x362d3
movl -0xd0(%rbp), %eax
subl $0x3, %eax
je 0x36328
jmp 0x3636d
movq -0x60(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x60(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x20(%rbp), %xmm0
subsd 0x70714(%rip), %xmm0    # 0xa6a20
movsd %xmm0, -0x40(%rbp)
movsd -0x28(%rbp), %xmm0
subsd 0x7070a(%rip), %xmm0    # 0xa6a28
movsd %xmm0, -0x48(%rbp)
jmp 0x3644f
movq -0x60(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x60(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x20(%rbp), %xmm0
subsd 0x706cf(%rip), %xmm0    # 0xa6a20
movsd %xmm0, -0x40(%rbp)
movsd -0x28(%rbp), %xmm0
subsd 0x706c5(%rip), %xmm0    # 0xa6a28
movsd %xmm0, -0x48(%rbp)
jmp 0x3644f
jmp 0x3636f
leaq 0x458f2(%rip), %rdi     # 0x7bc68
callq 0x10380
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movq -0x18(%rbp), %rax
movl 0xc67c(%rax), %edx
movb $0x0, %al
callq 0x10df0
movq 0x50bc3(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x50bb2(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x50ba4(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x45788(%rip), %rsi     # 0x7bb59
movl $0x50, %edx
callq 0x10840
movq 0x50b7e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x50b70(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x50b58(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x50b48(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x50b3b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x50b2d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x36647
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm2
movsd -0x38(%rbp), %xmm1
mulsd -0x48(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
cmpl $0x0, 0x70599(%rip)     # 0xa6a10
je 0x364c3
movsd -0x38(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x101d0
movsd %xmm0, -0xd8(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x101d0
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
movsd -0x50(%rbp), %xmm2
movl 0x7055f(%rip), %esi     # 0xa6a14
leaq 0x457df(%rip), %rdi     # 0x7bc9b
movb $0x3, %al
callq 0x10060
cmpl $0x0, 0x7054a(%rip)     # 0xa6a14
je 0x365b6
xorps %xmm0, %xmm0
ucomisd -0x50(%rbp), %xmm0
jbe 0x365b6
jmp 0x364e0
leaq 0x457fc(%rip), %rdi     # 0x7bce3
callq 0x10380
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x50a5c(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x50a4b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x50a3d(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x45621(%rip), %rsi     # 0x7bb59
movl $0x50, %edx
callq 0x10840
movq 0x50a17(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x50a09(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x509f1(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x509e1(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x509d4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x509c6(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x36647
movq -0x18(%rbp), %rax
movl 0xc67c(%rax), %eax
movl %eax, -0xdc(%rbp)
subl $0x1, %eax
je 0x365da
jmp 0x365cd
movl -0xdc(%rbp), %eax
subl $0x3, %eax
je 0x365f8
jmp 0x36614
movsd -0x20(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x30(%rax)
jmp 0x36614
movsd -0x20(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x28(%rax)
jmp 0x36618
jmp 0x36618
jmp 0x3661a
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x35b4e
movq -0x18(%rbp), %rdi
callq 0x10500
movsd -0x20(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
callq 0x11060
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)