// File: jaudoux[P]countTags/src/optionparser.h
// Function: option::PrintUsageImplementation::LineWrapper::process(option::PrintUsageImplementation::IStringWriter&, char const*, int)
void process(IStringWriter& write, const char* data, int len)
    {
      wrote_something = false;

      while (len > 0)
      {
        if (len <= width) // quick test that works because utf8width <= len (all wide chars have at least 2 bytes)
        {
          output(write, data, len);
          len = 0;
        }
        else // if (len > width)  it's possible (but not guaranteed) that utf8len > width
        {
          int utf8width = 0;
          int maxi = 0;
          while (maxi < len && utf8width < width)
          {
            int charbytes = 1;
            unsigned ch = (unsigned char) data[maxi];
            if (ch > 0xC1) // everything <= 0xC1 (yes, even 0xC1 itself) is not a valid UTF-8 start byte
            {
              // int __builtin_clz (unsigned int x)
              // Returns the number of leading 0-bits in x, starting at the most significant bit
              unsigned mask = (unsigned) -1 >> __builtin_clz(ch ^ 0xff);
              ch = ch & mask; // mask out length bits, we don't verify their correctness
              while ((maxi + charbytes < len) && //
                  (((unsigned char) data[maxi + charbytes] ^ 0x80) <= 0x3F)) // while next byte is continuation byte
              {
                ch = (ch << 6) ^ (unsigned char) data[maxi + charbytes] ^ 0x80; // add continuation to char code
                ++charbytes;
              }
              // ch is the decoded unicode code point
              if (ch >= 0x1100 && isWideChar(ch)) // the test for 0x1100 is here to avoid the function call in the Latin case
              {
                if (utf8width + 2 > width)
                  break;
                ++utf8width;
              }
            }
            ++utf8width;
            maxi += charbytes;
          }

          // data[maxi-1] is the last byte of the UTF-8 sequence of the last character that fits
          // onto the 1st line. If maxi == len, all characters fit on the line.

          if (maxi == len)
          {
            output(write, data, len);
            len = 0;
          }
          else // if (maxi < len)  at least 1 character (data[maxi] that is) doesn't fit on the line
          {
            int i;
            for (i = maxi; i >= 0; --i)
              if (data[i] == ' ')
                break;

            if (i >= 0)
            {
              output(write, data, i);
              data += i + 1;
              len -= i + 1;
            }
            else // did not find a space to split at => split before data[maxi]
            { // data[maxi] is always the beginning of a character, never a continuation byte
              output(write, data, maxi);
              data += maxi;
              len -= maxi;
            }
          }
        }
      }
      if (!wrote_something) // if we didn't already write something to make space in the buffer
        write_one_line(write); // write at most one line of actual output
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movb $0x0, 0xd0(%rax)
cmpl $0x0, -0x1c(%rbp)
jle 0x90f9
movq -0x40(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0xc4(%rcx), %eax
jg 0x8eff
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
callq 0x9490
movl $0x0, -0x1c(%rbp)
jmp 0x90f4
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x41(%rbp)
jge 0x8f2d
movq -0x40(%rbp), %rcx
movl -0x20(%rbp), %eax
cmpl 0xc4(%rcx), %eax
setl %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x8f39
jmp 0x902e
movl $0x1, -0x28(%rbp)
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x2c(%rbp)
cmpl $0xc1, -0x2c(%rbp)
jbe 0x9017
movl -0x2c(%rbp), %eax
xorl $0xff, %eax
bsrl %eax, %ecx
xorl $0x1f, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shrl %cl, %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
andl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x24(%rbp), %ecx
addl -0x28(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x42(%rbp)
jge 0x8fac
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
addl -0x28(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
xorl $0x80, %eax
cmpl $0x3f, %eax
setle %al
movb %al, -0x42(%rbp)
movb -0x42(%rbp), %al
testb $0x1, %al
jne 0x8fb5
jmp 0x8fe1
movl -0x2c(%rbp), %eax
shll $0x6, %eax
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %edx
addl -0x28(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
xorl %ecx, %eax
xorl $0x80, %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x8f7d
cmpl $0x1100, -0x2c(%rbp)    # imm = 0x1100
jb 0x9015
movl -0x2c(%rbp), %edi
callq 0x9370
testb $0x1, %al
jne 0x8ff8
jmp 0x9015
movq -0x40(%rbp), %rcx
movl -0x20(%rbp), %eax
addl $0x2, %eax
cmpl 0xc4(%rcx), %eax
jle 0x900c
jmp 0x902e
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x9017
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x28(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x8f0d
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x9056
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
callq 0x9490
movl $0x0, -0x1c(%rbp)
jmp 0x90f2
movl -0x24(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x9082
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0x9075
jmp 0x9082
jmp 0x9077
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x905c
cmpl $0x0, -0x34(%rbp)
jl 0x90c0
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x34(%rbp), %ecx
callq 0x9490
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x90f0
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x9490
movl -0x24(%rbp), %ecx
movq -0x18(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x24(%rbp), %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x90f2
jmp 0x90f4
jmp 0x8ec6
movq -0x40(%rbp), %rax
testb $0x1, 0xd0(%rax)
jne 0x9113
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x94e0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)