// File: /workspace/github_c_makefile_star2_O0/nimble-code[P]Uno/Src/uno_lts.c
// Function: lts_redirect
static State *
lts_redirect(State *s)
{	State *stc = s;
	leafnode *ln;
	SwStack *frame;

	if (!s || !s->n) return s;

	for (frame = stck; frame; frame = frame->nxt)
		if (frame->s == s)
		{	fprintf(stderr, "uno: %s:%d: goto cycle\n",
				s->n->hdr.fnm,
				s->n->hdr.line);
			return s;
		}

	frame = (SwStack *) emalloc(sizeof(SwStack));
	frame->s = s;
	frame->nxt = stck;
	stck = frame;
	
	if (s->n->hdr.which == NODE_T)
	{	switch (s->n->hdr.type) {
		case TN_JUMP:
			if (s->n->hdr.tok == RETURN)
				break;
			if ((ln = (leafnode *) s->n->lnode) != NULL)	/* assign */
			{	stc = lts_label_find(ln->data.sval->str);
				if (!stc) stc = s;
			}
			break;

		case TN_BLOCK:
		case TN_STEMNT:
		case TN_LABEL:	/* skip fillers, if unique successor */
			if (!s->succ)	/* not yet set, but already known to be unique */
				stc = s->nxt;
			else if (!s->succ->nxt)
				stc = s->succ->branch;

			if (!stc) stc = s;
			break;
		default:
			break;
	}	}

	if (stc != s)
		stc = lts_redirect(stc);

	stck = stck->nxt;	/* pop frame stack */

	return stc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x23fb5
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x23fc2
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2416e
movq 0x6200f(%rip), %rax     # 0x85fd8
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2402b
movq -0x28(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x2401b
movq 0x2a010(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x10(%rax), %ecx
leaq 0x2134c(%rip), %rsi     # 0x45353
movb $0x0, %al
callq 0x3170
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2416e
jmp 0x2401d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x23fcd
movl $0x10, %edi
callq 0x54c0
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq 0x61f8d(%rip), %rcx     # 0x85fd8
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq %rax, 0x61f7a(%rip)     # 0x85fd8
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x4, (%rax)
jne 0x2413d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x2c(%rbp)
subl $0x4, %eax
je 0x240ee
jmp 0x24082
movl -0x2c(%rbp), %eax
subl $0x1d, %eax
je 0x2409c
jmp 0x2408c
movl -0x2c(%rbp), %eax
addl $-0x22, %eax
subl $0x2, %eax
jb 0x240ee
jmp 0x24139
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x120, 0x18(%rax)      # imm = 0x120
jne 0x240b1
jmp 0x2413b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x240ec
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x24200
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x240ea
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x240ec
jmp 0x2413b
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x24107
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x24128
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x18(%rax)
jne 0x24126
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x24128
cmpq $0x0, -0x18(%rbp)
jne 0x24137
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x2413b
jmp 0x2413b
jmp 0x2413d
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x24154
movq -0x18(%rbp), %rdi
callq 0x23f90
movq %rax, -0x18(%rbp)
movq 0x61e7d(%rip), %rax     # 0x85fd8
movq 0x8(%rax), %rax
movq %rax, 0x61e72(%rip)     # 0x85fd8
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)