// File: /workspace/github_cpp_makefile_star2_O3/attractivechaos[P]udb2/stb/./stb.h
// Function: stb_wordwrap
int stb_wordwrap(int *pairs, int pair_max, int count, char *str)
{
   int n=0,i=0, start=0,nonwhite=0;
   if (pairs == NULL) pair_max = 0x7ffffff0;
   else pair_max *= 2;
   // parse 
   for(;;) {
      int s=i; // first whitespace char; last nonwhite+1
      int w;   // word start
      // accept whitespace
      while (isspace(str[i])) {
         if (str[i] == '\n' || str[i] == '\r') {
            if (str[i] + str[i+1] == '\n' + '\r') ++i;
            if (n >= pair_max) return -1;
            if (pairs) pairs[n] = start, pairs[n+1] = s-start;
            n += 2;
            nonwhite=0;
            start = i+1;
            s = start;
         }
         ++i;
      }
      if (i >= start+count) {
         // we've gone off the end using whitespace
         if (nonwhite) {
            if (n >= pair_max) return -1;
            if (pairs) pairs[n] = start, pairs[n+1] = s-start;
            n += 2;
            start = s = i;
            nonwhite=0;
         } else {
            // output all the whitespace
            while (i >= start+count) {
               if (n >= pair_max) return -1;
               if (pairs) pairs[n] = start, pairs[n+1] = count;
               n += 2;
               start += count;
            }
            s = start;
         }
      }

      if (str[i] == 0) break;
      // now scan out a word and see if it fits
      w = i;
      while (str[i] && !isspace(str[i])) {
         ++i;
      }
      // wrapped?
      if (i > start + count) {
         // huge?
         if (i-s <= count) {
            if (n >= pair_max) return -1;
            if (pairs) pairs[n] = start, pairs[n+1] = s-start;
            n += 2;
            start = w;
         } else {
            // This word is longer than one line. If we wrap it onto N lines
            // there are leftover chars. do those chars fit on the cur line?
            // But if we have leading whitespace, we force it to start here.
            if ((w-start) + ((i-w) % count) <= count || !nonwhite) {
               // output a full line
               if (n >= pair_max) return -1;
               if (pairs) pairs[n] = start, pairs[n+1] = count;
               n += 2;
               start += count;
               w = start;
            } else {
               // output a partial line, trimming trailing whitespace
               if (s != start) {
                  if (n >= pair_max) return -1;
                  if (pairs) pairs[n] = start, pairs[n+1] = s-start;
                  n += 2;
                  start = w;
               }
            }
            // now output full lines as needed
            while (start + count <= i) {
               if (n >= pair_max) return -1;
               if (pairs) pairs[n] = start, pairs[n+1] = count;
               n += 2;
               start += count;
            }
         }
      }
      nonwhite=1;
   }
   if (start < i) {
      if (n >= pair_max) return -1;
      if (pairs) pairs[n] = start, pairs[n+1] = i-start;
      n += 2;
   }
   return n>>1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movl %edx, %r15d
movq %rdi, %rbx
addl %esi, %esi
testq %rdi, %rdi
movl $0x7ffffff0, %ebp       # imm = 0x7FFFFFF0
cmovnel %esi, %ebp
callq 0x23b0
movq (%rax), %rsi
movslq %ebp, %rdi
leaq 0x1(%r14), %rax
movq %rax, 0x10(%rsp)
xorl %ecx, %ecx
xorl %r10d, %r10d
xorl %r9d, %r9d
xorl %r12d, %r12d
movslq %r10d, %rax
movsbq (%r14,%rax), %rdx
testb $0x20, 0x1(%rsi,%rdx,2)
jne 0xcedf
movl %r10d, %r11d
jmp 0xcf45
movl %r10d, %r11d
movzbl %dl, %eax
cmpb $0xa, %al
je 0xceee
cmpl $0xd, %eax
jne 0xcf33
movslq %r11d, %rdx
movsbl 0x1(%r14,%rdx), %r8d
addl %eax, %r8d
cmpl $0x17, %r8d
jne 0xcf06
incq %rdx
movl %edx, %r11d
cmpl %ebp, %ecx
jge 0xd0df
testq %rbx, %rbx
je 0xcf22
movslq %ecx, %rax
movl %r9d, (%rbx,%rax,4)
subl %r9d, %r10d
movl %r10d, 0x4(%rbx,%rax,4)
addl $0x2, %ecx
incl %r11d
xorl %r12d, %r12d
movl %r11d, %r9d
movl %r11d, %r10d
jmp 0xcf36
incl %r11d
movslq %r11d, %rax
movsbq (%r14,%rax), %rdx
testb $0x20, 0x1(%rsi,%rdx,2)
jne 0xcee2
leal (%r9,%r15), %edx
cmpl %edx, %r11d
jge 0xcf53
movl %r12d, %r13d
jmp 0xcfb2
testl %r12d, %r12d
je 0xcf82
cmpl %ebp, %ecx
jge 0xd0df
testq %rbx, %rbx
je 0xcf74
movslq %ecx, %rdx
movl %r9d, (%rbx,%rdx,4)
subl %r9d, %r10d
movl %r10d, 0x4(%rbx,%rdx,4)
addl $0x2, %ecx
xorl %r13d, %r13d
movl %r11d, %r9d
movl %r11d, %r10d
jmp 0xcfb2
movslq %ecx, %rcx
cmpq %rdi, %rcx
jge 0xd0df
testq %rbx, %rbx
je 0xcf9c
movl %r9d, (%rbx,%rcx,4)
movl %r15d, 0x4(%rbx,%rcx,4)
addq $0x2, %rcx
addl %r15d, %r9d
leal (%r15,%r9), %edx
cmpl %edx, %r11d
jge 0xcf85
xorl %r13d, %r13d
movl %r9d, %r10d
cmpb $0x0, (%r14,%rax)
je 0xd0f3
movl %r10d, 0x4(%rsp)
movslq %r11d, %rax
movb (%r14,%rax), %dl
movl %r11d, %r10d
testb %dl, %dl
je 0xcfef
addq 0x10(%rsp), %rax
movl %r11d, %r10d
movsbq %dl, %rdx
testb $0x20, 0x1(%rsi,%rdx,2)
jne 0xcfef
incl %r10d
movb (%rax), %dl
incq %rax
testb %dl, %dl
jne 0xcfd8
leal (%r9,%r15), %r8d
movl $0x1, %r12d
cmpl %r8d, %r10d
jle 0xcecb
movl %r10d, %eax
movl 0x4(%rsp), %edx
subl %edx, %eax
cmpl %r15d, %eax
jle 0xd065
movq %rdi, 0x8(%rsp)
movl %r11d, %edi
subl %r9d, %edi
movl %r10d, %eax
subl %r11d, %eax
cltd
idivl %r15d
addl %edi, %edx
cmpl %r15d, %edx
setg %al
testl %r13d, %r13d
setne %dl
testb %dl, %al
je 0xd087
movl 0x4(%rsp), %edx
subl %r9d, %edx
je 0xd0a2
cmpl %ebp, %ecx
movq 0x8(%rsp), %rdi
jge 0xd0df
testq %rbx, %rbx
je 0xd05d
movslq %ecx, %rax
movl %r9d, (%rbx,%rax,4)
movl %edx, 0x4(%rbx,%rax,4)
addl $0x2, %ecx
movl %r11d, %r9d
jmp 0xd0a7
cmpl %ebp, %ecx
jge 0xd0df
testq %rbx, %rbx
je 0xd07c
movslq %ecx, %rax
movl %r9d, (%rbx,%rax,4)
subl %r9d, %edx
movl %edx, 0x4(%rbx,%rax,4)
addl $0x2, %ecx
movl %r11d, %r9d
jmp 0xcecb
cmpl %ebp, %ecx
jge 0xd0df
testq %rbx, %rbx
je 0xd09c
movslq %ecx, %rax
movl %r9d, (%rbx,%rax,4)
movl %r15d, 0x4(%rbx,%rax,4)
addl $0x2, %ecx
movl %r8d, %r9d
movq 0x8(%rsp), %rdi
leal (%r9,%r15), %eax
cmpl %r10d, %eax
jg 0xcecb
movslq %ecx, %rcx
cmpq %rdi, %rcx
jge 0xd0df
testq %rbx, %rbx
je 0xd0ca
movl %r9d, (%rbx,%rcx,4)
movl %r15d, 0x4(%rbx,%rcx,4)
addq $0x2, %rcx
addl %r15d, %r9d
leal (%r15,%r9), %eax
cmpl %r10d, %eax
jle 0xd0b7
jmp 0xcecb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl %r9d, %r11d
jle 0xd115
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ebp, %ecx
jge 0xd0e4
testq %rbx, %rbx
je 0xd112
movslq %ecx, %rax
movl %r9d, (%rbx,%rax,4)
movl %r11d, 0x4(%rbx,%rax,4)
addl $0x2, %ecx
sarl %ecx
movl %ecx, %eax
jmp 0xd0e4