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

```asm
<insert_batch>:
  endbr64
  push   %r13
  mov    %rdi,%rax
  push   %r12
  lea    (%r8,%r8,2),%r12d
  push   %rbp
  mov    %r12d,%r11d
  push   %rbx
  mov    %esi,%ebx
  mov    %rdx,%rsi
  mov    %rcx,%rdx
  mov    (%rsi),%edi
  mov    0x4(%rsi),%r10d
  mov    0x8(%rsi),%ecx
  test   %r8d,%r8d
  je     L53
  jle    L114
  lea    -0x1(%r8),%esi
  cmp    $0x2,%esi
  jbe    L89
  movd   %edi,%xmm0
  movd   %r10d,%xmm4
  movd   %ecx,%xmm1
  mov    %r8d,%esi
  shr    $0x2,%esi
  punpckldq %xmm4,%xmm0
  mov    %rdx,%rcx
  sub    $0x1,%esi
  punpcklqdq %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  lea    (%rsi,%rsi,2),%rsi
  movdqa %xmm1,%xmm2
  shl    $0x4,%rsi
  lea    0x30(%rdx,%rsi,1),%rsi
  nopw   0x0(%rax,%rax,1)
L91:
  movdqu (%rcx),%xmm4
  movdqu 0x10(%rcx),%xmm5
  add    $0x30,%rcx
  movdqu -0x10(%rcx),%xmm6
  paddd  %xmm4,%xmm0
  paddd  %xmm5,%xmm2
  paddd  %xmm6,%xmm1
  cmp    %rcx,%rsi
  jne    L91
  pshufd $0xff,%xmm0,%xmm3
  movd   %xmm0,%edi
  mov    %r8d,%r13d
  movd   %xmm3,%ecx
  movdqa %xmm2,%xmm3
  and    $0xfffffffc,%r13d
  punpckhdq %xmm2,%xmm3
  add    %ecx,%edi
  movd   %xmm3,%ecx
  pshufd $0x55,%xmm1,%xmm3
  add    %ecx,%edi
  movd   %xmm3,%ecx
  pshufd $0x55,%xmm0,%xmm3
  movd   %xmm3,%r10d
  pshufd $0xff,%xmm2,%xmm3
  punpckhdq %xmm0,%xmm0
  add    %ecx,%edi
  movd   %xmm2,%ecx
  pshufd $0x55,%xmm2,%xmm2
  add    %ecx,%r10d
  movd   %xmm3,%ecx
  movdqa %xmm1,%xmm3
  punpckhdq %xmm1,%xmm3
  add    %ecx,%r10d
  movd   %xmm2,%esi
  movd   %xmm3,%ecx
  add    %ecx,%r10d
  movd   %xmm0,%ecx
  add    %esi,%ecx
  movd   %xmm1,%esi
  pshufd $0xff,%xmm1,%xmm1
  add    %esi,%ecx
  movd   %xmm1,%esi
  add    %esi,%ecx
  mov    %r13d,%esi
  cmp    %r8d,%r13d
  je     L114
L39:
  mov    %r8d,%ebp
  sub    %r13d,%ebp
  cmp    $0x1,%ebp
  je     L68
  lea    0x0(%r13,%r13,2),%r13
  movd   %r10d,%xmm7
  movd   %edi,%xmm0
  lea    (%rdx,%r13,4),%r13
  punpckldq %xmm7,%xmm0
  movd   %ecx,%xmm3
  movq   0x0(%r13),%xmm1
  movq   0x10(%r13),%xmm2
  paddd  %xmm0,%xmm1
  movq   0x8(%r13),%xmm0
  movd   %xmm2,%r10d
  paddd  %xmm3,%xmm0
  movd   %xmm1,%edi
  pshufd $0xe5,%xmm0,%xmm7
  movd   %xmm7,%ecx
  pshufd $0xe5,%xmm1,%xmm7
  add    %ecx,%edi
  movd   %xmm7,%ecx
  pshufd $0xe5,%xmm2,%xmm7
  movd   %xmm7,%r13d
  add    %ecx,%r10d
  movd   %xmm0,%ecx
  add    %r13d,%ecx
  mov    %ebp,%r13d
  and    $0xfffffffe,%r13d
  add    %r13d,%esi
  cmp    %r13d,%ebp
  je     L114
L68:
  lea    (%rsi,%rsi,2),%esi
  movslq %esi,%rsi
  add    (%rdx,%rsi,4),%edi
  add    0x4(%rdx,%rsi,4),%r10d
  add    0x8(%rdx,%rsi,4),%ecx
L114:
  cmp    $0x26,%r12d
  jg     L7
L53:
  lea    (%rbx,%rbx,2),%ebp
  cmp    %ebx,%r8d
  jge    L7
  movslq %r12d,%r12
  shl    $0x2,%r12
  add    %r12,%rax
  add    %r12,%rdx
  jmp    L119
  nopl   0x0(%rax)
L34:
  add    $0xc,%rax
  add    $0xc,%rdx
  cmp    %ebp,%r11d
  jge    L7
L119:
  mov    (%rax),%esi
  add    $0x3,%r11d
  sub    %edi,%esi
  mov    %esi,(%rdx)
  mov    0x4(%rax),%esi
  sub    %r10d,%esi
  mov    %esi,0x4(%rdx)
  mov    0x8(%rax),%esi
  sub    %ecx,%esi
  mov    %esi,0x8(%rdx)
  mov    (%rax),%edi
  mov    0x4(%rax),%r10d
  mov    0x8(%rax),%ecx
  cmp    $0x26,%r11d
  jle    L34
L7:
  pop    %rbx
  pop    %rbp
  mov    %r11d,(%r9)
  pop    %r12
  pop    %r13
  ret
L89:
  xor    %r13d,%r13d
  xor    %esi,%esi
  jmp    L39
```

assistant: ```c
void insert_batch(const int *input_ptr, const int ntriplets_left, const int *prevcoord, int *encode_ints, const int startenc, int *nenc) {
  int nencode = startenc * 3;
  int tmp_prevcoord[3];
  tmp_prevcoord[0] = prevcoord[0];
  tmp_prevcoord[1] = prevcoord[1];
  tmp_prevcoord[2] = prevcoord[2];
  if (startenc) {
    int i;
    for (i = 0; i < startenc; i++) {
      tmp_prevcoord[0] += encode_ints[i * 3];
      tmp_prevcoord[1] += encode_ints[i * 3 + 1];
      tmp_prevcoord[2] += encode_ints[i * 3 + 2];
    }
  }
  while ((nencode < 3 + 12 * 3) && (nencode < ntriplets_left * 3)) {
    encode_ints[nencode] = input_ptr[nencode] - tmp_prevcoord[0];
    encode_ints[nencode + 1] = input_ptr[nencode + 1] - tmp_prevcoord[1];
    encode_ints[nencode + 2] = input_ptr[nencode + 2] - tmp_prevcoord[2];
    tmp_prevcoord[0] = input_ptr[nencode];
    tmp_prevcoord[1] = input_ptr[nencode + 1];
    tmp_prevcoord[2] = input_ptr[nencode + 2];
    nencode += 3;
  }
  *nenc = nencode;
}
```