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

```asm
<main>:
  endbr64
  push   %rbx
  lea    D66(%rip),%rdi
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rsi
  call   <scanf@plt>
  cmp    $0x1,%eax
  je     L31
L94:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L163
  add    $0x20,%rsp
  xor    %eax,%eax
  pop    %rbx
  ret
L31:
  movsd  0x10(%rsp),%xmm1
  movsd  D68(%rip),%xmm0
  comisd %xmm0,%xmm1
  movapd %xmm1,%xmm2
  jb     L145
  nopl   0x0(%rax,%rax,1)
L114:
  subsd  %xmm0,%xmm2
  comisd %xmm0,%xmm2
  jae    L114
  movsd  %xmm2,0x10(%rsp)
  movapd %xmm2,%xmm1
L145:
  pxor   %xmm2,%xmm2
  comisd %xmm1,%xmm2
  jbe    L131
  cs nopw 0x0(%rax,%rax,1)
L13:
  addsd  %xmm0,%xmm1
  comisd %xmm1,%xmm2
  ja     L13
  movsd  %xmm1,0x10(%rsp)
L131:
  comisd %xmm2,%xmm1
  movsd  D20(%rip),%xmm2
  jb     L162
  comisd %xmm1,%xmm2
  movq   %xmm1,%rbx
  jbe    L162
L101:
  movq   %rbx,%xmm0
  movsd  %xmm1,0x8(%rsp)
  call   <sine@plt>
  lea    D43(%rip),%rdi
  mov    %eax,%esi
  call   <printf@plt>
  movsd  0x8(%rsp),%xmm1
  movapd %xmm1,%xmm0
  call   <cosine@plt>
  lea    D62(%rip),%rdi
  mov    %eax,%esi
  call   <printf@plt>
  jmp    L94
L162:
  comisd %xmm2,%xmm1
  movsd  D37(%rip),%xmm2
  jb     L106
  comisd %xmm1,%xmm2
  jbe    L106
  subsd  %xmm1,%xmm2
  movq   %xmm2,%rbx
  jmp    L101
L106:
  comisd %xmm2,%xmm1
  jb     L62
  movsd  D2(%rip),%xmm3
  comisd %xmm1,%xmm3
  ja     L115
L62:
  comisd %xmm1,%xmm0
  jbe    L101
  movapd %xmm1,%xmm4
  subsd  %xmm0,%xmm4
  subsd  %xmm1,%xmm0
  movq   %xmm4,%rbx
  movapd %xmm0,%xmm1
  jmp    L101
L115:
  subsd  %xmm1,%xmm2
  subsd  %xmm1,%xmm0
  movq   %xmm2,%rbx
  movapd %xmm0,%xmm1
  jmp    L101
L163:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D66
type: string
name: disassemble_data
arguments: data_label: D68
type: byte[8]
name: disassemble_data
arguments: data_label: D20
type: f64
name: disassemble_data
arguments: data_label: D43
type: string
name: disassemble_data
arguments: data_label: D62
type: string
name: disassemble_data
arguments: data_label: D37
type: f64
name: disassemble_data
arguments: data_label: D2
type: byte[8]

tool: D66: %lf

tool: {"D68": [0x18,0x2d,0x44,0x54,0xfb,0x21,0x19,0x40]}

tool: D20: 1.5707963267948966

tool: D43: sin = %.6lf


tool: D62: cos = %.6lf


tool: D37: 3.141592653589793

tool: {"D2": [0xd2,0x21,0x33,0x7f,0x7c,0xd9,0x12,0x40]}

assistant: ```c
int main() {
  double x;
  double s, c;
  if (scanf("%lf", &x) == 1) {
    while (x >= 2 * 3.14159265358979323846)
      x -= 2 * 3.14159265358979323846;
    while (x < 0)
      x += 2 * 3.14159265358979323846;
    if (0 <= x && x < 1.57079632679489661923)
      s = x, c = x;
    else if (1.57079632679489661923 <= x && x < 3.14159265358979323846)
      s = 3.14159265358979323846 - x, c = x;
    else if (3.14159265358979323846 <= x && x < 3.14159265358979323846 + 1.57079632679489661923)
      s = 3.14159265358979323846 - x, c = 2 * 3.14159265358979323846 - x;
    else if (3.14159265358979323846 <= 3.14159265358979323846 + 1.57079632679489661923 && x < 2 * 3.14159265358979323846)
      s = x - 2 * 3.14159265358979323846, c = 2 * 3.14159265358979323846 - x;
    printf("sin = %.6lf\n", sine(s));
    printf("cos = %.6lf\n", cosine(c));
  }
  return 0;
}
```