// File: sundale[P]gcode/rs274ngc/interp_o_word.cc
// Function: Interp::control_find_oword(block_struct*, setup_struct*, int*)
int Interp::control_find_oword( /* ARGUMENTS                       */
  block_pointer block,      /* pointer to block */
  setup_pointer settings,   /* pointer to machine settings      */
  int *o_index)             /* the index of o-word (returned) */
{
  static char name[] = "control_find_oword";
  int i;

  logDebug("Entered:%s", name);
  for(i=0; i<settings->oword_labels; i++)
    {
      if(0 == strcmp(settings->oword_offset[i].o_word_name, block->o_name))
	{
	  *o_index = i;
	  logDebug("Found oword[%d]: |%s|", i, block->o_name);
	  return INTERP_OK;
	}
    }
  logDebug("Unknown oword name: |%s|", block->o_name);
  ERS(NCE_UNKNOWN_OWORD_NUMBER);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
xorl %eax, %eax
movq 0x1ba77(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x6b524
callq 0x11950
movq -0x38(%rbp), %rdi
movl %eax, %ecx
leaq 0x138fa(%rip), %rsi     # 0x7edfd
xorl %edx, %edx
leaq 0x13846(%rip), %r8      # 0x7ed52
movl $0x8d, %r9d
leaq 0x1cd87(%rip), %rax     # 0x882a0
movq %rax, (%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x6b526
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xfb28(%rcx), %eax
jge 0x6b5e9
movq -0x20(%rbp), %rax
addq $0xfb30, %rax           # imm = 0xFB30
movslq -0x2c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x2d0(%rax), %rsi
callq 0x11820
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x6b5d9
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
xorl %eax, %eax
movq 0x1b9dd(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x6b5cb
callq 0x11950
movq -0x38(%rbp), %rdi
movl %eax, %ecx
movl -0x2c(%rbp), %r10d
movq -0x18(%rbp), %rax
movq 0x2d0(%rax), %rax
leaq 0x1386f(%rip), %rsi     # 0x7ee1b
xorl %edx, %edx
leaq 0x1379d(%rip), %r8      # 0x7ed52
movl $0x93, %r9d
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x6b5cd
movl $0x0, -0x4(%rbp)
jmp 0x6b705
jmp 0x6b5db
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6b52d
jmp 0x6b5eb
xorl %eax, %eax
movq 0x1b96c(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x6b633
callq 0x11950
movq -0x38(%rbp), %rdi
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq 0x2d0(%rax), %rax
leaq 0x1382b(%rip), %rsi     # 0x7ee44
xorl %edx, %edx
leaq 0x13730(%rip), %r8      # 0x7ed52
movl $0x97, %r9d
movq %rax, (%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x6b635
jmp 0x6b637
leaq 0x13832(%rip), %rdi     # 0x7ee70
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x1b908(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x1b8f7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1b8e9(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x137f9(%rip), %rsi     # 0x7ee85
movl $0x50, %edx
callq 0x10840
movq 0x1b8c3(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1b8b5(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1b89d(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1b88d(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1b880(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1b872(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop