user: What would the C source look like for the assembly code provided here?

```asm
<intersection_area_circle_triangle>:
  endbr64
  push   %r15
  mov    %rdx,%r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x288,%rsp
  movsd  (%rdi),%xmm7
  movsd  (%rdx),%xmm1
  movsd  D152(%rip),%xmm5
  movsd  %xmm0,0x78(%rsp)
  movsd  0x8(%rdi),%xmm4
  lea    0x120(%rsp),%r14
  movsd  D152(%rip),%xmm3
  mov    %rdi,0x10(%rsp)
  movapd %xmm7,%xmm2
  lea    0xa0(%rsp),%r12
  divsd  %xmm0,%xmm5
  movapd %xmm4,%xmm6
  mulsd  %xmm0,%xmm0
  mov    %fs:0x28,%rax
  mov    %rax,0x278(%rsp)
  xor    %eax,%eax
  movsd  %xmm7,0x18(%rsp)
  movsd  %xmm7,0x120(%rsp)
  addsd  %xmm1,%xmm7
  movq   $0x0,0x90(%rsp)
  movq   $0x0,0x98(%rsp)
  movsd  %xmm7,0x38(%rsp)
  movsd  %xmm7,0x140(%rsp)
  movapd %xmm4,%xmm7
  movsd  %xmm4,0x20(%rsp)
  movsd  %xmm4,0x128(%rsp)
  divsd  %xmm0,%xmm3
  movsd  %xmm5,(%rsp)
  movsd  %xmm3,0x48(%rsp)
  movsd  (%rsi),%xmm3
  addsd  %xmm3,%xmm2
  movsd  %xmm2,0x28(%rsp)
  movsd  %xmm2,0x130(%rsp)
  movsd  0x8(%rsi),%xmm2
  addsd  %xmm2,%xmm6
  movsd  %xmm6,0x30(%rsp)
  movsd  %xmm6,0x138(%rsp)
  movsd  0x8(%rdx),%xmm0
  movq   $0x0,0x150(%rsp)
  movq   $0x0,0x158(%rsp)
  addsd  %xmm0,%xmm7
  movsd  %xmm1,0x170(%rsp)
  movapd %xmm4,%xmm1
  movsd  %xmm3,0x160(%rsp)
  movsd  %xmm7,0x40(%rsp)
  movsd  %xmm7,0x148(%rsp)
  movsd  %xmm2,0x168(%rsp)
  movsd  %xmm0,0x178(%rsp)
L255:
  mov    %rbp,%rdx
  mov    $0x2,%eax
  shl    $0x4,%rdx
  movsd  (%r14,%rdx,1),%xmm0
  mov    %rdx,0x8(%rsp)
  call   <pythag2@plt>
  pxor   %xmm0,%xmm0
  mov    %ebp,%ecx
  mov    %ebx,%edi
  cvtsi2sd %eax,%xmm0
  mulsd  (%rsp),%xmm0
  mov    $0x1,%eax
  movsd  D152(%rip),%xmm3
  shl    %cl,%eax
  or     %eax,%ebx
  comisd %xmm0,%xmm3
  movsd  %xmm0,(%r12,%rbp,8)
  cmovb  %edi,%ebx
  add    $0x1,%rbp
  cmp    $0x3,%rbp
  je     L235
  mov    0x8(%rsp),%rdx
  movsd  0x138(%rsp,%rdx,1),%xmm1
  jmp    L255
  nopw   0x0(%rax,%rax,1)
L235:
  mov    0x10(%rsp),%rdi
  xor    %eax,%eax
  mov    %r15,%rdx
  mov    %r13,%rsi
  lea    0x90(%rsp),%r14
  mov    %ebx,%ebp
  mov    %r14,%rcx
  or     $0x8,%ebp
  call   <TriangleContainsPoint@plt>
  test   %eax,%eax
  cmove  %ebx,%ebp
  cmp    $0x7,%ebx
  je     L181
  movsd  (%r15),%xmm1
  movsd  0x8(%r15),%xmm0
  lea    0x180(%rsp),%rax
  lea    0xc0(%rsp),%r14
  movsd  0x8(%r13),%xmm2
  movsd  0x0(%r13),%xmm4
  mov    %rax,0x70(%rsp)
  mov    %rax,%r15
  movapd %xmm1,%xmm5
  movapd %xmm0,%xmm3
  xorpd  D168(%rip),%xmm1
  mov    %r14,%r13
  subsd  %xmm4,%xmm5
  subsd  %xmm2,%xmm3
  xorpd  D168(%rip),%xmm0
  movsd  %xmm4,0x8(%rsp)
  movsd  %xmm1,0x60(%rsp)
  lea    0x1b0(%rsp),%rbx
  movsd  %xmm1,0x1a0(%rsp)
  movapd %xmm2,%xmm1
  movsd  %xmm4,0x180(%rsp)
  movsd  %xmm2,0x10(%rsp)
  movsd  %xmm2,0x188(%rsp)
  movsd  %xmm5,0x50(%rsp)
  movsd  %xmm5,0x190(%rsp)
  movsd  %xmm3,0x58(%rsp)
  movsd  %xmm3,0x198(%rsp)
  movsd  %xmm0,0x68(%rsp)
  movsd  %xmm0,0x1a8(%rsp)
L363:
  movsd  (%r15),%xmm0
  mov    $0x2,%eax
  add    $0x10,%r15
  add    $0x8,%r13
  call   <pythag2@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  (%rsp),%xmm0
  movsd  %xmm0,-0x8(%r13)
  cmp    %rbx,%r15
  je     L368
  movsd  0x8(%r15),%xmm1
  jmp    L363
  nopw   0x0(%rax,%rax,1)
L368:
  movsd  0x20(%rsp),%xmm0
  movsd  0x18(%rsp),%xmm1
  lea    0x84(%rsp),%r8
  mov    %rbx,%r9
  mulsd  0x8(%rsp),%xmm1
  mov    %r8,%rdi
  xor    %edx,%edx
  xor    %r10d,%r10d
  mulsd  0x10(%rsp),%xmm0
  movsd  0x48(%rsp),%xmm6
  xor    %r15d,%r15d
  pxor   %xmm2,%xmm2
  movq   D201(%rip),%xmm3
  movapd %xmm3,%xmm4
  addsd  %xmm1,%xmm0
  movsd  0x28(%rsp),%xmm1
  mulsd  0x50(%rsp),%xmm1
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,0xe0(%rsp)
  movsd  0x30(%rsp),%xmm0
  mulsd  0x58(%rsp),%xmm0
  addsd  %xmm1,%xmm0
  movsd  0x40(%rsp),%xmm1
  mulsd  0x68(%rsp),%xmm1
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,0xe8(%rsp)
  movsd  0x38(%rsp),%xmm0
  mulsd  0x60(%rsp),%xmm0
  addsd  %xmm1,%xmm0
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,0xf0(%rsp)
L42:
  mov    %r15d,%ecx
  mov    %ebp,%esi
  lea    0x1(%r15),%eax
  sar    %cl,%esi
  mov    $0xaaaaaaab,%ecx
  mov    %rax,%r15
  imul   %rcx,%rax
  mov    %r15d,%ecx
  shr    $0x21,%rax
  lea    (%rax,%rax,2),%eax
  sub    %eax,%ecx
  mov    %ebp,%eax
  sar    %cl,%eax
  mov    %esi,%ecx
  and    %eax,%ecx
  and    $0x1,%ecx
  jne    L429
  movsd  (%r14,%rdx,1),%xmm0
  movsd  D152(%rip),%xmm7
  xor    %eax,%esi
  movsd  0xe0(%rsp,%rdx,1),%xmm6
  movsd  (%r12,%rdx,1),%xmm5
  and    $0x1,%esi
  mulsd  %xmm0,%xmm0
  mulsd  %xmm5,%xmm5
  subsd  D152(%rip),%xmm5
  divsd  %xmm0,%xmm7
  movapd %xmm6,%xmm0
  mulsd  %xmm6,%xmm0
  xorpd  D168(%rip),%xmm6
  movapd %xmm6,%xmm1
  mulsd  %xmm7,%xmm0
  mulsd  %xmm7,%xmm1
  subsd  %xmm5,%xmm0
  mulsd  %xmm7,%xmm0
  je     L158
  add    $0x1,%r10d
  comisd %xmm0,%xmm2
  movl   $0x1,(%rdi)
  ja     L328
  ucomisd %xmm0,%xmm2
  ja     L435
L479:
  sqrtsd %xmm0,%xmm0
L290:
  movapd %xmm0,%xmm5
  movsd  D4(%rip),%xmm7
  addsd  %xmm1,%xmm5
  subsd  %xmm0,%xmm1
  movapd %xmm3,%xmm0
  comisd %xmm7,%xmm5
  movapd %xmm5,%xmm6
  ja     L175
  comisd %xmm7,%xmm1
  andpd  %xmm3,%xmm6
  jbe    L83
L94:
  movapd %xmm1,%xmm7
  subsd  D152(%rip),%xmm7
  andpd  %xmm7,%xmm0
L383:
  cmpnltsd %xmm6,%xmm0
  andpd  %xmm0,%xmm5
  andnpd %xmm1,%xmm0
  orpd   %xmm0,%xmm5
  comisd %xmm5,%xmm2
  ja     L297
  movsd  D152(%rip),%xmm6
  minsd  %xmm5,%xmm6
  movapd %xmm6,%xmm5
L407:
  mov    0x70(%rsp),%rax
  movsd  (%rax,%rdx,2),%xmm0
  mulsd  %xmm5,%xmm0
  addsd  0x150(%rsp,%rdx,2),%xmm0
  mulsd  0x8(%rax,%rdx,2),%xmm5
  addsd  0x158(%rsp,%rdx,2),%xmm5
  movsd  %xmm0,(%r9)
  movsd  %xmm5,0x8(%r9)
  jmp    L531
  nop
L158:
  pxor   %xmm5,%xmm5
  comisd %xmm0,%xmm5
  jb     L341
  xchg   %ax,%ax
L429:
  movl   $0x0,(%rdi)
L531:
  add    $0x20,%r9
  add    $0x4,%rdi
  add    $0x8,%rdx
  cmp    $0x3,%r15d
  jne    L42
  test   %r10d,%r10d
  jne    L474
  and    $0x8,%ebp
  pxor   %xmm2,%xmm2
  je     L291
  movsd  0x78(%rsp),%xmm5
  movsd  D24(%rip),%xmm2
  mulsd  %xmm5,%xmm2
  mulsd  %xmm5,%xmm2
L291:
  mov    0x278(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L194
  add    $0x288,%rsp
  movapd %xmm2,%xmm0
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L474:
  cmp    $0x2,%r10d
  je     L149
  and    $0xfffffffd,%r10d
  mov    0x84(%rsp),%r13d
  cmp    $0x4,%r10d
  jne    L46
L16:
  mov    %r8,0x8(%rsp)
  xor    %r15d,%r15d
  xor    %r14d,%r14d
  xor    %r12d,%r12d
  lea    0x210(%rsp),%rax
  mov    %rax,(%rsp)
L201:
  bt     %r12d,%ebp
  jae    L263
  movsd  0x150(%rsp,%r15,8),%xmm0
  lea    (%r14,%r14,1),%eax
  movslq %eax,%rdx
  add    $0x1,%eax
  movsd  %xmm0,0x210(%rsp,%rdx,8)
  cltq
  movsd  0x158(%rsp,%r15,8),%xmm0
  movsd  %xmm0,0x210(%rsp,%rax,8)
  movslq %r14d,%rax
  add    $0x1,%r14d
  movl   $0x1,0x100(%rsp,%rax,4)
L263:
  test   %r13d,%r13d
  jle    L23
  lea    -0x1(%r13),%esi
  mov    %r15,%rax
  movslq %r14d,%rdi
  add    %r15,%rsi
  shl    $0x4,%rax
  mov    %rdi,%rdx
  shl    $0x4,%rsi
  shl    $0x4,%rdx
  add    %rbx,%rax
  add    (%rsp),%rdx
  lea    0x10(%rbx,%rsi,1),%rsi
  nopl   0x0(%rax)
L195:
  movsd  (%rax),%xmm0
  add    $0x10,%rax
  add    $0x10,%rdx
  movsd  %xmm0,-0x10(%rdx)
  movsd  -0x8(%rax),%xmm0
  movsd  %xmm0,-0x8(%rdx)
  cmp    %rsi,%rax
  jne    L195
  mov    %r13d,%edx
  lea    0x100(%rsp,%rdi,4),%rdi
  xor    %esi,%esi
  add    %r13d,%r14d
  shl    $0x2,%rdx
  call   <memset@plt>
L23:
  add    $0x1,%r12d
  add    $0x2,%r15
  cmp    $0x3,%r12d
  je     L356
  mov    0x8(%rsp),%rax
  mov    (%rax,%r15,2),%r13d
  jmp    L201
  nopl   (%rax)
L175:
  subsd  D152(%rip),%xmm6
  comisd %xmm7,%xmm1
  andpd  %xmm4,%xmm6
  ja     L94
L83:
  andpd  %xmm1,%xmm0
  jmp    L383
  nop
L356:
  cmp    $0x2,%r14d
  jg     L471
L46:
  movsd  D118(%rip),%xmm2
  jmp    L291
  nopw   0x0(%rax,%rax,1)
L297:
  movapd %xmm2,%xmm5
  jmp    L407
  nopl   0x0(%rax)
L328:
  movapd %xmm2,%xmm0
  jmp    L479
  nopl   0x0(%rax)
L341:
  ucomisd %xmm0,%xmm5
  ja     L88
  sqrtsd %xmm0,%xmm0
L529:
  movapd %xmm1,%xmm6
  movl   $0x0,(%rdi)
  subsd  %xmm0,%xmm6
  comisd %xmm5,%xmm6
  jbe    L531
  movsd  D152(%rip),%xmm7
  comisd %xmm6,%xmm7
  jbe    L531
  addsd  %xmm0,%xmm1
  comisd %xmm5,%xmm1
  jbe    L531
  comisd %xmm1,%xmm7
  jbe    L531
  mov    0x70(%rsp),%rax
  movl   $0x2,(%rdi)
  add    $0x2,%r10d
  movsd  (%rax,%rdx,2),%xmm0
  mulsd  %xmm6,%xmm0
  addsd  0x150(%rsp,%rdx,2),%xmm0
  mulsd  0x8(%rax,%rdx,2),%xmm6
  addsd  0x158(%rsp,%rdx,2),%xmm6
  movsd  %xmm0,(%r9)
  movsd  %xmm6,0x8(%r9)
  movsd  %xmm0,0x10(%r9)
  movsd  %xmm6,0x18(%r9)
  jmp    L531
  nopl   0x0(%rax)
L471:
  mov    %r14d,%edi
  xor    %eax,%eax
  lea    -0x1(%r14),%r12d
  mov    $0x1,%ebx
  lea    0x210(%rsp),%rsi
  lea    0x100(%rsp),%rbp
  movslq %r12d,%r13
  call   <polygon_area@plt>
  pxor   %xmm2,%xmm2
  lea    0x208(%rsp),%rdx
  lea    0x200(%rsp),%r15
  cvtsi2sd %eax,%xmm2
  jmp    L381
L481:
  mov    -0x8(%rbp,%rbx,4),%esi
  test   %esi,%esi
  jne    L506
L287:
  mov    -0x4(%rbp,%rbx,4),%ecx
  test   %ecx,%ecx
  je     L315
L506:
  cmp    %ebx,%r14d
  jle    L291
L217:
  add    $0x1,%rbx
L381:
  lea    -0x2(%rbx),%eax
  cmp    $0x1,%ebx
  jne    L481
  mov    0x100(%rsp,%r13,4),%edi
  mov    %r12d,%eax
  test   %edi,%edi
  je     L287
  jmp    L217
  nopw   0x0(%rax,%rax,1)
L149:
  mov    0x84(%rsp),%r13d
  mov    $0x1,%eax
  xor    %edx,%edx
  cmp    $0x1,%r13d
  jle    L498
L421:
  movslq %r10d,%r10
  movslq %r15d,%r15
  movsd  0x1b0(%rsp,%r10,8),%xmm0
  movsd  0x1b0(%rsp,%r15,8),%xmm1
  subsd  0x1b0(%rsp,%rdx,8),%xmm0
  subsd  0x1b0(%rsp,%rax,8),%xmm1
  mov    $0x2,%eax
  call   <pythag2@plt>
  movsd  0x78(%rsp),%xmm0
  mov    %eax,%edi
  mov    $0x1,%eax
  call   <CircularSectorArea@plt>
  pxor   %xmm2,%xmm2
  and    $0x8,%ebp
  cvtsi2sd %eax,%xmm2
  je     L291
  movsd  0x78(%rsp),%xmm4
  movsd  D24(%rip),%xmm0
  mulsd  %xmm4,%xmm0
  mulsd  %xmm4,%xmm0
  subsd  %xmm2,%xmm0
  movapd %xmm0,%xmm2
  jmp    L291
  nopl   (%rax)
L181:
  mov    %r15,%rdx
  mov    %r13,%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <LeftTurn@plt>
  pxor   %xmm2,%xmm2
  cvtsi2sd %eax,%xmm2
  andpd  D201(%rip),%xmm2
  mulsd  D4(%rip),%xmm2
  jmp    L291
  nopl   (%rax)
L315:
  add    %eax,%eax
  mov    %rbx,%rsi
  mov    %rdx,(%rsp)
  lea    0x1(%rax),%ecx
  shl    $0x4,%rsi
  cltq
  movsd  %xmm2,0x8(%rsp)
  movslq %ecx,%rcx
  movsd  (%rdx,%rsi,1),%xmm1
  movsd  (%r15,%rsi,1),%xmm0
  subsd  0x210(%rsp,%rcx,8),%xmm1
  subsd  0x210(%rsp,%rax,8),%xmm0
  mov    $0x2,%eax
  call   <pythag2@plt>
  movsd  0x78(%rsp),%xmm0
  mov    %eax,%edi
  mov    $0x1,%eax
  call   <CircularSectorArea@plt>
  pxor   %xmm0,%xmm0
  movsd  0x8(%rsp),%xmm2
  mov    (%rsp),%rdx
  cvtsi2sd %eax,%xmm0
  addsd  %xmm0,%xmm2
  jmp    L506
  nopw   0x0(%rax,%rax,1)
L498:
  cmpl   $0x1,0x88(%rsp)
  jle    L221
  mov    $0x5,%eax
  mov    $0x4,%edx
  mov    $0x7,%r15d
  mov    $0x6,%r10d
  jmp    L421
L221:
  cmpl   $0x1,0x8c(%rsp)
  jle    L16
  mov    $0x9,%eax
  mov    $0x8,%edx
  mov    $0xb,%r15d
  mov    $0xa,%r10d
  jmp    L421
L194:
  call   <__stack_chk_fail@plt>
L435:
  mov    %r8,0x28(%rsp)
  mov    %rdx,0x20(%rsp)
  mov    %rdi,0x18(%rsp)
  mov    %r9,0x10(%rsp)
  mov    %r10d,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <sqrt@plt>
  mov    0x28(%rsp),%r8
  mov    0x20(%rsp),%rdx
  pxor   %xmm2,%xmm2
  movq   D201(%rip),%xmm4
  mov    0x18(%rsp),%rdi
  mov    0x10(%rsp),%r9
  mov    0x8(%rsp),%r10d
  movsd  (%rsp),%xmm1
  movapd %xmm4,%xmm3
  jmp    L290
L88:
  mov    %r8,0x28(%rsp)
  mov    %rdx,0x20(%rsp)
  mov    %rdi,0x18(%rsp)
  mov    %r9,0x10(%rsp)
  mov    %r10d,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <sqrt@plt>
  pxor   %xmm2,%xmm2
  mov    0x28(%rsp),%r8
  movq   D201(%rip),%xmm4
  mov    0x20(%rsp),%rdx
  mov    0x18(%rsp),%rdi
  movapd %xmm2,%xmm5
  mov    0x10(%rsp),%r9
  mov    0x8(%rsp),%r10d
  movapd %xmm4,%xmm3
  movsd  (%rsp),%xmm1
  jmp    L529
```

