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

```asm
<intersect_triangle>:
  endbr64
  mov    %rsi,%rax
  mov    0x8(%rsp),%rsi
  movsd  (%rdx),%xmm9
  movsd  (%rcx),%xmm7
  subsd  %xmm9,%xmm7
  movsd  0x8(%rdx),%xmm14
  movsd  0x8(%rcx),%xmm3
  subsd  %xmm14,%xmm3
  movsd  0x10(%rdx),%xmm13
  movsd  0x10(%rcx),%xmm8
  subsd  %xmm13,%xmm8
  movsd  (%r8),%xmm2
  subsd  %xmm9,%xmm2
  movsd  0x8(%r8),%xmm6
  subsd  %xmm14,%xmm6
  movsd  0x10(%r8),%xmm5
  subsd  %xmm13,%xmm5
  movsd  0x8(%rax),%xmm4
  movsd  0x10(%rax),%xmm12
  movapd %xmm5,%xmm1
  mulsd  %xmm4,%xmm1
  movapd %xmm6,%xmm10
  mulsd  %xmm12,%xmm10
  subsd  %xmm10,%xmm1
  movsd  (%rax),%xmm0
  mulsd  %xmm2,%xmm12
  movapd %xmm5,%xmm10
  mulsd  %xmm0,%xmm10
  subsd  %xmm10,%xmm12
  mulsd  %xmm6,%xmm0
  mulsd  %xmm2,%xmm4
  subsd  %xmm4,%xmm0
  movapd %xmm7,%xmm4
  mulsd  %xmm1,%xmm4
  movapd %xmm3,%xmm10
  mulsd  %xmm12,%xmm10
  addsd  %xmm10,%xmm4
  movapd %xmm8,%xmm10
  mulsd  %xmm0,%xmm10
  addsd  %xmm10,%xmm4
  comisd D46(%rip),%xmm4
  jbe    L29
  mov    $0x0,%edx
  movsd  D22(%rip),%xmm10
  comisd %xmm4,%xmm10
  ja     L40
L29:
  movsd  D42(%rip),%xmm11
  divsd  %xmm4,%xmm11
  movsd  (%rdi),%xmm10
  subsd  %xmm9,%xmm10
  movsd  0x8(%rdi),%xmm9
  subsd  %xmm14,%xmm9
  movsd  0x10(%rdi),%xmm4
  subsd  %xmm13,%xmm4
  mulsd  %xmm10,%xmm1
  mulsd  %xmm9,%xmm12
  addsd  %xmm12,%xmm1
  mulsd  %xmm4,%xmm0
  addsd  %xmm0,%xmm1
  mulsd  %xmm11,%xmm1
  movsd  %xmm1,(%rsi)
  mov    $0x0,%edx
  pxor   %xmm0,%xmm0
  comisd %xmm1,%xmm0
  ja     L40
  comisd D42(%rip),%xmm1
  ja     L40
  movapd %xmm8,%xmm1
  mulsd  %xmm9,%xmm1
  movapd %xmm3,%xmm0
  mulsd  %xmm4,%xmm0
  subsd  %xmm0,%xmm1
  mulsd  %xmm7,%xmm4
  mulsd  %xmm10,%xmm8
  subsd  %xmm8,%xmm4
  mulsd  %xmm10,%xmm3
  mulsd  %xmm9,%xmm7
  subsd  %xmm7,%xmm3
  movapd %xmm1,%xmm0
  mulsd  (%rax),%xmm0
  movapd %xmm4,%xmm7
  mulsd  0x8(%rax),%xmm7
  addsd  %xmm7,%xmm0
  movapd %xmm3,%xmm7
  mulsd  0x10(%rax),%xmm7
  addsd  %xmm7,%xmm0
  mulsd  %xmm11,%xmm0
  mov    0x10(%rsp),%rax
  movsd  %xmm0,(%rax)
  pxor   %xmm7,%xmm7
  comisd %xmm0,%xmm7
  ja     L40
  addsd  (%rsi),%xmm0
  comisd D42(%rip),%xmm0
  ja     L40
  mulsd  %xmm1,%xmm2
  mulsd  %xmm4,%xmm6
  addsd  %xmm6,%xmm2
  mulsd  %xmm3,%xmm5
  addsd  %xmm5,%xmm2
  mulsd  %xmm11,%xmm2
  movsd  %xmm2,(%r9)
  mov    $0x1,%edx
L40:
  mov    %edx,%eax
  ret
```

tool_calls: name: read_data
arguments: data_tag: D46
data_type: byte[16]
name: read_data
arguments: data_tag: D22
data_type: f64
name: read_data
arguments: data_tag: D42
data_type: f64

tool: {"D46": [0x8d,0xed,0xb5,0xa0,0xf7,0xc6,0xb0,0xbe,0x8d,0xed,0xb5,0xa0,0xf7,0xc6,0xb0,0x3e]}

tool: D22: 1e-06

tool: D42: 1

assistant: ```c
int intersect_triangle(double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v) {
  double edge1[3], edge2[3], tvec[3], pvec[3], qvec[3];
  double det, inv_det;
  edge1[0] = vert1[0] - vert0[0];
  edge1[1] = vert1[1] - vert0[1];
  edge1[2] = vert1[2] - vert0[2];
  ;
  edge2[0] = vert2[0] - vert0[0];
  edge2[1] = vert2[1] - vert0[1];
  edge2[2] = vert2[2] - vert0[2];
  ;
  pvec[0] = dir[1] * edge2[2] - dir[2] * edge2[1];
  pvec[1] = dir[2] * edge2[0] - dir[0] * edge2[2];
  pvec[2] = dir[0] * edge2[1] - dir[1] * edge2[0];
  ;
  det = (edge1[0] * pvec[0] + edge1[1] * pvec[1] + edge1[2] * pvec[2]);
  if (det > -0.000001 && det < 0.000001)
    return 0;
  inv_det = 1.0 / det;
  tvec[0] = orig[0] - vert0[0];
  tvec[1] = orig[1] - vert0[1];
  tvec[2] = orig[2] - vert0[2];
  ;
  *u = (tvec[0] * pvec[0] + tvec[1] * pvec[1] + tvec[2] * pvec[2]) * inv_det;
  if (*u < 0.0 || *u > 1.0)
    return 0;
  qvec[0] = tvec[1] * edge1[2] - tvec[2] * edge1[1];
  qvec[1] = tvec[2] * edge1[0] - tvec[0] * edge1[2];
  qvec[2] = tvec[0] * edge1[1] - tvec[1] * edge1[0];
  ;
  *v = (dir[0] * qvec[0] + dir[1] * qvec[1] + dir[2] * qvec[2]) * inv_det;
  if (*v < 0.0 || *u + *v > 1.0)
    return 0;
  *t = (edge2[0] * qvec[0] + edge2[1] * qvec[1] + edge2[2] * qvec[2]) * inv_det;
  return 1;
}
```