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

```asm
<hsfc2d>:
  endbr64
  push   %r15
  mov    %rdx,%r9
  mov    $0x2,%edx
  push   %r14
  push   %r13
  push   %r12
  mov    D41(%rip),%r12
  push   %rbp
  push   %rbx
  mov    (%rsi),%ecx
  mov    %rdi,%rbx
  movslq (%r12),%rax
  cmp    %edx,%ecx
  cmovbe %rcx,%rdx
  imul   %rdx,%rax
  mov    D35(%rip),%edx
  shl    $0x2,%rax
  shr    %rax
  mov    %eax,%r13d
  test   %edx,%edx
  jne    L104
  movl   $0x2030100,D12(%rip)
  movl   $0x1,D35(%rip)
L104:
  test   %ecx,%ecx
  je     L72
  movl   $0x0,(%r9)
  cmp    $0x1,%ecx
  je     L72
  movl   $0x0,0x4(%r9)
L72:
  test   %eax,%eax
  je     L38
  mov    $0x1,%r11d
  xor    %ebp,%ebp
  mov    $0x1,%edi
  xor    %r10d,%r10d
  lea    D12(%rip),%r14
  jmp    L15
  nopl   0x0(%rax)
L14:
  mov    %esi,%ecx
  shl    %cl,%r15d
  or     %r15d,(%r9,%rax,4)
  test   %r8b,%r8b
  je     L108
L46:
  cmp    $0x3,%r8b
  jne    L106
  mov    %r10d,%eax
  xor    $0x3,%ebp
  mov    %r11d,%r10d
  mov    %eax,%r11d
L106:
  add    $0x1,%edi
  cmp    %edi,%r13d
  jb     L38
L15:
  movslq (%r12),%rdx
  mov    (%rbx),%eax
  mov    0x4(%rbx),%r15d
  mov    %rdx,%rsi
  shl    $0x2,%esi
  mov    %esi,%r8d
  sub    %edi,%r8d
  mov    %r8d,%ecx
  shr    %cl,%eax
  mov    %r10d,%ecx
  and    $0x1,%eax
  shl    %cl,%eax
  mov    %r8d,%ecx
  shr    %cl,%r15d
  mov    %r11d,%ecx
  mov    %r15d,%r8d
  and    $0x1,%r8d
  shl    %cl,%r8d
  movzbl %bpl,%ecx
  or     %r8d,%eax
  xor    %ecx,%eax
  lea    0x0(,%rdx,4),%rcx
  xor    %edx,%edx
  movzbl (%r14,%rax,1),%r15d
  lea    (%rdi,%rdi,1),%eax
  div    %rcx
  mov    %r15d,%r8d
  sub    %edx,%esi
  mov    %esi,%edx
  cmp    %rdx,%rcx
  jne    L14
  sub    $0x1,%eax
  or     %r15d,(%r9,%rax,4)
  test   %r8b,%r8b
  jne    L46
L108:
  mov    %r10d,%eax
  add    $0x1,%edi
  mov    %r11d,%r10d
  mov    %eax,%r11d
  cmp    %edi,%r13d
  jae    L15
L38:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void hsfc2d(unsigned coord[], unsigned *nkey, unsigned key[]) {
  static int init = 0;
  static unsigned char gray_inv[2 * 2];
  const unsigned NKey = (2 < *nkey) ? 2 : (*nkey);
  const unsigned NBits = ((sizeof(unsigned) * CHAR_BIT) * NKey) / 2;
  unsigned i;
  unsigned char order[2 + 2];
  unsigned char reflect;
  if (!init) {
    unsigned char gray[2 * 2];
    register unsigned k;
    register unsigned j;
    gray[0] = 0;
    for (k = 1; k < sizeof(gray); k <<= 1) {
      for (j = 0; j < k; j++)
        gray[k + j] = k | gray[k - (j + 1)];
    }
    for (k = 0; k < sizeof(gray); k++)
      gray_inv[gray[k]] = k;
    init = 1;
  }
  for (i = 0; i < NKey; ++i)
    key[i] = 0;
  order[0] = 0;
  order[1] = 1;
  reflect = (0 << 0) | (0);
  for (i = 1; i <= NBits; i++) {
    const unsigned s = (sizeof(unsigned) * CHAR_BIT) - i;
    const unsigned c = gray_inv[reflect ^ ((((coord[0] >> s) & 01) << order[0]) | (((coord[1] >> s) & 01) << order[1]))];
    const unsigned off = 2 * i;
    const unsigned which = off / (sizeof(unsigned) * CHAR_BIT);
    const unsigned shift = (sizeof(unsigned) * CHAR_BIT) - off % (sizeof(unsigned) * CHAR_BIT);
    if (shift == (sizeof(unsigned) * CHAR_BIT)) {
      key[which - 1] |= c;
    } else {
      key[which] |= c << shift;
    }
    switch (c) {
    case 3:
      reflect ^= 03;
    case 0:
      order[2 + 0] = order[0];
      order[2 + 1] = order[1];
      order[0] = order[2 + 1];
      order[1] = order[2 + 0];
      break;
    }
  }
}
```