user: Please show me the C implementation that matches the assembly code listed below:

```asm
<code_from_pwm>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %edi,%r12d
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %rcx,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x88(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  jle    L161
  mov    %edx,%eax
  mov    %edx,%r14d
  mov    %edx,%edi
  mov    %rsi,%r10
  shr    $0x2,%eax
  lea    0x10(%rsp),%rbx
  lea    -0x1(%rdx),%r15d
  xor    %edx,%edx
  sub    $0x1,%eax
  and    $0xfffffffc,%r14d
  mov    %rbx,%r9
  xor    %r8d,%r8d
  shl    $0x4,%rax
  xor    %ebp,%ebp
  lea    0x10(%rsi,%rax,1),%rcx
  mov    %edx,%eax
  add    $0x140,%edx
  test   %edi,%edi
  jle    L3
  nopl   0x0(%rax,%rax,1)
L89:
  cmp    $0x2,%r15d
  jbe    L119
  movd   %eax,%xmm6
  movd   %edx,%xmm7
  pxor   %xmm1,%xmm1
  mov    %r10,%rax
  pshufd $0x0,%xmm6,%xmm3
  pshufd $0x0,%xmm7,%xmm4
  nopl   0x0(%rax,%rax,1)
L152:
  movdqu (%rax),%xmm0
  movdqu (%rax),%xmm5
  movdqa %xmm4,%xmm2
  add    $0x10,%rax
  pcmpgtd %xmm3,%xmm0
  pcmpgtd %xmm5,%xmm2
  pand   %xmm2,%xmm0
  psubd  %xmm0,%xmm1
  cmp    %rcx,%rax
  jne    L152
  movdqa %xmm1,%xmm0
  mov    %r14d,%esi
  psrldq $0x8,%xmm0
  paddd  %xmm0,%xmm1
  movdqa %xmm1,%xmm0
  psrldq $0x4,%xmm0
  paddd  %xmm0,%xmm1
  movd   %xmm1,%eax
  cmp    %r14d,%edi
  je     L135
L75:
  movslq %esi,%r13
  lea    0x0(,%r13,4),%r11
  mov    (%r10,%r13,4),%r13d
  cmp    %r8d,%r13d
  jle    L145
  cmp    %edx,%r13d
  setl   %r13b
  cmp    $0x1,%r13b
  sbb    $0xffffffff,%eax
L145:
  lea    0x1(%rsi),%r13d
  cmp    %edi,%r13d
  jge    L135
  mov    0x4(%r10,%r11,1),%r13d
  cmp    %edx,%r13d
  jge    L38
  cmp    %r8d,%r13d
  setg   %r13b
  cmp    $0x1,%r13b
  sbb    $0xffffffff,%eax
L38:
  add    $0x2,%esi
  cmp    %esi,%edi
  jle    L135
  mov    0x8(%r10,%r11,1),%esi
  cmp    %r8d,%esi
  jle    L135
  cmp    %esi,%edx
  setg   %sil
  cmp    $0x1,%sil
  sbb    $0xffffffff,%eax
L135:
  mov    %eax,(%r9)
  add    $0x140,%r8d
  lea    0x1(%rbp),%eax
  add    $0x4,%r9
  cmp    %edx,%r12d
  jle    L87
  movslq %eax,%rbp
  mov    %edx,%eax
  add    $0x140,%edx
  test   %edi,%edi
  jg     L89
L3:
  xor    %eax,%eax
  jmp    L135
  nopl   0x0(%rax)
L87:
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  lea    0x4(%rbx),%rdx
  xor    %esi,%esi
  lea    (%rdx,%rbp,4),%rdi
  jmp    L57
L196:
  movslq %esi,%rcx
  add    $0x1,%esi
  movl   $0x3,(%rax,%rcx,4)
L44:
  mov    %rdx,%rbx
  cmp    %rdx,%rdi
  je     L79
L118:
  add    $0x4,%rdx
L57:
  mov    (%rbx),%ecx
  cmp    $0x5,%ecx
  jg     L196
  test   %ecx,%ecx
  jle    L44
  movslq %esi,%rcx
  mov    %rdx,%rbx
  add    $0x1,%esi
  movl   $0x2,(%rax,%rcx,4)
  cmp    %rdx,%rdi
  jne    L118
L79:
  mov    0x8(%rsp),%rbx
  mov    %rax,(%rbx)
  mov    0x88(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L198
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L119:
  xor    %eax,%eax
  xor    %esi,%esi
  jmp    L75
L161:
  xor    %edi,%edi
  call   <malloc@plt>
  jmp    L79
L198:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void code_from_pwm(int sig_length, int *positivepklocs, int positivepkcnt, int **codestorage) {
  int i = 0, j = 0, k = 0;
  int window = 2.5 * 128, numof_windows = 0, limit = 0, number = 0;
  int period[30];
  int *codetemp;
  while (i < sig_length) {
    limit = i + window;
    number = 0;
    for (j = 0; j < positivepkcnt; j++) {
      if (positivepklocs[j] < limit && positivepklocs[j] > i)
        number = number + 1;
    }
    i = i + window;
    period[k] = number;
    k = k + 1;
  }
  numof_windows = k;
  codetemp = (int *)malloc(numof_windows * sizeof(int));
  k = 0;
  for (i = 0; i < numof_windows; i++) {
    if (period[i] > 5) {
      codetemp[k] = 3;
      k = k + 1;
    } else if (period[i] > 0) {
      codetemp[k] = 2;
      k = k + 1;
    }
  }
  *codestorage = codetemp;
}
```