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

```asm
<router_rewrite_metric>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  xor    %edi,%edi
  push   %r14
  mov    %rcx,%r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  mov    %r8,%rbp
  push   %rbx
  sub    $0x38,%rsp
  cmpq   $0x0,0x70(%rsp)
  mov    %rsi,0x10(%rsp)
  setne  %dil
  mov    %r9,0x8(%rsp)
  call   <assert@plt>
  mov    0x70(%rsp),%rax
  movslq (%rax),%rbx
  cmp    $0x1fff,%rbx
  ja     L412
  lea    0x0(%r13,%rbx,1),%rax
  cmp    %rax,%r13
  jae    L256
  xor    %eax,%eax
  xchg   %ax,%ax
L313:
  movzbl 0x0(%r13,%rax,1),%edx
  mov    %dl,(%r15,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rbx
  jne    L313
  add    %r15,%rbx
L328:
  xor    %ecx,%ecx
  mov    %r13,%rax
  xor    %edi,%edi
  xor    %r12d,%r12d
  mov    %ecx,%r13d
  mov    %r14,%rsi
  mov    %rax,%rcx
  nopl   0x0(%rax)
L311:
  mov    %rbx,%rdx
  movzbl 0x0(%rbp),%eax
  sub    %r15,%rdx
  test   %r12b,%r12b
  jne    L305
  cmp    $0x5c,%al
  je     L227
L305:
  cmp    $0x1,%r12b
  jne    L158
  test   %r13d,%r13d
  jne    L158
  cmp    $0x5f,%al
  je     L101
  cmp    $0x5e,%al
  je     L214
  lea    -0x30(%rax),%r8d
  cmp    $0x9,%r8b
  jbe    L324
L6:
  test   %edi,%edi
  je     L322
  movslq %edi,%r8
  xor    %edi,%edi
  cmp    0x8(%rsp),%r8
  jbe    L60
L322:
  cmp    $0x5c,%al
  je     L264
  add    $0x1,%rdx
  cmp    $0x1fff,%rdx
  ja     L149
  mov    %al,(%rbx)
  movzbl 0x0(%rbp),%eax
  add    $0x1,%rbx
L149:
  test   %al,%al
  je     L394
  xor    %r13d,%r13d
  xor    %r12d,%r12d
L264:
  add    $0x1,%rbp
  jmp    L311
  nopl   0x0(%rax,%rax,1)
L158:
  test   %r12b,%r12b
  je     L322
  lea    -0x30(%rax),%r8d
  cmp    $0x9,%r8b
  ja     L6
L324:
  lea    (%rdi,%rdi,4),%eax
  movsbl %r8b,%r8d
  mov    $0x2,%r12d
  lea    (%r8,%rax,2),%edi
  jmp    L264
  nopw   0x0(%rax,%rax,1)
L227:
  xor    %r13d,%r13d
  mov    $0x1,%r12d
  jmp    L264
  nopl   0x0(%rax,%rax,1)
L394:
  mov    0x70(%rsp),%rax
  lea    -0x1(%rbx),%rbp
  mov    %rcx,%r13
  mov    %rsi,%r14
  mov    %rbp,%r12
  movslq 0x4(%rax),%rax
  sub    %r15,%r12
  add    %rax,%r13
  lea    (%rsi,%r12,1),%rax
  sub    %r13,%rax
  cmp    $0x1fff,%rax
  ja     L412
  cmp    %rsi,%r13
  jae    L375
  mov    %rsi,%rcx
  xor    %eax,%eax
  sub    %r13,%rcx
L185:
  movzbl 0x0(%r13,%rax,1),%edx
  mov    %dl,-0x1(%rbx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L185
  add    %rcx,%rbp
  mov    %rbp,%r12
  sub    %r15,%r12
L375:
  mov    0x10(%rsp),%rax
  mov    %r14,%rdi
  mov    %rbp,(%rax)
  call   <strlen@plt>
  cltq
  add    %r12,%rax
  cmp    $0x1fff,%rax
  jbe    L148
L412:
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L101:
  mov    $0x1,%r13d
  mov    $0x1,%r12d
  jmp    L264
  nopl   0x0(%rax)
L214:
  mov    $0x2,%r13d
  mov    $0x1,%r12d
  jmp    L264
  nopl   0x0(%rax)
L60:
  mov    0x70(%rsp),%r10
  lea    (%r10,%r8,8),%r9
  movslq (%r9),%r8
  test   %r8d,%r8d
  js     L322
  movslq 0x4(%r9),%r10
  lea    (%rcx,%r8,1),%r14
  lea    (%rcx,%r10,1),%r9
  lea    (%r9,%rdx,1),%r11
  sub    %r14,%r11
  cmp    $0x1fff,%r11
  ja     L322
  cmp    $0x1,%r13d
  je     L314
  cmp    $0x2,%r13d
  je     L153
  test   %r13d,%r13d
  jne    L322
  cmp    %r9,%r14
  jae    L322
  sub    %r8,%r10
  xor    %eax,%eax
  nopl   0x0(%rax)
L337:
  movzbl (%r14,%rax,1),%edx
  mov    %dl,(%rbx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%r10
  jne    L337
  add    %r10,%rbx
  movzbl 0x0(%rbp),%eax
  xor    %edi,%edi
  mov    %rbx,%rdx
  sub    %r15,%rdx
  jmp    L322
  nopl   (%rax)
L272:
  mov    %al,0x0(%rbp)
  add    $0x1,%rbp
  add    $0x1,%r14
L148:
  movzbl (%r14),%eax
  test   %al,%al
  jne    L272
  movb   $0x0,0x0(%rbp)
  lea    0x1(%rbp),%rax
  add    $0x38,%rsp
  pop    %rbx
  sub    %r15,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L256:
  mov    %r15,%rbx
  jmp    L328
L153:
  sub    %r8,%r10
  add    %rbx,%r10
  cmp    %r9,%r14
  jae    L322
  mov    %rcx,0x18(%rsp)
  mov    %rsi,0x20(%rsp)
  mov    %rbp,0x28(%rsp)
  mov    %r14,%rbp
  mov    %r10,%r14
  nopl   0x0(%rax)
L339:
  movsbl 0x0(%rbp),%edi
  add    $0x1,%rbx
  add    $0x1,%rbp
  call   <toupper@plt>
  mov    %al,-0x1(%rbx)
  cmp    %r14,%rbx
  jne    L339
L332:
  mov    0x28(%rsp),%rbp
  mov    %rbx,%rdx
  mov    0x18(%rsp),%rcx
  xor    %edi,%edi
  mov    0x20(%rsp),%rsi
  sub    %r15,%rdx
  movzbl 0x0(%rbp),%eax
  jmp    L322
L314:
  sub    %r8,%r10
  add    %rbx,%r10
  cmp    %r9,%r14
  jae    L322
  mov    %rcx,0x18(%rsp)
  mov    %rsi,0x20(%rsp)
  mov    %rbp,0x28(%rsp)
  mov    %r14,%rbp
  mov    %r10,%r14
  nopl   (%rax)
L410:
  movsbl 0x0(%rbp),%edi
  add    $0x1,%rbx
  add    $0x1,%rbp
  call   <tolower@plt>
  mov    %al,-0x1(%rbx)
  cmp    %r14,%rbx
  jne    L410
  jmp    L332
```

