user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<parseLength>:
  endbr64
  push   %r12
  xor    %r12d,%r12d
  cmpb   $0x30,(%rdi)
  je     L104
L146:
  mov    %r12d,%eax
  pop    %r12
  ret
  nopl   0x0(%rax)
L104:
  movzbl 0x1(%rdi),%edx
  mov    %rdi,%rax
  test   %dl,%dl
  js     L79
  cmpb   $0x2,0x2(%rdi)
  jne    L2
  cmpb   $0x1,0x3(%rdi)
  jne    L2
  movzbl %dl,%r12d
  lea    D41(%rip),%rsi
  mov    $0xa,%edi
  xor    %eax,%eax
  mov    %r12d,%ecx
  lea    D67(%rip),%rdx
  call   <writeError@plt>
  mov    %r12d,%eax
  pop    %r12
  ret
  xchg   %ax,%ax
L79:
  mov    %edx,%ecx
  and    $0x7f,%edx
  and    $0x7f,%ecx
  cmp    $0x1,%cl
  je     L57
  cmp    $0x2,%edx
  je     L32
  cmp    $0x3,%edx
  je     L95
  cmp    $0x4,%edx
  jne    L134
  movzbl 0x2(%rdi),%r12d
  movzbl 0x3(%rdi),%esi
  shl    $0x18,%r12d
  shl    $0x10,%esi
  add    %esi,%r12d
  movzbl 0x4(%rdi),%esi
  shl    $0x8,%esi
  add    %esi,%r12d
  movzbl 0x5(%rdi),%esi
  add    %esi,%r12d
L155:
  test   %r12d,%r12d
  jle    L134
  add    $0x2,%edx
  movslq %edx,%rdx
  cmpb   $0x2,(%rax,%rdx,1)
  jne    L134
  add    $0x3,%ecx
  movzbl %cl,%ecx
  cmpb   $0x1,(%rax,%rcx,1)
  jne    L134
  mov    %r12d,%ecx
  lea    D67(%rip),%rdx
  lea    D78(%rip),%rsi
  xor    %eax,%eax
  mov    $0xa,%edi
  call   <writeError@plt>
  mov    %r12d,%eax
  pop    %r12
  ret
  nopl   0x0(%rax)
L95:
  movzbl 0x2(%rdi),%r12d
  movzbl 0x3(%rdi),%esi
  shl    $0x10,%r12d
  shl    $0x8,%esi
  add    %esi,%r12d
  movzbl 0x4(%rdi),%esi
  add    %esi,%r12d
  jmp    L155
  nopl   0x0(%rax)
L2:
  lea    D67(%rip),%rdx
  lea    D16(%rip),%rsi
  mov    $0x3,%edi
  xor    %eax,%eax
  call   <writeError@plt>
  mov    $0xffffffff,%r12d
  jmp    L146
  nopl   (%rax)
L57:
  movzbl 0x2(%rdi),%r12d
  jmp    L155
  nopw   0x0(%rax,%rax,1)
L32:
  movzbl 0x2(%rdi),%r12d
  movzbl 0x3(%rdi),%esi
  shl    $0x8,%r12d
  add    %esi,%r12d
  jmp    L155
  nopl   (%rax)
L134:
  lea    D67(%rip),%rdx
  lea    D15(%rip),%rsi
  mov    $0x3,%edi
  xor    %eax,%eax
  call   <writeError@plt>
  mov    $0xffffffff,%r12d
  jmp    L146
```

tool_calls: name: parse_data
arguments: data_tag: D41
type: string
name: parse_data
arguments: data_tag: D67
type: string
name: parse_data
arguments: data_tag: D78
type: string
name: parse_data
arguments: data_tag: D16
type: string
name: parse_data
arguments: data_tag: D15
type: string

tool: D41: [%s] Single octet mode length: %d

tool: D67: snmp.mod

tool: D78: [%s] Multi-octet mode length: %d

tool: D16: [%s] Failed to parse length or SNMP version.

tool: D15: [%s] Failed to parse length or SNMP version (multi-octet mode).

assistant: ```c
int parseLength(unsigned char *bufReceive) {
  int nLength = 0;
  int nOctets = 0;
  if (bufReceive[0] == 0x30) {
    if (bufReceive[1] & 0x80) {
      nOctets = bufReceive[1] & 0x7f;
      if (nOctets == 1)
        nLength = bufReceive[2];
      else if (nOctets == 2)
        nLength = (bufReceive[2] << 8) + bufReceive[3];
      else if (nOctets == 3)
        nLength = (bufReceive[2] << 16) + (bufReceive[3] << 8) + bufReceive[4];
      else if (nOctets == 4)
        nLength = (bufReceive[2] << 24) + (bufReceive[3] << 16) + (bufReceive[4] << 8) + bufReceive[5];
      if ((nLength > 0) && ((bufReceive[2 + nOctets] == 0x02) && (bufReceive[2 + nOctets + 1] == 0x01)))
        writeError(10, "[%s] Multi-octet mode length: %d", "snmp.mod", nLength);
      else {
        writeError(3, "[%s] Failed to parse length or SNMP version (multi-octet mode).", "snmp.mod");
        nLength = -1;
      }
    } else if ((bufReceive[2] == 0x02) && (bufReceive[3] == 0x01)) {
      nLength = bufReceive[1];
      writeError(10, "[%s] Single octet mode length: %d", "snmp.mod", nLength);
    } else {
      writeError(3, "[%s] Failed to parse length or SNMP version.", "snmp.mod");
      nLength = -1;
    }
  }
  return nLength;
}
```