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

```asm
<castle_norm_key_bounds_check>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x20(%rsp),%r14
  lea    0x28(%rsp),%r13
  mov    %r14,%rsi
  call   <castle_norm_key_end@plt>
  mov    %r12,%rdi
  mov    %r13,%rsi
  lea    0x30(%rsp),%r12
  mov    %rax,0x8(%rsp)
  call   <castle_norm_key_end@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  mov    %rax,0x10(%rsp)
  call   <castle_norm_key_end@plt>
  mov    %r14,%rdi
  mov    %rax,0x18(%rsp)
  call   <castle_norm_key_dim_get@plt>
  mov    %r13,%rdi
  mov    %rax,%r14
  call   <castle_norm_key_dim_get@plt>
  mov    %r12,%rdi
  mov    %rax,%rbx
  call   <castle_norm_key_dim_get@plt>
  cmp    %rbx,%r14
  mov    %rax,%r8
  sete   %al
  xor    %edi,%edi
  cmp    %r8,%r14
  sete   %dil
  and    %eax,%edi
  call   <assert@plt>
  mov    0x20(%rsp),%rbp
  test   %r14,%r14
  je     L123
  xor    %r13d,%r13d
  jmp    L33
  nopl   0x0(%rax)
L72:
  mov    0x30(%rsp),%rdx
  mov    0x20(%rsp),%rdi
  mov    %r12d,%ecx
  mov    %ebp,%esi
  sub    %edx,%ecx
  sub    %edi,%esi
  call   <castle_norm_key_data_compare@plt>
  test   %rax,%rax
  jg     L38
  lea    0x1(%r13),%eax
  mov    %rbp,0x20(%rsp)
  mov    %rbx,0x28(%rsp)
  mov    %rax,%r13
  mov    %r12,0x30(%rsp)
  cmp    %r14,%rax
  jae    L123
L33:
  mov    %rbp,%rdi
  call   <castle_norm_key_dim_next@plt>
  mov    0x28(%rsp),%rdi
  mov    %rax,%rbp
  call   <castle_norm_key_dim_next@plt>
  mov    0x30(%rsp),%rdi
  mov    %rax,%rbx
  call   <castle_norm_key_dim_next@plt>
  mov    0x28(%rsp),%rdx
  mov    %ebx,%ecx
  mov    %ebp,%esi
  mov    0x20(%rsp),%rdi
  mov    %rax,%r12
  sub    %edx,%ecx
  sub    %edi,%esi
  call   <castle_norm_key_data_compare@plt>
  test   %rax,%rax
  jns    L72
  mov    $0xffffffff,%eax
  test   %r15,%r15
  je     L83
L103:
  mov    %r13d,(%r15)
L83:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L92
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L123:
  xor    %edi,%edi
  cmp    0x8(%rsp),%rbp
  je     L70
L11:
  call   <assert@plt>
  xor    %eax,%eax
  jmp    L83
  nopw   0x0(%rax,%rax,1)
L38:
  mov    $0x1,%eax
  test   %r15,%r15
  jne    L103
  jmp    L83
  nopl   0x0(%rax)
L70:
  mov    0x10(%rsp),%rax
  cmp    %rax,0x28(%rsp)
  jne    L11
  xor    %edi,%edi
  mov    0x18(%rsp),%rax
  cmp    %rax,0x30(%rsp)
  sete   %dil
  jmp    L11
L92:
  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;
}
```