user: Please show me the C implementation that matches the assembly code listed below:

```asm
<paint_rval_text>:
  endbr64
  push   %r15
  mov    %esi,%r15d
  push   %r14
  shr    $0x3,%r15d
  lea    0xb(%r8),%r14d
  push   %r13
  and    $0x1,%r15d
  mov    %rdi,%r13
  push   %r12
  mov    %edx,%r12d
  mov    %esi,%edx
  push   %rbp
  and    $0x30,%edx
  mov    %ecx,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x18,%rsp
  and    $0x1,%ebx
  je     L46
  test   %edx,%edx
  je     L122
L53:
  mov    %r12d,%edi
  xor    %eax,%eax
  mov    %edx,0x8(%rsp)
  call   <cmalloc@plt>
  mov    0x8(%rsp),%edx
  movslq %eax,%r10
  cmp    $0x10,%edx
  je     L55
  cmp    $0x20,%edx
  je     L115
L70:
  mov    %r10,0x8(%rsp)
  sub    $0x8,%rsp
  mov    %r15d,%r9d
  xor    %eax,%eax
  push   $0x1
  mov    %ebx,%r8d
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %r14d,%esi
  mov    %ebp,%edi
  call   <omshell_terminaldrawimagestring@plt>
  test   %ebx,%ebx
  pop    %r9
  pop    %r10
  mov    0x8(%rsp),%r10
  jne    L66
L34:
  add    $0x18,%rsp
  mov    %r10,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1070 <free@plt>
  xchg   %ax,%ax
L46:
  test   %edx,%edx
  jne    L53
  sub    $0x8,%rsp
  mov    %rdi,%rdx
  mov    %r15d,%r9d
  mov    %r12d,%ecx
  push   $0x0
  mov    %r14d,%esi
  mov    %ebp,%edi
  xor    %r8d,%r8d
  xor    %eax,%eax
  call   <omshell_terminaldrawimagestring@plt>
  pop    %rax
  pop    %rdx
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L55:
  movslq %r12d,%rcx
  mov    %r13,%rdi
  mov    %r10,%rax
  mov    $0x1e,%esi
  add    %r10,%rcx
  sub    %r10,%rdi
  test   %r12d,%r12d
  jle    L70
  nopl   (%rax)
L26:
  movzbl (%rdi,%rax,1),%edx
  cmp    $0x23,%dl
  cmove  %esi,%edx
  add    $0x1,%rax
  mov    %dl,-0x1(%rax)
  cmp    %rcx,%rax
  jne    L26
  jmp    L70
  nopl   0x0(%rax,%rax,1)
L122:
  sub    $0x8,%rsp
  mov    %r15d,%r9d
  mov    %r12d,%ecx
  mov    %rdi,%rdx
  push   $0x0
  mov    %r14d,%esi
  mov    %ebp,%edi
  mov    $0x1,%r8d
  xor    %eax,%eax
  call   <omshell_terminaldrawimagestring@plt>
  mov    %r12d,%ecx
  mov    %r14d,%esi
  lea    0x1(%rbp),%edi
  mov    %r15d,%r9d
  mov    %r13,%rdx
  mov    $0x1,%r8d
  xor    %eax,%eax
  movl   $0x0,(%rsp)
  call   <omshell_terminaldrawimagestring@plt>
  pop    %rcx
  pop    %rsi
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L66:
  mov    %r10,0x8(%rsp)
  sub    $0x8,%rsp
  lea    0x1(%rbp),%edi
  mov    %r15d,%r9d
  push   $0x1
  mov    $0x1,%r8d
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %r14d,%esi
  xor    %eax,%eax
  call   <omshell_terminaldrawimagestring@plt>
  pop    %rdi
  pop    %r8
  mov    0x8(%rsp),%r10
  jmp    L34
  nopl   0x0(%rax)
L115:
  test   %r12d,%r12d
  jle    L70
  movslq %r12d,%rdi
  mov    %r13,%r8
  mov    %r10,%rdx
  add    %r10,%rdi
  sub    %r10,%r8
L71:
  movzbl (%r8,%rdx,1),%eax
  mov    %eax,%ecx
  lea    -0x60(%rax),%esi
  and    $0x1f,%ecx
  add    $0x1,%ecx
  cmp    $0x1f,%sil
  cmovb  %ecx,%eax
  add    $0x1,%rdx
  mov    %al,-0x1(%rdx)
  cmp    %rdx,%rdi
  jne    L71
  jmp    L70
```

assistant: ```c
void paint_rval_text(str, rval, len, x, y) unsigned char *str;
int rval;
int len, x, y;
{
  unsigned char *buf;
  int overstrike;
  int i;
  int b = 0, inverso = 0;
  if (rval & 0x08) {
    inverso = 1;
  }
  overstrike = 0;
  if (rval & 0x01) {
    b = 1;
    if (0) {
      y += 11;
    } else {
      overstrike = 1;
      y += 11;
    }
  } else
    y += 11;
  if ((rval & 0x30) == 0x00) {
    omshell_terminaldrawimagestring(x, y, str, len, b, inverso, 0);
    if (overstrike) {
      omshell_terminaldrawimagestring(x + 1, y, str, len, b, inverso, 0);
    }
  } else {
    buf = (unsigned char *)cmalloc(len);
    if ((rval & 0x30) == 0x10) {
      for (i = 0; i < len; i++)
        buf[i] = (str[i] == '#') ? 036 : str[i];
    } else if ((rval & 0x30) == 0x20) {
      for (i = 0; i < len; i++)
        if (str[i] >= 0140 && str[i] <= 0176)
          buf[i] = (str[i] & 037) + 1;
        else
          buf[i] = str[i];
    }
    omshell_terminaldrawimagestring(x, y, str, len, b, inverso, 1);
    if (overstrike)
      omshell_terminaldrawimagestring(x + 1, y, str, len, b, inverso, 1);
    free((void *)buf);
  }
  y++;
  if (rval & 0x02) {
  }
  if (rval & 0x08) {
  }
  if (rval & 0x01) {
  }
}
```