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

```asm
<deriv1>:
  endbr64
  push   %rbp
  movapd %xmm0,%xmm4
  mov    %rsp,%rbp
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  cmp    $0x2,%edx
  je     L99
  cmp    $0x3,%edx
  je     L124
  pxor   %xmm2,%xmm2
  cmp    $0x1,%edx
  je     L113
L66:
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L44
  lea    -0x20(%rbp),%rsp
  movapd %xmm2,%xmm0
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L99:
  movsd  (%rdi),%xmm5
  movsd  0x8(%rdi),%xmm2
  movapd %xmm0,%xmm1
  movsd  %xmm0,-0x58(%rbp)
  movsd  D41(%rip),%xmm0
  movsd  %xmm5,-0x48(%rbp)
  movsd  0x10(%rdi),%xmm5
  movsd  %xmm2,-0x50(%rbp)
  movsd  %xmm5,-0x38(%rbp)
  call   <pow@plt>
  movsd  -0x38(%rbp),%xmm1
  movsd  -0x58(%rbp),%xmm4
  subsd  D13(%rip),%xmm1
  movsd  %xmm0,-0x40(%rbp)
  movapd %xmm4,%xmm0
  call   <pow@plt>
  movsd  -0x50(%rbp),%xmm2
  mulsd  -0x38(%rbp),%xmm2
  mulsd  %xmm0,%xmm2
  movsd  -0x40(%rbp),%xmm0
  mulsd  -0x48(%rbp),%xmm0
  addsd  %xmm0,%xmm2
  jmp    L66
  nopl   0x0(%rax)
L113:
  lea    -0x1(%rsi),%r14d
  mov    %rsp,%rcx
  mov    %rsp,%r13
  movslq %r14d,%rax
  lea    0xf(,%rax,8),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  and    $0xfffffffffffffff0,%rdx
  sub    %rax,%rcx
L140:
  cmp    %rcx,%rsp
  je     L166
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L140
  nopl   0x0(%rax,%rax,1)
L124:
  movsd  0x20(%rdi),%xmm1
  movsd  0x8(%rdi),%xmm6
  movsd  %xmm4,-0x48(%rbp)
  movapd %xmm1,%xmm0
  movsd  %xmm1,-0x50(%rbp)
  mulsd  %xmm4,%xmm0
  movsd  %xmm6,-0x38(%rbp)
  addsd  0x28(%rdi),%xmm0
  call   <cos@plt>
  movsd  -0x48(%rbp),%xmm4
  mulsd  -0x38(%rbp),%xmm4
  addsd  0x10(%rbx),%xmm4
  movsd  %xmm0,-0x40(%rbp)
  movapd %xmm4,%xmm0
  call   <sin@plt>
  movsd  -0x50(%rbp),%xmm1
  mulsd  0x18(%rbx),%xmm1
  movsd  -0x38(%rbp),%xmm2
  mulsd  (%rbx),%xmm2
  mulsd  -0x40(%rbp),%xmm2
  mulsd  %xmm0,%xmm1
  subsd  %xmm1,%xmm2
  jmp    L66
  nopl   (%rax)
L166:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L117
L169:
  mov    %rsp,%r12
  test   %r14d,%r14d
  js     L25
  cmp    $0x2,%r14d
  jbe    L21
  mov    %esi,%edx
  movdqa D43(%rip),%xmm3
  xor    %eax,%eax
  movdqa D4(%rip),%xmm6
  shr    $0x2,%edx
  movdqa D40(%rip),%xmm5
  shl    $0x5,%rdx
  nopl   0x0(%rax,%rax,1)
L27:
  movdqa %xmm3,%xmm2
  movupd 0x18(%rbx,%rax,1),%xmm7
  movupd 0x8(%rbx,%rax,1),%xmm1
  paddd  %xmm6,%xmm3
  paddd  %xmm5,%xmm2
  pshufd $0xee,%xmm2,%xmm0
  cvtdq2pd %xmm2,%xmm2
  cvtdq2pd %xmm0,%xmm0
  mulpd  %xmm2,%xmm1
  mulpd  %xmm7,%xmm0
  movups %xmm1,(%r12,%rax,1)
  movups %xmm0,0x10(%r12,%rax,1)
  add    $0x20,%rax
  cmp    %rdx,%rax
  jne    L27
  mov    %esi,%eax
  and    $0xfffffffc,%eax
  and    $0x3,%esi
  je     L148
L12:
  lea    0x1(%rax),%edx
  pxor   %xmm0,%xmm0
  movslq %eax,%rcx
  movslq %edx,%rdi
  cvtsi2sd %edx,%xmm0
  lea    (%r12,%rcx,8),%rcx
  mulsd  (%rbx,%rdi,8),%xmm0
  lea    0x0(,%rdi,8),%rsi
  movsd  %xmm0,(%rcx)
  cmp    %r14d,%edx
  jg     L148
  lea    0x2(%rax),%edx
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  mulsd  0x8(%rbx,%rsi,1),%xmm0
  movsd  %xmm0,0x8(%rcx)
  cmp    %edx,%r14d
  jl     L148
  add    $0x3,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  0x10(%rbx,%rsi,1),%xmm0
  movsd  %xmm0,0x10(%rcx)
L148:
  mov    %r14d,%r14d
  xor    %ebx,%ebx
  pxor   %xmm2,%xmm2
L190:
  pxor   %xmm1,%xmm1
  movsd  (%r12,%rbx,8),%xmm7
  movapd %xmm4,%xmm0
  movsd  %xmm2,-0x48(%rbp)
  cvtsi2sd %ebx,%xmm1
  movsd  %xmm4,-0x40(%rbp)
  movsd  %xmm7,-0x38(%rbp)
  call   <pow@plt>
  movsd  -0x38(%rbp),%xmm3
  mov    %rbx,%rax
  movsd  -0x48(%rbp),%xmm2
  add    $0x1,%rbx
  cmp    %rax,%r14
  movsd  -0x40(%rbp),%xmm4
  mulsd  %xmm0,%xmm3
  addsd  %xmm3,%xmm2
  jne    L190
L122:
  mov    %r13,%rsp
  jmp    L66
  nopl   0x0(%rax)
L117:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L169
L25:
  pxor   %xmm2,%xmm2
  jmp    L122
L21:
  xor    %eax,%eax
  jmp    L12
L44:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D41
type_infered: f64
name: parse_data
arguments: tag: D13
type_infered: f64
name: parse_data
arguments: tag: D43
type_infered: f32[4]
name: parse_data
arguments: tag: D4
type_infered: byte[16]
name: parse_data
arguments: tag: D40
type_infered: byte[16]

tool: D41: 2.7182818284

tool: D13: 1

tool: {"D43": [0.0,1.401298464324817e-45,2.802596928649634e-45,4.203895392974451e-45]}

tool: {"D4": [0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

tool: {"D40": [0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00]}

assistant: ```c
double deriv1(double *param, int dimension, int functiontype, double x) {
  int i;
  double first_derivate = 0;
  switch (functiontype) {
  case 1: {
    int len = (dimension - 1);
    double D[len];
    for (i = 0; i <= len; i++) {
      D[i] = param[i + 1] * (i + 1);
    }
    for (i = 0; i <= len; i++) {
      first_derivate += D[i] * (pow(x, i));
    }
    break;
  }
  case 2: {
    double a = param[0];
    double b = param[1];
    double n = param[2];
    first_derivate = (a * (pow(2.7182818284, x)) + b * n * (pow(x, (n - 1))));
    break;
  }
  case 3: {
    double A = param[0];
    double m = param[1];
    double t = param[2];
    double B = param[3];
    double n = param[4];
    double p = param[5];
    first_derivate = A * m * (cos(n * x + p)) - B * n * (sin(m * x + t));
    break;
  }
  }
  return first_derivate;
}
```