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

```asm
<ephcom_cal2jd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    -0x18(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  mov    -0x18(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%eax
  pxor   %xmm2,%xmm2
  cvtsi2sd %eax,%xmm2
  mov    -0x18(%rbp),%rax
  add    $0x14,%rax
  mov    (%rax),%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  D39(%rip),%xmm3
  divsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm0
  movsd  D39(%rip),%xmm2
  divsd  %xmm2,%xmm0
  addsd  %xmm1,%xmm0
  movsd  D3(%rip),%xmm1
  divsd  %xmm1,%xmm0
  movsd  D17(%rip),%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  cmpl   $0xffffffff,-0x1c(%rbp)
  je     L40
  cmpl   $0x0,-0x1c(%rbp)
  jne    L50
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x62d,%eax
  jle    L40
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x62e,%eax
  jne    L50
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  cmp    $0x9,%eax
  jle    L40
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  cmp    $0xa,%eax
  jne    L50
  mov    -0x18(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  cmp    $0xe,%eax
  jg     L50
L40:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  imul   $0x16f,%eax,%ecx
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1389(%rax),%esi
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  sub    $0x9,%eax
  movslq %eax,%rdx
  imul   $0xffffffff92492493,%rdx,%rdx
  shr    $0x20,%rdx
  add    %eax,%edx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  mov    %eax,%edi
  mov    %edx,%eax
  sub    %edi,%eax
  lea    (%rsi,%rax,1),%edx
  mov    %edx,%eax
  shl    $0x3,%eax
  sub    %edx,%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  neg    %eax
  add    %eax,%ecx
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  imul   $0x113,%eax,%eax
  movslq %eax,%rdx
  imul   $0x38e38e39,%rdx,%rdx
  shr    $0x20,%rdx
  sar    %edx
  sar    $0x1f,%eax
  mov    %eax,%esi
  mov    %edx,%eax
  sub    %esi,%eax
  lea    (%rcx,%rax,1),%edx
  mov    -0x18(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  add    $0x1a64f1,%eax
  mov    %eax,-0xc(%rbp)
  jmp    L51
L50:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  lea    0x12c0(%rax),%ecx
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  sub    $0xe,%eax
  movslq %eax,%rdx
  imul   $0x2aaaaaab,%rdx,%rdx
  shr    $0x20,%rdx
  sar    %edx
  sar    $0x1f,%eax
  mov    %eax,%esi
  mov    %edx,%eax
  sub    %esi,%eax
  add    %ecx,%eax
  imul   $0x5b5,%eax,%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  mov    %eax,%edi
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  lea    -0x2(%rax),%ecx
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  sub    $0xe,%eax
  movslq %eax,%rdx
  imul   $0x2aaaaaab,%rdx,%rdx
  shr    $0x20,%rdx
  mov    %edx,%esi
  sar    %esi
  sar    $0x1f,%eax
  sub    %esi,%eax
  mov    %eax,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  shl    $0x2,%eax
  add    %ecx,%eax
  imul   $0x16f,%eax,%eax
  movslq %eax,%rdx
  imul   $0x2aaaaaab,%rdx,%rdx
  shr    $0x20,%rdx
  sar    %edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  lea    (%rdi,%rax,1),%ecx
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1324(%rax),%esi
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  sub    $0xe,%eax
  movslq %eax,%rdx
  imul   $0x2aaaaaab,%rdx,%rdx
  shr    $0x20,%rdx
  sar    %edx
  sar    $0x1f,%eax
  mov    %eax,%edi
  mov    %edx,%eax
  sub    %edi,%eax
  add    %esi,%eax
  movslq %eax,%rdx
  imul   $0x51eb851f,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x5,%edx
  sar    $0x1f,%eax
  sub    %eax,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  neg    %eax
  lea    (%rcx,%rax,1),%edx
  mov    -0x18(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  sub    $0x7d4b,%eax
  mov    %eax,-0xc(%rbp)
L51:
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0xc(%rbp),%xmm0
  movsd  -0x8(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  pop    %rbp
  ret
```

tool_calls: name: read_data
arguments: tag: D39
datatype: f64
name: read_data
arguments: tag: D3
datatype: f64
name: read_data
arguments: tag: D17
datatype: f64

tool: D39: 60

tool: D3: 24

tool: D17: 0.5

assistant: ```c
double ephcom_cal2jd(int idate[6], int calendar_type) {
  double tjd;
  int jd;
  tjd = (idate[3] + (idate[4] + idate[5] / 60.0) / 60.0) / 24.0 - 0.5;
  if (calendar_type == -1 || (calendar_type == 0 && (idate[0] < 1582 || (idate[0] == 1582 && (idate[1] < 10 || (idate[1] == 10 && idate[2] < 15)))))) {
    jd = 367 * idate[0] - (7 * (idate[0] + 5001 + (idate[1] - 9) / 7)) / 4 + (275 * idate[1]) / 9 + idate[2] + 1729777;
  } else {
    jd = (1461 * (idate[0] + 4800 + (idate[1] - 14) / 12)) / 4 + (367 * (idate[1] - 2 - 12 * ((idate[1] - 14) / 12))) / 12 - (3 * ((idate[0] + 4900 + (idate[1] - 14) / 12) / 100)) / 4 + idate[2] - 32075;
  }
  tjd += (double)jd;
  return (tjd);
}
```