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

```asm
<parse_hex4>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  movl   $0x0,-0x4(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jle    L166
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jg     L166
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x30,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L187
L166:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x40,%al
  jle    L120
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x46,%al
  jg     L120
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x37,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L187
L120:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x60,%al
  jle    L172
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x66,%al
  jg     L172
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x57,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L187
L172:
  mov    $0x0,%eax
  jmp    L3
L187:
  shll   $0x4,-0x4(%rbp)
  addq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jle    L130
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jg     L130
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x30,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L160
L130:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x40,%al
  jle    L13
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x46,%al
  jg     L13
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x37,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L160
L13:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x60,%al
  jle    L167
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x66,%al
  jg     L167
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x57,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L160
L167:
  mov    $0x0,%eax
  jmp    L3
L160:
  shll   $0x4,-0x4(%rbp)
  addq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jle    L303
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jg     L303
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x30,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L392
L303:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x40,%al
  jle    L79
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x46,%al
  jg     L79
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x37,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L392
L79:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x60,%al
  jle    L125
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x66,%al
  jg     L125
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x57,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L392
L125:
  mov    $0x0,%eax
  jmp    L3
L392:
  shll   $0x4,-0x4(%rbp)
  addq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jle    L215
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jg     L215
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x30,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L7
L215:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x40,%al
  jle    L194
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x46,%al
  jg     L194
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x37,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L7
L194:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x60,%al
  jle    L224
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x66,%al
  jg     L224
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x57,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L7
L224:
  mov    $0x0,%eax
  jmp    L3
L7:
  mov    -0x4(%rbp),%eax
L3:
  pop    %rbp
  ret
```

assistant: ```c
unsigned parse_hex4(const char *str) {
  unsigned h = 0;
  if (*str >= '0' && *str <= '9')
    h += (*str) - '0';
  else if (*str >= 'A' && *str <= 'F')
    h += 10 + (*str) - 'A';
  else if (*str >= 'a' && *str <= 'f')
    h += 10 + (*str) - 'a';
  else
    return 0;
  h = h << 4;
  str++;
  if (*str >= '0' && *str <= '9')
    h += (*str) - '0';
  else if (*str >= 'A' && *str <= 'F')
    h += 10 + (*str) - 'A';
  else if (*str >= 'a' && *str <= 'f')
    h += 10 + (*str) - 'a';
  else
    return 0;
  h = h << 4;
  str++;
  if (*str >= '0' && *str <= '9')
    h += (*str) - '0';
  else if (*str >= 'A' && *str <= 'F')
    h += 10 + (*str) - 'A';
  else if (*str >= 'a' && *str <= 'f')
    h += 10 + (*str) - 'a';
  else
    return 0;
  h = h << 4;
  str++;
  if (*str >= '0' && *str <= '9')
    h += (*str) - '0';
  else if (*str >= 'A' && *str <= 'F')
    h += 10 + (*str) - 'A';
  else if (*str >= 'a' && *str <= 'f')
    h += 10 + (*str) - 'a';
  else
    return 0;
  return h;
}
```