user: 请从给定的汇编指令推导出C源代码：

```asm
<frequency_distribution>:
  endbr64
  mov    %esi,%eax
  push   %r15
  mov    %esi,%r15d
  push   %r14
  mov    %r8d,%r14d
  push   %r13
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  mov    %ecx,%edi
  push   %rbx
  mov    %edx,%ebx
  cltd
  not    %edi
  idiv   %ebx
  sub    $0x28,%rsp
  shr    $0x1f,%edi
  cmp    %ecx,%ebx
  mov    %ecx,0x14(%rsp)
  mov    %r8d,0x18(%rsp)
  mov    %r9,0x8(%rsp)
  mov    %eax,%r12d
  setg   %al
  mov    %edx,0x10(%rsp)
  and    %eax,%edi
  call   <assert@plt>
  xor    %edi,%edi
  test   %ebp,%ebp
  setg   %dil
  call   <assert@plt>
  mov    %r14d,%edi
  mov    %r14d,%eax
  not    %edi
  shr    $0x1f,%edi
  cmp    %eax,%r15d
  setge  %al
  mov    %edi,%r14d
  and    %eax,%edi
  call   <assert@plt>
  mov    0x60(%rsp),%edx
  mov    0x14(%rsp),%ecx
  test   %edx,%edx
  jne    L122
  test   %ebx,%ebx
  jle    L169
  xor    %eax,%eax
  xor    %r9d,%r9d
  xchg   %ax,%ax
L205:
  xor    %edx,%edx
  cmp    %eax,0x10(%rsp)
  setg   %dl
  add    %r12d,%edx
  cmp    %eax,%ecx
  je     L117
L44:
  add    $0x1,%eax
  add    %edx,%r9d
  cmp    %eax,%ebx
  jne    L205
  mov    0x18(%rsp),%eax
  mov    0x60(%rsp),%r13d
  cmp    %eax,0x60(%rsp)
  setle  %r14b
L49:
  xor    %edi,%edi
  cmp    %r12d,%r13d
  setge  %dil
  and    %r14d,%edi
  call   <assert@plt>
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  setg   %dil
  cmp    %r12d,%r13d
  sete   %al
  or     %eax,%edi
  movzbl %dil,%edi
  call   <assert@plt>
  add    $0x28,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L122:
  cmpl   $0x1,0x60(%rsp)
  je     L164
  xor    %r13d,%r13d
  cmpl   $0x2,0x60(%rsp)
  jne    L49
  lea    -0x1(%rbp,%r15,1),%r15d
  cmp    %r15d,%ebp
  jg     L49
  movl   $0x1,0x1c(%rsp)
  xor    %r14d,%r14d
  jmp    L61
  nopl   0x0(%rax)
L41:
  cmp    $0xffffffff,%eax
  je     L140
  mov    %eax,%r14d
L121:
  mov    %r14d,%edi
  mov    %ecx,0x14(%rsp)
  not    %edi
  shr    $0x1f,%edi
  cmp    %ebx,%r14d
  setl   %al
  sub    $0x1,%r15d
  and    %eax,%edi
  call   <assert@plt>
  cmp    %r15d,%ebp
  mov    0x14(%rsp),%ecx
  jg     L180
L61:
  cmp    %r14d,%ecx
  jne    L101
  mov    0x8(%rsp),%rsi
  movslq %r13d,%rax
  add    $0x1,%r13d
  mov    %r15d,(%rsi,%rax,4)
L101:
  mov    0x1c(%rsp),%eax
  add    %r14d,%eax
  cmp    %eax,%ebx
  jne    L41
L140:
  negl   0x1c(%rsp)
  jmp    L121
  nopl   0x0(%rax,%rax,1)
L117:
  test   %edx,%edx
  jle    L8
  lea    0x0(%rbp,%r9,1),%edi
  mov    0x8(%rsp),%r8
  lea    (%rdx,%rdi,1),%r11d
  nopw   0x0(%rax,%rax,1)
L50:
  mov    %edi,(%r8)
  add    $0x1,%edi
  add    $0x4,%r8
  cmp    %edi,%r11d
  jne    L50
L8:
  mov    %edx,0x60(%rsp)
  jmp    L44
L164:
  add    %ebp,%r15d
  cmp    %r15d,%ebp
  jge    L169
  xor    %edx,%edx
  xor    %r13d,%r13d
  nopl   (%rax)
L39:
  cmp    %edx,%ecx
  jne    L151
  mov    0x8(%rsp),%rsi
  movslq %r13d,%rax
  add    $0x1,%r13d
  mov    %ebp,(%rsi,%rax,4)
L151:
  lea    0x1(%rdx),%eax
  add    $0x1,%ebp
  cltd
  idiv   %ebx
  cmp    %r15d,%ebp
  jne    L39
L180:
  cmp    0x18(%rsp),%r13d
  setle  %r14b
  jmp    L49
  nop
L169:
  xor    %r13d,%r13d
  jmp    L49
```

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;
}
```