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

```asm
<zrpc_util_str2mac>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L107
  xor    %ebx,%ebx
  cmpb   $0x3a,(%rdi)
  mov    %rdi,%r12
  mov    %rsi,%rbp
  je     L37
L75:
  lea    0x30(%rsp),%rax
  mov    %rax,0x10(%rsp)
L97:
  mov    $0x3a,%esi
  mov    %r12,%rdi
  movl   $0x0,0x2c(%rsp)
  call   <strchr@plt>
  mov    %rax,0x18(%rsp)
  test   %rax,%rax
  je     L196
  mov    0x18(%rsp),%r13
  sub    %r12,%r13
  sar    $0x2,%r13
L156:
  cmp    $0x5,%r13
  ja     L232
  mov    0x10(%rsp),%r15
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %r15,%rdi
  call   <memcpy@plt>
  test   %r13,%r13
  je     L47
  mov    $0x2,%r12d
  lea    0x2c(%rsp),%r14
  jmp    L222
  nopl   0x0(%rax,%rax,1)
L17:
  mov    %ebx,%ecx
  mov    %r14,%rsi
  mov    %r15,%rdi
  add    %rbp,%rcx
  movb   $0x0,(%rcx)
  mov    %rcx,0x8(%rsp)
  call   <zrpc_util_convertchartohexa@plt>
  mov    0x2c(%rsp),%ecx
  test   %ecx,%ecx
  jne    L107
  mov    0x8(%rsp),%rcx
  shl    $0x4,%eax
  mov    %al,(%rcx)
L240:
  lea    -0x1(%r12),%rax
  cmp    %rax,%r13
  je     L107
  lea    0x4(%r15),%rdi
  mov    %r14,%rsi
  call   <zrpc_util_convertchartohexa@plt>
  mov    0x2c(%rsp),%edx
  test   %edx,%edx
  jne    L107
  test   %rbp,%rbp
  je     L197
  mov    %ebx,%ecx
  and    $0xf,%eax
  or     %al,0x0(%rbp,%rcx,1)
L197:
  add    $0x1,%ebx
  cmp    %r13,%r12
  jae    L114
  add    $0x2,%r12
  add    $0x8,%r15
  cmp    $0x6,%ebx
  je     L107
L222:
  test   %rbp,%rbp
  jne    L17
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <zrpc_util_convertchartohexa@plt>
  mov    0x2c(%rsp),%eax
  test   %eax,%eax
  je     L240
  nopw   0x0(%rax,%rax,1)
L107:
  xor    %eax,%eax
L111:
  mov    0x48(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L69
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L196:
  cmp    $0x5,%ebx
  jne    L232
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %rax,%r13
  jmp    L156
  nopl   (%rax)
L37:
  cmpb   $0x0,0x1(%rdi)
  jne    L75
L87:
  mov    $0x1,%eax
  jmp    L111
  nopl   0x0(%rax)
L114:
  mov    0x18(%rsp),%rax
  test   %rax,%rax
  je     L87
  add    $0x4,%rax
  mov    %rax,%r12
  cmp    $0x6,%ebx
  jne    L97
  jmp    L87
L232:
  mov    %rbp,%rsi
  lea    D0(%rip),%rdi
  xor    %eax,%eax
  call   <zrpc_log@plt>
  jmp    L107
L47:
  cmpq   $0x0,0x18(%rsp)
  je     L87
  mov    0x18(%rsp),%r12
  add    $0x4,%r12
  jmp    L97
L69:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D0
datatype: string

tool: D0: [%s]: format non recognized

assistant: ```c
int zrpc_util_str2mac(const char *str, char *mac) {
  unsigned int k = 0, i, j;
  uint8_t *ptr, *ptr2;
  size_t len;
  uint8_t car;
  if (!str)
    return 0;
  if (str[0] == ':' && str[1] == '\0')
    return 1;
  i = 0;
  ptr = (uint8_t *)str;
  while (i < 6) {
    uint8_t temp[5];
    int error = 0;
    ptr2 = (uint8_t *)strchr((const char *)ptr, ':');
    if (ptr2 == NULL) {
      if (i != 5) {
        zrpc_log("[%s]: format non recognized", mac);
        return 0;
      }
      len = strlen((char *)ptr);
    } else {
      len = ptr2 - ptr;
    }
    if (len > 5) {
      zrpc_log("[%s]: format non recognized", mac);
      return 0;
    }
    memcpy(temp, ptr, len);
    for (j = 0; j < len; j++) {
      if (k >= 6)
        return 0;
      if (mac)
        mac[k] = 0;
      car = zrpc_util_convertchartohexa(&temp[j], &error);
      if (error)
        return 0;
      if (mac)
        mac[k] = car << 4;
      j++;
      if (j == len)
        return 0;
      car = zrpc_util_convertchartohexa(&temp[j], &error) & 0xf;
      if (error)
        return 0;
      if (mac)
        mac[k] |= car & 0xf;
      k++;
      i++;
    }
    ptr = ptr2;
    if (ptr == NULL)
      break;
    ptr++;
  }
  if (mac && 0) {
    zrpc_log("leave correct : %02x:%02x:%02x:%02x:%02x:%02x", mac[0] & 0xff, mac[1] & 0xff, mac[2] & 0xff, mac[3] & 0xff, mac[4] & 0xff, mac[5] & 0xff);
  }
  return 1;
}
```