user: What is the c source code of the assembly code below:

```asm
<spf_indexes>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,%eax
  mov    %rdx,-0x28(%rbp)
  mov    %ax,-0x1c(%rbp)
  movzwl -0x1c(%rbp),%eax
  mov    %ax,-0x2(%rbp)
  mov    -0x28(%rbp),%rax
  and    $0x4,%eax
  test   %rax,%rax
  je     L83
  movzwl -0x2(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x2(%rbp)
L83:
  mov    -0x28(%rbp),%rax
  and    $0x8,%eax
  test   %rax,%rax
  je     L28
  mov    -0x28(%rbp),%rax
  and    $0x10,%eax
  test   %rax,%rax
  je     L6
  movzwl -0x2(%rbp),%eax
  movzwl %ax,%eax
  imul   $0xaaab,%eax,%eax
  shr    $0x10,%eax
  shr    %ax
  mov    %ax,-0x2(%rbp)
  jmp    L28
L6:
  movzwl -0x2(%rbp),%eax
  shr    %ax
  mov    %ax,-0x2(%rbp)
L28:
  mov    -0x28(%rbp),%rax
  and    $0x1,%eax
  test   %rax,%rax
  je     L20
  movzwl -0x2(%rbp),%eax
  sub    $0x1,%eax
  mov    %ax,-0x2(%rbp)
L20:
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  movw   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x6,%rax
  movw   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x8,%rax
  movw   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0xa,%rax
  movw   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0xc,%rax
  movw   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0xe,%rax
  movw   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x10,%rax
  movw   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  movw   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x2,%rax
  movzwl -0x2(%rbp),%edx
  sub    $0x1,%edx
  mov    %dx,(%rax)
  mov    -0x28(%rbp),%rax
  and    $0x1,%eax
  test   %rax,%rax
  je     L44
  mov    -0x28(%rbp),%rax
  and    $0x4,%eax
  test   %rax,%rax
  jne    L44
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rdx
  movzwl -0x2(%rbp),%eax
  mov    %ax,(%rdx)
  movzwl -0x2(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x4(%rbp)
  jmp    L89
L44:
  movzwl -0x2(%rbp),%eax
  mov    %ax,-0x4(%rbp)
L89:
  mov    -0x28(%rbp),%rax
  and    $0x8,%eax
  test   %rax,%rax
  je     L126
  mov    -0x18(%rbp),%rax
  lea    0x6(%rax),%rdx
  movzwl -0x4(%rbp),%eax
  mov    %ax,(%rdx)
  movzwl -0x4(%rbp),%edx
  movzwl -0x2(%rbp),%eax
  add    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    $0x8,%rax
  sub    $0x1,%edx
  mov    %dx,(%rax)
  mov    -0x28(%rbp),%rax
  and    $0x1,%eax
  test   %rax,%rax
  je     L100
  mov    -0x18(%rbp),%rax
  add    $0xa,%rax
  movzwl -0x4(%rbp),%ecx
  movzwl -0x2(%rbp),%edx
  add    %ecx,%edx
  mov    %dx,(%rax)
  movzwl -0x4(%rbp),%edx
  movzwl -0x2(%rbp),%eax
  add    %edx,%eax
  add    $0x1,%eax
  mov    %ax,-0x4(%rbp)
  jmp    L86
L100:
  movzwl -0x2(%rbp),%eax
  add    %ax,-0x4(%rbp)
L86:
  mov    -0x28(%rbp),%rax
  and    $0x10,%eax
  test   %rax,%rax
  je     L126
  mov    -0x18(%rbp),%rax
  lea    0xc(%rax),%rdx
  movzwl -0x4(%rbp),%eax
  mov    %ax,(%rdx)
  movzwl -0x4(%rbp),%edx
  movzwl -0x2(%rbp),%eax
  add    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    $0xe,%rax
  sub    $0x1,%edx
  mov    %dx,(%rax)
  mov    -0x28(%rbp),%rax
  and    $0x1,%eax
  test   %rax,%rax
  je     L126
  mov    -0x18(%rbp),%rax
  add    $0x10,%rax
  movzwl -0x4(%rbp),%ecx
  movzwl -0x2(%rbp),%edx
  add    %ecx,%edx
  mov    %dx,(%rax)
L126:
  nop
  pop    %rbp
  ret
```

assistant: ```c
void spf_indexes(unsigned short idx[9], unsigned short dim, long flag) {
  unsigned short nextidx, d = dim;
  if (flag & 0x04)
    d++;
  if (flag & 0x08) {
    if (flag & 0x10)
      d /= 3;
    else
      d /= 2;
  }
  if (flag & 0x01)
    d--;
  idx[2] = 0;
  idx[3] = 0;
  idx[4] = 0;
  idx[5] = 0;
  idx[6] = 0;
  idx[7] = 0;
  idx[8] = 0;
  idx[0] = 0;
  idx[1] = d - 1;
  if ((flag & 0x01) && !(flag & 0x04)) {
    idx[2] = d;
    nextidx = d + 1;
  } else
    nextidx = d;
  if (flag & 0x08) {
    idx[3] = nextidx;
    idx[4] = nextidx + d - 1;
    if (flag & 0x01) {
      idx[5] = nextidx + d;
      nextidx = nextidx + d + 1;
    } else
      nextidx = nextidx + d;
    if (flag & 0x10) {
      idx[6] = nextidx;
      idx[7] = nextidx + d - 1;
      if (flag & 0x01)
        idx[8] = nextidx + d;
    }
  }
}
```