// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_probe(block_struct*, int, setup_struct*)
int Interp::convert_probe(block_pointer block,   //!< pointer to a block of RS274 instructions
                          int g_code,
                          setup_pointer settings)        //!< pointer to machine settings             
{
  double end_x;
  double end_y;
  double end_z;
  double AA_end;
  double BB_end;
  double CC_end;
  double u_end;
  double v_end;
  double w_end;

  /* probe_type: 
     ~1 = error if probe operation is unsuccessful (ngc default)
     |1 = suppress error, report in # instead
     ~2 = move until probe trips (ngc default)
     |2 = move until probe clears */

  unsigned char probe_type = g_code - G_38_2;
  

  CHKS((block->x_flag == OFF && block->y_flag == OFF &&
       block->z_flag == OFF && block->a_flag == OFF &&
       block->b_flag == OFF && block->c_flag == OFF &&
       block->u_flag == OFF && block->v_flag == OFF &&
       block->w_flag == OFF && block->radius_flag == OFF &&
       block->theta_flag == OFF),
       NCE_X_Y_Z_A_B_C_U_V_AND_W_WORDS_ALL_MISSING_WITH_G38_2);
  CHKS((settings->cutter_comp_side != OFF),
      NCE_CANNOT_PROBE_WITH_CUTTER_RADIUS_COMP_ON);
  CHKS((settings->feed_rate == 0.0), NCE_CANNOT_PROBE_WITH_ZERO_FEED_RATE);
  CHKS(settings->feed_mode == UNITS_PER_REVOLUTION,
	  "Cannot probe with feed per rev mode");
  CHKS((settings->feed_rate == 0.0), NCE_CANNOT_PROBE_WITH_ZERO_FEED_RATE);
  CHP(find_ends(block, settings, &end_x, &end_y, &end_z,
                &AA_end, &BB_end, &CC_end,
                &u_end, &v_end, &w_end));
  CHKS(((!(probe_type & 1)) && 
        settings->current_x == end_x && settings->current_y == end_y &&
        settings->current_z == end_z && settings->AA_current == AA_end &&
        settings->BB_current == BB_end && settings->CC_current == CC_end &&
        settings->u_current == u_end && settings->v_current == v_end &&
        settings->w_current == w_end),
       NCE_START_POINT_TOO_CLOSE_TO_PROBE_POINT);
       
  TURN_PROBE_ON();
  STRAIGHT_PROBE(block->line_number, end_x, end_y, end_z,
                 AA_end, BB_end, CC_end,
                 u_end, v_end, w_end, probe_type);

  TURN_PROBE_OFF();
  settings->motion_mode = g_code;
  settings->probe_flag = ON;
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r14
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %rbx
cmpb $0x0, 0x270(%rsi)
jne 0x16e54
cmpb $0x0, 0x280(%r12)
jne 0x16e54
cmpb $0x0, 0x290(%r12)
jne 0x16e54
cmpb $0x0, (%r12)
jne 0x16e54
cmpb $0x0, 0x10(%r12)
jne 0x16e54
cmpb $0x0, 0x20(%r12)
jne 0x16e54
cmpb $0x0, 0x244(%r12)
jne 0x16e54
cmpb $0x0, 0x250(%r12)
jne 0x16e54
cmpb $0x0, 0x260(%r12)
jne 0x16e54
cmpl $0x0, 0x2a0(%r12)
jne 0x16e54
cmpl $0x0, 0x2b0(%r12)
je 0x170b4
cmpl $0x0, 0x624(%r14)
je 0x16e67
leaq 0x1b15c(%rip), %rdi     # 0x31fc1
jmp 0x16e83
movsd 0x678(%r14), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x16eda
jp 0x16eda
leaq 0x1b166(%rip), %rdi     # 0x31fe9
callq 0xb220
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
movq 0x260c4(%rip), %rbx     # 0x3cf60
leaq 0xc6d0(%rbx), %rdi
leaq 0x19b72(%rip), %rsi     # 0x30a1c
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
pushq $0x5
popq %r13
movl %r13d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, 0x670(%r14)
jne 0x16ef0
leaq 0x1b11f(%rip), %rsi     # 0x3200a
movq %rbx, %rdi
jmp 0x16e8e
leaq -0x30(%rbp), %rax
leaq -0x38(%rbp), %r10
leaq -0x40(%rbp), %r11
leaq -0x48(%rbp), %r13
leaq -0x70(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq -0x60(%rbp), %r9
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
pushq %rax
pushq %r10
pushq %r11
pushq %r13
leaq -0x50(%rbp), %rax
pushq %rax
leaq -0x58(%rbp), %rax
pushq %rax
callq 0xbb30
addq $0x30, %rsp
testl %eax, %eax
je 0x16f94
movl %eax, %r13d
movq 0x26023(%rip), %rbx     # 0x3cf60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x16ec8
imulq $0x50, %rax, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x19ab8(%rip), %rsi     # 0x30a1c
pushq $0x50
popq %rdx
callq 0xb940
movslq 0xd670(%rbx), %rax
imulq $0x50, %rax, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%rbx,%rcx)
incl %eax
movl %eax, 0xd670(%rbx)
movb %dl, 0xc720(%rbx,%rcx)
jmp 0x16ec8
testb $0x1, %r15b
jne 0x17045
movsd 0x600(%r14), %xmm0
ucomisd -0x70(%rbp), %xmm0
jne 0x17045
jp 0x17045
movsd 0x608(%r14), %xmm0
ucomisd -0x68(%rbp), %xmm0
jne 0x17045
jp 0x17045
movsd 0x610(%r14), %xmm0
ucomisd -0x60(%rbp), %xmm0
jne 0x17045
jp 0x17045
movsd 0x8(%r14), %xmm0
ucomisd -0x58(%rbp), %xmm0
jne 0x17045
jp 0x17045
movsd 0x20(%r14), %xmm0
ucomisd -0x50(%rbp), %xmm0
jne 0x17045
jp 0x17045
movsd 0x38(%r14), %xmm0
ucomisd -0x48(%rbp), %xmm0
jne 0x17045
jp 0x17045
movsd 0x50(%r14), %xmm0
ucomisd -0x40(%rbp), %xmm0
jne 0x17045
jp 0x17045
movsd 0x68(%r14), %xmm0
ucomisd -0x38(%rbp), %xmm0
jne 0x17045
jp 0x17045
movsd 0x80(%r14), %xmm0
ucomisd -0x30(%rbp), %xmm0
jne 0x17045
jp 0x17045
leaq 0x1afee(%rip), %rdi     # 0x3202e
jmp 0x16e83
leal -0x7e(%r15), %ebx
callq 0xbc30
movl 0x1d0(%r12), %edi
movsd -0x70(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
movsd -0x58(%rbp), %xmm3
movsd -0x50(%rbp), %xmm4
movsd -0x48(%rbp), %xmm5
movsd -0x40(%rbp), %xmm6
movsd -0x38(%rbp), %xmm7
movsd -0x30(%rbp), %xmm8
subq $0x10, %rsp
movsd %xmm8, (%rsp)
movzbl %bl, %esi
callq 0xb2d0
popq %rax
popq %rcx
callq 0xb050
movl %r15d, 0x1798(%r14)
movb $0x1, 0xc680(%r14)
xorl %r13d, %r13d
jmp 0x16ec8
leaq 0x1aecb(%rip), %rdi     # 0x31f86
jmp 0x16e83