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

```asm
<bessi>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  movsd  %xmm0,-0x38(%rbp)
  movsd  %xmm1,-0x40(%rbp)
  movsd  -0x38(%rbp),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x2c(%rbp)
  cmpl   $0x0,-0x2c(%rbp)
  jne    L34
  mov    -0x40(%rbp),%rax
  movq   %rax,%xmm0
  call   <bessi0@plt>
  movq   %xmm0,%rax
  jmp    L82
L34:
  cmpl   $0x1,-0x2c(%rbp)
  jne    L19
  mov    -0x40(%rbp),%rax
  movq   %rax,%xmm0
  call   <bessi1@plt>
  movq   %xmm0,%rax
  jmp    L82
L19:
  pxor   %xmm0,%xmm0
  ucomisd -0x40(%rbp),%xmm0
  jp     L95
  pxor   %xmm0,%xmm0
  ucomisd -0x40(%rbp),%xmm0
  jne    L95
  mov    D67(%rip),%rax
  jmp    L82
L95:
  movsd  -0x40(%rbp),%xmm0
  movq   D104(%rip),%xmm1
  andpd  %xmm0,%xmm1
  movsd  D83(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x18(%rbp)
  movsd  -0x18(%rbp),%xmm0
  movsd  %xmm0,-0x20(%rbp)
  movsd  D71(%rip),%xmm0
  movsd  %xmm0,-0x28(%rbp)
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x2c(%rbp),%xmm1
  movsd  D106(%rip),%xmm0
  mulsd  %xmm0,%xmm1
  movq   %xmm1,%rax
  movq   %rax,%xmm0
  call   <sqrt@plt>
  mov    %eax,%edx
  mov    -0x2c(%rbp),%eax
  add    %edx,%eax
  add    %eax,%eax
  mov    %eax,-0x30(%rbp)
  jmp    L76
L54:
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x30(%rbp),%xmm0
  mulsd  -0x10(%rbp),%xmm0
  mulsd  -0x28(%rbp),%xmm0
  movsd  -0x20(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x28(%rbp),%xmm0
  movsd  %xmm0,-0x20(%rbp)
  movsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movsd  -0x28(%rbp),%xmm0
  movq   D104(%rip),%xmm1
  andpd  %xmm1,%xmm0
  comisd D10(%rip),%xmm0
  jbe    L85
  movsd  -0x18(%rbp),%xmm1
  movsd  D2(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x18(%rbp)
  movsd  -0x28(%rbp),%xmm1
  movsd  D2(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movsd  -0x20(%rbp),%xmm1
  movsd  D2(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x20(%rbp)
L85:
  mov    -0x30(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jne    L100
  movsd  -0x20(%rbp),%xmm0
  movsd  %xmm0,-0x18(%rbp)
L100:
  subl   $0x1,-0x30(%rbp)
L76:
  cmpl   $0x0,-0x30(%rbp)
  jg     L54
  mov    -0x40(%rbp),%rax
  movq   %rax,%xmm0
  call   <bessi0@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  divsd  -0x28(%rbp),%xmm0
  movsd  -0x18(%rbp),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x18(%rbp)
  pxor   %xmm0,%xmm0
  comisd -0x40(%rbp),%xmm0
  jbe    L5
  mov    -0x2c(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L5
  movsd  -0x18(%rbp),%xmm0
  movq   D47(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movq   %xmm0,%rax
  jmp    L82
L5:
  mov    -0x18(%rbp),%rax
L82:
  movq   %rax,%xmm0
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D67
type_guessed: f64
name: retrieve_data
arguments: tag: D104
type_guessed: qword
name: retrieve_data
arguments: tag: D83
type_guessed: f64
name: retrieve_data
arguments: tag: D71
type_guessed: f64
name: retrieve_data
arguments: tag: D106
type_guessed: f64
name: retrieve_data
arguments: tag: D10
type_guessed: f64[2]
name: retrieve_data
arguments: tag: D2
type_guessed: byte[8]
name: retrieve_data
arguments: tag: D47
type_guessed: byte[8]

tool: D67: 0

tool: D104: 9223372036854775807

tool: D83: 2

tool: D71: 1

tool: D106: 40

tool: {"D10": [10000000000.0,1e-10]}

tool: {"D2": [0xbb,0xbd,0xd7,0xd9,0xdf,0x7c,0xdb,0x3d]}

tool: {"D47": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80]}

assistant: ```c
double bessi(double nn, double x) {
  int j, n;
  double bi, bim, bip, tox, ans;
  n = (int)nn;
  if (n == 0)
    return bessi0(x);
  if (n == 1)
    return bessi1(x);
  if (x == 0.0)
    return 0.0;
  else {
    tox = 2.0 / fabs(x);
    bip = ans = 0.0;
    bi = 1.0;
    for (j = 2 * (n + (int)sqrt(40.0 * n)); j > 0; j--) {
      bim = bip + j * tox * bi;
      bip = bi;
      bi = bim;
      if (fabs(bi) > 1.0e10) {
        ans *= 1.0e-10;
        bi *= 1.0e-10;
        bip *= 1.0e-10;
      }
      if (j == n)
        ans = bip;
    }
    ans *= bessi0(x) / bi;
    return x < 0.0 && (n & 1) ? -ans : ans;
  }
}
```