user: 请将以下的汇编代码转换成C语言代码:

```asm
<castle_norm_key_bounds_check>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rsi,%rbp
  mov    %rdx,%rbx
  mov    %rcx,%r15
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x20(%rsp),%r13
  mov    %r13,%rsi
  call   <castle_norm_key_end@plt>
  mov    %rax,0x8(%rsp)
  lea    0x28(%rsp),%r12
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <castle_norm_key_end@plt>
  mov    %rax,0x10(%rsp)
  lea    0x30(%rsp),%rbp
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <castle_norm_key_end@plt>
  mov    %rax,0x18(%rsp)
  mov    %r13,%rdi
  call   <castle_norm_key_dim_get@plt>
  mov    %rax,%r14
  mov    %r12,%rdi
  call   <castle_norm_key_dim_get@plt>
  mov    %rax,%rbx
  mov    %rbp,%rdi
  call   <castle_norm_key_dim_get@plt>
  mov    %rax,%rdx
  cmp    %rbx,%r14
  sete   %al
  cmp    %rdx,%r14
  sete   %dil
  movzbl %dil,%edi
  and    %eax,%edi
  call   <assert@plt>
  test   %r14,%r14
  je     L23
  mov    $0x0,%r13d
L99:
  mov    0x20(%rsp),%rdi
  call   <castle_norm_key_dim_next@plt>
  mov    %rax,%rbx
  mov    0x28(%rsp),%rdi
  call   <castle_norm_key_dim_next@plt>
  mov    %rax,%rbp
  mov    0x30(%rsp),%rdi
  call   <castle_norm_key_dim_next@plt>
  mov    %rax,%r12
  mov    0x28(%rsp),%rdx
  mov    0x20(%rsp),%rdi
  mov    %ebp,%ecx
  sub    %edx,%ecx
  mov    %ebx,%esi
  sub    %edi,%esi
  call   <castle_norm_key_data_compare@plt>
  test   %rax,%rax
  js     L0
  mov    0x30(%rsp),%rdx
  mov    0x20(%rsp),%rdi
  mov    %r12d,%ecx
  sub    %edx,%ecx
  mov    %ebx,%esi
  sub    %edi,%esi
  call   <castle_norm_key_data_compare@plt>
  test   %rax,%rax
  jg     L95
  mov    %rbx,0x20(%rsp)
  mov    %rbp,0x28(%rsp)
  mov    %r12,0x30(%rsp)
  add    $0x1,%r13d
  mov    %r13d,%eax
  cmp    %r14,%rax
  jb     L99
L23:
  mov    $0x0,%edi
  mov    0x8(%rsp),%rax
  cmp    %rax,0x20(%rsp)
  je     L109
L81:
  call   <assert@plt>
  mov    $0x0,%eax
L49:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L3
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L0:
  mov    $0xffffffff,%eax
  test   %r15,%r15
  je     L49
  mov    %r13d,(%r15)
  jmp    L49
L95:
  mov    $0x1,%eax
  test   %r15,%r15
  je     L49
  mov    %r13d,(%r15)
  jmp    L49
L109:
  mov    0x10(%rsp),%rax
  cmp    %rax,0x28(%rsp)
  jne    L81
  mov    0x18(%rsp),%rax
  cmp    %rax,0x30(%rsp)
  sete   %dil
  movzbl %dil,%edi
  jmp    L81
L3:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int castle_norm_key_bounds_check(const struct castle_norm_key *key, const struct castle_norm_key *lower, const struct castle_norm_key *upper, unsigned int *offending_dim) {
  const unsigned char *key_curr, *key_end = castle_norm_key_end(key, &key_curr);
  const unsigned char *lower_curr, *lower_end = castle_norm_key_end(lower, &lower_curr);
  const unsigned char *upper_curr, *upper_end = castle_norm_key_end(upper, &upper_curr);
  unsigned int dim;
  size_t key_dim = castle_norm_key_dim_get(&key_curr);
  size_t lower_dim = castle_norm_key_dim_get(&lower_curr);
  size_t upper_dim = castle_norm_key_dim_get(&upper_curr);
  assert(!(key_dim != lower_dim || key_dim != upper_dim));
  for (dim = 0; dim < key_dim; ++dim) {
    const unsigned char *key_next = castle_norm_key_dim_next(key_curr);
    const unsigned char *lower_next = castle_norm_key_dim_next(lower_curr);
    const unsigned char *upper_next = castle_norm_key_dim_next(upper_curr);
    if (castle_norm_key_data_compare(key_curr, key_next - key_curr, lower_curr, lower_next - lower_curr) < 0) {
      if (offending_dim)
        *offending_dim = dim;
      return -1;
    }
    if (castle_norm_key_data_compare(key_curr, key_next - key_curr, upper_curr, upper_next - upper_curr) > 0) {
      if (offending_dim)
        *offending_dim = dim;
      return 1;
    }
    key_curr = key_next;
    lower_curr = lower_next;
    upper_curr = upper_next;
  }
  assert(!(key_curr != key_end || lower_curr != lower_end || upper_curr != upper_end));
  return 0;
}
```