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

```asm
<vote_week_num>:
  endbr64
  push   %r14
  xor    %eax,%eax
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  call   <channel_get_count@plt>
  test   %eax,%eax
  je     L128
  lea    0x0(,%rax,4),%r12d
  mov    %eax,%r13d
  mov    %r12d,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L128
  mov    %r12d,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L117
  test   %r13d,%r13d
  jle    L144
  mov    %r13d,%edx
  lea    0x0(,%rdx,4),%rbx
  lea    0x0(%rbp,%rbx,1),%rax
  cmp    %rax,%r12
  jae    L182
  lea    (%r12,%rbx,1),%rax
  cmp    %rax,%rbp
  jb     L9
L182:
  mov    %rbx,%rdx
  mov    $0xff,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    %rbx,%rdx
  xor    %esi,%esi
  mov    %r12,%rdi
  call   <memset@plt>
L12:
  xor    %r14d,%r14d
  nopl   0x0(%rax)
L132:
  mov    %r14d,%edi
  call   <channel_get_sv_id@plt>
  mov    %eax,%edi
  test   %eax,%eax
  je     L86
  call   <nav_week_num@plt>
  cmp    $0xffffffff,%eax
  je     L86
  xor    %edx,%edx
  jmp    L171
  nopl   0x0(%rax)
L98:
  cmp    %eax,%ecx
  je     L3
  add    $0x4,%rdx
  cmp    %rdx,%rbx
  je     L86
L171:
  mov    0x0(%rbp,%rdx,1),%ecx
  lea    0x0(%rbp,%rdx,1),%rsi
  cmp    $0xffffffff,%ecx
  jne    L98
  mov    %eax,(%rsi)
  addl   $0x1,(%r12,%rdx,1)
  cs nopw 0x0(%rax,%rax,1)
L86:
  add    $0x1,%r14d
  cmp    %r14d,%r13d
  jne    L132
L144:
  mov    (%r12),%ecx
  mov    0x0(%rbp),%r14d
  cmp    $0x1,%r13d
  jle    L190
  lea    -0x2(%r13),%esi
  mov    $0x1,%eax
  add    $0x2,%rsi
  nopl   0x0(%rax)
L134:
  mov    (%r12,%rax,4),%edx
  cmp    %ecx,%edx
  jle    L88
  mov    0x0(%rbp,%rax,4),%r14d
  mov    %edx,%ecx
L88:
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L134
L190:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %r12,%rdi
  call   <free@plt>
L27:
  pop    %rbx
  mov    %r14d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L3:
  addl   $0x1,(%r12,%rdx,1)
  jmp    L86
L9:
  xor    %eax,%eax
  nopl   0x0(%rax)
L150:
  movl   $0xffffffff,0x0(%rbp,%rax,4)
  movl   $0x0,(%r12,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L150
  jmp    L12
L117:
  mov    %rbp,%rdi
  call   <free@plt>
L128:
  mov    $0xffffffff,%r14d
  jmp    L27
```

assistant: ```c
int vote_week_num(void) {
  int *week_nums;
  int *votes;
  int count = channel_get_count();
  int i, c;
  int max_week, max_votes;
  if (count == 0)
    return -1;
  week_nums = malloc(sizeof(int) * count);
  if (week_nums == NULL)
    return -1;
  votes = malloc(sizeof(int) * count);
  if (votes == NULL) {
    free(week_nums);
    return -1;
  }
  for (i = 0; i < count; i++) {
    week_nums[i] = -1;
    votes[i] = 0;
  }
  for (c = 0; c < count; c++) {
    int sv, week;
    sv = channel_get_sv_id(c);
    if (sv == 0)
      continue;
    week = nav_week_num(sv);
    if (week == -1)
      continue;
    for (i = 0; i < count; i++) {
      if (week_nums[i] == -1) {
        week_nums[i] = week;
        votes[i] = votes[i] + 1;
        break;
      } else if (week_nums[i] == week) {
        votes[i] = votes[i] + 1;
        break;
      }
    }
  }
  max_votes = votes[0];
  max_week = week_nums[0];
  for (i = 1; i < count; i++) {
    if (votes[i] > max_votes) {
      max_votes = votes[i];
      max_week = week_nums[i];
    }
  }
  free(week_nums);
  free(votes);
  return max_week;
}
```