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

```asm
<scan_motif4>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %edx,-0x54(%rbp)
  mov    %ecx,-0x58(%rbp)
  movss  %xmm0,-0x5c(%rbp)
  mov    %r8,-0x68(%rbp)
  mov    %r9,-0x70(%rbp)
  mov    -0x58(%rbp),%eax
  sub    -0x54(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  movl   $0x0,-0x30(%rbp)
  cmpl   $0x0,0x28(%rbp)
  jle    L119
  mov    -0x54(%rbp),%eax
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <cvector@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x54(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%esi
  mov    $0x0,%edi
  call   <cvector@plt>
  mov    %rax,-0x18(%rbp)
L119:
  mov    -0x54(%rbp),%eax
  neg    %eax
  mov    %eax,-0x28(%rbp)
  movl   $0x1,-0x20(%rbp)
  movl   $0x1,-0x38(%rbp)
  jmp    L139
L190:
  mov    -0x38(%rbp),%eax
  sub    -0x28(%rbp),%eax
  cmp    %eax,0x18(%rbp)
  jge    L18
  pxor   %xmm0,%xmm0
  movss  %xmm0,-0x2c(%rbp)
  movl   $0x1,-0x34(%rbp)
  jmp    L46
L249:
  mov    -0x38(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x39(%rbp)
  cmpb   $0x0,-0x39(%rbp)
  setg   %dl
  cmpb   $0x4,-0x39(%rbp)
  setle  %al
  and    %edx,%eax
  test   %al,%al
  je     L248
  movsbq -0x39(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  movss  %xmm0,-0x1c(%rbp)
  movss  -0x2c(%rbp),%xmm0
  addss  -0x1c(%rbp),%xmm0
  movss  %xmm0,-0x2c(%rbp)
  jmp    L53
L248:
  pxor   %xmm0,%xmm0
  cvtss2sd -0x2c(%rbp),%xmm0
  movsd  D30(%rip),%xmm1
  subsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,-0x2c(%rbp)
L53:
  addl   $0x1,-0x34(%rbp)
L46:
  mov    -0x34(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jle    L249
  movss  -0x2c(%rbp),%xmm0
  comiss -0x5c(%rbp),%xmm0
  jb     L18
  mov    -0x38(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  addl   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x68(%rbp),%rax
  add    %rax,%rdx
  mov    -0x58(%rbp),%eax
  sub    -0x38(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x30(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    -0x20(%rbp),%edx
  mov    %dl,(%rax)
  cmpl   $0x0,0x28(%rbp)
  jle    L18
  movl   $0x1,-0x34(%rbp)
  jmp    L105
L1:
  mov    -0x38(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    -0x34(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x34(%rbp)
L105:
  mov    -0x34(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jle    L1
  mov    -0x18(%rbp),%rax
  lea    D54(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0x18(%rbp),%rdx
  mov    -0x54(%rbp),%esi
  mov    -0x10(%rbp),%rax
  mov    $0x1,%ecx
  mov    %rax,%rdi
  call   <num2seq@plt>
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x20(%rbp),%r8d
  mov    -0x18(%rbp),%rdi
  mov    -0x2c(%rbp),%esi
  mov    0x28(%rbp),%edx
  mov    0x20(%rbp),%rax
  mov    %r8d,%r9d
  mov    %rdi,%r8
  movd   %esi,%xmm0
  lea    D58(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
L18:
  addl   $0x1,-0x38(%rbp)
L139:
  mov    -0x38(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L190
  movl   $0x0,-0x20(%rbp)
  mov    -0x54(%rbp),%eax
  neg    %eax
  mov    %eax,-0x28(%rbp)
  cmpl   $0x1,0x10(%rbp)
  jne    L182
  mov    -0x58(%rbp),%eax
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <cvector@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x58(%rbp),%edx
  mov    -0x8(%rbp),%rcx
  mov    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <revcomp@plt>
  movl   $0x1,-0x38(%rbp)
  jmp    L100
L214:
  mov    -0x38(%rbp),%eax
  sub    -0x28(%rbp),%eax
  cmp    %eax,0x18(%rbp)
  jge    L219
  pxor   %xmm0,%xmm0
  movss  %xmm0,-0x2c(%rbp)
  movl   $0x1,-0x34(%rbp)
  jmp    L146
L0:
  mov    -0x38(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x39(%rbp)
  cmpb   $0x0,-0x39(%rbp)
  setg   %dl
  cmpb   $0x4,-0x39(%rbp)
  setle  %al
  and    %edx,%eax
  test   %al,%al
  je     L131
  movsbq -0x39(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  movss  %xmm0,-0x1c(%rbp)
  movss  -0x2c(%rbp),%xmm0
  addss  -0x1c(%rbp),%xmm0
  movss  %xmm0,-0x2c(%rbp)
  jmp    L28
L131:
  pxor   %xmm0,%xmm0
  cvtss2sd -0x2c(%rbp),%xmm0
  movsd  D30(%rip),%xmm1
  subsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,-0x2c(%rbp)
L28:
  addl   $0x1,-0x34(%rbp)
L146:
  mov    -0x34(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jle    L0
  movss  -0x2c(%rbp),%xmm0
  comiss -0x5c(%rbp),%xmm0
  jb     L219
  mov    -0x38(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  addl   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x68(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x30(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  cmpl   $0x0,0x28(%rbp)
  jle    L219
  movl   $0x1,-0x34(%rbp)
  jmp    L199
L52:
  mov    -0x38(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x34(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x34(%rbp)
L199:
  mov    -0x34(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jle    L52
  mov    -0x18(%rbp),%rax
  lea    D54(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0x18(%rbp),%rdx
  mov    -0x54(%rbp),%esi
  mov    -0x10(%rbp),%rax
  mov    $0x1,%ecx
  mov    %rax,%rdi
  call   <num2seq@plt>
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x20(%rbp),%r8d
  mov    -0x18(%rbp),%rdi
  mov    -0x2c(%rbp),%esi
  mov    0x28(%rbp),%edx
  mov    0x20(%rbp),%rax
  mov    %r8d,%r9d
  mov    %rdi,%r8
  movd   %esi,%xmm0
  lea    D58(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
L219:
  addl   $0x1,-0x38(%rbp)
L100:
  mov    -0x38(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L214
  mov    -0x58(%rbp),%edx
  mov    -0x8(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <free_cvector@plt>
L182:
  cmpl   $0x0,0x28(%rbp)
  jle    L235
  mov    -0x54(%rbp),%edx
  mov    -0x10(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <free_cvector@plt>
  mov    -0x54(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <free_cvector@plt>
L235:
  mov    -0x30(%rbp),%eax
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D30
type: f64
name: read_data
arguments: tag: D54
type: string
name: read_data
arguments: tag: D58
type: string

tool: D30: 7.6

tool: 

tool: D58: %d	%d	%.4f	%s	%d


assistant: ```c
int scan_motif4(float **weight_matrix, char *sequence, int motif_length, int seq_length, float threshold, int *pos, char *strand, int rc, int min_dist, FILE *log_file, int seq_nr) {
  int i, j, k;
  int i_stop;
  char c;
  float p;
  int n;
  float current_score;
  char *revcomp_seq;
  int curr_strand;
  char *word;
  char *numword;
  int previous_position;
  i_stop = seq_length - motif_length;
  n = 0;
  if (seq_nr > 0) {
    numword = cvector(1, motif_length);
    word = cvector(0, motif_length - 1);
  }
  previous_position = -motif_length;
  curr_strand = 1;
  for (i = 1; i <= i_stop; i++) {
    if ((i - previous_position) > min_dist) {
      current_score = 0.0;
      for (j = 1; j <= motif_length; j++) {
        c = sequence[i + j - 1];
        if ((c > 0) & (c < 5)) {
          p = weight_matrix[c][j];
          current_score += p;
        } else {
          current_score += -7.6;
        }
      }
      if (current_score >= threshold) {
        previous_position = i;
        n++;
        pos[n] = seq_length - i;
        strand[n] = curr_strand;
        if (seq_nr > 0) {
          for (j = 1; j <= motif_length; j++)
            numword[j] = sequence[i + j - 1];
          sprintf(word, "");
          num2seq(numword, motif_length, word, 1);
          fprintf(log_file, "%d\t%d\t%.4f\t%s\t%d\n", seq_nr, pos[n], current_score, word, curr_strand);
        }
      }
    }
  }
  curr_strand = 0;
  previous_position = -motif_length;
  if (rc == 1) {
    revcomp_seq = cvector(1, seq_length);
    revcomp(sequence, revcomp_seq, seq_length);
    for (i = 1; i <= i_stop; i++) {
      if ((i - previous_position) > min_dist) {
        current_score = 0.0;
        for (j = 1; j <= motif_length; j++) {
          c = revcomp_seq[i + j - 1];
          if ((c > 0) & (c < 5)) {
            p = weight_matrix[c][j];
            current_score += p;
          } else {
            current_score += -7.6;
          }
        }
        if (current_score >= threshold) {
          previous_position = i;
          n++;
          pos[n] = i;
          strand[n] = 0;
          if (seq_nr > 0) {
            for (j = 1; j <= motif_length; j++)
              numword[j] = revcomp_seq[i + j - 1];
            sprintf(word, "");
            num2seq(numword, motif_length, word, 1);
            fprintf(log_file, "%d\t%d\t%.4f\t%s\t%d\n", seq_nr, pos[n], current_score, word, curr_strand);
          }
        }
      }
    }
    free_cvector(revcomp_seq, 1, seq_length);
  }
  if (seq_nr > 0) {
    free_cvector(numword, 1, motif_length);
    free_cvector(word, 0, motif_length - 1);
  }
  return n;
}
```