// File: /workspace/github_c_makefile_star2_O0/ksherlock[P]nroff_man/render.c
// Function: append
void append(const unsigned char *cp) {

	unsigned start, end;
	unsigned i, j, k;
	unsigned xlen;
	uint_fast8_t c;

	xlen = 0;
	i = 0;
	j = 0;

	if (cp[0] == ' ') flush(0);

	k = buffer_offset;

	for(;;) {
		while (isspace(cp[i])) ++i;
		if (cp[i] == 0) { buffer_offset = k; return; }
		start = i;
		xlen = 0;
		for(;;++i) {
			c = cp[i];
			if (c == 0 || isspace(c)) {
				int avail;
				end = i;
				/* xlen = printed size */
				/* if word ends w [.?!], should add 2 spaces...
				*/
				/* flush() depends on buffer_offset, etc */
				avail = width - buffer_width;

				/* todo -- also check if k + end - start + 1 > sizeof(buffer) */

				if (buffer_width + xlen > width) {

					/* try to hyphenate */
					if (hy && avail > 2) {
						int cookie[2];
						int ok;
						ok = hyphenate(cp + start, avail, cookie);
						if (ok) {
							unsigned xend;
							xend = start + cookie[0];

							for (j = start; j < xend; ++j)
								buffer[k++] = cp[j];
							buffer[k++] = '-';
							buffer_width += cookie[1] + 1;
							buffer_words++;

							xlen -= cookie[1];
							start = xend;
						}
					}

					buffer_offset = k;
					buffer[k] = 0;
					flush(1);
					k = 0;
				}
				
				if (xlen > width) {
					man_warnx("Word is too long.");
					xlen = 0;
					continue;
				}
				for (j = start; j < end; ++j)
					buffer[k++] = cp[j];

				if (c == 0 && j > 1) {
					/* if word ends w/ [.?!] should add extra space */
					if (is_sentence(cp, j)) {
						buffer[k++] = ' ';
						xlen++;
					}
				}

				buffer[k++] = XSPACE;
				buffer[k] = 0;
				xlen++; /* space */
				buffer_width += xlen;
				buffer_words++;

				if (c == 0) {
					buffer_offset = k;
					return;
				}
				xlen = 0;
				break;

			} else {
				if (c <= NBSPACE) xlen++;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x20, %eax
jne 0x9334
xorl %edi, %edi
callq 0x9650
movl 0x95de(%rip), %eax      # 0x12918
movl %eax, -0x1c(%rbp)
jmp 0x933f
callq 0x41d0
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movl -0x14(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x936e
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x933f
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x938c
movl -0x1c(%rbp), %eax
movl %eax, 0x9591(%rip)      # 0x12918
jmp 0x963c
movl -0x14(%rbp), %eax
movl %eax, -0xc(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x0, %eax
je 0x93d0
callq 0x41d0
movq (%rax), %rax
movzbl -0x21(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x9611
movl -0x14(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq 0x4f57(%rip), %rax      # 0xe334
movl (%rax), %eax
subl 0x952f(%rip), %eax      # 0x12914
movl %eax, -0x28(%rbp)
movl 0x9526(%rip), %eax      # 0x12914
addl -0x20(%rbp), %eax
leaq 0x4f3c(%rip), %rcx      # 0xe334
cmpl (%rcx), %eax
jbe 0x94fa
leaq 0x4f15(%rip), %rax      # 0xe31c
cmpl $0x0, (%rax)
je 0x94d0
cmpl $0x2, -0x28(%rbp)
jle 0x94d0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
addq %rax, %rdi
movl -0x28(%rbp), %esi
leaq -0x30(%rbp), %rdx
callq 0x99e0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x94ce
movl -0xc(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x9482
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movb (%rax,%rcx), %dl
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x94ac(%rip), %rax      # 0x12920
movb %dl, (%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x944c
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x9488(%rip), %rax      # 0x12920
movb $0x2d, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
addl 0x946c(%rip), %eax      # 0x12914
movl %eax, 0x9466(%rip)      # 0x12914
movl 0x9468(%rip), %eax      # 0x1291c
addl $0x1, %eax
movl %eax, 0x945f(%rip)      # 0x1291c
movl -0x2c(%rbp), %ecx
movl -0x20(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x94d0
movl -0x1c(%rbp), %eax
movl %eax, 0x943f(%rip)      # 0x12918
movl -0x1c(%rbp), %eax
movl %eax, %ecx
leaq 0x943b(%rip), %rax      # 0x12920
movb $0x0, (%rax,%rcx)
movl $0x1, %edi
callq 0x9650
movl $0x0, -0x1c(%rbp)
movl -0x20(%rbp), %eax
leaq 0x4e30(%rip), %rcx      # 0xe334
cmpl (%rcx), %eax
jbe 0x9522
xorl %edi, %edi
leaq 0x2f02(%rip), %rsi      # 0xc413
callq 0x49d0
movl $0x0, -0x20(%rbp)
jmp 0x9629
movl -0xc(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jae 0x955e
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movb (%rax,%rcx), %dl
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x93d0(%rip), %rax      # 0x12920
movb %dl, (%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x9528
movzbl -0x21(%rbp), %eax
cmpl $0x0, %eax
jne 0x95a3
cmpl $0x1, -0x18(%rbp)
jbe 0x95a3
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x9ae0
cmpl $0x0, %eax
je 0x95a1
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x938c(%rip), %rax      # 0x12920
movb $0x20, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x95a3
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x9367(%rip), %rax      # 0x12920
movb $-0x7f, (%rax,%rcx)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
leaq 0x9357(%rip), %rax      # 0x12920
movb $0x0, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl 0x9335(%rip), %eax      # 0x12914
movl %eax, 0x932f(%rip)      # 0x12914
movl 0x9331(%rip), %eax      # 0x1291c
addl $0x1, %eax
movl %eax, 0x9328(%rip)      # 0x1291c
movzbl -0x21(%rbp), %eax
cmpl $0x0, %eax
jne 0x9608
movl -0x1c(%rbp), %eax
movl %eax, 0x9312(%rip)      # 0x12918
jmp 0x963c
movl $0x0, -0x20(%rbp)
jmp 0x9637
movzbl -0x21(%rbp), %eax
cmpl $0x80, %eax
jg 0x9625
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x9627
jmp 0x9629
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x9399
jmp 0x933d
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)