// File: /workspace/github_c_makefile_star2_O2/NedFreed[P]msglint/msglint.c
// Function: wordwrap
static void wordwrap(const char *str, int len, int indent,
		     int *ppos, char *wbuf, int buflen, int *bufused)
{
    char *wptr = wbuf + *bufused;
    char *wend = wbuf + buflen - 1;
    const char *end = str + len;
    int pos = *ppos;

    /* loop over words */
    do {
	/* copy word to buffer */
	if (str != NULL) {
	    while (str < end && !isspace(*str) && wptr < wend) {
		*wptr = *str;
		++wptr, ++str;
	    }
	    if (str == end) break;
	}
	
	/* check if we need to word wrap
	 *  word wrap at 78 chars unless at beginning of line,
	 *  word wouldn't fit on new line or we're on the last word and it
	 *  will barely squeeze in under 80 columns
	 */
	if (pos > indent && wptr - wbuf + pos >= 78 &&
	    wptr - wbuf + indent < 80 &&
	    (str != NULL || wptr - wbuf + pos > 79)) {
	    fprintf(outfile, NEWLINE);
	    fprintf(outfile, "%.*s", indent, pad_str);
	    pos = indent;
	}
	pos += wptr - wbuf;

	/* deal with spaces */
	if (str != NULL) {
	    while (str < end && isspace(*str) && wptr < wend && pos < 78) {
		*wptr = *str;
		if (*str == '\n') {
		    pos = 78;
		    ++str;
		} else {
		    ++wptr, ++str, ++pos;
		}
	    }
	    while (str < end && isspace(*str)) ++str;
	}

	/* print it */
	*wptr = '\0';
	fprintf(outfile, "%s", wbuf);
	wptr = wbuf;

	/* check for end case */
	if (str == NULL) {
	    fprintf(outfile, NEWLINE);
	    break;
	}
    } while (str < end);
	
    /* set results */
    *ppos = pos;
    *bufused = wptr - wbuf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %rbp
movq %rdi, %r12
movq %r9, 0x18(%rsp)
movslq (%r9), %r14
movslq %esi, %rbx
addq %rdi, %rbx
movq %rcx, 0x10(%rsp)
movl (%rcx), %r13d
movl %edx, 0xc(%rsp)
movslq %edx, %rax
pushq $0x50
popq %rcx
subq %rax, %rcx
movq %rcx, 0x20(%rsp)
testq %r12, %r12
je 0x5022
cmpq %rbx, %r12
jae 0x5018
callq 0x2200
movq (%rax), %rcx
movsbq (%r12), %rax
testb $0x20, 0x1(%rcx,%rax,2)
jne 0x5018
cmpq $0xfe, %r14
jg 0x5018
movb %al, (%rbp,%r14)
incq %r14
incq %r12
jmp 0x4fe9
cmpq %rbx, %r12
jne 0x5025
jmp 0x513a
xorl %r12d, %r12d
leaq (%r14,%rbp), %r15
cmpl 0xc(%rsp), %r13d
jle 0x5089
movslq %r13d, %rax
addq %r14, %rax
cmpq $0x4e, %rax
jl 0x5089
cmpq 0x20(%rsp), %r14
jge 0x5089
testq %r12, %r12
jne 0x5056
cmpq $0x4f, %rax
ja 0x5056
addl %r14d, %r13d
jmp 0x50fa
movq 0xda9b(%rip), %rsi      # 0x12af8
pushq $0xa
popq %rdi
callq 0x2100
movq 0xda8c(%rip), %rdi      # 0x12af8
leaq 0x9f29(%rip), %rsi      # 0xef9c
movl 0xc(%rsp), %r13d
movl %r13d, %edx
leaq 0x6d6e(%rip), %rcx      # 0xbdf0
xorl %eax, %eax
callq 0x2120
addl %r14d, %r13d
testq %r12, %r12
je 0x50fa
leaq (%r14,%rbp), %r15
cmpq %rbx, %r12
jae 0x50df
callq 0x2200
movq (%rax), %rcx
movsbq (%r12), %rax
testb $0x20, 0x1(%rcx,%rax,2)
je 0x50df
cmpq $0xfe, %r14
jg 0x50df
cmpl $0x4d, %r13d
jg 0x50df
movb %al, (%r15)
incl %r13d
xorl %eax, %eax
cmpb $0xa, (%r12)
setne %al
pushq $0x4e
popq %rcx
cmovel %ecx, %r13d
addq %rax, %r14
incq %r12
jmp 0x5091
incq %r12
cmpq %rbx, %r12
jae 0x50fd
callq 0x2200
movq (%rax), %rax
movsbq (%r12), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x50dc
jmp 0x50fd
xorl %r12d, %r12d
movb $0x0, (%r15)
movq 0xd9f0(%rip), %rsi      # 0x12af8
movq %rbp, %rdi
callq 0x20e0
testq %r12, %r12
je 0x5126
movl $0x0, %r14d
cmpq %rbx, %r12
jb 0x4fe4
jmp 0x5135
movq 0xd9cb(%rip), %rsi      # 0x12af8
pushq $0xa
popq %rdi
callq 0x2100
movq %rbp, %r14
jmp 0x513d
addq %rbp, %r14
movq 0x10(%rsp), %rax
movl %r13d, (%rax)
subl %ebp, %r14d
movq 0x18(%rsp), %rax
movl %r14d, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq