user: 请将以下的汇编代码转换成C语言代码：

```asm
<util_format_unsigned_encode_rgtc_ubyte>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xa8,%rsp
  mov    %rdi,0x20(%rsp)
  mov    %rsi,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  test   %ecx,%ecx
  jle    L397
  mov    %edx,%esi
  mov    %ecx,%ebp
  mov    $0x0,%ebx
  mov    $0x0,%r8d
  mov    $0x0,%r11d
  mov    $0xffffffff,%r9d
  mov    $0x0,%r10d
  mov    $0x0,%r13d
  mov    $0x1,%edi
  jmp    L659
L468:
  mov    %edi,%r8d
L54:
  add    $0x1,%edx
  movzbl %dl,%eax
  cmp    %esi,%eax
  jge    L911
L916:
  cltq
  movzbl (%rcx,%rax,1),%eax
  test   %al,%al
  je     L468
  cmp    $0xff,%al
  je     L11
  cmp    %al,%r10b
  cmovb  %eax,%r10d
  cmp    %al,%r9b
  cmova  %eax,%r9d
  jmp    L54
L11:
  mov    %edi,%ebx
  jmp    L54
L911:
  add    $0x1,%r11d
  movzbl %r11b,%eax
  cmp    %ebp,%eax
  jge    L427
L659:
  test   %esi,%esi
  jle    L911
  movzbl %r11b,%eax
  lea    (%r12,%rax,4),%rcx
  mov    $0x0,%edx
  mov    %r13d,%eax
  jmp    L916
L427:
  cmp    %r9b,%r10b
  jb     L904
  jne    L551
  mov    %r8d,%eax
  or     %ebx,%eax
  je     L397
L551:
  test   %r8d,%r8d
  mov    $0x0,%eax
  cmove  %r9d,%eax
  mov    %al,0x18(%rsp)
  test   %ebx,%ebx
  mov    $0xffffffff,%eax
  cmove  %r10d,%eax
  mov    %al,0x1b(%rsp)
L382:
  movzbl 0x1b(%rsp),%eax
  mov    %eax,%ebx
  mov    %eax,0x3c(%rsp)
  movzbl 0x18(%rsp),%edi
  mov    %edi,0x40(%rsp)
  mov    %edi,%r8d
  sub    %eax,%r8d
  add    %r8d,%r8d
  lea    (%rax,%rax,2),%eax
  lea    (%rbx,%rax,4),%edx
  add    %edi,%edx
  lea    0x59(%rsp),%rax
  mov    %rax,0x28(%rsp)
  lea    0x60(%rsp),%r11
  mov    %rax,%rcx
L400:
  movslq %edx,%rax
  imul   $0xffffffff92492493,%rax,%rax
  shr    $0x20,%rax
  add    %edx,%eax
  sar    $0x3,%eax
  mov    %edx,%edi
  sar    $0x1f,%edi
  sub    %edi,%eax
  mov    %al,(%rcx)
  add    %r8d,%edx
  add    $0x1,%rcx
  cmp    %r11,%rcx
  jne    L400
  test   %ebp,%ebp
  jle    L640
  movzbl 0x59(%rsp),%ebx
  movzbl 0x5a(%rsp),%r13d
  movzbl 0x5b(%rsp),%r15d
  movzbl 0x5c(%rsp),%eax
  mov    %al,0x38(%rsp)
  movzbl 0x5d(%rsp),%edi
  mov    %dil,0xe(%rsp)
  movzbl 0x5e(%rsp),%edi
  mov    %dil,0x1c(%rsp)
  movzbl 0x5f(%rsp),%edi
  mov    %dil,0x34(%rsp)
  movzbl 0x18(%rsp),%ecx
  movzbl 0x1b(%rsp),%edi
  lea    (%rcx,%rcx,1),%r14d
  lea    (%r14,%rcx,1),%eax
  lea    (%rdi,%rax,2),%eax
  movslq %eax,%rdx
  imul   $0xffffffff92492493,%rdx,%rdx
  shr    $0x20,%rdx
  add    %edx,%eax
  sar    $0x2,%eax
  mov    %eax,%edx
  neg    %edx
  mov    %dx,0x4c(%rsp)
  lea    (%rdi,%rdi,1),%r11d
  lea    0x0(,%rcx,4),%eax
  lea    (%rax,%rcx,1),%edx
  add    %r11d,%edx
  movslq %edx,%r8
  imul   $0xffffffff92492493,%r8,%r8
  shr    $0x20,%r8
  add    %r8d,%edx
  sar    $0x2,%edx
  neg    %edx
  mov    %dx,0x30(%rsp)
  add    %edi,%r11d
  add    %r11d,%eax
  movslq %eax,%rdx
  imul   $0xffffffff92492493,%rdx,%rdx
  shr    $0x20,%rdx
  add    %edx,%eax
  sar    $0x2,%eax
  mov    %eax,%edx
  neg    %edx
  mov    %dx,0x10(%rsp)
  lea    (%r14,%rcx,1),%edx
  lea    0x0(,%rdi,4),%eax
  add    %eax,%edx
  movslq %edx,%r8
  imul   $0xffffffff92492493,%r8,%r8
  shr    $0x20,%r8
  add    %r8d,%edx
  sar    $0x2,%edx
  neg    %edx
  mov    %dx,0xc(%rsp)
  add    %edi,%eax
  add    %r14d,%eax
  movslq %eax,%rdx
  imul   $0xffffffff92492493,%rdx,%rdx
  shr    $0x20,%rdx
  add    %edx,%eax
  sar    $0x2,%eax
  mov    %eax,%edx
  neg    %edx
  mov    %dx,0xa(%rsp)
  lea    (%rcx,%r11,2),%eax
  movslq %eax,%rdx
  imul   $0xffffffff92492493,%rdx,%rdx
  shr    $0x20,%rdx
  add    %edx,%eax
  sar    $0x2,%eax
  mov    %eax,%ecx
  neg    %ecx
  mov    %cx,0x8(%rsp)
  mov    $0x0,%r14d
  mov    $0x0,%edi
  mov    $0x0,%r8d
  movzbl 0x18(%rsp),%ecx
  mov    %cx,0x44(%rsp)
  movzbl 0x1b(%rsp),%ecx
  movzbl 0x38(%rsp),%r11d
  mov    %r10b,0x18(%rsp)
  mov    %r9b,0x1b(%rsp)
  mov    %ecx,%r10d
  jmp    L322
L904:
  test   %r8d,%r8d
  je     L397
  test   %ebx,%ebx
  je     L397
  movb   $0x0,0x18(%rsp)
  movb   $0xff,0x1b(%rsp)
  jmp    L382
L397:
  movzbl (%r12),%eax
  mov    0x20(%rsp),%rbx
  mov    %al,(%rbx)
  movb   $0x0,0x2(%rbx)
  movb   $0x0,0x3(%rbx)
  movb   $0x0,0x4(%rbx)
  movb   $0x0,0x5(%rbx)
  movb   $0x0,0x6(%rbx)
  movb   $0x0,0x7(%rbx)
L64:
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L1136
  add    $0xa8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L421:
  cmp    %r13b,%al
  jbe    L1148
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x2,0x60(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x8(%rsp),%ax
L1001:
  cwtl
  imul   %eax,%eax
  add    %eax,%edi
  add    $0x1,%ecx
  movzbl %cl,%edx
  cmp    %esi,%edx
  jge    L99
L1078:
  movslq %edx,%rax
  movzbl (%r9,%rax,1),%eax
  cmp    %bl,%al
  jbe    L421
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x0,0x60(%rsp,%rdx,1)
  movzbl %al,%eax
  sub    %r10d,%eax
  jmp    L1001
L1148:
  cmp    %r15b,%al
  jbe    L1
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x3,0x60(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0xa(%rsp),%ax
  jmp    L1001
L1:
  cmp    %r11b,%al
  jbe    L1139
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x4,0x60(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0xc(%rsp),%ax
  jmp    L1001
L1139:
  cmp    0xe(%rsp),%al
  jbe    L885
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x5,0x60(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x10(%rsp),%ax
  jmp    L1001
L885:
  cmp    0x1c(%rsp),%al
  jbe    L594
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x6,0x60(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x30(%rsp),%ax
  jmp    L1001
L594:
  cmp    0x34(%rsp),%al
  jbe    L308
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x7,0x60(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x4c(%rsp),%ax
  jmp    L1001
L308:
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x1,0x60(%rsp,%rdx,1)
  movzbl %al,%eax
  sub    0x44(%rsp),%ax
  jmp    L1001
L99:
  add    $0x1,%r14d
  movzbl %r14b,%r8d
  cmp    %ebp,%r8d
  jge    L1149
L322:
  test   %esi,%esi
  jle    L99
  movzbl %r14b,%eax
  lea    (%r12,%rax,4),%r9
  shl    $0x2,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  jmp    L1078
L1149:
  movzbl 0x18(%rsp),%r10d
  movzbl 0x1b(%rsp),%r9d
  cmp    $0x1f,%edi
  jbe    L640
  movzbl %r10b,%eax
  mov    %eax,0x34(%rsp)
  movzbl %r9b,%ebx
  mov    %ebx,0x38(%rsp)
  mov    %eax,%r11d
  sub    %ebx,%r11d
  add    %r11d,%r11d
  lea    (%rbx,%rbx,8),%edx
  add    %eax,%edx
  mov    0x28(%rsp),%rcx
  lea    0x5(%rcx),%rbx
  mov    %rbx,0x10(%rsp)
L154:
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x22,%rax
  mov    %edx,%r8d
  sar    $0x1f,%r8d
  sub    %r8d,%eax
  mov    %al,(%rcx)
  add    %r11d,%edx
  add    $0x1,%rcx
  cmp    %rbx,%rcx
  jne    L154
  movzbl 0x59(%rsp),%ebx
  movzbl 0x5a(%rsp),%r13d
  movzbl 0x5b(%rsp),%r8d
  movzbl 0x5c(%rsp),%eax
  mov    %al,0xe(%rsp)
  movzbl 0x5d(%rsp),%eax
  mov    %al,0x1b(%rsp)
  movzbl %r10b,%r15d
  mov    %r15d,0x48(%rsp)
  movzbl %r9b,%ecx
  mov    %ecx,%r14d
  mov    %ecx,0x44(%rsp)
  lea    (%rcx,%r15,4),%eax
  cltq
  imul   $0x66666667,%rax,%rax
  sar    $0x21,%rax
  neg    %eax
  mov    %ax,0x30(%rsp)
  lea    (%r15,%r15,1),%eax
  lea    (%rax,%r15,1),%edx
  lea    (%rcx,%rcx,1),%ecx
  add    %ecx,%edx
  movslq %edx,%rdx
  imul   $0x66666667,%rdx,%rdx
  sar    $0x21,%rdx
  neg    %edx
  mov    %dx,0x18(%rsp)
  add    %r14d,%ecx
  add    %ecx,%eax
  cltq
  imul   $0x66666667,%rax,%rax
  sar    $0x21,%rax
  neg    %eax
  mov    %ax,0xc(%rsp)
  lea    (%r15,%r14,4),%eax
  cltq
  imul   $0x66666667,%rax,%rax
  sar    $0x21,%rax
  neg    %eax
  mov    %ax,0xa(%rsp)
  mov    $0x0,%r11d
  mov    $0x0,%ecx
  mov    $0x0,%eax
  mov    $0x0,%r15d
  movzbl %r10b,%edx
  mov    %dx,0x4c(%rsp)
  movzbl %r9b,%edx
  mov    %dx,0x8(%rsp)
  mov    $0x0,%r14d
  mov    %edi,0x1c(%rsp)
  mov    %r8d,%edi
  jmp    L145
L1088:
  cmp    $0xff,%al
  je     L492
  cmp    %bl,%al
  ja     L662
  add    %r9d,%edx
  movslq %edx,%rdx
  movb   $0x0,0x70(%rsp,%rdx,1)
  movzbl %al,%eax
  sub    0x8(%rsp),%ax
  jmp    L902
L492:
  add    %r9d,%edx
  movslq %edx,%rdx
  movb   $0x7,0x70(%rsp,%rdx,1)
  mov    %r14d,%eax
L902:
  cwtl
  imul   %eax,%eax
  add    %eax,%ecx
  add    $0x1,%r8d
  movzbl %r8b,%edx
  cmp    %esi,%edx
  jge    L855
L1035:
  movslq %edx,%rax
  movzbl (%r10,%rax,1),%eax
  test   %al,%al
  jne    L1088
  add    %r9d,%edx
  movslq %edx,%rdx
  movb   $0x6,0x70(%rsp,%rdx,1)
  mov    %r14d,%eax
  jmp    L902
L662:
  cmp    %r13b,%al
  ja     L1081
  add    %r9d,%edx
  movslq %edx,%rdx
  movb   $0x2,0x70(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0xa(%rsp),%ax
  jmp    L902
L1081:
  cmp    %dil,%al
  ja     L74
  add    %r9d,%edx
  movslq %edx,%rdx
  movb   $0x3,0x70(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0xc(%rsp),%ax
  jmp    L902
L74:
  cmp    0xe(%rsp),%al
  ja     L240
  add    %r9d,%edx
  movslq %edx,%rdx
  movb   $0x4,0x70(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x18(%rsp),%ax
  jmp    L902
L240:
  cmp    0x1b(%rsp),%al
  ja     L294
  add    %r9d,%edx
  movslq %edx,%rdx
  movb   $0x5,0x70(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x30(%rsp),%ax
  jmp    L902
L294:
  add    %r9d,%edx
  movslq %edx,%rdx
  movb   $0x1,0x70(%rsp,%rdx,1)
  movzbl %al,%eax
  sub    0x4c(%rsp),%ax
  jmp    L902
L855:
  add    $0x1,%r11d
  movzbl %r11b,%eax
  cmp    %ebp,%eax
  jge    L24
L145:
  test   %esi,%esi
  jle    L855
  movzbl %r11b,%edx
  lea    (%r12,%rdx,4),%r10
  lea    0x0(,%rax,4),%r9d
  mov    $0x0,%r8d
  mov    %r15d,%edx
  jmp    L1035
L123:
  add    $0x1,%edx
  movzbl %dl,%eax
  cmp    %esi,%eax
  jge    L236
L1130:
  cltq
  movzbl (%r8,%rax,1),%r11d
  movzbl %r11b,%eax
  movswl %r10w,%ebx
  cmp    %ebx,%eax
  jle    L98
  movzbl %r11b,%ebx
  cmp    %r14d,%eax
  cmovle %ebx,%r10d
L98:
  movswl %r9w,%ebx
  cmp    %ebx,%eax
  jge    L123
  movzbl %r11b,%r11d
  cmp    %r13d,%eax
  cmovg  %r11d,%r9d
  jmp    L123
L236:
  add    $0x1,%r15d
  movzbl %r15b,%eax
  cmp    %ebp,%eax
  jge    L614
L458:
  test   %esi,%esi
  jle    L236
  movzbl %r15b,%eax
  lea    (%r12,%rax,4),%r8
  mov    $0x0,%edx
  mov    $0x0,%eax
  jmp    L1130
L614:
  cmp    %r10w,%r9w
  jge    L181
L598:
  movswl %r10w,%eax
  movswl %r9w,%edx
  mov    %eax,%r8d
  sub    %edx,%r8d
  lea    (%r8,%r8,1),%ebx
  lea    (%rdx,%rdx,8),%edx
  add    %eax,%edx
  mov    0x28(%rsp),%r8
  mov    0x10(%rsp),%r11
L404:
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x22,%rax
  mov    %edx,%r13d
  sar    $0x1f,%r13d
  sub    %r13d,%eax
  mov    %al,(%r8)
  add    %ebx,%edx
  add    $0x1,%r8
  cmp    %r11,%r8
  jne    L404
  mov    %r9d,%ebx
  shr    $0xf,%bx
  add    %r9d,%ebx
  sar    %bx
  movswl %bx,%ebx
  movswl %r10w,%r15d
  lea    0xff(%r15),%edx
  mov    %edx,%eax
  shr    $0x1f,%eax
  lea    (%rax,%rdx,1),%r14d
  sar    %r14d
  movzbl 0x59(%rsp),%eax
  mov    %al,0x30(%rsp)
  movzbl 0x5a(%rsp),%edx
  mov    %dl,0xa(%rsp)
  movzbl 0x5b(%rsp),%edx
  mov    %dl,0xe(%rsp)
  movzbl 0x5c(%rsp),%edx
  mov    %dl,0x1b(%rsp)
  movzbl 0x5d(%rsp),%edx
  mov    %dl,0x44(%rsp)
  movswl %r9w,%r11d
  lea    (%r11,%r15,4),%edx
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x21,%rax
  sar    $0x1f,%edx
  sub    %eax,%edx
  mov    %dx,0x4e(%rsp)
  lea    (%r11,%r11,1),%eax
  lea    (%r15,%r15,1),%r13d
  lea    0x0(%r13,%r15,1),%edx
  add    %eax,%edx
  movslq %edx,%r8
  imul   $0x66666667,%r8,%r8
  sar    $0x21,%r8
  sar    $0x1f,%edx
  sub    %r8d,%edx
  mov    %dx,0x4c(%rsp)
  add    %r11d,%eax
  add    %r13d,%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  sar    $0x21,%rdx
  sar    $0x1f,%eax
  sub    %edx,%eax
  mov    %ax,0x18(%rsp)
  lea    (%r15,%r11,4),%edx
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x21,%rax
  sar    $0x1f,%edx
  sub    %eax,%edx
  mov    %dx,0xc(%rsp)
  mov    $0x0,%r11d
  mov    $0x0,%r13d
  mov    $0x0,%edx
  mov    $0x0,%r8d
  mov    $0x0,%r15d
  mov    %r10w,0x1c(%rsp)
  mov    %r9w,0x8(%rsp)
  movzbl 0x30(%rsp),%r10d
  mov    %edx,%r9d
  mov    %ecx,0x30(%rsp)
  mov    %edi,0x48(%rsp)
  jmp    L977
L181:
  mov    $0xfe,%r10d
  mov    $0x1,%r9d
  jmp    L598
L865:
  cmp    0xa(%rsp),%al
  ja     L954
  movzbl %al,%eax
  add    0xc(%rsp),%ax
  add    %eax,%r8d
  add    %eax,%r9d
  add    $0x1,%r13d
  add    $0x1,%r11d
L689:
  add    $0x1,%edx
  movzbl %dl,%eax
  cmp    %esi,%eax
  jge    L783
L973:
  cltq
  movzbl (%rdi,%rax,1),%eax
  movzbl %al,%ecx
  cmp    %ebx,%ecx
  jle    L689
  cmp    %r14d,%ecx
  jg     L689
  cmp    %r10b,%al
  ja     L865
  movzbl %al,%eax
  sub    0x8(%rsp),%ax
  add    %eax,%r8d
  add    $0x1,%r13d
  jmp    L689
L954:
  cmp    0xe(%rsp),%al
  ja     L730
  movzbl %al,%eax
  add    0x18(%rsp),%ax
  add    %eax,%r8d
  add    %eax,%r9d
  add    $0x1,%r13d
  add    $0x1,%r11d
  jmp    L689
L730:
  cmp    0x1b(%rsp),%al
  ja     L758
  movzbl %al,%eax
  add    0x4c(%rsp),%ax
  add    %eax,%r8d
  add    %eax,%r9d
  add    $0x1,%r13d
  add    $0x1,%r11d
  jmp    L689
L758:
  cmp    0x44(%rsp),%al
  ja     L987
  movzbl %al,%eax
  add    0x4e(%rsp),%ax
  add    %eax,%r8d
  add    %eax,%r9d
  add    $0x1,%r13d
  add    $0x1,%r11d
  jmp    L689
L987:
  movzbl %al,%eax
  sub    0x1c(%rsp),%ax
  add    %eax,%r9d
  add    $0x1,%r11d
  jmp    L689
L783:
  add    $0x1,%r15d
  movzbl %r15b,%eax
  cmp    %ebp,%eax
  jge    L693
L977:
  test   %esi,%esi
  jle    L783
  movzbl %r15b,%eax
  lea    (%r12,%rax,4),%rdi
  mov    $0x0,%edx
  mov    $0x0,%eax
  jmp    L973
L693:
  movzwl 0x1c(%rsp),%r10d
  mov    %r9d,%r15d
  movzwl 0x8(%rsp),%r9d
  mov    0x30(%rsp),%ecx
  mov    0x48(%rsp),%edi
  movswl %r8w,%eax
  test   %r13b,%r13b
  mov    $0x1,%edx
  cmovne %r13d,%edx
  movzbl %dl,%r8d
  cltd
  idiv   %r8d
  lea    (%r9,%rax,1),%ebx
  test   %bx,%bx
  mov    $0x0,%eax
  cmovns %ebx,%eax
  mov    %eax,%ebx
  mov    %ax,0x8(%rsp)
  movswl %r15w,%eax
  test   %r11b,%r11b
  mov    $0x1,%edx
  cmove  %edx,%r11d
  movzbl %r11b,%r8d
  cltd
  idiv   %r8d
  lea    (%r10,%rax,1),%edx
  mov    $0xff,%eax
  cmp    %ax,%dx
  cmovle %edx,%eax
  mov    %ax,0xe(%rsp)
  movswl %ax,%r8d
  movswl %bx,%eax
  mov    %r8d,%edx
  sub    %eax,%edx
  lea    (%rdx,%rdx,1),%r9d
  lea    (%rax,%rax,8),%edx
  add    %r8d,%edx
  mov    0x28(%rsp),%r8
  mov    0x10(%rsp),%r11
L963:
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x22,%rax
  mov    %edx,%r10d
  sar    $0x1f,%r10d
  sub    %r10d,%eax
  mov    %al,(%r8)
  add    %r9d,%edx
  add    $0x1,%r8
  cmp    %r11,%r8
  jne    L963
  movzwl 0x8(%rsp),%r15d
  mov    %r15d,%r13d
  shr    $0xf,%r13w
  add    %r15d,%r13d
  sar    %r13w
  movswl %r13w,%r13d
  movswl 0xe(%rsp),%r8d
  lea    0xff(%r8),%edx
  mov    %edx,%eax
  shr    $0x1f,%eax
  lea    (%rax,%rdx,1),%r14d
  sar    %r14d
  movzbl 0x59(%rsp),%ebx
  movzbl 0x5a(%rsp),%eax
  mov    %al,0x10(%rsp)
  movzbl 0x5b(%rsp),%edx
  mov    %dl,0xc(%rsp)
  movzbl 0x5c(%rsp),%edx
  mov    %dl,0x1b(%rsp)
  movzbl 0x5d(%rsp),%edx
  mov    %dl,0x30(%rsp)
  movswl %r15w,%r10d
  lea    (%r10,%r8,4),%edx
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x21,%rax
  sar    $0x1f,%edx
  sub    %eax,%edx
  mov    %dx,0x4c(%rsp)
  lea    (%r8,%r8,1),%r11d
  lea    (%r11,%r8,1),%edx
  lea    (%r10,%r10,1),%eax
  add    %eax,%edx
  movslq %edx,%r9
  imul   $0x66666667,%r9,%r9
  sar    $0x21,%r9
  sar    $0x1f,%edx
  sub    %r9d,%edx
  mov    %dx,0x28(%rsp)
  add    %r10d,%eax
  add    %r11d,%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  sar    $0x21,%rdx
  sar    $0x1f,%eax
  sub    %edx,%eax
  mov    %ax,0x18(%rsp)
  lea    (%r8,%r10,4),%edx
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x21,%rax
  sar    $0x1f,%edx
  sub    %eax,%edx
  mov    %dx,0xa(%rsp)
  mov    $0x0,%r15d
  mov    $0x0,%r10d
  mov    $0x0,%r11d
  mov    %r11d,%r8d
  movzbl 0x10(%rsp),%r11d
  mov    %ecx,0x10(%rsp)
  mov    %edi,0x1c(%rsp)
  jmp    L1120
L163:
  cmp    %r14d,%edi
  jle    L1023
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x7,0x80(%rsp,%rdx,1)
  movzbl %al,%edx
  mov    $0xff,%eax
  sub    %edx,%eax
L539:
  cwtl
  imul   %eax,%eax
  add    %eax,%r10d
  add    $0x1,%ecx
  movzbl %cl,%edx
  cmp    %esi,%edx
  jge    L721
L593:
  movslq %edx,%rax
  movzbl (%r9,%rax,1),%eax
  movzbl %al,%edi
  cmp    %r13d,%edi
  jg     L163
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x6,0x80(%rsp,%rdx,1)
  movzbl %al,%eax
  jmp    L539
L1023:
  cmp    %bl,%al
  ja     L119
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x0,0x80(%rsp,%rdx,1)
  movzbl %al,%eax
  sub    0x8(%rsp),%ax
  jmp    L539
L119:
  cmp    %r11b,%al
  ja     L42
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x2,0x80(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0xa(%rsp),%ax
  jmp    L539
L42:
  cmp    0xc(%rsp),%al
  ja     L569
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x3,0x80(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x18(%rsp),%ax
  jmp    L539
L569:
  cmp    0x1b(%rsp),%al
  ja     L1084
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x4,0x80(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x28(%rsp),%ax
  jmp    L539
L1084:
  cmp    0x30(%rsp),%al
  ja     L881
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x5,0x80(%rsp,%rdx,1)
  movzbl %al,%eax
  add    0x4c(%rsp),%ax
  jmp    L539
L881:
  add    %r8d,%edx
  movslq %edx,%rdx
  movb   $0x1,0x80(%rsp,%rdx,1)
  movzbl %al,%eax
  sub    0xe(%rsp),%ax
  jmp    L539
L721:
  add    $0x1,%r15d
  movzbl %r15b,%r8d
  cmp    %ebp,%r8d
  jge    L435
L1120:
  test   %esi,%esi
  jle    L721
  movzbl %r15b,%eax
  lea    (%r12,%rax,4),%r9
  shl    $0x2,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  jmp    L593
L435:
  mov    0x10(%rsp),%ecx
  mov    0x1c(%rsp),%edi
  cmp    %r10d,%ecx
  mov    %r10d,%eax
  cmovbe %ecx,%eax
  cmp    %edi,%eax
  jae    L640
  cmp    %r10d,%ecx
  jbe    L195
  lea    0x80(%rsp),%rcx
  movzbl 0xe(%rsp),%edx
  movzbl 0x8(%rsp),%esi
  mov    0x20(%rsp),%rdi
  mov    $0x0,%eax
  call   <util_format_unsigned_write_rgtc_encoded_channel@plt>
  jmp    L64
L640:
  lea    0x60(%rsp),%rcx
  mov    0x40(%rsp),%edx
  mov    0x3c(%rsp),%esi
  mov    0x20(%rsp),%rdi
  mov    $0x0,%eax
  call   <util_format_unsigned_write_rgtc_encoded_channel@plt>
  jmp    L64
L781:
  cmp    %ecx,%edi
  jbe    L640
L195:
  lea    0x70(%rsp),%rcx
  mov    0x34(%rsp),%edx
  mov    0x38(%rsp),%esi
  mov    0x20(%rsp),%rdi
  mov    $0x0,%eax
  call   <util_format_unsigned_write_rgtc_encoded_channel@plt>
  jmp    L64
L24:
  mov    0x1c(%rsp),%edi
  cmp    $0x60,%ecx
  jbe    L781
  cmp    $0x60,%edi
  jbe    L781
  mov    0x48(%rsp),%eax
  sub    0x44(%rsp),%eax
  movslq %eax,%r13
  imul   $0xffffffff92492493,%r13,%r13
  shr    $0x20,%r13
  add    %eax,%r13d
  sar    $0x4,%r13d
  sar    $0x1f,%eax
  mov    %eax,%r14d
  sub    %r13d,%r14d
  add    $0xfe,%r14d
  sub    %eax,%r13d
  mov    $0x0,%r10d
  mov    $0x0,%r15d
  mov    $0xff,%r9d
  jmp    L458
L1136:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void util_format_unsigned_encode_rgtc_ubyte(unsigned char *blkaddr, unsigned char srccolors[4][4], int numxpixels, int numypixels) {
  unsigned char alphabase[2], alphause[2];
  short alphatest[2] = {0};
  unsigned int alphablockerror1, alphablockerror2, alphablockerror3;
  unsigned char i, j, aindex, acutValues[7];
  unsigned char alphaenc1[16], alphaenc2[16], alphaenc3[16];
  int alphaabsmin = 0, alphaabsmax = 0;
  short alphadist;
  alphabase[0] = 0xff;
  alphabase[1] = 0;
  for (j = 0; j < numypixels; j++) {
    for (i = 0; i < numxpixels; i++) {
      if (srccolors[j][i] == 0)
        alphaabsmin = 1;
      else if (srccolors[j][i] == 0xff)
        alphaabsmax = 1;
      else {
        if (srccolors[j][i] > alphabase[1])
          alphabase[1] = srccolors[j][i];
        if (srccolors[j][i] < alphabase[0])
          alphabase[0] = srccolors[j][i];
      }
    }
  }
  if (((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax)) {
    *blkaddr++ = srccolors[0][0];
    blkaddr++;
    *blkaddr++ = 0;
    *blkaddr++ = 0;
    *blkaddr++ = 0;
    *blkaddr++ = 0;
    *blkaddr++ = 0;
    *blkaddr++ = 0;
    return;
  }
  alphablockerror1 = 0x0;
  alphablockerror2 = 0xffffffff;
  alphablockerror3 = 0xffffffff;
  if (alphaabsmin)
    alphause[0] = 0;
  else
    alphause[0] = alphabase[0];
  if (alphaabsmax)
    alphause[1] = 0xff;
  else
    alphause[1] = alphabase[1];
  for (aindex = 0; aindex < 7; aindex++) {
    acutValues[aindex] = (alphause[0] * (2 * aindex + 1) + alphause[1] * (14 - (2 * aindex + 1))) / 14;
  }
  for (j = 0; j < numypixels; j++) {
    for (i = 0; i < numxpixels; i++) {
      if (srccolors[j][i] > acutValues[0]) {
        alphaenc1[4 * j + i] = 0;
        alphadist = srccolors[j][i] - alphause[1];
      } else if (srccolors[j][i] > acutValues[1]) {
        alphaenc1[4 * j + i] = 2;
        alphadist = srccolors[j][i] - (alphause[1] * 6 + alphause[0] * 1) / 7;
      } else if (srccolors[j][i] > acutValues[2]) {
        alphaenc1[4 * j + i] = 3;
        alphadist = srccolors[j][i] - (alphause[1] * 5 + alphause[0] * 2) / 7;
      } else if (srccolors[j][i] > acutValues[3]) {
        alphaenc1[4 * j + i] = 4;
        alphadist = srccolors[j][i] - (alphause[1] * 4 + alphause[0] * 3) / 7;
      } else if (srccolors[j][i] > acutValues[4]) {
        alphaenc1[4 * j + i] = 5;
        alphadist = srccolors[j][i] - (alphause[1] * 3 + alphause[0] * 4) / 7;
      } else if (srccolors[j][i] > acutValues[5]) {
        alphaenc1[4 * j + i] = 6;
        alphadist = srccolors[j][i] - (alphause[1] * 2 + alphause[0] * 5) / 7;
      } else if (srccolors[j][i] > acutValues[6]) {
        alphaenc1[4 * j + i] = 7;
        alphadist = srccolors[j][i] - (alphause[1] * 1 + alphause[0] * 6) / 7;
      } else {
        alphaenc1[4 * j + i] = 1;
        alphadist = srccolors[j][i] - alphause[0];
      }
      alphablockerror1 += alphadist * alphadist;
    }
  }
  if (alphablockerror1 >= 32) {
    alphablockerror2 = 0;
    for (aindex = 0; aindex < 5; aindex++) {
      acutValues[aindex] = (alphabase[0] * (10 - (2 * aindex + 1)) + alphabase[1] * (2 * aindex + 1)) / 10;
    }
    for (j = 0; j < numypixels; j++) {
      for (i = 0; i < numxpixels; i++) {
        if (srccolors[j][i] == 0) {
          alphaenc2[4 * j + i] = 6;
          alphadist = 0;
        } else if (srccolors[j][i] == 0xff) {
          alphaenc2[4 * j + i] = 7;
          alphadist = 0;
        } else if (srccolors[j][i] <= acutValues[0]) {
          alphaenc2[4 * j + i] = 0;
          alphadist = srccolors[j][i] - alphabase[0];
        } else if (srccolors[j][i] <= acutValues[1]) {
          alphaenc2[4 * j + i] = 2;
          alphadist = srccolors[j][i] - (alphabase[0] * 4 + alphabase[1] * 1) / 5;
        } else if (srccolors[j][i] <= acutValues[2]) {
          alphaenc2[4 * j + i] = 3;
          alphadist = srccolors[j][i] - (alphabase[0] * 3 + alphabase[1] * 2) / 5;
        } else if (srccolors[j][i] <= acutValues[3]) {
          alphaenc2[4 * j + i] = 4;
          alphadist = srccolors[j][i] - (alphabase[0] * 2 + alphabase[1] * 3) / 5;
        } else if (srccolors[j][i] <= acutValues[4]) {
          alphaenc2[4 * j + i] = 5;
          alphadist = srccolors[j][i] - (alphabase[0] * 1 + alphabase[1] * 4) / 5;
        } else {
          alphaenc2[4 * j + i] = 1;
          alphadist = srccolors[j][i] - alphabase[1];
        }
        alphablockerror2 += alphadist * alphadist;
      }
    }
    if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) {
      short blockerrlin1 = 0;
      short blockerrlin2 = 0;
      unsigned char nralphainrangelow = 0;
      unsigned char nralphainrangehigh = 0;
      alphatest[0] = 0xff;
      alphatest[1] = 0;
      for (j = 0; j < numypixels; j++) {
        for (i = 0; i < numxpixels; i++) {
          if ((srccolors[j][i] > alphatest[1]) && (srccolors[j][i] < (0xff - (alphabase[1] - alphabase[0]) / 28)))
            alphatest[1] = srccolors[j][i];
          if ((srccolors[j][i] < alphatest[0]) && (srccolors[j][i] > (alphabase[1] - alphabase[0]) / 28))
            alphatest[0] = srccolors[j][i];
        }
      }
      if (alphatest[1] <= alphatest[0]) {
        alphatest[0] = 0 + 1;
        alphatest[1] = 0xff - 1;
      }
      for (aindex = 0; aindex < 5; aindex++) {
        acutValues[aindex] = (alphatest[0] * (10 - (2 * aindex + 1)) + alphatest[1] * (2 * aindex + 1)) / 10;
      }
      for (j = 0; j < numypixels; j++) {
        for (i = 0; i < numxpixels; i++) {
          if (srccolors[j][i] <= alphatest[0] / 2) {
          } else if (srccolors[j][i] > ((0xff + alphatest[1]) / 2)) {
          } else if (srccolors[j][i] <= acutValues[0]) {
            blockerrlin1 += (srccolors[j][i] - alphatest[0]);
            nralphainrangelow += 1;
          } else if (srccolors[j][i] <= acutValues[1]) {
            blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5);
            blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5);
            nralphainrangelow += 1;
            nralphainrangehigh += 1;
          } else if (srccolors[j][i] <= acutValues[2]) {
            blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5);
            blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5);
            nralphainrangelow += 1;
            nralphainrangehigh += 1;
          } else if (srccolors[j][i] <= acutValues[3]) {
            blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5);
            blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5);
            nralphainrangelow += 1;
            nralphainrangehigh += 1;
          } else if (srccolors[j][i] <= acutValues[4]) {
            blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5);
            blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5);
            nralphainrangelow += 1;
            nralphainrangehigh += 1;
          } else {
            blockerrlin2 += (srccolors[j][i] - alphatest[1]);
            nralphainrangehigh += 1;
          }
        }
      }
      if (nralphainrangelow == 0)
        nralphainrangelow = 1;
      if (nralphainrangehigh == 0)
        nralphainrangehigh = 1;
      alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow);
      if (alphatest[0] < 0) {
        alphatest[0] = 0;
      }
      alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh);
      if (alphatest[1] > 0xff) {
        alphatest[1] = 0xff;
      }
      alphablockerror3 = 0;
      for (aindex = 0; aindex < 5; aindex++) {
        acutValues[aindex] = (alphatest[0] * (10 - (2 * aindex + 1)) + alphatest[1] * (2 * aindex + 1)) / 10;
      }
      for (j = 0; j < numypixels; j++) {
        for (i = 0; i < numxpixels; i++) {
          if (srccolors[j][i] <= alphatest[0] / 2) {
            alphaenc3[4 * j + i] = 6;
            alphadist = srccolors[j][i];
          } else if (srccolors[j][i] > ((0xff + alphatest[1]) / 2)) {
            alphaenc3[4 * j + i] = 7;
            alphadist = 0xff - srccolors[j][i];
          } else if (srccolors[j][i] <= acutValues[0]) {
            alphaenc3[4 * j + i] = 0;
            alphadist = srccolors[j][i] - alphatest[0];
          } else if (srccolors[j][i] <= acutValues[1]) {
            alphaenc3[4 * j + i] = 2;
            alphadist = srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5;
          } else if (srccolors[j][i] <= acutValues[2]) {
            alphaenc3[4 * j + i] = 3;
            alphadist = srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5;
          } else if (srccolors[j][i] <= acutValues[3]) {
            alphaenc3[4 * j + i] = 4;
            alphadist = srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5;
          } else if (srccolors[j][i] <= acutValues[4]) {
            alphaenc3[4 * j + i] = 5;
            alphadist = srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5;
          } else {
            alphaenc3[4 * j + i] = 1;
            alphadist = srccolors[j][i] - alphatest[1];
          }
          alphablockerror3 += alphadist * alphadist;
        }
      }
    }
  }
  if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) {
    util_format_unsigned_write_rgtc_encoded_channel(blkaddr, alphause[1], alphause[0], alphaenc1);
  } else if (alphablockerror2 <= alphablockerror3) {
    util_format_unsigned_write_rgtc_encoded_channel(blkaddr, alphabase[0], alphabase[1], alphaenc2);
  } else {
    util_format_unsigned_write_rgtc_encoded_channel(blkaddr, (unsigned char)alphatest[0], (unsigned char)alphatest[1], alphaenc3);
  }
}
```