// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpw $0x0, 0x38(%rax)
jne 0x5e65
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0xb8(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0xc0(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0xf792(%rip), %rsi      # 0x15540
callq 0x3c80
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x5dcb
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x9940
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x10720
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
orl $0x2, %eax
subl $0x16, %eax
je 0x5df7
jmp 0x5e25
movq -0x8(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
movq -0x28(%rbp), %rcx
leaq 0x19103(%rip), %rax     # 0x1ef10
movq (%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rcx
leaq 0xf72c(%rip), %rsi      # 0x15548
movb $0x0, %al
callq 0x32d0
jmp 0x5e46
movq -0x8(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0xf725(%rip), %rsi      # 0x15564
movb $0x0, %al
callq 0x32d0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x118, %rsi            # imm = 0x118
callq 0x95e0
movq -0x8(%rbp), %rdi
callq 0x6350
jmp 0x5e6f
movq -0x8(%rbp), %rax
movw $0x0, 0x38(%rax)
movq -0x8(%rbp), %rdi
callq 0x9180
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
movups -0x48(%rbp), %xmm0
movaps %xmm0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
addl $-0x67, %eax
movl %eax, %ecx
movq %rcx, -0x78(%rbp)
subl $0x11, %eax
ja 0x5fe6
movq -0x78(%rbp), %rax
leaq 0xf41c(%rip), %rcx      # 0x152c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
callq 0x6380
jmp 0x600d
movq -0x8(%rbp), %rdi
callq 0x63d0
jmp 0x600d
jmp 0x600d
movq -0x8(%rbp), %rdi
callq 0x8f80
movq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rsi
callq 0x11ca0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x5f16
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x4c60
movq -0x8(%rbp), %rdi
callq 0x6060
jmp 0x5f26
movq -0x8(%rbp), %rdi
leaq 0xf64d(%rip), %rsi      # 0x1556e
callq 0x95e0
movq -0x8(%rbp), %rdi
movl $0xfffffefe, %esi       # imm = 0xFFFFFEFE
callq 0x8d90
jmp 0x600d
movq -0x8(%rbp), %rdi
leaq 0xf0fd(%rip), %rsi      # 0x15041
callq 0x95e0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8d90
jmp 0x600d
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x8(%rbp), %rcx
addq 0x80(%rcx), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x9720
movl %eax, -0x54(%rbp)
cmpl $0xfffffeff, -0x54(%rbp) # imm = 0xFFFFFEFF
jne 0x5fd8
movl $0xfffffefe, -0x54(%rbp) # imm = 0xFFFFFEFE
movq -0x70(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rdi
leaq 0xf3d2(%rip), %rsi      # 0x153a5
callq 0x95e0
movq -0x8(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x8d90
jmp 0x600d
movq -0x8(%rbp), %rdi
leaq 0xf594(%rip), %rsi      # 0x15585
callq 0x95e0
movq -0x8(%rbp), %rdi
callq 0x6350
movq -0x8(%rbp), %rdi
movl $0xfffffefe, %esi       # imm = 0xFFFFFEFE
callq 0x8d90
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)