// File: /workspace/github_c_makefile_star2_O3/hoobaa[P]ficl/tools.c
// Function: ficlPrimitiveStepBreak
static void ficlPrimitiveStepBreak(ficlVm *vm)
{
    ficlString command;
    ficlWord *word;
    ficlWord *pOnStep;
    ficlWordKind kind;

    if (!vm->restart)
    {
        FICL_VM_ASSERT(vm, vm->callback.system->breakpoint.address);
        FICL_VM_ASSERT(vm, vm->callback.system->breakpoint.oldXT);
        /*
        ** Clear the breakpoint that caused me to run
        ** Restore the original instruction at the breakpoint, 
        ** and restore the IP
        */
        vm->ip = (ficlIp)(vm->callback.system->breakpoint.address);
        *vm->ip = vm->callback.system->breakpoint.oldXT;

        /*
        ** If there's an onStep, do it
        */
        pOnStep = ficlSystemLookup(vm->callback.system, "on-step");
        if (pOnStep)
            ficlVmExecuteXT(vm, pOnStep);

        /*
        ** Print the name of the next instruction
        */
        word = vm->callback.system->breakpoint.oldXT;

        kind = ficlWordClassify(word);

        switch (kind)
        {
			case FICL_WORDKIND_INSTRUCTION:
			case FICL_WORDKIND_INSTRUCTION_WITH_ARGUMENT:
				sprintf(vm->pad, "next: %s (instruction %ld)\n", ficlDictionaryInstructionNames[(long)word], (long)word);
				break;
			default:
				sprintf(vm->pad, "next: %s\n", word->name);
				break;
		}

        ficlVmTextOut(vm, vm->pad);
        ficlDebugPrompt(vm);
    }
    else
    {
        vm->restart = 0;
    }

    command = ficlVmGetWord(vm);

	switch (command.text[0])
	{
		case 'i':
		    ficlPrimitiveStepIn(vm);
			break;

		case 'o':
		    ficlPrimitiveStepOver(vm);
			break;

		case 'g':
			break;

		case 'l':
		{
			ficlWord *xt;
			xt = ficlDictionaryFindEnclosingWord(ficlVmGetDictionary(vm), (ficlCell *)(vm->ip));
			if (xt)
			{
				ficlStackPushPointer(vm->dataStack, xt);
				ficlPrimitiveSeeXT(vm);
			}
			else
			{
				ficlVmTextOut(vm, "sorry - can't do that\n");
			}
			ficlVmThrow(vm, FICL_VM_STATUS_RESTART);
			break;
		}

		case 'q':
		{
			ficlVmTextOut(vm, FICL_PROMPT);
			ficlVmThrow(vm, FICL_VM_STATUS_ABORT);
			break;
		}

		case 'x':
		{
			/*
			** Take whatever's left in the TIB and feed it to a subordinate ficlVmExecuteString
			*/ 
			int returnValue;
			ficlString s;
			ficlWord *oldRunningWord = vm->runningWord;

			FICL_STRING_SET_POINTER(s, vm->tib.text + vm->tib.index);
			FICL_STRING_SET_LENGTH(s, vm->tib.end - FICL_STRING_GET_POINTER(s));

			returnValue = ficlVmExecuteString(vm, s);

			if (returnValue == FICL_VM_STATUS_OUT_OF_TEXT)
			{
				returnValue = FICL_VM_STATUS_RESTART;
				vm->runningWord = oldRunningWord;
				ficlVmTextOut(vm, "\n");
			}

			ficlVmThrow(vm, returnValue);
			break;
		}

		default:
		{
			ficlVmTextOut(vm,
				"i -- step In\n"
				"o -- step Over\n"
				"g -- Go (execute to completion)\n"
				"l -- List source code\n"
				"q -- Quit (stop debugging and abort)\n"
				"x -- eXecute the rest of the line as Ficl words\n"
			);
			ficlDebugPrompt(vm);
			ficlVmThrow(vm, FICL_VM_STATUS_RESTART);
			break;
		}
	}

    return;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpw $0x0, 0x38(%rdi)
je 0x4e0a
movw $0x0, 0x38(%rbx)
jmp 0x4eb3
movq 0x18(%rbx), %rax
movq 0xb8(%rax), %rcx
movq %rcx, 0x40(%rbx)
movq 0xc0(%rax), %rax
movq %rax, (%rcx)
movq 0x18(%rbx), %rdi
leaq 0x96d6(%rip), %rsi      # 0xe504
callq 0x39e6
testq %rax, %rax
je 0x4e43
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6da9
movq 0x18(%rbx), %rax
movq 0xc0(%rax), %r14
movq %r14, %rdi
callq 0xb94e
orl $0x2, %eax
leaq 0x118(%rbx), %rdi
cmpl $0x16, %eax
jne 0x4e83
leaq 0x13084(%rip), %rax     # 0x17ef0
movq (%rax,%r14,8), %rdx
leaq 0x9695(%rip), %rsi      # 0xe50c
movq %r14, %rcx
xorl %eax, %eax
callq 0x32f0
jmp 0x4e95
movq 0x10(%r14), %rdx
leaq 0x969a(%rip), %rsi      # 0xe528
xorl %eax, %eax
callq 0x32f0
leaq 0x118(%rbx), %rsi
movq %rbx, %rdi
callq 0x6b89
leaq 0x9746(%rip), %rsi      # 0xe5f1
movq %rbx, %rdi
callq 0x6b89
movq %rbx, %rdi
callq 0x69c5
movzbl (%rdx), %ecx
leal -0x67(%rcx), %eax
cmpl $0xa, %eax
ja 0x4f0c
leaq 0x940b(%rip), %rcx      # 0xe2d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x68f3
movq 0x40(%rbx), %rsi
movq %rax, %rdi
callq 0xc6c4
testq %rax, %rax
je 0x4ff4
movq 0x60(%rbx), %rdi
movq %rax, %rsi
callq 0x4316
movq %rbx, %rdi
callq 0x5041
jmp 0x5003
cmpl $0x78, %ecx
jne 0x4f5e
movq 0x48(%rbx), %r14
movq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
addq 0x80(%rbx), %rdx
subq %rdx, %rsi
movq %rbx, %rdi
callq 0x6c0b
cmpl $0xfffffeff, %eax       # imm = 0xFFFFFEFF
jne 0x4f54
movq %r14, 0x48(%rbx)
leaq 0x9422(%rip), %rsi      # 0xe369
movq %rbx, %rdi
callq 0x6b89
movl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
movq %rbx, %rdi
movl %eax, %esi
jmp 0x500b
leaq 0x95e4(%rip), %rsi      # 0xe549
movq %rbx, %rdi
callq 0x6b89
leaq 0x967d(%rip), %rsi      # 0xe5f1
jmp 0x4ffb
leaq 0x90c1(%rip), %rsi      # 0xe041
movq %rbx, %rdi
callq 0x6b89
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
jmp 0x500b
movq 0x18(%rbx), %rdi
leaq 0x9497(%rip), %rsi      # 0xe434
callq 0x39e6
movq %rax, %r14
movq 0x40(%rbx), %rax
movq (%rax), %rdi
callq 0xb94e
cmpl $0x7, %eax
je 0x4fbb
cmpl $0x2, %eax
jne 0x4fe5
movq 0x18(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0xb8(%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0xc0(%rax)
movq %r14, 0x8(%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x51d2
leaq 0x9537(%rip), %rsi      # 0xe532
movq %rbx, %rdi
callq 0x6b89
movq %rbx, %rdi
movl $0xfffffefe, %esi       # imm = 0xFFFFFEFE
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x67c2