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

```asm
<translate_mac>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x170,%rsp
  mov    %rdi,-0x168(%rbp)
  mov    %rsi,-0x170(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x138(%rbp)
  movq   $0x0,-0x158(%rbp)
  movq   $0x0,-0x150(%rbp)
  mov    -0x170(%rbp),%rax
  mov    $0x4,%edx
  mov    %rax,%rsi
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <memcpy@plt>
  lea    D9(%rip),%rax
  mov    %rax,-0x140(%rbp)
  mov    $0x0,%edi
  call   <debugfs_mount@plt>
  mov    %rax,-0x128(%rbp)
  cmpq   $0x0,-0x128(%rbp)
  je     L44
  lea    -0x110(%rbp),%rdx
  mov    -0x168(%rbp),%rax
  mov    $0x101,%ecx
  mov    %rax,%rsi
  lea    D38(%rip),%rax
  mov    %rax,%rdi
  call   <debugfs_make_path@plt>
  lea    -0x110(%rbp),%rax
  lea    D11(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x138(%rbp)
  cmpq   $0x0,-0x138(%rbp)
  je     L243
  jmp    L218
L111:
  movl   $0x0,-0x15c(%rbp)
  movl   $0x0,-0x160(%rbp)
  mov    -0x150(%rbp),%rax
  mov    %rax,-0x130(%rbp)
  jmp    L165
L65:
  movq   $0x0,-0x130(%rbp)
  cmpl   $0x3,-0x160(%rbp)
  je     L129
  cmpl   $0x3,-0x160(%rbp)
  ja     L224
  cmpl   $0x2,-0x160(%rbp)
  je     L45
  cmpl   $0x2,-0x160(%rbp)
  ja     L224
  cmpl   $0x0,-0x160(%rbp)
  je     L163
  cmpl   $0x1,-0x160(%rbp)
  je     L8
  jmp    L224
L163:
  mov    -0x120(%rbp),%rax
  lea    D55(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L167
  movl   $0x1,-0x15c(%rbp)
  jmp    L224
L167:
  movl   $0x1,-0x160(%rbp)
  jmp    L224
L8:
  mov    -0x120(%rbp),%rax
  mov    %rax,%rdi
  call   <ether_aton@plt>
  mov    %rax,-0x118(%rbp)
  cmpq   $0x0,-0x118(%rbp)
  je     L148
  mov    -0x118(%rbp),%rax
  mov    $0x4,%edx
  lea    D9(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcmp@plt>
  test   %eax,%eax
  je     L146
L148:
  movl   $0x1,-0x15c(%rbp)
  jmp    L224
L146:
  movl   $0x2,-0x160(%rbp)
  jmp    L224
L45:
  mov    -0x120(%rbp),%rax
  lea    D53(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L106
  movl   $0x3,-0x160(%rbp)
  jmp    L106
L129:
  mov    -0x120(%rbp),%rax
  mov    %rax,%rdi
  call   <ether_aton@plt>
  mov    %rax,-0x118(%rbp)
  cmpq   $0x0,-0x118(%rbp)
  jne    L118
  movl   $0x1,-0x15c(%rbp)
  jmp    L224
L118:
  mov    -0x118(%rbp),%rax
  mov    %rax,-0x140(%rbp)
  jmp    L116
L106:
  nop
L224:
  cmpl   $0x0,-0x15c(%rbp)
  je     L165
  jmp    L218
L165:
  lea    -0x148(%rbp),%rdx
  mov    -0x130(%rbp),%rax
  lea    D44(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strtok_r@plt>
  mov    %rax,-0x120(%rbp)
  cmpq   $0x0,-0x120(%rbp)
  jne    L65
L218:
  mov    -0x138(%rbp),%rdx
  lea    -0x158(%rbp),%rcx
  lea    -0x150(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <getline@plt>
  cmp    $0xffffffff,%eax
  jne    L111
  jmp    L116
L44:
  nop
  jmp    L116
L243:
  nop
L116:
  cmpq   $0x0,-0x138(%rbp)
  je     L39
  mov    -0x138(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L39:
  mov    -0x150(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x140(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L288
  call   <__stack_chk_fail@plt>
L288:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_label: D38
data_type: string
name: parse_data
arguments: data_label: D11
data_type: string
name: parse_data
arguments: data_label: D55
data_type: string
name: parse_data
arguments: data_label: D53
data_type: string
name: parse_data
arguments: data_label: D44
data_type: string

tool: D38: %s/batman_adv/%s/transtable_global

tool: D11: r

tool: D55: *

tool: D53: via

tool: D44:  	

assistant: ```c
struct ether_addr *translate_mac(const char *mesh_iface, struct ether_addr *mac) {
  enum {
    tg_start,
    tg_mac,
    tg_via,
    tg_originator,
  } pos;
  char full_path[256 + 1];
  char *debugfs_mnt;
  static struct ether_addr in_mac;
  struct ether_addr *mac_result, *mac_tmp;
  FILE *f = NULL;
  size_t len = 0;
  char *line = NULL;
  char *input, *saveptr, *token;
  int line_invalid;
  memcpy(&in_mac, mac, sizeof(in_mac));
  mac_result = &in_mac;
  debugfs_mnt = debugfs_mount(NULL);
  if (!debugfs_mnt)
    goto out;
  debugfs_make_path("%s/batman_adv/%s"
                    "/"
                    "transtable_global",
                    mesh_iface, full_path, sizeof(full_path));
  f = fopen(full_path, "r");
  if (!f)
    goto out;
  while (getline(&line, &len, f) != -1) {
    line_invalid = 0;
    pos = tg_start;
    input = line;
    while ((token = strtok_r(input, " \t", &saveptr))) {
      input = NULL;
      switch (pos) {
      case tg_start:
        if (strcmp(token, "*") != 0)
          line_invalid = 1;
        else
          pos = tg_mac;
        break;
      case tg_mac:
        mac_tmp = ether_aton(token);
        if (!mac_tmp || memcmp(mac_tmp, &in_mac, sizeof(in_mac)) != 0)
          line_invalid = 1;
        else
          pos = tg_via;
        break;
      case tg_via:
        if (strcmp(token, "via") == 0)
          pos = tg_originator;
        break;
      case tg_originator:
        mac_tmp = ether_aton(token);
        if (!mac_tmp) {
          line_invalid = 1;
        } else {
          mac_result = mac_tmp;
          goto out;
        }
        break;
      }
      if (line_invalid)
        break;
    }
  }
out:
  if (f)
    fclose(f);
  free(line);
  return mac_result;
}
```