// File: /workspace/github_c_makefile_star2_O2/dalnefre[P]kernel_abe/emit.c
// Function: str_to_cons
CONS*
str_to_cons(char* in)
{
	int state = 1;
	int c;
	char* tk;
	int n;
	CONS* out = NIL;
	char buf[256];
	
	XDBUG_ENTER("str_to_cons");
	assert(in != NULL);
	strncpy(buf, "", sizeof(buf));
	tk = in;
	XDBUG_PRINT("", ("in=%s", in));
	while (state) {
		c = *in;			/* get character */
		XDBUG_PRINT("", ("state=%d c=%d", state, c));
		XDBUG_PRINT("", ("in=%s", in));
		XDBUG_PRINT("", ("tk=%s", tk));
		switch (state) {
		case 1:				/* initial state (optional whitespace) */
			if (c == '\0') {
				state = -1;		/* fail */
			} else if (isspace(c)) {
				state = 1;
			} else if (isdigit(c) || (c == '-')) {
				tk = in;
				n = ((c == '-') ? 0 : (c - '0'));
				state = 2;
			} else if (isprint(c) && !is_reserved(c)) {
				tk = in;
				state = 3;
			} else if (c == '"') {
				tk = in;
				state = 4;
			} else if (c == '(') {
				CONS* q = cons(NIL, NIL);
				CONS* p = NIL;

				XDBUG_PRINT("", ("list begin"));
				++in;		/* consume character */
				for (;;) {
					while (isspace((int)(*in))) {
						++in;		/* consume character */
					}
					if (*in == ')') {
						++in;		/* consume character */
						XDBUG_PRINT("", ("list end"));
						break;
					} else if (*in == ':') {
						XDBUG_PRINT("", ("pair split"));
						++in;		/* consume character */
						p = str_to_cons(in);
						if (p == NULL) {
							break;
						}
						CQ_PUT(q, p);
						in = nextptr;
						while (isspace((int)(*in))) {
							++in;		/* consume character */
						}
						if (*in == ')') {
							++in;		/* consume character */
							XDBUG_PRINT("", ("pair end"));
							break;
						} else {
							p = NULL;
							break;
						}
					}
					p = str_to_cons(in);
					if (p == NULL) {
						break;
					}
					CQ_PUT(q, cons(p, NIL));
					in = nextptr;
				}
				out = CQ_PEEK(q);
				state = ((p == NULL) ? -1 : 0);		/* done */
			} else if (c == '\'') {
				CONS* p;

				XDBUG_PRINT("", ("quoted literal"));
				++in;		/* consume character */
				p = str_to_cons(in);
				if (p != NULL) {
					out = cons(ATOM("literal"), cons(p, NIL));
					in = nextptr;
					state = 0;		/* done */
				} else {
					state = -1;		/* fail */
				}
			} else {
				state = -1;		/* fail */
			}
			break;
		case 2:				/* numeric token */
			if ((c == '\0') || isspace(c) || is_reserved(c)) {
				if (*tk == '-') {
					if ((in - tk) > 1) {
						n = -n;
					} else {
						--in;		/* push back charactrer */
						state = 3;	/* re-interpret as an atom */
						break;
					}
				}
				out = NUMBER(n);
				state = 0;		/* done */
			} else if (isdigit(c)) {
				n = (n * 10) + (c - '0');
				state = 2;
			} else if (isprint(c)) {
				state = 3;
			} else {
				state = -1;		/* fail */
			}
			break;
		case 3:				/* atomic token */
			if ((c == '\0') || isspace(c) || is_reserved(c)) {
				if ((in - tk) < sizeof(buf)) {
					strncpy(buf, tk, (in - tk));
					XDBUG_PRINT("", ("ATOM(%s) c=%d", buf, c));
					out = ATOM(buf);
					if (out == ATOM("NIL")) {
						out = NIL;
					}
					state = 0;		/* done */
				} else {
					DBUG_PRINT("", ("token buffer overflow! %d >= %d", (in - tk), sizeof(buf)));
					state = -1;
				}
			} else if (isprint(c)) {
				state = 3;
			} else {
				state = -1;		/* fail */
			}
			break;
		case 4:				/* quoted token */
			if ((c == '\0') || !isprint(c)) {
				state = -1;		/* fail */
			} else if (c == '"') {
				if (*tk != '"') {
					state = -1;
				} else if ((in - tk) < sizeof(buf)) {
					++tk;	/* skip leading quote */
					strncpy(buf, tk, (in - tk));
					XDBUG_PRINT("", ("ATOM(\"%s\") c=%d", buf, c));
					out = ATOM(buf);
					if (out == ATOM("NIL")) {
						out = NIL;
					}
					++in;	/* skip trailing quote */
					state = 0;		/* done */
				} else {
					DBUG_PRINT("", ("token buffer overflow! %d >= %d", (in - tk), sizeof(buf)));
					state = -1;
				}
			} else {
				state = 4;
			}
			break;
		default:
			DBUG_PRINT("", ("PARSE FAIL -->%s", in));
			TRACE(printf("PARSE FAIL -->%s\n", in));
			XDBUG_RETURN NULL;	/* parse error */
		}
		if (state >= 0) {
			nextptr = in;
			++in;				/* move to next character */
		}
	}
	XDBUG_PRINT("", ("out=%s", cons_to_str(out)));
	XDBUG_PRINT("", ("next=%s", nextptr));
	XDBUG_RETURN out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
testq %rdi, %rdi
je 0x154fe
movq %rdi, %r13
leaq 0x10(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2110
leaq 0xf369(%rip), %rax      # 0x242a0
pushq $0x1
popq %rcx
leaq 0x81cf(%rip), %rbx      # 0x1d110
movq %rax, 0x8(%rsp)
movq %r13, %r15
testl %ecx, %ecx
je 0x1547b
decl %ecx
cmpl $0x3, %ecx
ja 0x15495
movsbl (%r15), %ebp
movslq %ebp, %r14
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
pushq $-0x1
popq %rax
movl %eax, %ecx
testb %r14b, %r14b
je 0x14f49
callq 0x2270
movq %rax, %r12
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
btl $0xd, %eax
jb 0x151e7
btl $0xb, %eax
jb 0x151f2
cmpb $0x2d, %r14b
je 0x151f2
btl $0xe, %eax
jae 0x1520c
cmpb $0x27, %r14b
je 0x1520c
cmpb $0x22, %r14b
je 0x1520c
cmpb $0x3a, %r14b
je 0x1520c
andb $-0x2, %bpl
cmpb $0x28, %bpl
je 0x1520c
movq %r15, %r13
jmp 0x151ee
testb %r14b, %r14b
je 0x1501c
callq 0x2270
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
btl $0xd, %eax
jb 0x1501c
cmpb $0x3a, %bpl
ja 0x15237
movzbl %bpl, %ecx
movabsq $0x400038400000000, %rdx # imm = 0x400038400000000
btq %rcx, %rdx
jae 0x15237
movq %r15, %r12
subq %r13, %r12
cmpq $0xff, %r12
ja 0x15174
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2070
movq %r14, %rdi
callq 0x1691f
movq %rax, %r14
leaq 0x9415(%rip), %rdi      # 0x1e469
callq 0x1691f
cmpq %rax, %r14
jne 0x15065
leaq 0xf23b(%rip), %r14      # 0x242a0
movq %r14, 0x8(%rsp)
jmp 0x1516d
pushq $-0x1
popq %rax
movl %eax, %ecx
testb %r14b, %r14b
je 0x14f49
callq 0x2270
movq (%rax), %rax
testb $0x40, 0x1(%rax,%r14,2)
pushq $-0x1
popq %rax
movl %eax, %ecx
je 0x14f49
cmpb $0x22, %bpl
jne 0x15219
cmpb $0x22, (%r13)
movl %eax, %ecx
jne 0x14f49
movq %r15, %r12
subq %r13, %r12
cmpq $0xff, %r12
ja 0x1524b
incq %r13
movq %r15, %rdx
subq %r13, %rdx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x2070
movq %r14, %rdi
callq 0x1691f
movq %rax, %r14
leaq 0x937e(%rip), %rdi      # 0x1e469
callq 0x1691f
cmpq %rax, %r14
jne 0x150fc
leaq 0xf1a4(%rip), %r14      # 0x242a0
movq %r14, 0x8(%rsp)
incq %r15
jmp 0x1516d
testb %r14b, %r14b
je 0x15140
callq 0x2270
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
btl $0xd, %eax
jb 0x15140
cmpb $0x3a, %r14b
ja 0x1522d
movzbl %r14b, %ecx
movabsq $0x400038400000000, %rdx # imm = 0x400038400000000
btq %rcx, %rdx
jae 0x1522d
cmpb $0x2d, (%r13)
jne 0x1515b
movq %r15, %rax
subq %r13, %rax
cmpq $0x2, %rax
jl 0x151eb
negl 0x4(%rsp)
movslq 0x4(%rsp), %rax
leaq 0x3(,%rax,4), %rax
movq %rax, 0x8(%rsp)
xorl %eax, %eax
jmp 0x1521c
leaq 0xf7b5(%rip), %rax      # 0x24930
cmpl $0x0, (%rax)
pushq $-0x1
popq %rax
movl %eax, %ecx
je 0x14f49
leaq 0xf1a0(%rip), %rax      # 0x24330
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0x71ac(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1a7f4
pushq $-0x1
popq %rcx
testl %eax, %eax
je 0x14f49
leaq 0xf177(%rip), %rax      # 0x24330
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0x25a, 0xc(%rax)       # imm = 0x25A
movl $0x100, %edx            # imm = 0x100
leaq 0x84e0(%rip), %rdi      # 0x1d6b3
movq %r12, %rsi
xorl %eax, %eax
callq 0x1b0f0
pushq $-0x1
popq %rax
movl %eax, %ecx
jmp 0x14f49
pushq $0x1
jmp 0x1521b
decq %r15
pushq $0x3
jmp 0x1521b
addl $-0x30, %ebp
cmpb $0x2d, %r14b
movl $0x0, %eax
cmovel %eax, %ebp
movl %ebp, 0x4(%rsp)
movq %r15, %r13
pushq $0x2
jmp 0x1521b
cmpb $0x22, %r14b
jne 0x152a3
movq %r15, %r13
pushq $0x4
popq %rax
movq %r15, 0xf5dd(%rip)      # 0x24800
incq %r15
movl %eax, %ecx
jmp 0x14f49
btl $0xb, %eax
jb 0x15364
btl $0xe, %eax
pushq $-0x1
popq %rax
movl %eax, %ecx
pushq $0x3
popq %rax
jae 0x14f49
jmp 0x1521c
leaq 0xf6de(%rip), %rax      # 0x24930
cmpl $0x0, (%rax)
pushq $-0x1
popq %rax
movl %eax, %ecx
je 0x14f49
leaq 0xf0c9(%rip), %rax      # 0x24330
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0x70d5(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1a7f4
pushq $-0x1
popq %rcx
testl %eax, %eax
je 0x14f49
leaq 0xf0a0(%rip), %rax      # 0x24330
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0x274, 0xc(%rax)       # imm = 0x274
jmp 0x151c7
cmpb $0x28, %r14b
jne 0x15377
leaq 0xefec(%rip), %rdi      # 0x242a0
movq %rdi, %rsi
callq 0x19164
movq %rax, %r14
incq %r15
movq (%r12), %rax
movsbq (%r15), %rcx
incq %r15
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x152c6
movzbl %cl, %eax
cmpl $0x29, %eax
je 0x15419
cmpl $0x3a, %eax
je 0x153de
decq %r15
movq %r15, %rdi
callq 0x14f02
testq %rax, %rax
je 0x15414
movq %rax, %rbp
movq %r14, %rdi
callq 0x191fb
leaq 0xef91(%rip), %r15      # 0x242a0
cmpq %r15, %rax
je 0x15337
movq %r14, %rdi
callq 0x19306
movq %r15, %rsi
movq %rax, %r15
movq %rbp, %rdi
callq 0x19164
movq %r15, %rdi
movq %rax, %rsi
callq 0x1941f
jmp 0x1534d
movq %rbp, %rdi
movq %r15, %rsi
callq 0x19164
movq %r14, %rdi
movq %rax, %rsi
callq 0x19411
movq %r14, %rdi
movq %rax, %rsi
callq 0x1941f
movq 0xf4a1(%rip), %r15      # 0x24800
jmp 0x152c2
imull $0xa, 0x4(%rsp), %eax
addl %ebp, %eax
addl $-0x30, %eax
movl %eax, 0x4(%rsp)
jmp 0x15208
pushq $-0x1
popq %rax
movl %eax, %ecx
cmpb $0x27, %r14b
jne 0x14f49
incq %r15
movq %r15, %rdi
callq 0x14f02
movq %rax, %r12
pushq $-0x1
popq %rax
movl %eax, %ecx
testq %r12, %r12
je 0x14f49
leaq 0x8302(%rip), %rdi      # 0x1d6ab
callq 0x1691f
movq %rax, %r14
movq %r12, %rdi
leaq 0xeee5(%rip), %rsi      # 0x242a0
callq 0x19164
movq %r14, %rdi
movq %rax, %rsi
callq 0x19164
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movq 0xf427(%rip), %r15      # 0x24800
jmp 0x1521c
movq %r15, %rdi
callq 0x14f02
testq %rax, %rax
je 0x15414
movq %rax, %rbp
movq %r14, %rdi
callq 0x191fb
movq %r14, %rdi
cmpq 0xebc0(%rip), %rax      # 0x23fc0
je 0x1541e
callq 0x19306
movq %rax, %rdi
movq %rbp, %rsi
callq 0x1941f
jmp 0x15426
xorl %r12d, %r12d
jmp 0x1545b
movb $0x1, %r12b
jmp 0x1545b
movq %rbp, %rsi
callq 0x19411
movq %r14, %rdi
movq %rax, %rsi
callq 0x1941f
movq 0xf3c8(%rip), %r15      # 0x24800
movq (%r12), %rax
decq %r15
movsbq 0x1(%r15), %rcx
incq %r15
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x1543f
xorl %r12d, %r12d
cmpb $0x29, %cl
sete %r12b
addq %r12, %r15
movq %r14, %rdi
callq 0x191fb
movq %rax, 0x8(%rsp)
xorl %eax, %eax
pushq $-0x1
popq %rcx
testb %r12b, %r12b
je 0x14f49
jmp 0x1521c
movq 0x8(%rsp), %rbx
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf494(%rip), %rax      # 0x24930
cmpl $0x0, (%rax)
je 0x154e9
leaq 0xee88(%rip), %rax      # 0x24330
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0x6e94(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1a7f4
testl %eax, %eax
je 0x154e9
leaq 0xee66(%rip), %rax      # 0x24330
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0x27c, 0xc(%rax)       # imm = 0x27C
leaq 0x81f4(%rip), %rdi      # 0x1d6d3
movq %r15, %rsi
xorl %eax, %eax
callq 0x1b0f0
leaq 0x81f4(%rip), %rdi      # 0x1d6e4
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x20e0
jmp 0x15480
leaq 0x8181(%rip), %rdi      # 0x1d686
leaq 0x7c48(%rip), %rsi      # 0x1d154
leaq 0x817e(%rip), %rcx      # 0x1d691
movl $0x1e3, %edx            # imm = 0x1E3
callq 0x2100