// File: /workspace/github_c_makefile_star2_O2/ksherlock[P]nroff_man/read2.c
// Function: read_text
const unsigned char *read_text(void) {

	unsigned ff = 0;
	for(;;) {
		const unsigned char *cp = read_line();
		if (type == tkEOF) return NULL;

		switch(type) {
			case tkDT:
				continue;
			case tkUR:
			case tkUE:
			case tkMT:
			case tkME:
			case tkIX:
				continue;

			/* next-line fonts */
			case tkB:
			case tkSB:
				ff = FONT_B;
				if (argc) return font(ff);
				continue;
			case tkR:
			case tkSM:
				ff = FONT_R;
				if (argc) return font(ff);
				continue;
			case tkI:
				ff = FONT_I;
				if (argc) return font(ff);
				continue;
			case tkSY:
				/* bold up argv0 but retain the type */
				if (argc) {
					unsigned i;
					buffer[0] = FONT_B;
					i = xstrcpy(buffer+1, argv[0]);
					/* pre-increment to adjust for buffer+1 */
					buffer[++i] = FONT_R;
					buffer[++i] = 0;
					argv[0] = buffer;
					return "";
				}

			/* current-line fonts */
			case tkBI: return fonts(FONT_B, FONT_I);
			case tkBR: return fonts(FONT_B, FONT_R);
			case tkIB: return fonts(FONT_I, FONT_B);
			case tkIR: return fonts(FONT_I, FONT_R);
			case tkRI: return fonts(FONT_R, FONT_I);
			case tkRB: return fonts(FONT_R, FONT_B);

			/* plan-9 Manual Reference.  First word is italic */
			case tkMR: return font_first_word(FONT_I);

			case tkOP: {
				unsigned i;

				if (argc == 0) continue;
				buffer[0] = '[';
				buffer[1] = FONT_B;
				i = 2 + xstrcpy(buffer+2, argv[0]);
				buffer[i++] = FONT_R;
				if (argc > 1) {
					buffer[i++] = NBSPACE;
					buffer[i++] = FONT_I;
					i += xstrcpy(buffer + i, argv[1]);
					buffer[i++] = FONT_R;
				}
				buffer[i++] = ']'; 
				buffer[i] = 0; 
				type = tkTEXT;
				return buffer;
			}

			case tkTEXT:
				if (ff) {
					unsigned i;
					buffer[0] = ff;
					i = xstrcpy(buffer+1, cp);
					/* pre-increment to adjust for buffer+1 */
					buffer[++i] = FONT_R;
					buffer[++i] = 0;
					ff = 0;
					return buffer;
				}
			default:
				return cp;
		}

	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebp, %ebp
leaq 0x8868(%rip), %r15      # 0xe310
leaq 0x3c49(%rip), %r12      # 0x96f8
leaq 0x88aa(%rip), %r14      # 0xe360
callq 0x4868
movq %rax, %rbx
movl (%r15), %eax
cmpq $0x25, %rax
ja 0x5c74
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl (%r14), %r13d
testl %r13d, %r13d
je 0x5ab6
jmp 0x5c86
movl $0x84, %ebp
cmpl $0x0, (%r14)
je 0x5ab6
jmp 0x5d1e
movl $0x83, %ebp
cmpl $0x0, (%r14)
je 0x5ab6
jmp 0x5d25
movl $0x85, %ebp
cmpl $0x0, (%r14)
je 0x5ab6
movl $0x85, %edi
jmp 0x5d2a
movl $0x83, %edi
jmp 0x5b73
movl $0x85, %edi
jmp 0x5c57
cmpl $0x0, (%r14)
je 0x5b6e
movb $-0x7c, 0x993c(%rip)    # 0xf470
leaq 0x9935(%rip), %rbx      # 0xf470
leaq 0x987e(%rip), %r14      # 0xf3c0
movq (%r14), %rsi
leaq 0x9925(%rip), %rdi      # 0xf471
callq 0x5a84
leal 0x1(%rax), %ecx
movb $-0x7d, (%rcx,%rbx)
addl $0x2, %eax
movb $0x0, (%rax,%rbx)
movq %rbx, (%r14)
leaq 0x42c9(%rip), %rbx      # 0x9e32
jmp 0x5c74
movl $0x84, %edi
movl $0x85, %esi
jmp 0x5c68
testl %ebp, %ebp
je 0x5c74
movb %bpl, 0x98e4(%rip)      # 0xf470
leaq 0x98dd(%rip), %r14      # 0xf470
leaq 0x98d7(%rip), %rdi      # 0xf471
movq %rbx, %rsi
callq 0x5a84
leal 0x1(%rax), %ecx
movb $-0x7d, (%rcx,%r14)
addl $0x2, %eax
movb $0x0, (%rax,%r14)
movq %r14, %rbx
jmp 0x5c74
xorl %ebx, %ebx
jmp 0x5c74
movl $0x85, %edi
jmp 0x5c63
movl (%r14), %eax
testl %eax, %eax
je 0x5c6d
movb $-0x7b, 0x9893(%rip)    # 0xf470
movl $0x1, (%r15)
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
pushq $0x1
popq %rdx
leaq 0x97cb(%rip), %rsi      # 0xf3c0
leaq 0x9874(%rip), %rbx      # 0xf470
pushq $0x1
popq %rdi
movabsq $0x100000000, %r8       # imm = 0x100000000
movslq %edx, %r9
cmpq %rax, %rcx
je 0x5d14
movq (%rsi,%rcx,8), %r10
leaq (%rbx,%r9), %r11
shlq $0x20, %r9
movq %rdi, %r14
movb -0x1(%r10,%r14), %bpl
testb %bpl, %bpl
je 0x5c3d
movb %bpl, -0x1(%r11,%r14)
incq %r14
addq %r8, %r9
incl %edx
jmp 0x5c24
testq %rcx, %rcx
jne 0x5c4d
incl %edx
sarq $0x20, %r9
movb $-0x7d, (%r9,%rbx)
incq %rcx
jmp 0x5c09
movl $0x84, %edi
movl $0x83, %esi
jmp 0x5c68
movl $0x83, %edi
movl $0x84, %esi
callq 0x5db3
leaq 0x97fc(%rip), %rbx      # 0xf470
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movw $0x845b, 0x97e1(%rip)   # imm = 0x845B
leaq 0x97da(%rip), %rbx      # 0xf470
leaq 0x9723(%rip), %r12      # 0xf3c0
movq (%r12), %rsi
leaq 0x97ca(%rip), %rdi      # 0xf472
callq 0x5a84
movl %eax, %r14d
leal 0x2(%r14), %ecx
leal 0x3(%r14), %eax
movb $-0x7d, (%rcx,%rbx)
cmpl $0x2, %r13d
jl 0x5cfc
leal 0x4(%r14), %ecx
movl %eax, %eax
leaq 0x97a1(%rip), %r13      # 0xf470
movb $-0x80, (%rax,%r13)
leal 0x5(%r14), %edi
movb $-0x7b, (%rcx,%r13)
addq %r13, %rdi
movq 0x8(%r12), %rsi
callq 0x5a84
leal (%rax,%r14), %ecx
addl $0x5, %ecx
addl %r14d, %eax
addl $0x6, %eax
movb $-0x7d, (%rcx,%r13)
movl %eax, %ecx
incl %eax
movb $0x5d, (%rcx,%rbx)
movb $0x0, (%rax,%rbx)
movl $0x1, (%r15)
jmp 0x5c74
movb $0x0, (%r9,%rbx)
jmp 0x5c74
movl $0x84, %edi
jmp 0x5d2a
movl $0x83, %edi
callq 0x5d34
jmp 0x5c6d