user: Converte this assembly snippet into its equivalent C code:

```asm
<GrOffScreen4BPPPixelDrawMultiple>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %rdi,0x8(%rsp)
  mov    %rdx,%rdi
  mov    %rcx,%rdx
  mov    %r8,%r12
  mov    0x50(%rsp),%r14
  mov    0x58(%rsp),%r13
  movzwl 0x1(%rbx),%eax
  add    $0x1,%eax
  sar    %eax
  cltq
  imul   %rdi,%rax
  mov    %rsi,%rcx
  shr    $0x3f,%rcx
  add    %rsi,%rcx
  sar    %rcx
  lea    0x36(%rax,%rcx,1),%rbp
  add    %rbx,%rbp
  test   $0x1,%sil
  sete   %bl
  movzbl %bl,%ebx
  shl    $0x2,%rbx
  cmp    $0x4,%r9
  je     L2
  cmp    $0x8,%r9
  je     L24
  cmp    $0x1,%r9
  je     L92
L49:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L24:
  mov    %r14,%r15
  test   %r8,%r8
  je     L49
L97:
  add    $0x1,%r15
  movzbl -0x1(%r15),%eax
  lea    (%rax,%rax,2),%eax
  cltq
  mov    0x0(%r13,%rax,1),%rsi
  and    $0xffffff,%esi
  mov    0x8(%rsp),%rdi
  call   <GrOffScreen4BPPColorTranslate@plt>
  mov    $0xf,%edx
  mov    %ebx,%ecx
  shl    %cl,%edx
  not    %edx
  and    0x0(%rbp),%dl
  shl    %cl,%rax
  or     %eax,%edx
  mov    %dl,0x0(%rbp)
  mov    %rbx,%rax
  xor    $0x4,%rbx
  cmp    $0x4,%rax
  setne  %al
  movzbl %al,%eax
  add    %rax,%rbp
  mov    %r14,%rax
  sub    %r15,%rax
  add    %r12,%rax
  jne    L97
  jmp    L49
L92:
  test   %r8,%r8
  je     L49
  mov    $0x7,%r9d
  mov    $0xf,%r8d
  jmp    L118
L82:
  mov    $0x0,%edx
  test   %r12,%r12
  je     L49
L118:
  add    $0x1,%r14
  movzbl -0x1(%r14),%edi
  cmp    $0x7,%rdx
  jg     L82
  test   %r12,%r12
  je     L82
L133:
  mov    %r9d,%ecx
  sub    %edx,%ecx
  mov    %rdi,%rax
  shr    %cl,%rax
  and    $0x1,%eax
  mov    0x0(%r13,%rax,8),%rsi
  mov    %ebx,%ecx
  shl    %cl,%rsi
  mov    %r8d,%eax
  shl    %cl,%eax
  not    %eax
  and    0x0(%rbp),%al
  or     %esi,%eax
  mov    %al,0x0(%rbp)
  mov    %rbx,%rax
  xor    $0x4,%rbx
  cmp    $0x4,%rax
  setne  %al
  movzbl %al,%eax
  add    %rax,%rbp
  add    $0x1,%rdx
  sub    $0x1,%r12
  cmp    $0x7,%rdx
  jg     L82
  test   %r12,%r12
  jne    L133
  jmp    L82
L2:
  test   $0x1,%dl
  je     L63
L150:
  lea    0x1(%r14),%r15
  movzbl (%r14),%eax
  and    $0xf,%eax
  lea    (%rax,%rax,2),%eax
  cltq
  mov    0x0(%r13,%rax,1),%rsi
  and    $0xffffff,%esi
  mov    0x8(%rsp),%rdi
  call   <GrOffScreen4BPPColorTranslate@plt>
  mov    %rax,%rsi
  mov    $0xf,%eax
  mov    %ebx,%ecx
  shl    %cl,%eax
  mov    %eax,%edx
  not    %edx
  and    0x0(%rbp),%dl
  shl    %cl,%rsi
  or     %esi,%edx
  mov    %dl,0x0(%rbp)
  cmp    $0x4,%rbx
  setne  %al
  movzbl %al,%eax
  add    %rax,%rbp
  sub    $0x1,%r12
  mov    %r15,%r14
  xor    $0x4,%rbx
L63:
  mov    $0xf,%r15d
L6:
  test   %r12,%r12
  je     L49
  movzbl (%r14),%eax
  shr    $0x4,%al
  lea    (%rax,%rax,2),%rax
  and    $0x3f,%eax
  mov    0x0(%r13,%rax,1),%rsi
  and    $0xffffff,%esi
  mov    0x8(%rsp),%rdi
  call   <GrOffScreen4BPPColorTranslate@plt>
  mov    %r15d,%edx
  mov    %ebx,%ecx
  shl    %cl,%edx
  not    %edx
  and    0x0(%rbp),%dl
  shl    %cl,%rax
  or     %eax,%edx
  mov    %dl,0x0(%rbp)
  mov    %rbx,%rdx
  xor    $0x4,%rdx
  cmp    $0x4,%rbx
  setne  %al
  movzbl %al,%eax
  add    %rax,%rbp
  sub    $0x1,%r12
  jne    L146
  mov    %rdx,%rbx
  jmp    L6
L146:
  mov    %rdx,%rbx
  jmp    L150
```

