user: Converte this assembly snippet into its equivalent C code:

```asm
<kernel_dtrsv_t_1_lib4>:
  endbr64
  test   %edi,%edi
  jle    L162
  push   %r14
  mov    %edi,%r9d
  mov    %esi,%r11d
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdx,%rbx
  cmp    $0x4,%edi
  jg     L21
  lea    0x8(%rdx),%rsi
  lea    0x8(%r8),%rdi
  pxor   %xmm0,%xmm0
  mov    $0x1,%r12d
L113:
  cmp    %r9d,%r12d
  jge    L13
L135:
  sub    %r12d,%r9d
  cmp    $0x1,%r9d
  je     L62
  mov    %r9d,%edx
  xor    %eax,%eax
  shr    %edx
  shl    $0x4,%rdx
  nopl   0x0(%rax)
L74:
  movupd (%rdi,%rax,1),%xmm1
  movupd (%rsi,%rax,1),%xmm4
  add    $0x10,%rax
  mulpd  %xmm4,%xmm1
  addsd  %xmm1,%xmm0
  unpckhpd %xmm1,%xmm1
  addsd  %xmm1,%xmm0
  cmp    %rdx,%rax
  jne    L74
  mov    %r9d,%edx
  and    $0xfffffffe,%edx
  mov    %edx,%eax
  shl    $0x3,%rax
  add    %rax,%rsi
  add    %rax,%rdi
  cmp    %edx,%r9d
  je     L13
L62:
  movsd  (%rsi),%xmm1
  mulsd  (%rdi),%xmm1
  addsd  %xmm1,%xmm0
L13:
  movsd  (%r8),%xmm1
  movsd  (%rbx),%xmm2
  subsd  %xmm0,%xmm1
  test   %r11d,%r11d
  je     L79
  mulsd  %xmm1,%xmm2
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  movsd  %xmm2,(%r8)
  ret
  cs nopw 0x0(%rax,%rax,1)
L21:
  movsd  0x10(%rdx),%xmm1
  movsd  0x8(%rdx),%xmm0
  mov    %ecx,%ebp
  lea    0x20(%r8),%rdi
  mulsd  0x10(%r8),%xmm1
  lea    0x0(,%rcx,4),%r10d
  mulsd  0x8(%r8),%xmm0
  movslq %r10d,%r10
  addsd  D6(%rip),%xmm0
  lea    0x0(,%r10,8),%rcx
  lea    (%rdx,%rcx,1),%rsi
  addsd  %xmm0,%xmm1
  movsd  0x18(%rdx),%xmm0
  mulsd  0x18(%r8),%xmm0
  addsd  %xmm1,%xmm0
  cmp    $0xb,%r9d
  jle    L22
  lea    -0xc(%r9),%r13d
  shl    $0x4,%r10
  mov    %rsi,%rdx
  shr    $0x3,%r13d
  mov    %r13d,%r14d
  mov    %r14,%rax
  shl    $0x6,%rax
  lea    0x60(%r8,%rax,1),%r12
  mov    %rdi,%rax
  nopl   0x0(%rax)
L17:
  movsd  (%rdx),%xmm1
  mulsd  (%rax),%xmm1
  add    $0x40,%rax
  addsd  %xmm0,%xmm1
  movsd  0x8(%rdx),%xmm0
  mulsd  -0x38(%rax),%xmm0
  addsd  %xmm1,%xmm0
  movsd  0x10(%rdx),%xmm1
  mulsd  -0x30(%rax),%xmm1
  addsd  %xmm0,%xmm1
  movsd  0x18(%rdx),%xmm0
  mulsd  -0x28(%rax),%xmm0
  addsd  %xmm1,%xmm0
  movsd  (%rdx,%rcx,1),%xmm1
  mulsd  -0x20(%rax),%xmm1
  addsd  %xmm0,%xmm1
  movsd  0x8(%rdx,%rcx,1),%xmm0
  mulsd  -0x18(%rax),%xmm0
  addsd  %xmm1,%xmm0
  movsd  0x10(%rdx,%rcx,1),%xmm1
  mulsd  -0x10(%rax),%xmm1
  addsd  %xmm0,%xmm1
  movsd  0x18(%rdx,%rcx,1),%xmm0
  mulsd  -0x8(%rax),%xmm0
  add    %r10,%rdx
  addsd  %xmm1,%xmm0
  cmp    %r12,%rax
  jne    L17
  lea    0x1(%r14),%rax
  lea    0xc(,%r13,8),%r12d
  imul   %rax,%r10
  shl    $0x6,%rax
  add    %rax,%rdi
  lea    -0x3(%r9),%eax
  add    %r10,%rsi
  cmp    %r12d,%eax
  jle    L113
L72:
  lea    -0x4(%r9),%r13d
  cmp    $0x1,%ebp
  mov    %r13d,%ebp
  jne    L152
  sub    %r12d,%ebp
  mov    %rdi,%rdx
  mov    %rsi,%rax
  xor    %r10d,%r10d
  shr    $0x2,%ebp
  add    $0x1,%ebp
  cs nopw 0x0(%rax,%rax,1)
L77:
  movupd (%rdx),%xmm1
  movupd (%rax),%xmm5
  add    $0x1,%r10d
  add    $0x20,%rdx
  movupd 0x10(%rax),%xmm6
  movupd -0x10(%rdx),%xmm2
  add    %rcx,%rax
  mulpd  %xmm5,%xmm1
  mulpd  %xmm6,%xmm2
  addsd  %xmm1,%xmm0
  unpckhpd %xmm1,%xmm1
  addsd  %xmm0,%xmm1
  movapd %xmm2,%xmm0
  unpckhpd %xmm2,%xmm2
  addsd  %xmm1,%xmm0
  addsd  %xmm2,%xmm0
  cmp    %r10d,%ebp
  ja     L77
L140:
  sub    %r12d,%r13d
  shr    $0x2,%r13d
  lea    0x1(%r13),%eax
  lea    0x4(%r12,%r13,4),%r12d
  imul   %rax,%rcx
  shl    $0x5,%rax
  add    %rax,%rdi
  add    %rcx,%rsi
  jmp    L113
  nopl   0x0(%rax)
L79:
  divsd  %xmm2,%xmm1
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  movsd  %xmm1,(%r8)
  ret
  nopw   0x0(%rax,%rax,1)
L162:
  ret
L152:
  sub    %r12d,%ebp
  mov    %rsi,%rdx
  mov    %rdi,%rax
  xor    %r10d,%r10d
  shr    $0x2,%ebp
  add    $0x1,%ebp
  nopl   0x0(%rax,%rax,1)
L96:
  movupd (%rax),%xmm7
  movupd (%rdx),%xmm2
  add    $0x1,%r10d
  add    $0x20,%rax
  movupd 0x10(%rdx),%xmm1
  add    %rcx,%rdx
  mulpd  %xmm7,%xmm2
  movupd -0x10(%rax),%xmm7
  mulpd  %xmm7,%xmm1
  addsd  %xmm2,%xmm0
  unpckhpd %xmm2,%xmm2
  addsd  %xmm2,%xmm0
  addsd  %xmm1,%xmm0
  unpckhpd %xmm1,%xmm1
  addsd  %xmm1,%xmm0
  cmp    %ebp,%r10d
  jb     L96
  jmp    L140
L22:
  mov    $0x4,%r12d
  cmp    $0x7,%r9d
  jg     L72
  jmp    L135
```

