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

```asm
<gauss_solve_triangular>:
  endbr64
  push   %r15
  lea    -0x1(%rcx),%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,-0x18(%rsp)
  mov    %rdx,%rsi
  mov    %eax,-0x20(%rsp)
  test   %eax,%eax
  jle    L76
  movslq %ecx,%r8
  mov    %eax,%r12d
  lea    0x10(%rsi),%rax
  mov    %ecx,%edx
  mov    %r8,%r11
  mov    %rax,-0x10(%rsp)
  lea    0x8(%rsi),%r9
  lea    -0x2(%rcx),%r14d
  shl    $0x4,%r11
  shl    $0x3,%r8
  mov    %ecx,%r15d
  xor    %r13d,%r13d
  mov    %r11,-0x28(%rsp)
  xor    %r10d,%r10d
  nopw   0x0(%rax,%rax,1)
L98:
  mov    -0x18(%rsp),%rax
  movsd  -0x8(%r9),%xmm0
  mov    %r10d,%ebx
  add    $0x1,%r10d
  movslq (%rax,%r13,4),%rax
  lea    (%rsi,%rax,8),%rax
  movsd  (%rax),%xmm1
  movsd  %xmm0,(%rax)
  movsd  %xmm1,-0x8(%r9)
  cmp    %r10d,%edx
  jle    L111
  mov    %r12d,%ebp
  movslq %r15d,%rax
  lea    -0x1(%rbp),%rcx
  add    %r13,%rbp
  add    %r13,%rax
  imul   %r8,%rcx
  lea    (%rsi,%rbp,8),%rbp
  shl    $0x3,%rax
  mov    %rbp,%r11
  xor    %ebp,%ebp
  test   %edx,%edx
  cmovs  %rcx,%rbp
  add    %rax,%rbp
  add    %rdi,%rbp
  cmp    %rbp,%r11
  setb   %bpl
  xor    %r11d,%r11d
  test   %edx,%edx
  cmovs  %r11,%rcx
  add    %rax,%rcx
  add    %rdi,%rcx
  cmp    %rcx,%r9
  seta   %cl
  or     %bpl,%cl
  je     L110
  cmp    $0x2,%r14d
  jbe    L110
  mov    %r12d,%ecx
  movapd %xmm1,%xmm2
  mov    -0x28(%rsp),%r11
  add    %rdi,%rax
  shr    %ecx
  unpcklpd %xmm2,%xmm2
  sub    $0x1,%ecx
  shl    $0x4,%rcx
  lea    0x10(%r9,%rcx,1),%rbp
  mov    %r9,%rcx
  nopl   0x0(%rax)
L101:
  movsd  (%rax),%xmm0
  movupd (%rcx),%xmm4
  add    $0x10,%rcx
  movhpd (%rax,%r8,1),%xmm0
  add    %r11,%rax
  mulpd  %xmm2,%xmm0
  addpd  %xmm4,%xmm0
  movups %xmm0,-0x10(%rcx)
  cmp    %rbp,%rcx
  jne    L101
  mov    %r12d,%ecx
  mov    %r11,-0x28(%rsp)
  and    $0xfffffffe,%ecx
  lea    (%rcx,%r10,1),%eax
  cmp    %r12d,%ecx
  je     L111
  movslq %eax,%rcx
  imul   %edx,%eax
  lea    (%rsi,%rcx,8),%rcx
  add    %ebx,%eax
  cltq
  mulsd  (%rdi,%rax,8),%xmm1
  addsd  (%rcx),%xmm1
  movsd  %xmm1,(%rcx)
L111:
  add    $0x1,%r13
  add    $0x8,%r9
  add    %edx,%r15d
  sub    $0x1,%r14d
  sub    $0x1,%r12d
  cmp    -0x20(%rsp),%r10d
  jne    L98
  mov    -0x28(%rsp),%r11
  lea    0x1(%rdx),%ecx
  cmp    $0x1,%edx
  jne    L97
  movsd  (%rsi),%xmm0
  divsd  (%rdi),%xmm0
  movsd  %xmm0,(%rsi)
  movsd  -0x8(%rdi,%r8,1),%xmm1
  mulsd  %xmm0,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rsi)
L76:
  pop    %rbx
  movsd  (%rsi),%xmm0
  divsd  (%rdi),%xmm0
  movsd  %xmm0,(%rsi)
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L110:
  mov    -0x10(%rsp),%rbx
  mov    %r14d,%ecx
  mov    -0x28(%rsp),%r11
  add    %rdi,%rax
  add    %r13,%rcx
  lea    (%rbx,%rcx,8),%rbx
  mov    %r9,%rcx
  nopw   0x0(%rax,%rax,1)
L127:
  movsd  (%rax),%xmm0
  add    $0x8,%rcx
  add    %r8,%rax
  mulsd  %xmm1,%xmm0
  addsd  -0x8(%rcx),%xmm0
  movsd  %xmm0,-0x8(%rcx)
  cmp    %rcx,%rbx
  jne    L127
  mov    %r11,-0x28(%rsp)
  jmp    L111
L97:
  mov    %edx,%r9d
  movslq %r10d,%rax
  lea    -0x8(%rdi,%r8,1),%r13
  xor    %ebp,%ebp
  not    %r9d
  imul   %ecx,%r10d
  movslq %r9d,%r9
  lea    0x0(,%r9,8),%rbx
  mov    %rbx,-0x28(%rsp)
  lea    0x10(%rsi),%rbx
  movslq %r10d,%rcx
  mov    %rbx,-0x20(%rsp)
  lea    (%rdi,%rcx,8),%r12
  nopl   0x0(%rax)
L73:
  mov    %eax,%r9d
  mov    %rbp,%rcx
  mov    %rbp,%rbx
  movsd  (%rsi,%rax,8),%xmm1
  sub    $0x1,%r9
  test   %eax,%eax
  lea    0x0(,%rax,8),%r14
  mov    %eax,%r10d
  cmovg  %r9,%rcx
  shl    $0x3,%r9
  divsd  (%r12),%xmm1
  mov    %eax,%r15d
  movsd  %xmm1,(%rsi,%rax,8)
  imul   %r8,%rcx
  test   %eax,%eax
  cmovle %rbp,%r9
  add    %rsi,%r9
  test   %edx,%edx
  cmovs  %rcx,%rbx
  add    %r14,%rbx
  add    %rdi,%rbx
  cmp    %rbx,%r9
  setb   %r9b
  test   %edx,%edx
  cmovs  %rbp,%rcx
  add    %r14,%rcx
  add    %rdi,%rcx
  cmp    %rcx,%rsi
  seta   %cl
  or     %r9b,%cl
  je     L152
  cmp    $0x3,%eax
  jle    L152
  test   %eax,%eax
  mov    $0x1,%r14d
  movapd %xmm1,%xmm3
  mov    %rsi,%rcx
  cmovg  %eax,%r14d
  unpcklpd %xmm3,%xmm3
  mov    %r14d,%r9d
  shr    %r9d
  lea    -0x1(%r9),%ebx
  mov    %r13,%r9
  shl    $0x4,%rbx
  add    -0x20(%rsp),%rbx
  xchg   %ax,%ax
L142:
  movsd  (%r9),%xmm0
  movupd (%rcx),%xmm2
  add    $0x10,%rcx
  movhpd (%r9,%r8,1),%xmm0
  add    %r11,%r9
  mulpd  %xmm3,%xmm0
  subpd  %xmm0,%xmm2
  movups %xmm2,-0x10(%rcx)
  cmp    %rcx,%rbx
  jne    L142
  mov    %r14d,%ecx
  and    $0xfffffffe,%ecx
  and    $0x1,%r14d
  je     L165
  movslq %ecx,%r9
  imul   %edx,%ecx
  lea    (%rsi,%r9,8),%r9
  movsd  (%r9),%xmm0
  add    %r10d,%ecx
  movslq %ecx,%rcx
  mulsd  (%rdi,%rcx,8),%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%r9)
L165:
  sub    $0x1,%rax
  add    -0x28(%rsp),%r12
  sub    $0x8,%r13
  test   %eax,%eax
  jg     L73
  jmp    L76
L152:
  mov    %r13,%r9
  xor    %ecx,%ecx
  nopl   (%rax)
L35:
  movsd  (%r9),%xmm2
  movsd  (%rsi,%rcx,8),%xmm0
  add    %r8,%r9
  mulsd  %xmm1,%xmm2
  subsd  %xmm2,%xmm0
  movsd  %xmm0,(%rsi,%rcx,8)
  add    $0x1,%rcx
  cmp    %ecx,%r15d
  jg     L35
  jmp    L165
```

assistant: ```c
void gauss_solve_triangular(const double *A, const int *p, double *b, int n) {
  for (int k = 0; k < n - 1; ++k) {
    int m = p[k];
    double t = b[m];
    b[m] = b[k];
    b[k] = t;
    for (int i = k + 1; i < n; ++i)
      b[i] += A[k + n * i] * t;
  }
  for (int k = n - 1; k > 0; --k) {
    b[k] /= A[k + n * k];
    double t = b[k];
    for (int i = 0; i < k; ++i)
      b[i] -= A[k + n * i] * t;
  }
  b[0] /= A[0 + 0 * n];
}
```