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

```asm
<format_address>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    %rsi,%rbp
  mov    %r8d,%ebx
  cmp    $0x4,%rcx
  je     L6
  cmp    $0x10,%rcx
  je     L57
  test   %rsi,%rsi
  je     L112
  movb   $0x0,(%rdi)
L112:
  cmp    $0xffffffff,%ebx
  je     L10
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %rax,%rcx
  cmp    %rax,%rbp
  jbe    L45
L161:
  lea    0x1(%rcx),%rsi
  movb   $0x2f,(%r12,%rcx,1)
  mov    %ebx,%eax
  mov    $0xcccccccd,%edx
  imul   %rdx,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  mov    %ebx,%edi
  sub    %eax,%edi
  add    $0x30,%edi
  cmp    $0x9,%ebx
  ja     L55
  cmp    %rsi,%rbp
  jbe    L194
L173:
  lea    0x1(%rsi),%rax
  mov    %dil,(%r12,%rsi,1)
  cmp    %rax,%rbp
  jbe    L117
  movb   $0x0,0x1(%r12,%rsi,1)
L10:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L6:
  call   <format_ipv4_address@plt>
  lea    -0x21(%rbx),%eax
  cmp    $0xffffffdd,%eax
  ja     L112
  mov    $0x20,%ebx
L70:
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %rax,%rcx
  cmp    %rax,%rbp
  ja     L161
  mov    %ebx,%eax
  mov    $0xcccccccd,%edx
  imul   %rdx,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%edx
  add    %edx,%edx
  mov    %ebx,%edi
  sub    %edx,%edi
  add    $0x30,%edi
  cmp    $0x63,%ebx
  jbe    L81
L194:
  test   %rbp,%rbp
  je     L10
L117:
  movb   $0x0,-0x1(%r12,%rbp,1)
  jmp    L10
L57:
  call   <format_ipv6_address@plt>
  lea    -0x81(%rbx),%eax
  cmp    $0xffffff7d,%eax
  ja     L112
  mov    $0x80,%ebx
  jmp    L70
L55:
  mov    %rsi,%rcx
  jmp    L91
L45:
  mov    %ebx,%eax
  mov    $0xcccccccd,%edx
  imul   %rdx,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  mov    %ebx,%edi
  sub    %eax,%edi
  add    $0x30,%edi
  cmp    $0x9,%ebx
  jbe    L194
L91:
  mov    %ebx,%eax
  mov    $0xcccccccd,%edx
  imul   %rdx,%rax
  shr    $0x23,%rax
  cmp    $0x63,%ebx
  jbe    L81
  cmp    %rcx,%rbp
  jbe    L194
  mov    %ebx,%edx
  imul   $0x51eb851f,%rdx,%rdx
  shr    $0x25,%rdx
  add    $0x30,%edx
  mov    %dl,(%r12,%rcx,1)
  lea    0x1(%rcx),%rcx
L81:
  cmp    %rbp,%rcx
  jae    L194
  lea    0x1(%rcx),%rsi
  mov    %eax,%edx
  mov    $0xcccccccd,%r8d
  imul   %r8,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%edx
  add    %edx,%edx
  sub    %edx,%eax
  add    $0x30,%eax
  mov    %al,(%r12,%rcx,1)
  cmp    %rsi,%rbp
  ja     L173
  jmp    L117
```

assistant: ```c
void format_address(char *buf, size_t sizeof_buf, const void *v_addr, size_t sizeof_addr, unsigned prefix_length) {
  if (sizeof_addr == 4) {
    format_ipv4_address(buf, sizeof_buf, v_addr);
    if (prefix_length != ~0 && prefix_length > 32)
      prefix_length = 32;
  } else if (sizeof_addr == 16) {
    format_ipv6_address(buf, sizeof_buf, v_addr);
    if (prefix_length != ~0 && prefix_length > 128)
      prefix_length = 128;
  } else if (sizeof_buf > 0)
    buf[0] = '\0';
  if (prefix_length != ~0) {
    size_t d = strlen(buf);
    char c2;
    unsigned number = prefix_length;
    if (d < sizeof_buf)
      buf[d++] = '/';
    c2 = (number % 10) + '0';
    number /= 10;
    if (number) {
      char c1;
      c1 = (number % 10) + '0';
      number /= 10;
      if (number) {
        int c0;
        c0 = number + '0';
        if (d < sizeof_buf)
          buf[d++] = (char)c0;
      }
      if (d < sizeof_buf)
        buf[d++] = c1;
    }
    if (d < sizeof_buf)
      buf[d++] = c2;
    if (d < sizeof_buf)
      buf[d] = '\0';
    else if (sizeof_buf)
      buf[sizeof_buf - 1] = '\0';
  }
}
```