// File: /workspace/github_cpp_makefile_star2_O3/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 0x157ae(%rip), %r12     # 0x40f60
cmpl $0x0, 0x1b6b4(%r12)
jle 0x2b7f8
callq 0xaf80
leaq 0x16437(%rip), %r10     # 0x41c00
leaq 0xe7d5(%rip), %rsi      # 0x39fa5
leaq 0xe7fc(%rip), %r8       # 0x39fd3
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x63, %r9d
xorl %eax, %eax
pushq 0x2d0(%r15)
pushq %r10
callq 0xb470
addq $0x10, %rsp
leaq -0x2c(%rbp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xaec0
testl %eax, %eax
je 0x2b83d
movslq 0xfb28(%rbx), %r13
cmpq $0x3e8, %r13            # imm = 0x3E8
jl 0x2b8ad
leaq 0xe7fc(%rip), %rdi      # 0x3a025
callq 0xa1f0
movq %r14, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
jmp 0x2b876
leaq 0x680(%rbx), %rdx
movl 0xc6b4(%rbx), %ecx
movq 0x2d0(%r15), %r8
movslq -0x2c(%rbp), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq 0xfb48(%rbx,%rax), %r9
leaq 0xe778(%rip), %rsi      # 0x39fe4
movq %r14, %rdi
xorl %eax, %eax
callq 0xa850
leaq 0xc6d0(%r12), %rdi
leaq 0xe5c8(%rip), %rsi      # 0x39e4d
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%r12)
movl $0x1, 0xd670(%r12)
movl $0x5, %eax
jmp 0x2b92a
leal 0x1(%r13), %eax
movl %eax, 0xfb28(%rbx)
movq 0x2d0(%r15), %rdi
callq 0xb4e0
leaq (,%r13,2), %r14
addq %r13, %r14
shlq $0x4, %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 0xb4e0
movq %rax, 0xfb48(%rbx,%r14)
movl $0xffffffff, 0xfb5c(%rbx,%r14) # imm = 0xFFFFFFFF
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
nop