tool_calls: name: read_data
arguments: label: D6
type: f64

tool: D6: 0

assistant: ```c
void kernel_dtrsv_t_1_lib4(int kmax, int inverted_diag, double *A, int sda, double *x) {
  if (kmax <= 0)
    return;
  const int lda = 4;
  const int bs = 4;
  int k;
  double *tA, *tx;
  tA = A;
  tx = x;
  double x_0, x_1, x_2, x_3, y_0 = 0;
  k = 1;
  if (kmax > 4) {
    x_1 = x[1];
    x_2 = x[2];
    x_3 = x[3];
    y_0 += A[1 + lda * 0] * x_1;
    y_0 += A[2 + lda * 0] * x_2;
    y_0 += A[3 + lda * 0] * x_3;
    k = 4;
    A += 4 + (sda - 1) * lda;
    x += 4;
    for (; k < kmax - 7; k += 8) {
      x_0 = x[0];
      x_1 = x[1];
      x_2 = x[2];
      x_3 = x[3];
      y_0 += A[0 + lda * 0] * x_0;
      y_0 += A[1 + lda * 0] * x_1;
      y_0 += A[2 + lda * 0] * x_2;
      y_0 += A[3 + lda * 0] * x_3;
      A += sda * bs;
      x += 4;
      x_0 = x[0];
      x_1 = x[1];
      x_2 = x[2];
      x_3 = x[3];
      y_0 += A[0 + lda * 0] * x_0;
      y_0 += A[1 + lda * 0] * x_1;
      y_0 += A[2 + lda * 0] * x_2;
      y_0 += A[3 + lda * 0] * x_3;
      A += sda * bs;
      x += 4;
    }
    for (; k < kmax - 3; k += 4) {
      x_0 = x[0];
      x_1 = x[1];
      x_2 = x[2];
      x_3 = x[3];
      y_0 += A[0 + lda * 0] * x_0;
      y_0 += A[1 + lda * 0] * x_1;
      y_0 += A[2 + lda * 0] * x_2;
      y_0 += A[3 + lda * 0] * x_3;
      A += sda * bs;
      x += 4;
    }
  } else {
    A += 1;
    x += 1;
  }
  for (; k < kmax; k++) {
    x_0 = x[0];
    y_0 += A[0 + lda * 0] * x_0;
    A += 1;
    x += 1;
  }
  A = tA;
  x = tx;
  if (inverted_diag) {
    y_0 = x[0] - y_0;
    y_0 *= A[0 + lda * 0];
    x[0] = y_0;
  } else {
    y_0 = x[0] - y_0;
    y_0 /= A[0 + lda * 0];
    x[0] = y_0;
  }
}
```