// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/interp_o_word.cc
// Function: Interp::control_save_offset(int, block_struct*, setup_struct*)
int Interp::control_save_offset( /* ARGUMENTS                   */
 int line,                   /* (o-word) line number        */
 block_pointer block,        /* pointer to a block of RS274/NGC instructions */
 setup_pointer settings)     /* pointer to machine settings */
{
  static char name[] = "control_save_offset";
  int index;

  logDebug("Entered:%s for o_name:|%s|", name, block->o_name);

  if(control_find_oword(block, settings, &index) == INTERP_OK)
  {
      // already exists
      ERS("File:%s line:%d redefining sub: o|%s| already defined in file:%s",
               settings->filename, settings->sequence_number,
	       block->o_name,
               settings->oword_offset[index].filename);
      //return INTERP_OK;
  }

  CHKS((settings->oword_labels >= INTERP_OWORD_LABELS),
      NCE_TOO_MANY_OWORD_LABELS);


  index = settings->oword_labels++;
  //logDebug("index: %d offset: %ld", index, block->offset);

  //  settings->oword_offset[index].o_word = line;
  settings->oword_offset[index].o_word_name = strdup(block->o_name);
  settings->oword_offset[index].type = block->o_type;
  settings->oword_offset[index].offset = block->offset;
  settings->oword_offset[index].filename = strdup(settings->filename);
  settings->oword_offset[index].repeat_count = -1;

  // the sequence number has already been bumped, so save
  // the proper value
  settings->oword_offset[index].sequence_number =
    settings->sequence_number - 1;

  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r15
movq %rdi, %r14
movq 0x1437c(%rip), %r12     # 0x3cf60
cmpl $0x0, 0x1b6b4(%r12)
jle 0x28c26
callq 0xc0b0
leaq 0x150c5(%rip), %r10     # 0x3dcc0
leaq 0xd3a3(%rip), %rsi      # 0x35fa5
leaq 0xd3ca(%rip), %r8       # 0x35fd3
pushq $0x63
popq %r9
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
xorl %eax, %eax
pushq 0x2d0(%r15)
pushq %r10
callq 0xc5e0
popq %rax
popq %rcx
leaq -0x2c(%rbp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xbfe0
testl %eax, %eax
je 0x28c6b
movslq 0xfb28(%rbx), %r13
cmpq $0x3e8, %r13            # imm = 0x3E8
jl 0x28cd2
leaq 0xd3ce(%rip), %rdi      # 0x36025
callq 0xb220
movq %r14, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
jmp 0x28ca0
leaq 0x680(%rbx), %rdx
movl 0xc6b4(%rbx), %ecx
movq 0x2d0(%r15), %r8
movslq -0x2c(%rbp), %rax
imulq $0x30, %rax, %rax
movq 0xfb48(%rbx,%rax), %r9
leaq 0xd34e(%rip), %rsi      # 0x35fe4
movq %r14, %rdi
xorl %eax, %eax
callq 0xb8e0
leaq 0xc6d0(%r12), %rdi
leaq 0xd19e(%rip), %rsi      # 0x35e4d
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%r12)
movl $0x1, 0xd670(%r12)
pushq $0x5
popq %rax
jmp 0x28d41
leal 0x1(%r13), %eax
movl %eax, 0xfb28(%rbx)
movq 0x2d0(%r15), %rdi
callq 0xc650
imulq $0x30, %r13, %r14
movq %rax, 0xfb38(%rbx,%r14)
movl 0x2c8(%r15), %eax
movl %eax, 0xfb40(%rbx,%r14)
movq 0x2c0(%r15), %rax
movq %rax, 0xfb50(%rbx,%r14)
leaq 0x680(%rbx), %rdi
callq 0xc650
movq %rax, 0xfb48(%rbx,%r14)
orl $-0x1, 0xfb5c(%rbx,%r14)
movl 0xc6b4(%rbx), %eax
decl %eax
movl %eax, 0xfb58(%rbx,%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq