user: Converte this assembly snippet into its equivalent C code:

```asm
<pcapack_sweep>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    0x28(%rsp),%eax
  test   %edi,%edi
  je     L238
  mov    %esi,%r10d
  mov    %rdx,%rsi
  mov    %r9d,%edx
  test   %r10d,%r10d
  je     L238
  lea    -0x1(%r9),%r9d
  cmp    $0x1,%r9d
  ja     L46
  lea    -0x1(%rax),%r9d
  cmp    $0x3,%r9d
  ja     L1121
  cmp    $0x1,%edx
  jne    L1001
  cmp    %r8d,%edi
  jne    L1001
  cmp    $0x1,%eax
  je     L1136
  cmp    $0x2,%eax
  je     L1318
  cmp    $0x3,%eax
  je     L958
  test   %r10d,%r10d
  jle    L607
  mov    $0x0,%r11d
  mov    $0x0,%r9d
  mov    %edi,%r8d
  jmp    L305
L1136:
  test   %r10d,%r10d
  jle    L1306
  mov    $0x0,%r11d
  mov    $0x0,%r9d
  mov    %edi,%r8d
  jmp    L1079
L167:
  movslq %r11d,%rax
  lea    (%rsi,%rax,8),%rdx
  mov    $0x0,%eax
L1023:
  movsd  (%rdx,%rax,8),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %r8,%rax
  jne    L1023
L567:
  add    $0x1,%r9d
  add    %edi,%r11d
  cmp    %r9d,%r10d
  je     L1104
L1079:
  test   %edi,%edi
  jg     L167
  jmp    L567
L1318:
  test   %r10d,%r10d
  jle    L940
  mov    $0x0,%r11d
  mov    $0x0,%r9d
  mov    %edi,%r8d
  jmp    L216
L527:
  movslq %r11d,%rax
  lea    (%rsi,%rax,8),%rdx
  mov    $0x0,%eax
L794:
  movsd  (%rdx,%rax,8),%xmm0
  subsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r8
  jne    L794
L135:
  add    $0x1,%r9d
  add    %edi,%r11d
  cmp    %r9d,%r10d
  je     L1358
L216:
  test   %edi,%edi
  jg     L527
  jmp    L135
L958:
  test   %r10d,%r10d
  jle    L1193
  mov    $0x0,%r11d
  mov    $0x0,%r9d
  mov    %edi,%r8d
  jmp    L1316
L408:
  add    $0x1,%r9d
  add    %edi,%r11d
  cmp    %r9d,%r10d
  je     L219
L1316:
  test   %edi,%edi
  jle    L408
  movslq %r11d,%rax
  lea    (%rsi,%rax,8),%rdx
  mov    $0x0,%eax
L925:
  movsd  (%rdx,%rax,8),%xmm0
  mulsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r8
  jne    L925
  jmp    L408
L327:
  movslq %r11d,%rax
  lea    (%rsi,%rax,8),%rdx
  mov    $0x0,%eax
L852:
  movsd  (%rdx,%rax,8),%xmm0
  divsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %r8,%rax
  jne    L852
L119:
  add    $0x1,%r9d
  add    %edi,%r11d
  cmp    %r9d,%r10d
  je     L8
L305:
  test   %edi,%edi
  jg     L327
  jmp    L119
L1001:
  cmp    $0x2,%edx
  jne    L986
  cmp    %r8d,%r10d
  jne    L986
  cmp    $0x1,%eax
  je     L508
  cmp    $0x2,%eax
  je     L311
  cmp    $0x3,%eax
  je     L106
  test   %r10d,%r10d
  jle    L1063
  mov    %rcx,%r8
  lea    -0x1(%r10),%eax
  lea    0x8(%rcx,%rax,8),%r9
  mov    $0x0,%ecx
  lea    -0x1(%rdi),%r11d
  lea    0x8(%rsi),%r10
  jmp    L589
L508:
  test   %r10d,%r10d
  jle    L1062
  mov    %rcx,%r8
  lea    -0x1(%r10),%eax
  lea    0x8(%rcx,%rax,8),%r9
  mov    $0x0,%ecx
  lea    -0x1(%rdi),%r11d
  lea    0x8(%rsi),%r10
L949:
  movsd  (%r8),%xmm1
  test   %edi,%edi
  jle    L372
  movslq %ecx,%rdx
  lea    (%rsi,%rdx,8),%rax
  add    %r11,%rdx
  lea    (%r10,%rdx,8),%rdx
L1034:
  movapd %xmm1,%xmm0
  addsd  (%rax),%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L1034
L372:
  add    $0x8,%r8
  add    %edi,%ecx
  cmp    %r9,%r8
  jne    L949
L1062:
  mov    $0x0,%eax
  jmp    L1353
L311:
  test   %r10d,%r10d
  jle    L1062
  mov    %rcx,%r8
  lea    -0x1(%r10),%eax
  lea    0x8(%rcx,%rax,8),%r9
  mov    $0x0,%ecx
  lea    -0x1(%rdi),%r11d
  lea    0x8(%rsi),%r10
L1300:
  movsd  (%r8),%xmm1
  test   %edi,%edi
  jle    L111
  movslq %ecx,%rdx
  lea    (%rsi,%rdx,8),%rax
  add    %r11,%rdx
  lea    (%r10,%rdx,8),%rdx
L1132:
  movsd  (%rax),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rax,%rdx
  jne    L1132
L111:
  add    $0x8,%r8
  add    %edi,%ecx
  cmp    %r9,%r8
  jne    L1300
  jmp    L1062
L106:
  test   %r10d,%r10d
  jle    L1062
  mov    %rcx,%r8
  lea    -0x1(%r10),%eax
  lea    0x8(%rcx,%rax,8),%r9
  mov    $0x0,%ecx
  lea    -0x1(%rdi),%r11d
  lea    0x8(%rsi),%r10
L648:
  movsd  (%r8),%xmm1
  test   %edi,%edi
  jle    L776
  movslq %ecx,%rdx
  lea    (%rsi,%rdx,8),%rax
  add    %r11,%rdx
  lea    (%r10,%rdx,8),%rdx
L509:
  movapd %xmm1,%xmm0
  mulsd  (%rax),%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rax,%rdx
  jne    L509
L776:
  add    $0x8,%r8
  add    %edi,%ecx
  cmp    %r9,%r8
  jne    L648
  jmp    L1062
L952:
  add    $0x8,%r8
  add    %edi,%ecx
  cmp    %r9,%r8
  je     L1051
L589:
  movsd  (%r8),%xmm1
  test   %edi,%edi
  jle    L952
  movslq %ecx,%rdx
  lea    (%rsi,%rdx,8),%rax
  add    %r11,%rdx
  lea    (%r10,%rdx,8),%rdx
L341:
  movsd  (%rax),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L341
  jmp    L952
L1051:
  mov    $0x0,%eax
  jmp    L1353
L986:
  cmp    $0x1,%eax
  je     L844
  cmp    $0x2,%eax
  je     L669
  cmp    $0x3,%eax
  je     L211
  cmp    $0x1,%edx
  je     L706
  test   %r10d,%r10d
  jle    L939
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    -0x1(%rdi),%r13d
  lea    0x8(%rsi),%r12
L877:
  mov    %ebx,%eax
  cltd
  idiv   %r8d
  test   %edi,%edi
  jle    L1139
  movslq %ebp,%rax
  lea    (%rsi,%rax,8),%r9
  add    %r13,%rax
  lea    (%r12,%rax,8),%r11
L1007:
  movslq %edx,%rax
  movsd  (%r9),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%r9)
  lea    (%r10,%rdx,1),%eax
  cltd
  idiv   %r8d
  add    $0x8,%r9
  cmp    %r11,%r9
  jne    L1007
L1139:
  add    $0x1,%ebx
  add    %edi,%ebp
  cmp    %ebx,%r10d
  jne    L877
  mov    $0x0,%eax
  jmp    L1353
L844:
  cmp    $0x1,%edx
  je     L79
  test   %r10d,%r10d
  jle    L499
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    -0x1(%rdi),%r13d
  lea    0x8(%rsi),%r12
  jmp    L1168
L79:
  test   %r10d,%r10d
  jle    L545
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    -0x1(%rdi),%r13d
  lea    0x8(%rsi),%r12
  jmp    L493
L32:
  movslq %ebp,%rax
  lea    (%rsi,%rax,8),%r9
  add    %r13,%rax
  lea    (%r12,%rax,8),%r11
L1199:
  movslq %edx,%rax
  movsd  (%r9),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%r9)
  lea    0x1(%rdx),%eax
  cltd
  idiv   %r8d
  add    $0x8,%r9
  cmp    %r11,%r9
  jne    L1199
L452:
  add    $0x1,%ebx
  add    %edi,%ebp
  cmp    %ebx,%r10d
  je     L1046
L493:
  test   %edi,%edi
  jg     L32
  jmp    L452
L686:
  add    $0x1,%ebx
  add    %edi,%ebp
  cmp    %ebx,%r10d
  je     L27
L1168:
  mov    %ebx,%eax
  cltd
  idiv   %r8d
  test   %edi,%edi
  jle    L686
  movslq %ebp,%rax
  lea    (%rsi,%rax,8),%r9
  add    %r13,%rax
  lea    (%r12,%rax,8),%r11
L628:
  movslq %edx,%rax
  movsd  (%r9),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%r9)
  lea    (%r10,%rdx,1),%eax
  cltd
  idiv   %r8d
  add    $0x8,%r9
  cmp    %r11,%r9
  jne    L628
  jmp    L686
L27:
  mov    $0x0,%eax
  jmp    L1353
L669:
  cmp    $0x1,%edx
  je     L566
  test   %r10d,%r10d
  jle    L833
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    -0x1(%rdi),%r13d
  lea    0x8(%rsi),%r12
L1008:
  mov    %ebx,%eax
  cltd
  idiv   %r8d
  test   %edi,%edi
  jle    L935
  movslq %ebp,%rax
  lea    (%rsi,%rax,8),%r9
  add    %r13,%rax
  lea    (%r12,%rax,8),%r11
L120:
  movslq %edx,%rax
  movsd  (%r9),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%r9)
  lea    (%r10,%rdx,1),%eax
  cltd
  idiv   %r8d
  add    $0x8,%r9
  cmp    %r11,%r9
  jne    L120
L935:
  add    $0x1,%ebx
  add    %edi,%ebp
  cmp    %ebx,%r10d
  jne    L1008
  mov    $0x0,%eax
  jmp    L1353
L566:
  test   %r10d,%r10d
  jle    L44
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    -0x1(%rdi),%r13d
  lea    0x8(%rsi),%r12
  jmp    L48
L1183:
  movslq %ebp,%rax
  lea    (%rsi,%rax,8),%r9
  add    %r13,%rax
  lea    (%r12,%rax,8),%r11
L532:
  movslq %edx,%rax
  movsd  (%r9),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%r9)
  lea    0x1(%rdx),%eax
  cltd
  idiv   %r8d
  add    $0x8,%r9
  cmp    %r11,%r9
  jne    L532
L379:
  add    $0x1,%ebx
  add    %edi,%ebp
  cmp    %ebx,%r10d
  je     L906
L48:
  test   %edi,%edi
  jg     L1183
  jmp    L379
L211:
  cmp    $0x1,%edx
  je     L269
  test   %r10d,%r10d
  jle    L724
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    -0x1(%rdi),%r13d
  lea    0x8(%rsi),%r12
L586:
  mov    %ebx,%eax
  cltd
  idiv   %r8d
  test   %edi,%edi
  jle    L1315
  movslq %ebp,%rax
  lea    (%rsi,%rax,8),%r9
  add    %r13,%rax
  lea    (%r12,%rax,8),%r11
L338:
  movslq %edx,%rax
  movsd  (%r9),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%r9)
  lea    (%r10,%rdx,1),%eax
  cltd
  idiv   %r8d
  add    $0x8,%r9
  cmp    %r11,%r9
  jne    L338
L1315:
  add    $0x1,%ebx
  add    %edi,%ebp
  cmp    %ebx,%r10d
  jne    L586
  mov    $0x0,%eax
  jmp    L1353
L269:
  test   %r10d,%r10d
  jle    L1031
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    -0x1(%rdi),%r13d
  lea    0x8(%rsi),%r12
  jmp    L358
L50:
  movslq %ebp,%rax
  lea    (%rsi,%rax,8),%r9
  add    %r13,%rax
  lea    (%r12,%rax,8),%r11
L1188:
  movslq %edx,%rax
  movsd  (%r9),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%r9)
  lea    0x1(%rdx),%eax
  cltd
  idiv   %r8d
  add    $0x8,%r9
  cmp    %r11,%r9
  jne    L1188
L273:
  add    $0x1,%ebx
  add    %edi,%ebp
  cmp    %ebx,%r10d
  je     L865
L358:
  test   %edi,%edi
  jg     L50
  jmp    L273
L706:
  test   %r10d,%r10d
  jle    L1327
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    -0x1(%rdi),%r13d
  lea    0x8(%rsi),%r12
  jmp    L314
L738:
  movslq %ebp,%rax
  lea    (%rsi,%rax,8),%r9
  add    %r13,%rax
  lea    (%r12,%rax,8),%r11
L682:
  movslq %edx,%rax
  movsd  (%r9),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%r9)
  lea    0x1(%rdx),%eax
  cltd
  idiv   %r8d
  add    $0x8,%r9
  cmp    %r11,%r9
  jne    L682
L775:
  add    $0x1,%ebx
  add    %edi,%ebp
  cmp    %ebx,%r10d
  je     L3
L314:
  test   %edi,%edi
  jg     L738
  jmp    L775
L238:
  mov    $0x0,%eax
L1353:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L46:
  mov    $0xfffffffa,%eax
  jmp    L1353
L1121:
  mov    $0xfffffff9,%eax
  jmp    L1353
L1306:
  mov    $0x0,%eax
  jmp    L1353
L1104:
  mov    $0x0,%eax
  jmp    L1353
L940:
  mov    $0x0,%eax
  jmp    L1353
L1358:
  mov    $0x0,%eax
  jmp    L1353
L1193:
  mov    $0x0,%eax
  jmp    L1353
L219:
  mov    $0x0,%eax
  jmp    L1353
L607:
  mov    $0x0,%eax
  jmp    L1353
L8:
  mov    $0x0,%eax
  jmp    L1353
L1063:
  mov    $0x0,%eax
  jmp    L1353
L545:
  mov    $0x0,%eax
  jmp    L1353
L1046:
  mov    $0x0,%eax
  jmp    L1353
L499:
  mov    $0x0,%eax
  jmp    L1353
L44:
  mov    $0x0,%eax
  jmp    L1353
L906:
  mov    $0x0,%eax
  jmp    L1353
L833:
  mov    $0x0,%eax
  jmp    L1353
L1031:
  mov    $0x0,%eax
  jmp    L1353
L865:
  mov    $0x0,%eax
  jmp    L1353
L724:
  mov    $0x0,%eax
  jmp    L1353
L1327:
  mov    $0x0,%eax
  jmp    L1353
L3:
  mov    $0x0,%eax
  jmp    L1353
L939:
  mov    $0x0,%eax
  jmp    L1353
```

assistant: ```c
int pcapack_sweep(const int m, const int n, double *restrict x, double *restrict vec, const int lvec, const int margin, const int fun) {
  int i, j;
  int pos;
  double tmp;
  if (m == 0 || n == 0)
    return 0;
  if (margin != 1 && margin != 2)
    return -6;
  if (fun != 1 && fun != 2 && fun != 3 && fun != 4)
    return -7;
  if (margin == 1 && lvec == m) {
    if (fun == 1) {
      for (j = 0; j < n; j++) {
        for (i = 0; i < m; i++) {
          x[i + m * j] += vec[i];
        }
      };
    } else if (fun == 2) {
      for (j = 0; j < n; j++) {
        for (i = 0; i < m; i++) {
          x[i + m * j] -= vec[i];
        }
      };
    } else if (fun == 3) {
      for (j = 0; j < n; j++) {
        for (i = 0; i < m; i++) {
          x[i + m * j] *= vec[i];
        }
      };
    } else if (fun == 4) {
      for (j = 0; j < n; j++) {
        for (i = 0; i < m; i++) {
          x[i + m * j] /= vec[i];
        }
      };
    }
  } else if (margin == 2 && lvec == n) {
    if (fun == 1) {

#pragma omp parallel for default(shared) private(i, j, tmp) if (m * n > OMP_MIN_SIZE)
      for (j = 0; j < n; j++) {
        tmp = vec[j];
        for (i = 0; i < m; i++) {
          x[i + m * j] += tmp;
        }
      };
    } else if (fun == 2) {

#pragma omp parallel for default(shared) private(i, j, tmp) if (m * n > OMP_MIN_SIZE)
      for (j = 0; j < n; j++) {
        tmp = vec[j];
        for (i = 0; i < m; i++) {
          x[i + m * j] -= tmp;
        }
      };
    } else if (fun == 3) {

#pragma omp parallel for default(shared) private(i, j, tmp) if (m * n > OMP_MIN_SIZE)
      for (j = 0; j < n; j++) {
        tmp = vec[j];
        for (i = 0; i < m; i++) {
          x[i + m * j] *= tmp;
        }
      };
    }
    if (fun == 4) {

#pragma omp parallel for default(shared) private(i, j, tmp) if (m * n > OMP_MIN_SIZE)
      for (j = 0; j < n; j++) {
        tmp = vec[j];
        for (i = 0; i < m; i++) {
          x[i + m * j] /= tmp;
        }
      };
    }
  } else {
    if (fun == 1) {
      if (margin == 1) {
        pos = 1;
        for (j = 0; j < n; j++) {
          for (i = 0; i < m; i++) {
            x[i + m * j] += vec[pos];
            pos = (pos + 1) % lvec;
          }
        };
      } else if (margin == 2) {

#pragma omp parallel for default(shared) private(i, j, tmp) if (m * n > OMP_MIN_SIZE)
        for (j = 0; j < n; j++) {
          pos = j % lvec;
          for (i = 0; i < m; i++) {
            x[i + m * j] += vec[pos];
            pos = (pos + n) % lvec;
          }
        };
      }
    } else if (fun == 2) {
      if (margin == 1) {
        pos = 1;
        for (j = 0; j < n; j++) {
          for (i = 0; i < m; i++) {
            x[i + m * j] += vec[pos];
            pos = (pos + 1) % lvec;
          }
        };
      } else if (margin == 2) {

#pragma omp parallel for default(shared) private(i, j, tmp) if (m * n > OMP_MIN_SIZE)
        for (j = 0; j < n; j++) {
          pos = j % lvec;
          for (i = 0; i < m; i++) {
            x[i + m * j] += vec[pos];
            pos = (pos + n) % lvec;
          }
        };
      }
    } else if (fun == 3) {
      if (margin == 1) {
        pos = 1;
        for (j = 0; j < n; j++) {
          for (i = 0; i < m; i++) {
            x[i + m * j] += vec[pos];
            pos = (pos + 1) % lvec;
          }
        };
      } else if (margin == 2) {

#pragma omp parallel for default(shared) private(i, j, tmp) if (m * n > OMP_MIN_SIZE)
        for (j = 0; j < n; j++) {
          pos = j % lvec;
          for (i = 0; i < m; i++) {
            x[i + m * j] += vec[pos];
            pos = (pos + n) % lvec;
          }
        };
      }
    } else if (fun == 4) {
      if (margin == 1) {
        pos = 1;
        for (j = 0; j < n; j++) {
          for (i = 0; i < m; i++) {
            x[i + m * j] += vec[pos];
            pos = (pos + 1) % lvec;
          }
        };
      } else if (margin == 2) {

#pragma omp parallel for default(shared) private(i, j, tmp) if (m * n > OMP_MIN_SIZE)
        for (j = 0; j < n; j++) {
          pos = j % lvec;
          for (i = 0; i < m; i++) {
            x[i + m * j] += vec[pos];
            pos = (pos + n) % lvec;
          }
        };
      }
    }
  }
  return 0;
}
```