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

```asm
<maiseg>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x3b8,%rsp
  movsd  %xmm0,-0x3a8(%rbp)
  mov    %rdi,-0x3b0(%rbp)
  mov    %rsi,-0x3b8(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  pxor   %xmm0,%xmm0
  comisd -0x3a8(%rbp),%xmm0
  ja     L327
  movsd  -0x3a8(%rbp),%xmm0
  movsd  D9(%rip),%xmm1
  comisd %xmm1,%xmm0
  jbe    L61
L327:
  lea    D45(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <mexErrMsgTxt@plt>
L61:
  movsd  -0x3a8(%rbp),%xmm0
  comisd D34(%rip),%xmm0
  jbe    L398
  movl   $0x1,-0x398(%rbp)
  movsd  D9(%rip),%xmm0
  subsd  -0x3a8(%rbp),%xmm0
  movsd  %xmm0,-0x3a8(%rbp)
  jmp    L136
L398:
  movl   $0x0,-0x398(%rbp)
L136:
  movl   $0x0,-0x390(%rbp)
  jmp    L318
L370:
  movl   $0x0,-0x394(%rbp)
  jmp    L106
L12:
  mov    -0x394(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x390(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  add    %rax,%rax
  add    %rcx,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x380(%rbp,%rax,8)
  addl   $0x1,-0x394(%rbp)
L106:
  cmpl   $0x5,-0x394(%rbp)
  jle    L12
  addl   $0x1,-0x390(%rbp)
L318:
  cmpl   $0x5,-0x390(%rbp)
  jle    L370
  movl   $0x0,-0x390(%rbp)
  jmp    L18
L208:
  movl   $0x0,-0x394(%rbp)
  jmp    L86
L195:
  mov    -0x394(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x390(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  add    %rax,%rax
  add    %rcx,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x140(%rbp,%rax,8)
  addl   $0x1,-0x394(%rbp)
L86:
  cmpl   $0x5,-0x394(%rbp)
  jle    L195
  addl   $0x1,-0x390(%rbp)
L18:
  cmpl   $0x5,-0x390(%rbp)
  jle    L208
  movl   $0x0,-0x390(%rbp)
  jmp    L383
L279:
  movl   $0x0,-0x394(%rbp)
  jmp    L214
L394:
  mov    -0x394(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x390(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  add    %rax,%rax
  add    %rcx,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x260(%rbp,%rax,8)
  addl   $0x1,-0x394(%rbp)
L214:
  cmpl   $0x5,-0x394(%rbp)
  jle    L394
  addl   $0x1,-0x390(%rbp)
L383:
  cmpl   $0x5,-0x390(%rbp)
  jle    L279
  movl   $0x1,-0x390(%rbp)
  jmp    L43
L29:
  movl   $0xfffffffe,-0x394(%rbp)
  jmp    L76
L425:
  mov    -0x390(%rbp),%edx
  mov    -0x394(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  mov    %eax,%ebx
  mov    -0x394(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x390(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  sub    %eax,%ebx
  mov    %ebx,%edx
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x390(%rbp),%xmm1
  mov    -0x394(%rbp),%eax
  lea    0x2(%rax),%edx
  mov    -0x390(%rbp),%eax
  sub    $0x1,%eax
  divsd  %xmm1,%xmm0
  movslq %eax,%rcx
  movslq %edx,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  add    %rax,%rax
  add    %rcx,%rax
  movsd  %xmm0,-0x380(%rbp,%rax,8)
  addl   $0x1,-0x394(%rbp)
L76:
  cmpl   $0x0,-0x394(%rbp)
  jle    L425
  addl   $0x1,-0x390(%rbp)
L43:
  cmpl   $0x3,-0x390(%rbp)
  jle    L29
  movl   $0x1,-0x390(%rbp)
  jmp    L27
L73:
  movl   $0x2,-0x394(%rbp)
  jmp    L80
L173:
  mov    -0x390(%rbp),%edx
  mov    -0x394(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  mov    %eax,%ebx
  mov    -0x394(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x390(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  sub    %eax,%ebx
  mov    %ebx,%edx
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x390(%rbp),%xmm1
  mov    -0x394(%rbp),%eax
  lea    0x2(%rax),%edx
  mov    -0x390(%rbp),%eax
  add    $0x2,%eax
  divsd  %xmm1,%xmm0
  movslq %eax,%rcx
  movslq %edx,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  add    %rax,%rax
  add    %rcx,%rax
  movsd  %xmm0,-0x380(%rbp,%rax,8)
  addl   $0x1,-0x394(%rbp)
L80:
  cmpl   $0x3,-0x394(%rbp)
  jle    L173
  addl   $0x1,-0x390(%rbp)
L27:
  cmpl   $0x3,-0x390(%rbp)
  jle    L73
  movl   $0x1,-0x390(%rbp)
  jmp    L418
L245:
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x390(%rbp),%xmm0
  mov    -0x3a8(%rbp),%rax
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <pow@plt>
  movq   %xmm0,%rax
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x390(%rbp),%xmm1
  mov    -0x390(%rbp),%edx
  sub    $0x1,%edx
  movq   %rax,%xmm0
  divsd  %xmm1,%xmm0
  movslq %edx,%rax
  add    $0x12,%rax
  movsd  %xmm0,-0x380(%rbp,%rax,8)
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x390(%rbp),%xmm0
  mov    -0x3a8(%rbp),%rax
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <pow@plt>
  movapd %xmm0,%xmm1
  movsd  D9(%rip),%xmm0
  subsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x390(%rbp),%xmm1
  mov    -0x390(%rbp),%eax
  add    $0x2,%eax
  divsd  %xmm1,%xmm0
  cltq
  add    $0x12,%rax
  movsd  %xmm0,-0x380(%rbp,%rax,8)
  addl   $0x1,-0x390(%rbp)
L418:
  cmpl   $0x3,-0x390(%rbp)
  jle    L245
  lea    -0x380(%rbp),%rax
  mov    $0x6,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <matinv@plt>
  movl   $0x1,-0x38c(%rbp)
  jmp    L205
L156:
  movl   $0xffffffff,-0x394(%rbp)
  jmp    L419
L149:
  mov    -0x38c(%rbp),%edx
  mov    -0x394(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  mov    %eax,%ebx
  mov    -0x394(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x38c(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  mov    %eax,%edx
  mov    %ebx,%eax
  sub    %edx,%eax
  add    %eax,%eax
  pxor   %xmm2,%xmm2
  cvtsi2sd %eax,%xmm2
  movsd  %xmm2,-0x3c0(%rbp)
  mov    -0x38c(%rbp),%eax
  mov    %eax,%esi
  mov    $0x2,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x38c(%rbp),%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x394(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x38c(%rbp),%eax
  sub    $0x1,%eax
  movsd  -0x3c0(%rbp),%xmm0
  divsd  %xmm1,%xmm0
  movslq %eax,%rcx
  movslq %edx,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  add    %rax,%rax
  add    %rcx,%rax
  movsd  %xmm0,-0x140(%rbp,%rax,8)
  addl   $0x1,-0x394(%rbp)
L419:
  cmpl   $0x0,-0x394(%rbp)
  jle    L149
  addl   $0x1,-0x38c(%rbp)
L205:
  cmpl   $0x3,-0x38c(%rbp)
  jle    L156
  movl   $0x1,-0x388(%rbp)
  jmp    L132
L256:
  movl   $0x2,-0x394(%rbp)
  jmp    L305
L148:
  mov    -0x388(%rbp),%edx
  mov    -0x394(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  mov    %eax,%ebx
  mov    -0x394(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x388(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  mov    %eax,%edx
  mov    %ebx,%eax
  sub    %edx,%eax
  add    %eax,%eax
  pxor   %xmm3,%xmm3
  cvtsi2sd %eax,%xmm3
  movsd  %xmm3,-0x3c0(%rbp)
  mov    -0x388(%rbp),%eax
  mov    %eax,%esi
  mov    $0x2,%edi
  mov    $0x0,%eax
  call   <aipow@plt>
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x388(%rbp),%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x394(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x388(%rbp),%eax
  add    $0x2,%eax
  movsd  -0x3c0(%rbp),%xmm0
  divsd  %xmm1,%xmm0
  movslq %eax,%rcx
  movslq %edx,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  add    %rax,%rax
  add    %rcx,%rax
  movsd  %xmm0,-0x140(%rbp,%rax,8)
  addl   $0x1,-0x394(%rbp)
L305:
  cmpl   $0x4,-0x394(%rbp)
  jle    L148
  movl   $0x1,-0x38c(%rbp)
  jmp    L236
L329:
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x38c(%rbp),%xmm0
  mov    -0x3a8(%rbp),%rax
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <pow@plt>
  addsd  %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x38c(%rbp),%xmm1
  mov    -0x38c(%rbp),%eax
  sub    $0x1,%eax
  divsd  %xmm1,%xmm0
  cltq
  add    $0xc,%rax
  movsd  %xmm0,-0x140(%rbp,%rax,8)
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x38c(%rbp),%xmm0
  mov    D34(%rip),%rax
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <pow@plt>
  movq   %xmm0,%rbx
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x38c(%rbp),%xmm0
  mov    -0x3a8(%rbp),%rax
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <pow@plt>
  movapd %xmm0,%xmm1
  movq   %rbx,%xmm0
  subsd  %xmm1,%xmm0
  addsd  %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x38c(%rbp),%xmm1
  mov    -0x38c(%rbp),%eax
  add    $0x2,%eax
  divsd  %xmm1,%xmm0
  cltq
  add    $0xc,%rax
  movsd  %xmm0,-0x140(%rbp,%rax,8)
  addl   $0x1,-0x38c(%rbp)
L236:
  cmpl   $0x3,-0x38c(%rbp)
  jle    L329
  addl   $0x1,-0x388(%rbp)
L132:
  cmpl   $0x3,-0x388(%rbp)
  jle    L256
  lea    -0x260(%rbp),%rcx
  lea    -0x380(%rbp),%rdx
  lea    -0x140(%rbp),%rax
  mov    %rcx,%r9
  mov    $0x6,%r8d
  mov    %rdx,%rcx
  mov    $0x6,%edx
  mov    $0x6,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <matmpy@plt>
  cmpl   $0x0,-0x398(%rbp)
  jne    L254
  movl   $0x0,-0x384(%rbp)
  jmp    L300
L261:
  mov    -0x384(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x3b0(%rbp),%rax
  add    %rdx,%rax
  mov    -0x384(%rbp),%edx
  movslq %edx,%rdx
  add    $0xc,%rdx
  movsd  -0x260(%rbp,%rdx,8),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x384(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x3b8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x384(%rbp),%edx
  movslq %edx,%rdx
  add    $0x12,%rdx
  movsd  -0x260(%rbp,%rdx,8),%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x384(%rbp)
L300:
  cmpl   $0x5,-0x384(%rbp)
  jle    L261
  mov    -0x3b0(%rbp),%rax
  add    $0x30,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x3b8(%rbp),%rax
  add    $0x30,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  jmp    L317
L254:
  mov    -0x3b0(%rbp),%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x3b8(%rbp),%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  movl   $0x0,-0x384(%rbp)
  jmp    L163
L83:
  mov    $0x5,%eax
  sub    -0x384(%rbp),%eax
  mov    %eax,%edx
  mov    -0x384(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x3b8(%rbp),%rax
  add    %rcx,%rax
  movslq %edx,%rdx
  add    $0xc,%rdx
  movsd  -0x260(%rbp,%rdx,8),%xmm0
  movsd  %xmm0,(%rax)
  mov    $0x5,%eax
  sub    -0x384(%rbp),%eax
  mov    %eax,%edx
  mov    -0x384(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x3b0(%rbp),%rax
  add    %rcx,%rax
  movslq %edx,%rdx
  add    $0x12,%rdx
  movsd  -0x260(%rbp,%rdx,8),%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x384(%rbp)
L163:
  cmpl   $0x5,-0x384(%rbp)
  jle    L83
L317:
  nop
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L112
  call   <__stack_chk_fail@plt>
L112:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D9
type_guessed: f32[2]
name: retrieve_data
arguments: data_tag: D45
type_guessed: string
name: retrieve_data
arguments: data_tag: D34
type_guessed: f32

tool: {"D9": [0.0,1.875]}

tool: D45: eta0 out of range in maiseg

tool: D34: 0

assistant: ```c
void maiseg(eta0, SegFiltLeft, SegFiltRight) double eta0, SegFiltLeft[], SegFiltRight[];
{
  int flip;
  int lp1, kp1, kpp1, kpp2, ll;
  double Mmat[2 * 2 + 2][2 * 2 + 2], Pmat[2 * 2 + 2][2 * 2 + 2], Jmat[2 * 2 + 2][2 * 2 + 2];
  if ((2 % 2) || 2 < 2) {
    mexErrMsgTxt("D must be an even integer >= 2 in maiseg");
  }
  if (eta0 < 0 || eta0 > 1) {
    mexErrMsgTxt("eta0 out of range in maiseg");
  }
  if (eta0 > .5) {
    flip = 1;
    eta0 = 1 - eta0;
  } else
    flip = 0;
  for (kp1 = 0; kp1 < 2 * 2 + 2; kp1++)
    for (lp1 = 0; lp1 < 2 * 2 + 2; lp1++)
      Mmat[kp1][lp1] = 0.;
  for (kp1 = 0; kp1 < 2 * 2 + 2; kp1++)
    for (lp1 = 0; lp1 < 2 * 2 + 2; lp1++)
      Jmat[kp1][lp1] = 0.;
  for (kp1 = 0; kp1 < 2 * 2 + 2; kp1++)
    for (lp1 = 0; lp1 < 2 * 2 + 2; lp1++)
      Pmat[kp1][lp1] = 0.;
  for (kp1 = 1; kp1 <= (2 + 1); kp1++) {
    for (lp1 = -2; lp1 <= 0; lp1++) {
      Mmat[2 + lp1][kp1 - 1] = (aipow(lp1, kp1) - aipow(lp1 - 1, kp1)) / ((double)kp1);
    }
  }
  for (kp1 = 1; kp1 <= (2 + 1); kp1++)
    for (lp1 = 2; lp1 <= (2 + 1); lp1++)
      Mmat[2 + lp1][2 + kp1] = (aipow(lp1, kp1) - aipow(lp1 - 1, kp1)) / ((double)kp1);
  for (kp1 = 1; kp1 <= (2 + 1); kp1++) {
    Mmat[2 + 1][kp1 - 1] = (pow(eta0, kp1)) / ((double)kp1);
    Mmat[2 + 1][2 + kp1] = (1 - pow(eta0, kp1)) / ((double)kp1);
  }
  matinv(&(Mmat[0][0]), 2 * 2 + 2);
  for (kpp1 = 1; kpp1 <= (2 + 1); kpp1++) {
    for (lp1 = (-2 + 1); lp1 <= 0; lp1++) {
      Jmat[2 + lp1 - 1][kpp1 - 1] = 2 * (aipow(lp1, kpp1) - aipow(lp1 - 1, kpp1)) / (aipow(2, kpp1) * (double)kpp1);
    }
  }
  for (kpp2 = 1; kpp2 <= (2 + 1); kpp2++) {
    for (lp1 = 2; lp1 <= (2 + 2); lp1++)
      Jmat[2 + lp1 - 1][2 + kpp2] = 2 * (aipow(lp1, kpp2) - aipow(lp1 - 1, kpp2)) / (aipow(2, kpp2) * (double)kpp2);
    for (kpp1 = 1; kpp1 <= (2 + 1); kpp1++) {
      Jmat[2][kpp1 - 1] = 2 * (pow(eta0, kpp1)) / ((double)kpp1);
      Jmat[2][2 + kpp1] = 2 * (pow(.5, kpp1) - pow(eta0, kpp1)) / ((double)kpp1);
    }
  }
  matmpy(&(Jmat[0][0]), 2 * 2 + 2, 2 * 2 + 2, &(Mmat[0][0]), 2 * 2 + 2, &(Pmat[0][0]));
  if (flip == 0) {
    for (ll = 0; ll < 2 * 2 + 2; ll++) {
      SegFiltLeft[ll] = Pmat[2][ll];
      SegFiltRight[ll] = Pmat[2 + 1][ll];
    }
    SegFiltLeft[2 * 2 + 2] = 0.0;
    SegFiltRight[2 * 2 + 2] = 0.0;
  } else {
    SegFiltLeft[0] = 0.0;
    SegFiltRight[0] = 0.0;
    for (ll = 0; ll < 2 * 2 + 2; ll++) {
      SegFiltRight[ll + 1] = Pmat[2][2 * 2 + 1 - ll];
      SegFiltLeft[ll + 1] = Pmat[2 + 1][2 * 2 + 1 - ll];
    }
  }
}
```