user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<betai>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x38,%rsp
  movsd  %xmm0,-0x28(%rbp)
  movsd  %xmm1,-0x30(%rbp)
  movsd  %xmm2,-0x38(%rbp)
  pxor   %xmm0,%xmm0
  comisd -0x38(%rbp),%xmm0
  ja     L85
  movsd  -0x38(%rbp),%xmm0
  movsd  D16(%rip),%xmm1
  comisd %xmm1,%xmm0
  jbe    L4
L85:
  lea    D37(%rip),%rax
  mov    %rax,%rdi
  call   <fatalx@plt>
L4:
  pxor   %xmm0,%xmm0
  ucomisd -0x38(%rbp),%xmm0
  jp     L95
  pxor   %xmm0,%xmm0
  ucomisd -0x38(%rbp),%xmm0
  jne    L95
  pxor   %xmm0,%xmm0
  jmp    L7
L95:
  movsd  D16(%rip),%xmm0
  ucomisd -0x38(%rbp),%xmm0
  jp     L72
  movsd  D16(%rip),%xmm0
  ucomisd -0x38(%rbp),%xmm0
  jne    L72
  movsd  D16(%rip),%xmm0
  jmp    L7
L72:
  movsd  -0x28(%rbp),%xmm0
  addsd  -0x30(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  call   <lgamma@plt>
  mov    %rax,%rbx
  mov    -0x28(%rbp),%rax
  movq   %rax,%xmm0
  call   <lgamma@plt>
  sub    %rax,%rbx
  mov    -0x30(%rbp),%rax
  movq   %rax,%xmm0
  call   <lgamma@plt>
  mov    %rbx,%rdx
  sub    %rax,%rdx
  pxor   %xmm6,%xmm6
  cvtsi2sd %rdx,%xmm6
  movsd  %xmm6,-0x40(%rbp)
  mov    -0x38(%rbp),%rax
  movq   %rax,%xmm0
  call   <log@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  mulsd  -0x28(%rbp),%xmm0
  addsd  -0x40(%rbp),%xmm0
  movsd  %xmm0,-0x40(%rbp)
  movsd  D16(%rip),%xmm0
  movapd %xmm0,%xmm4
  subsd  -0x38(%rbp),%xmm4
  movq   %xmm4,%rax
  movq   %rax,%xmm0
  call   <log@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm5
  mulsd  -0x30(%rbp),%xmm5
  movapd %xmm5,%xmm0
  addsd  -0x40(%rbp),%xmm0
  cvttsd2si %xmm0,%rax
  mov    %rax,%rdi
  call   <exp@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x18(%rbp)
  movsd  -0x28(%rbp),%xmm1
  movsd  D16(%rip),%xmm0
  addsd  %xmm1,%xmm0
  movsd  -0x28(%rbp),%xmm1
  movapd %xmm1,%xmm2
  addsd  -0x30(%rbp),%xmm2
  movsd  D57(%rip),%xmm1
  addsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm0
  comisd -0x38(%rbp),%xmm0
  jbe    L25
  movsd  -0x38(%rbp),%xmm1
  movsd  -0x30(%rbp),%xmm0
  mov    -0x28(%rbp),%rax
  movapd %xmm1,%xmm2
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <betacf@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  mulsd  -0x18(%rbp),%xmm0
  divsd  -0x28(%rbp),%xmm0
  jmp    L7
L25:
  movsd  D16(%rip),%xmm0
  movapd %xmm0,%xmm1
  subsd  -0x38(%rbp),%xmm1
  movsd  -0x28(%rbp),%xmm0
  mov    -0x30(%rbp),%rax
  movapd %xmm1,%xmm2
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <betacf@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  mulsd  -0x18(%rbp),%xmm0
  movapd %xmm0,%xmm1
  divsd  -0x30(%rbp),%xmm1
  movsd  D16(%rip),%xmm0
  subsd  %xmm1,%xmm0
L7:
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D16
data_type: f64
name: disassemble_data
arguments: label: D37
data_type: string
name: disassemble_data
arguments: label: D57
data_type: f64

tool: D16: 1

tool: D37: Bad x in routine betai


tool: D57: 2

assistant: ```c
double betai(double a, double b, double x) {
  double betacf(double a, double b, double x);
  double bt;
  if (x < 0.0 || x > 1.0)
    fatalx("Bad x in routine betai\n");
  if (x == 0.0)
    return 0.0;
  if (x == 1.0)
    return 1.0;
  bt = exp(lgamma(a + b) - lgamma(a) - lgamma(b) + a * log(x) + b * log(1.0 - x));
  if (x < (a + 1.0) / (a + b + 2.0))
    return bt * betacf(a, b, x) / a;
  else
    return 1.0 - bt * betacf(b, a, 1.0 - x) / b;
}
```