// File: sundale[P]gcode/rs274ngc/interp_execute.cc
// Function: Interp::execute_block(block_struct*, setup_struct*)
int Interp::execute_block(block_pointer block,   //!< pointer to a block of RS274/NGC instructions
                         setup_pointer settings)        //!< pointer to machine settings                 
{
  int status;

  block->line_number = settings->sequence_number;

  if (block->comment[0] != 0) {
    CHP(convert_comment(block->comment));
  }
  if (block->g_modes[14] != -1) {
    CHP(convert_spindle_mode(block, settings));
  }
  if (block->g_modes[5] != -1) {
    CHP(convert_feed_mode(block->g_modes[5], settings));
  }
  if (block->f_number > -1.0) {
    if (settings->feed_mode != INVERSE_TIME) {
      CHP(convert_feed_rate(block, settings));
    }
    /* INVERSE_TIME is handled elsewhere */
  }
  if (block->s_number > -1.0) {
    CHP(convert_speed(block, settings));
  }
  if (block->t_number != -1) {
    CHP(convert_tool_select(block, settings));
  }
  CHP(convert_m(block, settings));
  CHP(convert_g(block, settings));
  if (block->m_modes[4] != -1) {        /* converts m0, m1, m2, m30, or m60 */
    status = convert_stop(block, settings);
    if (status == INTERP_EXIT)
      return INTERP_EXIT;
    else if (status != INTERP_OK)
      ERP(status);
  }
  if (settings->probe_flag == ON)
    return INTERP_EXECUTE_FINISH;

  if (settings->input_flag == ON)
    return INTERP_EXECUTE_FINISH;

  if (settings->toolchange_flag == ON)
    return INTERP_EXECUTE_FINISH;

  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movl 0xc6b4(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x1d0(%rax)
movq -0x18(%rbp), %rax
movsbl 0x30(%rax), %eax
cmpl $0x0, %eax
je 0x55b42
jmp 0x55a63
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x30, %rsi
callq 0x11fc0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x55b3e
jmp 0x55a83
movq 0x314d6(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x55b33
movq 0x314c2(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x314b4(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x26ed8(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x3148e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x31480(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x31468(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x31458(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x3144b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x3143d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x55b40
jmp 0x55b42
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x188(%rax)
je 0x55c34
jmp 0x55b55
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x116e0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x55c30
jmp 0x55b75
movq 0x313e4(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x55c25
movq 0x313d0(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x313c2(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x26de6(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x3139c(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x3138e(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x31376(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x31366(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x31359(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x3134b(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x55c32
jmp 0x55c34
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x164(%rax)
je 0x55d2c
jmp 0x55c47
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x164(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0x10f20
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x55d28
jmp 0x55c6d
movq 0x312ec(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x55d1d
movq 0x312d8(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x312ca(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x26cee(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x312a4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x31296(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x3127e(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x3126e(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x31261(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x31253(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x55d2a
jmp 0x55d2c
movq -0x18(%rbp), %rax
movsd 0x148(%rax), %xmm0
movsd 0x22b20(%rip), %xmm1    # 0x78860
ucomisd %xmm1, %xmm0
jbe 0x55e3e
movq -0x20(%rbp), %rax
cmpl $0x1, 0x670(%rax)
je 0x55e3c
jmp 0x55d5d
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x12140
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x55e38
jmp 0x55d7d
movq 0x311dc(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x55e2d
movq 0x311c8(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x311ba(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x26bde(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x31194(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x31186(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x3116e(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x3115e(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x31151(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x31143(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x55e3a
jmp 0x55e3c
jmp 0x55e3e
movq -0x18(%rbp), %rax
movsd 0x238(%rax), %xmm0
movsd 0x22a0e(%rip), %xmm1    # 0x78860
ucomisd %xmm1, %xmm0
jbe 0x55f3d
jmp 0x55e5e
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x10c00
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x55f39
jmp 0x55e7e
movq 0x310db(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x55f2e
movq 0x310c7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x310b9(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x26add(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x31093(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x31085(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x3106d(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x3105d(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x31050(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x31042(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x55f3b
jmp 0x55f3d
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x240(%rax)
je 0x5602f
jmp 0x55f50
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x11f70
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x5602b
jmp 0x55f70
movq 0x30fe9(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x56020
movq 0x30fd5(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x30fc7(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x269eb(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x30fa1(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30f93(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x30f7b(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x30f6b(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x30f5e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30f50(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x5602d
jmp 0x5602f
jmp 0x56031
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x115f0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x5610c
jmp 0x56051
movq 0x30f08(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x56101
movq 0x30ef4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x30ee6(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x2690a(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x30ec0(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30eb2(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x30e9a(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x30e8a(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x30e7d(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30e6f(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x5610e
jmp 0x56110
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x10230
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x561eb
jmp 0x56130
movq 0x30e29(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x561e0
movq 0x30e15(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x30e07(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x2682b(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x30de1(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30dd3(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x30dbb(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x30dab(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x30d9e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30d90(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x561ed
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x1f0(%rax)
je 0x562ec
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x11d60
movl %eax, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
jne 0x56224
movl $0x1, -0x4(%rbp)
jmp 0x5634a
cmpl $0x0, -0x24(%rbp)
je 0x562e8
jmp 0x56230
movq 0x30d29(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x562e0
movq 0x30d15(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x30d07(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x2672b(%rip), %rsi     # 0x7c999
movl $0x50, %edx
callq 0x10840
movq 0x30ce1(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30cd3(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x30cbb(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x30cab(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x30c9e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30c90(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5634a
jmp 0x562ea
jmp 0x562ec
movq -0x20(%rbp), %rax
movb 0xc680(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x56309
movl $0x2, -0x4(%rbp)
jmp 0x5634a
movq -0x20(%rbp), %rax
movb 0xc681(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x56326
movl $0x2, -0x4(%rbp)
jmp 0x5634a
movq -0x20(%rbp), %rax
movb 0xc682(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x56343
movl $0x2, -0x4(%rbp)
jmp 0x5634a
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)