// File: /workspace/github_cpp_makefile_star2_O3/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 0x16726
cmpb $0x0, 0x280(%r12)
jne 0x16726
cmpb $0x0, 0x290(%r12)
jne 0x16726
cmpb $0x0, (%r12)
jne 0x16726
cmpb $0x0, 0x10(%r12)
jne 0x16726
cmpb $0x0, 0x20(%r12)
jne 0x16726
cmpb $0x0, 0x244(%r12)
jne 0x16726
cmpb $0x0, 0x250(%r12)
jne 0x16726
cmpb $0x0, 0x260(%r12)
jne 0x16726
cmpl $0x0, 0x2a0(%r12)
jne 0x16726
cmpl $0x0, 0x2b0(%r12)
je 0x16997
cmpl $0x0, 0x624(%r14)
je 0x16739
leaq 0x1f880(%rip), %rdi     # 0x35fb7
jmp 0x16755
movsd 0x678(%r14), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x167b1
jp 0x167b1
leaq 0x1f88a(%rip), %rdi     # 0x35fdf
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x2a7f2(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0x1e2a0(%rip), %rsi     # 0x34a1c
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %r13d
movl %r13d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, 0x670(%r14)
jne 0x167c7
leaq 0x1f83e(%rip), %rsi     # 0x36000
movq %rbx, %rdi
jmp 0x16760
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 0xaa70
addq $0x30, %rsp
testl %eax, %eax
je 0x16875
movl %eax, %r13d
movq 0x2a74c(%rip), %rbx     # 0x40f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x1679f
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x1e1dd(%rip), %rsi     # 0x34a1c
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 0x1679f
testb $0x1, %r15b
jne 0x16926
movsd 0x600(%r14), %xmm0
ucomisd -0x70(%rbp), %xmm0
jne 0x16926
jp 0x16926
movsd 0x608(%r14), %xmm0
ucomisd -0x68(%rbp), %xmm0
jne 0x16926
jp 0x16926
movsd 0x610(%r14), %xmm0
ucomisd -0x60(%rbp), %xmm0
jne 0x16926
jp 0x16926
movsd 0x8(%r14), %xmm0
ucomisd -0x58(%rbp), %xmm0
jne 0x16926
jp 0x16926
movsd 0x20(%r14), %xmm0
ucomisd -0x50(%rbp), %xmm0
jne 0x16926
jp 0x16926
movsd 0x38(%r14), %xmm0
ucomisd -0x48(%rbp), %xmm0
jne 0x16926
jp 0x16926
movsd 0x50(%r14), %xmm0
ucomisd -0x40(%rbp), %xmm0
jne 0x16926
jp 0x16926
movsd 0x68(%r14), %xmm0
ucomisd -0x38(%rbp), %xmm0
jne 0x16926
jp 0x16926
movsd 0x80(%r14), %xmm0
ucomisd -0x30(%rbp), %xmm0
jne 0x16926
jp 0x16926
leaq 0x1f703(%rip), %rdi     # 0x36024
jmp 0x16755
leal -0x7e(%r15), %ebx
callq 0xab40
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 0xa2a0
addq $0x10, %rsp
callq 0xa050
movl %r15d, 0x1798(%r14)
movb $0x1, 0xc680(%r14)
xorl %r13d, %r13d
jmp 0x1679f
leaq 0x1f5de(%rip), %rdi     # 0x35f7c
jmp 0x16755
nop