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

```asm
<frequency_distribution>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,%r12d
  mov    %edx,%ebx
  mov    %ecx,%ebp
  mov    %r8d,%r13d
  mov    %r8d,0x18(%rsp)
  mov    %r9,0x10(%rsp)
  mov    %esi,0x8(%rsp)
  mov    %esi,%eax
  cltd
  idiv   %ebx
  mov    %edx,%r15d
  mov    %eax,%r14d
  mov    %ecx,%edi
  not    %edi
  shr    $0x1f,%edi
  cmp    %ecx,%ebx
  setg   %al
  and    %eax,%edi
  call   <assert@plt>
  test   %r12d,%r12d
  setg   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %r13d,%edi
  not    %edi
  shr    $0x1f,%edi
  cmp    %r13d,0x8(%rsp)
  setge  %al
  and    %eax,%edi
  call   <assert@plt>
  cmpl   $0x0,0x60(%rsp)
  jne    L5
  test   %ebx,%ebx
  jle    L122
  mov    0x60(%rsp),%eax
  mov    %eax,%edi
L123:
  cmp    %eax,%r15d
  setg   %dl
  movzbl %dl,%edx
  add    %r14d,%edx
  cmp    %eax,%ebp
  je     L45
L15:
  add    %edx,%edi
  add    $0x1,%eax
  cmp    %eax,%ebx
  jne    L123
  mov    0x60(%rsp),%r13d
L19:
  cmp    %r14d,%r13d
  setge  %al
  cmp    0x18(%rsp),%r13d
  setle  %dil
  movzbl %dil,%edi
  and    %eax,%edi
  call   <assert@plt>
  test   %r15d,%r15d
  setg   %dil
  cmp    %r14d,%r13d
  sete   %al
  or     %eax,%edi
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %r13d,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L45:
  test   %edx,%edx
  jle    L175
  lea    (%r12,%rdi,1),%ecx
  mov    0x10(%rsp),%rsi
  lea    (%rcx,%rdx,1),%r8d
L218:
  mov    %ecx,(%rsi)
  add    $0x1,%ecx
  add    $0x4,%rsi
  cmp    %ecx,%r8d
  jne    L218
  mov    %edx,0x60(%rsp)
  jmp    L15
L175:
  mov    %edx,0x60(%rsp)
  jmp    L15
L5:
  cmpl   $0x1,0x60(%rsp)
  je     L137
  mov    $0x0,%r13d
  cmpl   $0x2,0x60(%rsp)
  jne    L19
  mov    0x8(%rsp),%eax
  lea    -0x1(%r12,%rax,1),%eax
  mov    %eax,0xc(%rsp)
  cmp    %eax,%r12d
  jg     L104
  movl   $0x1,0x1c(%rsp)
  movl   $0x0,0x8(%rsp)
  jmp    L8
L137:
  mov    0x8(%rsp),%ecx
  add    %r12d,%ecx
  cmp    %ecx,%r12d
  jge    L146
  mov    $0x0,%edx
  mov    $0x0,%r13d
  jmp    L28
L148:
  lea    0x1(%rdx),%eax
  cltd
  idiv   %ebx
  add    $0x1,%r12d
  cmp    %ecx,%r12d
  je     L19
L28:
  cmp    %edx,%ebp
  jne    L148
  movslq %r13d,%rax
  mov    0x10(%rsp),%rsi
  mov    %r12d,(%rsi,%rax,4)
  lea    0x1(%r13),%r13d
  jmp    L148
L159:
  movslq %r13d,%rax
  mov    0x10(%rsp),%rsi
  mov    0xc(%rsp),%ecx
  mov    %ecx,(%rsi,%rax,4)
  lea    0x1(%r13),%r13d
  jmp    L30
L207:
  negl   0x1c(%rsp)
L185:
  mov    0x8(%rsp),%eax
  mov    %eax,%edi
  not    %edi
  shr    $0x1f,%edi
  cmp    %ebx,%eax
  setl   %al
  and    %eax,%edi
  call   <assert@plt>
  subl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%eax
  cmp    %eax,%r12d
  jg     L19
L8:
  cmp    0x8(%rsp),%ebp
  je     L159
L30:
  mov    0x8(%rsp),%eax
  add    0x1c(%rsp),%eax
  cmp    %eax,%ebx
  je     L207
  cmp    $0xffffffff,%eax
  je     L207
  mov    %eax,0x8(%rsp)
  jmp    L185
L122:
  mov    0x60(%rsp),%r13d
  jmp    L19
L146:
  mov    $0x0,%r13d
  jmp    L19
L104:
  mov    $0x0,%r13d
  jmp    L19
```

assistant: ```c
int frequency_distribution(int nw_low, int nw, int npes, int pe, int maxlw, int *freq_index, int type) {
  int my_n_local_w = 0;
  int min_n_local_w, n_local_w;
  int leftover_w;
  int index = 0, ipe, dpe, iw, i;
  min_n_local_w = nw / npes;
  leftover_w = nw % npes;
  assert(0 <= pe && pe < npes);
  assert(0 < nw_low);
  assert(0 <= maxlw && maxlw <= nw);
  if (type == 0) {
    for (ipe = 0; ipe < npes; ipe++) {
      n_local_w = min_n_local_w + (ipe < leftover_w ? 1 : 0);
      if (pe == ipe) {
        my_n_local_w = n_local_w;
        for (i = 0; i < my_n_local_w; i++) {
          freq_index[i] = nw_low + index + i;
        }
      }
      index += n_local_w;
    }
  } else if (type == 1) {
    ipe = 0;
    for (iw = nw_low; iw < nw + nw_low; iw++) {
      if (ipe == pe)
        freq_index[my_n_local_w++] = iw;
      ipe = (ipe + 1) % npes;
    }
  } else if (type == 2) {
    ipe = 0;
    dpe = 1;
    for (iw = nw - 1 + nw_low; iw >= nw_low; iw--) {
      if (ipe == pe)
        freq_index[my_n_local_w++] = iw;
      ipe += dpe;
      if (ipe == npes || ipe == -1) {
        dpe *= -1;
        ipe += dpe;
      }
      assert(0 <= ipe && ipe < npes);
    }
  }
  assert(min_n_local_w <= my_n_local_w && my_n_local_w <= maxlw);
  assert(leftover_w > 0 || min_n_local_w == my_n_local_w);
  return my_n_local_w;
}
```