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

```asm
<csamplestatepath>:
  endbr64
  push   %rbp
  mov    %rdx,%r8
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x68,%rsp
  mov    0x10(%rbp),%rax
  mov    0x28(%rbp),%r12d
  mov    %ecx,-0x64(%rbp)
  mov    %r9,-0x48(%rbp)
  mov    %rax,-0x50(%rbp)
  mov    0x18(%rbp),%rax
  mov    %rax,-0x70(%rbp)
  mov    0x20(%rbp),%rax
  mov    %rax,-0x60(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    %edi,%eax
  cltd
  idiv   %ecx
  mov    %edx,%ebx
  lea    0x1(%rax),%edx
  test   %ebx,%ebx
  jne    L22
  mov    %eax,%edx
  mov    %ecx,%ebx
L22:
  movslq %r12d,%rax
  mov    %rsp,%rsi
  mov    %edi,%r15d
  lea    0xf(,%rax,8),%rax
  sub    %ebx,%r15d
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rcx
  cmp    %rsi,%rsp
  je     L74
L130:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L130
L74:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L50
L65:
  movslq %edx,%rdx
  lea    0x7(%rsp),%rsi
  mov    (%r8,%rdx,8),%rcx
  mov    %rsi,%rax
  lea    0x0(,%rdx,8),%r14
  and    $0xfffffffffffffff8,%rsi
  shr    $0x3,%rax
  movsd  (%rcx),%xmm0
  movsd  %xmm0,0x0(,%rax,8)
  cmp    $0x1,%r12d
  jle    L44
  lea    -0x1(%r12),%edx
  mov    $0x1,%eax
  jmp    L97
  nopl   0x0(%rax,%rax,1)
L5:
  add    $0x1,%rax
L97:
  addsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%rsi,%rax,8)
  cmp    %rax,%rdx
  jne    L5
L44:
  mov    -0x50(%rbp),%rax
  movslq %edi,%rdi
  mov    %r12d,%edx
  lea    -0x4(%rax,%rdi,4),%r13
  xor    %edi,%edi
  call   <sample@plt>
  mov    %eax,0x0(%r13)
  test   %r15d,%r15d
  js     L42
  mov    -0x64(%rbp),%edx
  mov    -0x50(%rbp),%rdi
  mov    %ebx,-0x74(%rbp)
  add    -0x60(%rbp),%r14
  neg    %edx
  add    $0x4,%rdi
  mov    %r14,-0x60(%rbp)
  movslq %edx,%rcx
  mov    %rdi,-0x88(%rbp)
  mov    %rcx,-0x80(%rbp)
  movslq %r15d,%rcx
  mov    %rcx,-0x58(%rbp)
  nopl   0x0(%rax,%rax,1)
L153:
  mov    -0x60(%rbp),%rdi
  mov    -0x58(%rbp),%rcx
  cltq
  lea    0x0(,%rax,8),%rbx
  mov    (%rdi),%rdx
  mov    %ecx,-0x68(%rbp)
  mov    %ecx,%r14d
  mov    %ecx,%r13d
  mov    (%rdx,%rax,8),%rsi
  test   %ecx,%ecx
  je     L139
  mov    -0x70(%rbp),%rax
  mov    -0x50(%rbp),%rdi
  lea    -0x1(%rcx),%r13d
  mov    %r12d,%edx
  mov    (%rax,%rcx,4),%r8d
  movslq %r13d,%rax
  lea    (%rdi,%rax,4),%r15
  xor    %edi,%edi
  mov    %r8d,-0x78(%rbp)
  call   <samplebinsearch@plt>
  movslq -0x78(%rbp),%r8
  mov    %eax,(%r15)
L96:
  mov    -0x74(%rbp),%eax
  add    %r14d,%eax
  lea    -0x2(%rax),%edx
  cmp    %edx,%r13d
  jge    L124
  movslq %r13d,%rdx
  mov    -0x50(%rbp),%rcx
  sub    $0x3,%eax
  lea    0x0(,%rdx,4),%rsi
  sub    %r13d,%eax
  lea    (%rcx,%rsi,1),%r14
  mov    -0x70(%rbp),%rcx
  add    %rdx,%rax
  lea    0x8(%rcx,%rsi,1),%r15
  mov    -0x88(%rbp),%rcx
  lea    (%rcx,%rax,4),%r13
  nopl   0x0(%rax)
L36:
  mov    -0x48(%rbp),%rax
  movslq (%r14),%rdx
  xor    %edi,%edi
  add    $0x4,%r14
  add    $0x4,%r15
  mov    (%rax,%r8,8),%rax
  mov    (%rax,%rdx,8),%rax
  mov    %r12d,%edx
  mov    (%rax,%rbx,1),%rsi
  call   <samplebinsearch@plt>
  mov    %eax,(%r14)
  movslq -0x4(%r15),%r8
  cmp    %r13,%r14
  jne    L36
L124:
  subq   $0x8,-0x60(%rbp)
  mov    -0x64(%rbp),%ebx
  cmp    %ebx,-0x68(%rbp)
  js     L42
  mov    -0x58(%rbp),%rdi
  mov    -0x80(%rbp),%rbx
  mov    -0x50(%rbp),%rax
  mov    -0x4(%rax,%rdi,4),%eax
  add    %rbx,%rdi
  mov    -0x64(%rbp),%ebx
  mov    %rdi,-0x58(%rbp)
  mov    %ebx,-0x74(%rbp)
  jmp    L153
L139:
  mov    -0x70(%rbp),%rax
  xor    %edi,%edi
  mov    %r12d,%edx
  mov    0x4(%rax),%r8d
  mov    %r8d,-0x78(%rbp)
  call   <samplebinsearch@plt>
  mov    -0x50(%rbp),%rdi
  movslq -0x78(%rbp),%r8
  mov    %eax,(%rdi)
  jmp    L96
  nopl   (%rax)
L42:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L135
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L50:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L65
L135:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void csamplestatepath(int T, int *obs, double **fwds, int R, double ***mats, double ****rmats, int *states, int *storedpos, double ***sneak, int N) {
  double *distribution;
  int pos, cs, js, je;
  int p, s, e;
  int md = T % R;
  if (md == 0) {
    md = R;
    p = T / R;
  } else {
    p = T / R + 1;
  }
  e = T;
  s = T - md;
  double tmp[N];
  tmp[0] = fwds[p][0];
  int i;
  for (i = 1; i < N; i++)
    tmp[i] = tmp[i - 1] + fwds[p][i];
  states[e - 1] = sample(0, tmp, N);
  while (s >= 0) {
    p--;
    cs = states[e - 1];
    if (s > 0) {
      js = s - 1;
      pos = storedpos[s];
      states[js] = samplebinsearch(0, sneak[p + 1][cs], N);
    } else {
      js = 0;
      pos = storedpos[1];
      states[js] = samplebinsearch(0, sneak[p + 1][cs], N);
    }
    je = md + s - 2;
    for (; js < je; js++) {
      distribution = rmats[pos][states[js]][cs];
      states[js + 1] = samplebinsearch(0, distribution, N);
      pos = storedpos[js + 2];
    }
    md = R;
    s -= md;
    e = s + md;
  }
}
```