user: 请从给定的汇编指令推导出C源代码:

```asm
<ex3>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  mov    %rdi,%rbp
  xor    %edi,%edi
  push   %rbx
  mov    %edx,%ebx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <time@plt>
  mov    %eax,%edi
  call   <srand@plt>
  xor    %eax,%eax
  mov    %rbp,0x20(%rsp)
  call   <rand@plt>
  movl   $0x1,0x14(%rsp)
  cltd
  idiv   %r12d
  cmp    $0x1,%r12d
  jle    L117
  cmp    $0x1,%ebx
  mov    %edx,%ebp
  mov    $0x1,%eax
  sete   %r13b
  xor    %r14d,%r14d
  jmp    L197
  nopl   (%rax)
L68:
  test   %r13b,%r13b
  je     L111
  mov    $0x4,%esi
  lea    0x14(%rsp),%rdi
  call   <flipBit@plt>
  mov    0x14(%rsp),%ecx
  pxor   %xmm0,%xmm0
  mov    0x20(%rsp),%rsi
  cvtsi2sd %ecx,%xmm0
  lea    -0x2(%rcx,%rcx,1),%r15d
  mov    %r15d,%eax
  mov    %r15d,0x18(%rsp)
  sub    %r14d,%eax
  mov    %eax,0x1c(%rsp)
  cltq
  lea    (%rsi,%rax,8),%rax
  movsd  %xmm0,(%rax)
  mov    %rax,0x20(%rsp)
L56:
  lea    0x20(%rsp),%r8
  lea    D4(%rip),%rdi
  mov    %r15d,%r14d
  mov    %r8,%rsi
  call   <writeValue@plt>
L72:
  mov    0x14(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x14(%rsp)
  cmp    %r12d,%eax
  jge    L117
L197:
  cmp    %ebp,%eax
  je     L68
L111:
  lea    -0x2(%rax,%rax,1),%r15d
  mov    %r15d,0x18(%rsp)
  cmp    $0x2,%ebx
  je     L9
  mov    %r15d,%ecx
  sub    %r14d,%ecx
  mov    %ecx,0x1c(%rsp)
  cmp    $0x3,%ebx
  jne    L206
  cmp    %ebp,%eax
  je     L158
L114:
  pxor   %xmm0,%xmm0
  mov    0x20(%rsp),%rsi
  movslq %ecx,%rcx
  cvtsi2sd %eax,%xmm0
  lea    (%rsi,%rcx,8),%rcx
  movsd  %xmm0,(%rcx)
  mov    %rcx,0x20(%rsp)
L142:
  lea    0x20(%rsp),%r8
  lea    D20(%rip),%rdi
  mov    %r15d,%r14d
  mov    %r8,%rsi
  call   <writeValue@plt>
  mov    0x14(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x14(%rsp)
  cmp    %r12d,%eax
  jl     L197
  nopl   (%rax)
L117:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L75
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L9:
  cmp    %ebp,%eax
  je     L62
L20:
  pxor   %xmm0,%xmm0
  mov    %r15d,%ecx
  mov    0x20(%rsp),%rsi
  cvtsi2sd %eax,%xmm0
  sub    %r14d,%ecx
  mov    %ecx,0x1c(%rsp)
  movslq %ecx,%rcx
  lea    (%rsi,%rcx,8),%rcx
  movsd  %xmm0,(%rcx)
  mov    %rcx,0x20(%rsp)
L196:
  lea    0x20(%rsp),%r8
  lea    D41(%rip),%rdi
  mov    %r15d,%r14d
  mov    %r8,%rsi
  call   <writeValue@plt>
  jmp    L72
L206:
  pxor   %xmm0,%xmm0
  mov    0x20(%rsp),%rsi
  movslq %ecx,%rcx
  cvtsi2sd %eax,%xmm0
  lea    (%rsi,%rcx,8),%rcx
  movsd  %xmm0,(%rcx)
  mov    %rcx,0x20(%rsp)
  cmp    $0x4,%ebx
  jne    L112
  lea    0x20(%rsp),%r8
  cmp    %ebp,%eax
  je     L136
L92:
  mov    %r15d,%r14d
L213:
  mov    %r8,%rsi
  lea    D11(%rip),%rdi
  call   <writeValue@plt>
  jmp    L72
  nopl   0x0(%rax)
L136:
  mov    %r8,%rdi
  mov    $0x8,%esi
  mov    %r8,0x8(%rsp)
  call   <flipBit@plt>
  mov    0x8(%rsp),%r8
  jmp    L92
  nopl   0x0(%rax)
L158:
  lea    0x1c(%rsp),%rdi
  mov    $0x4,%esi
  call   <flipBit@plt>
  mov    0x14(%rsp),%eax
  mov    0x1c(%rsp),%ecx
  mov    0x18(%rsp),%r15d
  jmp    L114
  nopl   0x0(%rax)
L62:
  lea    0x18(%rsp),%rdi
  mov    $0x4,%esi
  call   <flipBit@plt>
  mov    0x14(%rsp),%eax
  mov    0x18(%rsp),%r15d
  jmp    L20
L112:
  cmp    $0x1,%ebx
  je     L56
  cmp    $0x2,%ebx
  je     L196
  cmp    $0x3,%ebx
  je     L142
  mov    %r15d,%r14d
  lea    0x20(%rsp),%r8
  cmp    $0x4,%ebx
  je     L213
  test   %ebx,%ebx
  jne    L72
  mov    %r8,%rsi
  lea    D6(%rip),%rdi
  call   <writeValue@plt>
  jmp    L72
L75:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_label: D4
type_infered: string
name: parse_data
arguments: data_label: D20
type_infered: string
name: parse_data
arguments: data_label: D41
type_infered: string
name: parse_data
arguments: data_label: D11
type_infered: string
name: parse_data
arguments: data_label: D6
type_infered: string

tool: D4: ex3_var_addr_fi_1.csv

tool: D20: ex3_var_addr_fi_3.csv

tool: D41: ex3_var_addr_fi_2.csv

tool: D11: ex3_var_addr_fi_4.csv

tool: D6: ex3_var_addr.csv

assistant: ```c
void ex3(double *A, int n, int ch) {
  srand(time(NULL));
  double *addr = A;
  int pid = 0;
  int tidx = 1 + (rand() % n - 1);
  for (int i = 1; i < n; i++) {
    if (ch == 1 && tidx == i) {
      flipBit((void *)&i, 4);
    }
    int id = 2 * i - 2;
    if (ch == 2 && tidx == i) {
      flipBit((void *)&id, 4);
    }
    int rid = id - pid;
    if (ch == 3 && tidx == i) {
      flipBit((void *)&rid, 4);
    }
    addr[rid] = i;
    pid = id;
    addr = &addr[rid];
    if (ch == 4 && tidx == i) {
      flipBit((void *)&addr, 8);
    }
    if (ch == 1)
      writeValue("ex3_var_addr_fi_1.csv", (void *)&addr);
    if (ch == 2)
      writeValue("ex3_var_addr_fi_2.csv", (void *)&addr);
    if (ch == 3)
      writeValue("ex3_var_addr_fi_3.csv", (void *)&addr);
    if (ch == 4)
      writeValue("ex3_var_addr_fi_4.csv", (void *)&addr);
    if (ch == 0)
      writeValue("ex3_var_addr.csv", (void *)&addr);
  }
}
```