tool_calls: name: unpack_data
arguments: label: D152
type: f64
name: unpack_data
arguments: label: D168
type: f32[4]
name: unpack_data
arguments: label: D201
type: qword[2]
name: unpack_data
arguments: label: D4
type: f64
name: unpack_data
arguments: label: D24
type: f64
name: unpack_data
arguments: label: D118
type: f32[2]

tool: D152: 1

tool: {"D168": [0.0,-0.0,0.0,0.0]}

tool: {"D201": [0x7fffffffffffffff,0x0000000000000000]}

tool: D4: 0.5

tool: D24: 3.141592653589793

tool: {"D118": [0.0,-1.875]}

assistant: ```c
double intersection_area_circle_triangle(double radius, const double tri_org[2], const double tri_u[2], const double tri_v[2]) {
  const double origin[2] = {0, 0};
  int i, j;
  const double iradius = 1. / radius;
  const double iradius2 = 1. / (radius * radius);
  int inside = 0;
  double vert[6];
  vert[2 * 0 + 0] = tri_org[0];
  vert[2 * 0 + 1] = tri_org[1];
  vert[2 * 1 + 0] = (tri_org[0] + tri_u[0]);
  vert[2 * 1 + 1] = (tri_org[1] + tri_u[1]);
  vert[2 * 2 + 0] = (tri_org[0] + tri_v[0]);
  vert[2 * 2 + 1] = (tri_org[1] + tri_v[1]);
  double vert_org[6];
  vert_org[2 * 0 + 0] = 0;
  vert_org[2 * 0 + 1] = 0;
  vert_org[2 * 1 + 0] = tri_u[0];
  vert_org[2 * 1 + 1] = tri_u[1];
  vert_org[2 * 2 + 0] = tri_v[0];
  vert_org[2 * 2 + 1] = tri_v[1];
  double tri_r[3];
  for (i = 0; i < 3; ++i) {
    tri_r[i] = pythag2(vert[2 * i + 0], vert[2 * i + 1]) * iradius;
    if (tri_r[i] <= 1.0) {
      inside |= (1 << i);
    }
  }
  if (TriangleContainsPoint(tri_org, tri_u, tri_v, origin)) {
    inside |= (1 << 3);
  }
  if ((inside & 0x7) == 0x7) {
    return 0.5 * fabs(LeftTurn(origin, tri_u, tri_v));
  }
  double seg[6];
  seg[2 * 0 + 0] = tri_u[0];
  seg[2 * 0 + 1] = tri_u[1];
  seg[2 * 1 + 0] = (tri_v[0] - tri_u[0]);
  seg[2 * 1 + 1] = (tri_v[1] - tri_u[1]);
  seg[2 * 2 + 0] = -tri_v[0];
  seg[2 * 2 + 1] = -tri_v[1];
  double side_length[3];
  for (i = 0; i < 3; ++i) {
    side_length[i] = pythag2(seg[2 * i + 0], seg[2 * i + 1]) * iradius;
  }
  double seg_dot[3];
  for (i = 0; i < 3; ++i) {
    seg_dot[i] = (vert[2 * i + 0] * seg[2 * i + 0] + vert[2 * i + 1] * seg[2 * i + 1]) * iradius2;
  }
  double xp[12];
  int nxp[3];
  int nx = 0;
  for (i = 0; i < 3; ++i) {
    int ip1 = (i + 1) % 3;
    int in0 = (inside & (1 << i)) ? 1 : 0;
    int in1 = (inside & (1 << ip1)) ? 1 : 0;
    if (in0 && in1) {
      nxp[i] = 0;
    } else {
      double isl2 = 1. / (side_length[i] * side_length[i]);
      double disc = (seg_dot[i] * seg_dot[i] * isl2 - (tri_r[i] * tri_r[i] - 1)) * isl2;
      double t0 = -seg_dot[i] * isl2;
      double t, t2, tdist, t2dist;
      if (in0 != in1) {
        nxp[i] = 1;
        nx += 1;
        if (disc < 0) {
          disc = 0;
        }
        disc = sqrt(disc);
        t = t0 + disc;
        t2 = t0 - disc;
        if (t > 0.5) {
          tdist = fabs(t - 1.);
        } else {
          tdist = fabs(t);
        }
        if (t2 > 0.5) {
          t2dist = fabs(t2 - 1.);
        } else {
          t2dist = fabs(t2);
        }
        if (t2dist < tdist) {
          t = t2;
        }
        if (t < 0) {
          t = 0;
        }
        if (t > 1) {
          t = 1;
        }
        xp[2 * 2 * i + 0] = vert_org[2 * i + 0] + t * seg[2 * i + 0];
        xp[2 * 2 * i + 1] = vert_org[2 * i + 1] + t * seg[2 * i + 1];
      } else {
        if (disc <= 0) {
          nxp[i] = 0;
        } else {
          disc = sqrt(disc);
          nxp[i] = 0;
          t = t0 - disc;
          t2 = t0 + disc;
          if (0 < t && t < 1 && 0 < t2 && t2 < 1) {
            xp[2 * (2 * i + 0) + 0] = vert_org[2 * i + 0] + t * seg[2 * i + 0];
            xp[2 * (2 * i + 0) + 1] = vert_org[2 * i + 1] + t * seg[2 * i + 1];
            xp[2 * (2 * i + 1) + 0] = vert_org[2 * i + 0] + t * seg[2 * i + 0];
            xp[2 * (2 * i + 1) + 1] = vert_org[2 * i + 1] + t * seg[2 * i + 1];
            nxp[i] += 2;
            nx += 2;
          }
        }
      }
    }
  }
  if (0 == nx) {
    if ((inside & 0x7) == 0x7) {
      return -1;
    } else {
      if (inside & 0x8) {
        return 3.14159265358979323846 * radius * radius;
      } else {
        return 0;
      }
    }
  } else if (2 == nx) {
    if (nxp[0] < 2 && nxp[1] < 2 && nxp[2] < 2) {
    } else {
      for (i = 0; i < 3; ++i) {
        if (nxp[i] > 1) {
          break;
        }
      }
      double sector_area = CircularSectorArea(radius, pythag2(xp[2 * (2 * i + 1) + 0] - xp[2 * 2 * i + 0], xp[2 * (2 * i + 1) + 1] - xp[2 * 2 * i + 1]));
      if (inside & (1 << 3)) {
        return 3.14159265358979323846 * radius * radius - sector_area;
      } else {
        return sector_area;
      }
    }
  } else if (4 == nx) {
  } else if (6 == nx) {
  } else {
    return -1;
  }
  int vtype[6];
  double vp[12];
  int nv = 0;
  for (i = 0; i < 3; ++i) {
    if (inside & (1 << i)) {
      vp[2 * nv + 0] = vert_org[2 * i + 0];
      vp[2 * nv + 1] = vert_org[2 * i + 1];
      vtype[nv++] = 1;
    }
    for (j = 0; j < nxp[i]; ++j) {
      vp[2 * nv + 0] = xp[2 * (2 * i + j) + 0];
      vp[2 * nv + 1] = xp[2 * (2 * i + j) + 1];
      vtype[nv++] = 0;
    }
  }
  if (nv < 3) {
    return -1;
  }
  double area = polygon_area(nv, vp);
  for (i = 0; i < nv; ++i) {
    int im1 = i - 1;
    if (im1 < 0) {
      im1 = nv - 1;
    }
    if ((0 == vtype[im1]) && (0 == vtype[i])) {
      area += CircularSectorArea(radius, pythag2(vp[2 * i + 0] - vp[2 * im1 + 0], vp[2 * i + 1] - vp[2 * im1 + 1]));
    }
  }
  return area;
}
```