// File: /workspace/github_c_makefile_star2_O1/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, %r14
movq %rdi, %r12
movq %r9, 0x18(%rsp)
movslq (%r9), %rbp
movslq %esi, %r13
addq %rdi, %r13
movq %rcx, 0x10(%rsp)
movl (%rcx), %ebx
movl %edx, 0xc(%rsp)
movslq %edx, %rax
movl $0x50, %ecx
subq %rax, %rcx
movq %rcx, 0x20(%rsp)
testq %r12, %r12
je 0x5294
cmpq %r13, %r12
jae 0x5286
callq 0x21f0
movq (%rax), %rdx
movsbq (%r12), %rcx
testb $0x20, 0x1(%rdx,%rcx,2)
jne 0x5286
cmpq $0xfe, %rbp
jg 0x5286
movb %cl, (%r14,%rbp)
incq %rbp
incq %r12
cmpq %r13, %r12
jb 0x525f
leaq (%r14,%rbp), %rax
cmpq %r13, %r12
jne 0x5297
jmp 0x53ae
xorl %r12d, %r12d
cmpl 0xc(%rsp), %ebx
jle 0x52ee
movslq %ebx, %rax
addq %rbp, %rax
cmpq $0x4e, %rax
jl 0x52ee
cmpq 0x20(%rsp), %rbp
jge 0x52ee
testq %r12, %r12
jne 0x52bb
cmpq $0x50, %rax
jl 0x52ee
movq 0xc826(%rip), %rsi      # 0x11ae8
movl $0xa, %edi
callq 0x2100
movq 0xc815(%rip), %rdi      # 0x11ae8
leaq 0x9d16(%rip), %rsi      # 0xeff0
movl 0xc(%rsp), %ebx
movl %ebx, %edx
leaq 0x6b59(%rip), %rcx      # 0xbe40
xorl %eax, %eax
callq 0x2110
addl %ebp, %ebx
testq %r12, %r12
je 0x5369
leaq (%r14,%rbp), %r15
cmpq %r13, %r12
jae 0x5346
callq 0x21f0
movq (%rax), %rdx
movsbq (%r12), %rcx
testb $0x20, 0x1(%rdx,%rcx,2)
je 0x5346
cmpq $0xfe, %rbp
jg 0x5346
cmpl $0x4d, %ebx
jg 0x5346
movb %cl, (%r15)
incl %ebx
xorl %ecx, %ecx
cmpb $0xa, (%r12)
setne %cl
movl $0x4e, %edx
cmovel %edx, %ebx
addq %rcx, %rbp
incq %r12
leaq (%r14,%rbp), %r15
cmpq %r13, %r12
jb 0x5303
cmpq %r13, %r12
jae 0x5372
callq 0x21f0
movq (%rax), %rax
movsbq (%r12), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x5372
incq %r12
cmpq %r13, %r12
jb 0x5353
jmp 0x5372
addq %r14, %rbp
movq %rbp, %r15
xorl %r12d, %r12d
movb $0x0, (%r15)
movq 0xc76b(%rip), %rsi      # 0x11ae8
movq %r14, %rdi
callq 0x20e0
testq %r12, %r12
je 0x539a
movl $0x0, %ebp
cmpq %r13, %r12
jb 0x5250
jmp 0x53ab
movq 0xc747(%rip), %rsi      # 0x11ae8
movl $0xa, %edi
callq 0x2100
movq %r14, %rax
movq 0x10(%rsp), %rcx
movl %ebx, (%rcx)
subl %r14d, %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq