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

```asm
<optim_>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  mov    %r8,-0x38(%rbp)
  mov    %r9,-0x40(%rbp)
  subq   $0x8,-0x18(%rbp)
  subq   $0x8,-0x20(%rbp)
  subq   $0x8,-0x28(%rbp)
  subq   $0xc,0x20(%rbp)
  subq   $0x4,-0x38(%rbp)
  subq   $0x4,-0x40(%rbp)
  subq   $0x4,0x10(%rbp)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,D162(%rip)
  mov    0x18(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,D608(%rip)
  mov    D162(%rip),%eax
  test   %eax,%eax
  js     L164
  mov    D608(%rip),%eax
  test   %eax,%eax
  jle    L164
  movl   $0x0,D535(%rip)
  mov    D162(%rip),%eax
  test   %eax,%eax
  je     L75
  nop
L219:
  mov    D535(%rip),%edx
  mov    D608(%rip),%eax
  cmp    %eax,%edx
  je     L91
  mov    D535(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D498(%rip)
  movl   $0x0,D498(%rip)
  mov    D162(%rip),%eax
  mov    %eax,-0x8(%rbp)
  movl   $0x1,D271(%rip)
  jmp    L217
L87:
  mov    D271(%rip),%eax
  add    %eax,%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,D280(%rip)
  mov    D271(%rip),%eax
  add    %eax,%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,D255(%rip)
  mov    D280(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,D592(%rip)
  mov    D592(%rip),%eax
  mov    %eax,D512(%rip)
  mov    D512(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,D287(%rip)
L195:
  mov    D287(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    D255(%rip),%eax
  cmp    %eax,%edx
  je     L147
  mov    D287(%rip),%eax
  mov    %eax,D483(%rip)
  mov    D483(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,D483(%rip)
  mov    D483(%rip),%edx
  mov    D592(%rip),%eax
  cmp    %eax,%edx
  je     L245
  jmp    L195
L245:
  mov    D483(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%edx
  neg    %edx
  cmovs  %eax,%edx
  mov    D255(%rip),%eax
  cmp    %eax,%edx
  jne    L129
  mov    D483(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  js     L220
  jmp    L134
L147:
  nop
L134:
  mov    D483(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,D483(%rip)
  mov    D483(%rip),%eax
  test   %eax,%eax
  js     L29
  mov    D483(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,D464(%rip)
  mov    D464(%rip),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%edx
  neg    %edx
  cmovns %edx,%eax
  mov    %eax,D464(%rip)
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  mov    -0x20(%rbp),%rdx
  lea    0x8(%rdx),%rcx
  mov    -0x18(%rbp),%rdx
  add    $0x8,%rdx
  sub    $0x8,%rsp
  push   %rax
  mov    %rcx,%r9
  mov    %rdx,%r8
  lea    D255(%rip),%rax
  mov    %rax,%rcx
  lea    D280(%rip),%rax
  mov    %rax,%rdx
  lea    D483(%rip),%rax
  mov    %rax,%rsi
  lea    D464(%rip),%rax
  mov    %rax,%rdi
  call   <swptst_@plt>
  add    $0x10,%rsp
  test   %eax,%eax
  je     L127
  mov    0x10(%rbp),%rax
  add    $0x4,%rax
  mov    -0x40(%rbp),%rdx
  lea    0x4(%rdx),%rsi
  mov    -0x38(%rbp),%rdx
  lea    0x4(%rdx),%rcx
  lea    D102(%rip),%rdx
  push   %rdx
  push   %rax
  mov    %rsi,%r9
  mov    %rcx,%r8
  lea    D255(%rip),%rax
  mov    %rax,%rcx
  lea    D280(%rip),%rax
  mov    %rax,%rdx
  lea    D483(%rip),%rax
  mov    %rax,%rsi
  lea    D464(%rip),%rax
  mov    %rax,%rdi
  call   <swap_@plt>
  add    $0x10,%rsp
  mov    D102(%rip),%eax
  test   %eax,%eax
  je     L79
  movl   $0x1,D498(%rip)
  mov    D271(%rip),%eax
  add    %eax,%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    0x20(%rbp),%rax
  add    %rax,%rdx
  mov    D464(%rip),%eax
  mov    %eax,(%rdx)
  mov    D271(%rip),%eax
  add    %eax,%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    0x20(%rbp),%rax
  add    %rax,%rdx
  mov    D483(%rip),%eax
  mov    %eax,(%rdx)
  jmp    L242
L220:
  nop
  jmp    L242
L29:
  nop
  jmp    L242
L127:
  nop
L242:
  mov    D271(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D128(%rip)
L217:
  mov    D128(%rip),%eax
  cmp    %eax,-0x8(%rbp)
  jge    L87
  mov    D498(%rip),%eax
  test   %eax,%eax
  je     L98
  jmp    L219
L75:
  nop
  jmp    L37
L98:
  nop
L37:
  mov    D498(%rip),%edx
  mov    0x18(%rbp),%rax
  mov    %edx,(%rax)
  mov    0x28(%rbp),%rax
  movl   $0x0,(%rax)
  mov    $0x0,%eax
  jmp    L237
L91:
  nop
  mov    D608(%rip),%edx
  mov    0x18(%rbp),%rax
  mov    %edx,(%rax)
  mov    0x28(%rbp),%rax
  movl   $0x1,(%rax)
  mov    $0x0,%eax
  jmp    L237
L164:
  nop
  mov    0x18(%rbp),%rax
  movl   $0x0,(%rax)
  mov    0x28(%rbp),%rax
  movl   $0x2,(%rax)
  mov    $0x0,%eax
  jmp    L237
L129:
  nop
  mov    D498(%rip),%edx
  mov    0x18(%rbp),%rax
  mov    %edx,(%rax)
  mov    0x28(%rbp),%rax
  movl   $0x3,(%rax)
  mov    $0x0,%eax
  jmp    L237
L79:
  nop
  mov    D498(%rip),%edx
  mov    0x18(%rbp),%rax
  mov    %edx,(%rax)
  mov    0x28(%rbp),%rax
  movl   $0x4,(%rax)
  mov    $0x0,%eax
L237:
  leave
  ret
```

assistant: ```c
int optim_(double *x, double *y, double *z__, int *na, int *list, int *lptr, int *lend, int *nit, int *iwk, int *ier) {
  int i__1, i__2;
  static int i__, n1, n2, lp, io1, io2, nna, lp21, lpl, lpp;
  static int swp;
  static int iter;
  static int maxit;
  --x;
  --y;
  --z__;
  iwk -= 3;
  --list;
  --lptr;
  --lend;
  nna = *na;
  maxit = *nit;
  if (nna < 0 || maxit < 1) {
    goto L7;
  }
  iter = 0;
  if (nna == 0) {
    goto L5;
  }
L1:
  if (iter == maxit) {
    goto L6;
  }
  ++iter;
  swp = (0);
  i__1 = nna;
  for (i__ = 1; i__ <= i__1; ++i__) {
    io1 = iwk[(i__ << 1) + 1];
    io2 = iwk[(i__ << 1) + 2];
    lpl = lend[io1];
    lpp = lpl;
    lp = lptr[lpp];
  L2:
    if (list[lp] == io2) {
      goto L3;
    }
    lpp = lp;
    lp = lptr[lpp];
    if (lp != lpl) {
      goto L2;
    }
    if ((i__2 = list[lp], ((i__2) >= 0 ? (i__2) : -(i__2))) != io2) {
      goto L8;
    }
    if (list[lp] < 0) {
      goto L4;
    }
  L3:
    n2 = list[lpp];
    if (n2 < 0) {
      goto L4;
    }
    lp = lptr[lp];
    n1 = (i__2 = list[lp], ((i__2) >= 0 ? (i__2) : -(i__2)));
    if (!swptst_(&n1, &n2, &io1, &io2, &x[1], &y[1], &z__[1])) {
      goto L4;
    }
    swap_(&n1, &n2, &io1, &io2, &list[1], &lptr[1], &lend[1], &lp21);
    if (lp21 == 0) {
      goto L9;
    }
    swp = (1);
    iwk[(i__ << 1) + 1] = n1;
    iwk[(i__ << 1) + 2] = n2;
  L4:;
  }
  if (swp) {
    goto L1;
  }
L5:
  *nit = iter;
  *ier = 0;
  return 0;
L6:
  *nit = maxit;
  *ier = 1;
  return 0;
L7:
  *nit = 0;
  *ier = 2;
  return 0;
L8:
  *nit = iter;
  *ier = 3;
  return 0;
L9:
  *nit = iter;
  *ier = 4;
  return 0;
}
```