assistant: ```c
void GrOffScreen4BPPPixelDrawMultiple(void *pvDisplayData, long lX, long lY, long lX0, long lCount, long lBPP, const unsigned char *pucData, const unsigned char *pucPalette) {
  unsigned char *pucPtr;
  unsigned long ulByte;
  long lBytesPerRow;
  ;
  ;
  ;
  pucPtr = (unsigned char *)pvDisplayData;
  lBytesPerRow = (*(unsigned short *)(pucPtr + 1) + 1) / 2;
  pucPtr += (lBytesPerRow * lY) + (lX / 2) + 6 + (16 * 3);
  lX = (1 - (lX & 1)) * 4;
  switch (lBPP) {
  case 1: {
    while (lCount) {
      ulByte = *pucData++;
      for (; (lX0 < 8) && lCount; lX0++, lCount--) {
        *pucPtr = ((*pucPtr & ~(0xf << lX)) | (((unsigned long *)pucPalette)[(ulByte >> (7 - lX0)) & 1] << lX));
        if (lX ^= 4) {
          pucPtr++;
        }
      }
      lX0 = 0;
    }
    break;
  }
  case 4: {
    switch (lX0 & 1) {
    case 0:
      while (lCount) {
        ulByte = (*pucData >> 4) * 3;
        ulByte = (*(unsigned long *)(pucPalette + ulByte) & 0x00ffffff);
        ulByte = GrOffScreen4BPPColorTranslate(pvDisplayData, ulByte);
        *pucPtr = (*pucPtr & ~(0xf << lX)) | (ulByte << lX);
        if (lX ^= 4) {
          pucPtr++;
        }
        lCount--;
        if (lCount) {
        case 1:
          ulByte = (*pucData++ & 15) * 3;
          ulByte = (*(unsigned long *)(pucPalette + ulByte) & 0x00ffffff);
          ulByte = GrOffScreen4BPPColorTranslate(pvDisplayData, ulByte);
          *pucPtr = ((*pucPtr & ~(0xf << lX)) | (ulByte << lX));
          if (lX ^= 4) {
            pucPtr++;
          }
          lCount--;
        }
      }
    }
    break;
  }
  case 8: {
    while (lCount--) {
      ulByte = *pucData++ * 3;
      ulByte = *(unsigned long *)(pucPalette + ulByte) & 0x00ffffff;
      ulByte = GrOffScreen4BPPColorTranslate(pvDisplayData, ulByte);
      *pucPtr = (*pucPtr & ~(0xf << lX)) | (ulByte << lX);
      if (lX ^= 4) {
        pucPtr++;
      }
    }
    break;
  }
  }
}
```