assistant: ```c
size_t router_rewrite_metric(char (*newmetric)[8192], char **newfirstspace, const char *metric, const char *firstspace, const char *replacement, const size_t nmatch, const regmatch_t *pmatch) {
  char escape = 0;
  int ref = 0;
  char *s = *newmetric;
  const char *p;
  const char *q;
  const char *t;
  enum rewrite_case { RETAIN, LOWER, UPPER } rcase = RETAIN;
  assert(pmatch != NULL);
  q = metric;
  t = metric + pmatch[0].rm_so;
  if (s - *newmetric + t - q < sizeof(*newmetric)) {
    while (q < t)
      *s++ = *q++;
  } else {
    return 0;
  }
  for (p = replacement;; p++) {
    switch (*p) {
    case '\\':
      if (!escape) {
        escape = 1;
        rcase = RETAIN;
        break;
      }
    default:
      if (escape == 1 && rcase == RETAIN && *p == '_') {
        rcase = LOWER;
      } else if (escape == 1 && rcase == RETAIN && *p == '^') {
        rcase = UPPER;
      } else if (escape && *p >= '0' && *p <= '9') {
        escape = 2;
        ref *= 10;
        ref += *p - '0';
      } else {
        if (escape) {
          if (ref > 0 && ref <= nmatch && pmatch[ref].rm_so >= 0) {
            q = metric + pmatch[ref].rm_so;
            t = metric + pmatch[ref].rm_eo;
            if (s - *newmetric + t - q < sizeof(*newmetric)) {
              switch (rcase) {
              case RETAIN:
                while (q < t)
                  *s++ = *q++;
                break;
              case LOWER:
                while (q < t)
                  *s++ = (char)tolower(*q++);
                break;
              case UPPER:
                while (q < t)
                  *s++ = (char)toupper(*q++);
                break;
              }
            }
          }
          ref = 0;
        }
        if (*p != '\\') {
          escape = 0;
          rcase = RETAIN;
          if (s - *newmetric + 1 < sizeof(*newmetric))
            *s++ = *p;
        }
      }
      break;
    }
    if (*p == '\0')
      break;
  }
  s--;
  q = metric + pmatch[0].rm_eo;
  t = firstspace;
  if (s - *newmetric + t - q < sizeof(*newmetric)) {
    while (q < t)
      *s++ = *q++;
  } else {
    return 0;
  }
  *newfirstspace = s;
  if (s - *newmetric + strlen(firstspace) < sizeof(*newmetric)) {
    for (p = firstspace; *p != '\0'; p++)
      *s++ = *p;
    *s++ = '\0';
    return s - *newmetric;
  }
  return 0;
}
```