// File: /workspace/github_c_makefile_star2_O0/Oric4ever[P]lcc65/6502/build/../src/stmt.c
// Function: forstmt
static void forstmt(lab, swp, lev) int lab,lev; struct swtch *swp; {
	Tree e1, e2, e3;
	Coordinate pt2, pt3;
	static char follow[] = { IF, ID, '}', 0 };

	e1 = e2 = e3 = 0;
	t = gettok();
	expect('(');
	definept(0);
	if (kind[t] == ID)
		e1 = expr0(';');
	else
		expect(';');
	walk(e1, 0, 0);
	pt2 = src;
	refinc *= 10;
	if (kind[t] == ID)
		e2 = texpr(conditional, ';');
	else
		expect(';');
	pt3 = src;
	if (kind[t] == ID)
		e3 = texpr(expr0, ')');
	else
		test(')', follow);
	if (glevel == 2) {	/* e1; L: if (!e2) goto L+2; S; L+1: e3; goto L; L+2: */
		definelab(lab);
		definept(&pt2);
		if (e2)
			walk(e2, 0, lab + 2);
		statement(lab, swp, lev);
		definelab(lab + 1);
		definept(&pt3);
		if (e3)
			walk(e3, 0, 0);
		branch(lab);
	} else {	/* e1; goto L+3; L: S; L+1: e3; L+3: if (e2) goto L; L+2: */
		int once = 0;
		if (e2) {
			once = foldcond(e1, e2);
			if (!once)
				branch(lab + 3);
		}
		definelab(lab);
		statement(lab, swp, lev);
		definelab(lab + 1);
		definept(&pt3);
		if (e3)
			walk(e3, 0, 0);
		if (e2) {
			if (!once)
				definelab(lab + 3);
			definept(&pt2);
			walk(e2, lab, 0);
		} else {
			definept(&pt2);
			branch(lab);
		}
	}
	if (findlabel(lab + 2)->ref)
		definelab(lab + 2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
callq 0x15170
movl %eax, %ecx
leaq 0x1bbe8(%rip), %rax     # 0x3db80
movl %ecx, (%rax)
movl $0x28, %edi
callq 0xd670
xorl %eax, %eax
movl %eax, %edi
callq 0x20a20
leaq 0x1bbcc(%rip), %rax     # 0x3db80
movl (%rax), %eax
movl %eax, %ecx
leaq 0x179d1(%rip), %rax     # 0x39990
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0x21fd8
movl $0x3b, %edi
callq 0xff90
movq %rax, -0x20(%rbp)
jmp 0x21fe2
movl $0x3b, %edi
callq 0xd670
movq -0x20(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x3a80
leaq 0x1bae2(%rip), %rax     # 0x3dad8
movq (%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
imull $0xa, 0x17fa8(%rip), %eax # 0x39fb4
movl %eax, 0x17fa2(%rip)     # 0x39fb4
leaq 0x1bb67(%rip), %rax     # 0x3db80
movl (%rax), %eax
movl %eax, %ecx
leaq 0x1796c(%rip), %rax     # 0x39990
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0x22044
leaq -0x12444(%rip), %rdi    # 0xfbf0
movl $0x3b, %esi
callq 0x26110
movq %rax, -0x28(%rbp)
jmp 0x2204e
movl $0x3b, %edi
callq 0xd670
leaq 0x1ba83(%rip), %rax     # 0x3dad8
movq (%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
leaq 0x1bb15(%rip), %rax     # 0x3db80
movl (%rax), %eax
movl %eax, %ecx
leaq 0x1791a(%rip), %rax     # 0x39990
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0x22096
leaq -0x120f6(%rip), %rdi    # 0xff90
movl $0x29, %esi
callq 0x26110
movq %rax, -0x30(%rbp)
jmp 0x220a7
movl $0x29, %edi
leaq 0x17f1a(%rip), %rsi     # 0x39fbc
callq 0xdb30
leaq 0x1bb52(%rip), %rax     # 0x3dc00
cmpl $0x2, (%rax)
jne 0x22120
movl -0x4(%rbp), %edi
callq 0x208b0
leaq -0x40(%rbp), %rdi
callq 0x20a20
cmpq $0x0, -0x28(%rbp)
je 0x220dc
movq -0x28(%rbp), %rdi
movl -0x4(%rbp), %edx
addl $0x2, %edx
xorl %esi, %esi
callq 0x3a80
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x21500
movl -0x4(%rbp), %edi
addl $0x1, %edi
callq 0x208b0
leaq -0x50(%rbp), %rdi
callq 0x20a20
cmpq $0x0, -0x30(%rbp)
je 0x22113
movq -0x30(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x3a80
movl -0x4(%rbp), %edi
callq 0x21370
jmp 0x221d4
movl $0x0, -0x54(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x22151
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x22ab0
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x2214f
movl -0x4(%rbp), %edi
addl $0x3, %edi
callq 0x21370
jmp 0x22151
movl -0x4(%rbp), %edi
callq 0x208b0
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x21500
movl -0x4(%rbp), %edi
addl $0x1, %edi
callq 0x208b0
leaq -0x50(%rbp), %rdi
callq 0x20a20
cmpq $0x0, -0x30(%rbp)
je 0x22190
movq -0x30(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x3a80
cmpq $0x0, -0x28(%rbp)
je 0x221c1
cmpl $0x0, -0x54(%rbp)
jne 0x221a8
movl -0x4(%rbp), %edi
addl $0x3, %edi
callq 0x208b0
leaq -0x40(%rbp), %rdi
callq 0x20a20
movq -0x28(%rbp), %rdi
movl -0x4(%rbp), %esi
xorl %edx, %edx
callq 0x3a80
jmp 0x221d2
leaq -0x40(%rbp), %rdi
callq 0x20a20
movl -0x4(%rbp), %edi
callq 0x21370
jmp 0x221d4
movl -0x4(%rbp), %edi
addl $0x2, %edi
callq 0x245d0
cmpl $0x0, 0x1c(%rax)
je 0x221f0
movl -0x4(%rbp), %edi
addl $0x2, %edi
callq 0x208b0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)