// File: /workspace/github_cpp_makefile_star2_O2/mdpkh[P]retro6k/src/main.cpp
// Function: LogStep
void LogStep()
{
	extern uint32_t clockticks6502;
	extern uint16_t pc;
	extern uint8_t sp, a, x, y, status;
	static dlogentry* laststateentry = nullptr, * lastinstentry = nullptr, * lastboringentry = nullptr;
	bool newsuppresslogging = (bool)(syspflags[pc >> 8] & pageflags::PF_DONTLOG);
	if (newsuppresslogging && !suppresslogging)
	{
		if (laststateentry && lastinstentry)
			lastinstentry->instentry.cycles = clockticks6502 - laststateentry->stateentry.ticks;
		lastboringentry = ExtendLog(dletype::LT_BORING);
		lastboringentry->boringentry.entryclock = clockticks6502;
		lastboringentry->boringentry.complete = false;
		lastinstentry = nullptr;
	}
	else if (!newsuppresslogging && suppresslogging)
	{
		lastboringentry->boringentry.exitclock = clockticks6502;
		lastboringentry->boringentry.complete = true;
	}
	suppresslogging = newsuppresslogging;
	if (suppresslogging)
		return;
	if (partialinst && partialinst->entrytype == dletype::LT_PARTIALINST)
		partialinst->entrytype = dletype::LT_INST;
	dlogentry* newentry = ExtendLog(dletype::LT_STATE);
	newentry->stateentry.ticks = clockticks6502;
	newentry->stateentry.pc = pc;
	newentry->stateentry.sp = sp;
	newentry->stateentry.a = a;
	newentry->stateentry.x = x;
	newentry->stateentry.y = y;
	newentry->stateentry.status = status;
	if (laststateentry && lastinstentry)
		lastinstentry->instentry.cycles = newentry->stateentry.ticks - laststateentry->stateentry.ticks;
	if (laststateentry && laststateentry->stateentry.sp != newentry->stateentry.sp)
		LogStack(sp);
	laststateentry = newentry;
	lastinstentry = partialinst = ExtendLog(dletype::LT_PARTIALINST);
	debuglogexpectargs = -1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x10c58(%rip), %rax     # 0x1b478
leaq 0x815f67(%rip), %r14    # 0x82078e
movzbl 0x1(%r14), %ecx
movb (%rax,%rcx), %cl
movl %ecx, %ebx
shrb $0x7, %bl
movb 0x10e97(%rip), %al      # 0x1b6d1
testb %cl, %cl
js 0xa902
testb %al, %al
je 0xa85d
leaq 0x815f37(%rip), %rax    # 0x820784
movl (%rax), %eax
movq 0x814b6a(%rip), %rcx    # 0x81f3c0
movl %eax, 0x8(%rcx)
movb $0x1, 0xc(%rcx)
movb %bl, 0x10e6e(%rip)      # 0x1b6d1
movq 0x810fe6(%rip), %rax    # 0x81b850
testq %rax, %rax
je 0xa877
cmpb $0x6, (%rax)
jne 0xa877
movb $0x7, (%rax)
pushq $0x5
popq %rdi
callq 0xa0c1
movq %rax, %rbx
leaq 0x815efb(%rip), %rax    # 0x820784
movb (%rax), %cl
movb %cl, 0x4(%rbx)
movzwl (%r14), %eax
movw %ax, 0x6(%rbx)
leaq 0x815eef(%rip), %rax    # 0x82078c
movb (%rax), %al
movb %al, 0x8(%rbx)
leaq 0x815ee7(%rip), %rdx    # 0x820790
movb (%rdx), %dl
movb %dl, 0x9(%rbx)
leaq 0x815edc(%rip), %rdx    # 0x820791
movb (%rdx), %dl
movb %dl, 0xa(%rbx)
leaq 0x815ed1(%rip), %rdx    # 0x820792
movb (%rdx), %dl
movb %dl, 0xb(%rbx)
leaq 0x815ec6(%rip), %rdx    # 0x820793
movb (%rdx), %dl
movb %dl, 0xc(%rbx)
movq 0x814ad7(%rip), %rdx    # 0x81f3b0
testq %rdx, %rdx
setne %dil
movq 0x814ad1(%rip), %rsi    # 0x81f3b8
testq %rsi, %rsi
setne %r8b
andb %dil, %r8b
cmpb $0x1, %r8b
jne 0xa968
subb 0x4(%rdx), %cl
movb %cl, 0x9(%rsi)
movb 0x8(%rbx), %cl
jmp 0xa96f
testb %al, %al
jne 0xa960
movq 0x814aa3(%rip), %rax    # 0x81f3b0
testq %rax, %rax
setne %dl
movq 0x814a9e(%rip), %rcx    # 0x81f3b8
testq %rcx, %rcx
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0xa939
leaq 0x815e53(%rip), %rdx    # 0x820784
movb (%rdx), %dl
subb 0x4(%rax), %dl
movb %dl, 0x9(%rcx)
pushq $0xa
popq %rdi
callq 0xa0c1
movq %rax, 0x814a78(%rip)    # 0x81f3c0
leaq 0x815e35(%rip), %rcx    # 0x820784
movl (%rcx), %ecx
movl %ecx, 0x4(%rax)
movb $0x0, 0xc(%rax)
andq $0x0, 0x814a58(%rip)    # 0x81f3b8
movb %bl, 0x10d6b(%rip)      # 0x1b6d1
jmp 0xa9a0
movl %eax, %ecx
testq %rdx, %rdx
je 0xa97c
cmpb %cl, 0x8(%rdx)
je 0xa97c
movzbl %al, %edi
callq 0xb638
movq %rbx, 0x814a2d(%rip)    # 0x81f3b0
pushq $0x6
popq %rdi
callq 0xa0c1
movq %rax, 0x810ebe(%rip)    # 0x81b850
movq %rax, 0x814a1f(%rip)    # 0x81f3b8
orl $-0x1, 0x810ea4(%rip)   # 0x81b844
addq $0x8, %rsp
popq %rbx
popq %r14
retq