user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<is_balanced>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L43
  cmpl   $0x0,-0xc(%rbp)
  sete   %al
  movzbl %al,%eax
  jmp    L3
L43:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3a,%al
  je     L182
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x28,%al
  je     L182
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x29,%al
  je     L182
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  mov    %rdx,%rdi
  call   <is_balanced>
  jmp    L3
L182:
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <trim_right@plt>
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x3a,%eax
  je     L194
  cmp    $0x3a,%eax
  jg     L186
  cmp    $0x28,%eax
  je     L222
  cmp    $0x29,%eax
  je     L75
  jmp    L186
L222:
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <is_balanced>
  jmp    L3
L75:
  cmpl   $0x0,-0xc(%rbp)
  je     L277
  mov    -0xc(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <is_balanced>
  jmp    L3
L277:
  mov    $0x0,%eax
  jmp    L3
L194:
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x28,%eax
  je     L104
  cmp    $0x29,%eax
  je     L274
  jmp    L89
L104:
  mov    -0x8(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  mov    %rdx,%rdi
  call   <is_balanced>
  test   %eax,%eax
  jne    L269
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <is_balanced>
  test   %eax,%eax
  je     L198
L269:
  mov    $0x1,%eax
  jmp    L3
L198:
  mov    $0x0,%eax
  jmp    L3
L274:
  cmpl   $0x0,-0xc(%rbp)
  je     L30
  mov    -0x8(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  mov    %rdx,%rdi
  call   <is_balanced>
  test   %eax,%eax
  jne    L20
  mov    -0xc(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <is_balanced>
  test   %eax,%eax
  je     L47
L20:
  mov    $0x1,%eax
  jmp    L3
L47:
  mov    $0x0,%eax
  jmp    L3
L30:
  mov    -0x8(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  mov    %rdx,%rdi
  call   <is_balanced>
  jmp    L3
L89:
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  mov    %rdx,%rdi
  call   <is_balanced>
  jmp    L3
L186:
  mov    $0x0,%eax
L3:
  leave
  ret
```

assistant: ```c
bool is_balanced(char *p, unsigned c) {
  if (*p == '\0')
    return !c;
  if (p[0] != ':' && p[0] != '(' && p[0] != ')')
    return is_balanced(p + 1, c);
  trim_right(p);
  switch (p[0]) {
  case '(':
    return is_balanced(p + 1, c + 1);
  case ')':
    if (c)
      return is_balanced(p + 1, c - 1);
    return false;
  case ':':
    switch (p[1]) {
    case '(':
      return is_balanced(p + 2, c) || is_balanced(p + 2, c + 1);
    case ')':
      if (c)
        return is_balanced(p + 2, c) || is_balanced(p + 2, c - 1);
      return is_balanced(p + 2, c);
    default:
      return is_balanced(p + 1, c);
    }
  default:
    return false;
  }
}
```