user: What is the c source code of the assembly code below:

```asm
<hugeglasso>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  movslq %ecx,%r13
  mov    %r13d,%eax
  push   %r12
  imul   %r13d,%eax
  push   %rbp
  mov    %r13,%rbp
  push   %rbx
  lea    0x0(,%r13,4),%rbx
  cltq
  sub    $0xe8,%rsp
  lea    0x0(,%rax,4),%r12
  mov    %rdi,0x78(%rsp)
  mov    %r12,%rdi
  movsd  %xmm0,0x8(%rsp)
  call   <malloc@plt>
  mov    %r12,%rdi
  mov    %rax,0x30(%rsp)
  call   <malloc@plt>
  mov    %r13,0x70(%rsp)
  mov    %rbx,%rdi
  shl    $0x3,%r13
  mov    %rax,0x68(%rsp)
  call   <malloc@plt>
  mov    %r13,%rdi
  mov    %r13,0x50(%rsp)
  mov    %rax,0x38(%rsp)
  call   <malloc@plt>
  mov    %r13,%rdi
  mov    %rax,%r12
  call   <malloc@plt>
  test   %ebp,%ebp
  movsd  0x8(%rsp),%xmm6
  mov    %rax,0x80(%rsp)
  jle    L487
  lea    0x4(%rbx),%rax
  mov    0x68(%rsp),%r10
  mov    %r14,%r9
  xor    %r11d,%r11d
  mov    %rax,0x20(%rsp)
  mov    0x50(%rsp),%rax
  xor    %r13d,%r13d
  pxor   %xmm7,%xmm7
  movq   D34(%rip),%xmm1
  mov    0x38(%rsp),%rcx
  mov    %r10,0x8(%rsp)
  add    $0x8,%rax
  mov    %rax,0x28(%rsp)
  lea    -0x1(%rbp),%eax
  movapd %xmm1,%xmm3
  mov    %eax,0xa8(%rsp)
  mov    %rax,0x40(%rsp)
  xor    %eax,%eax
L3:
  mov    0x78(%rsp),%rdi
  mov    0x8(%rsp),%rsi
  movl   $0x0,(%rcx,%rax,4)
  xor    %edx,%edx
  movsd  (%rdi,%r11,1),%xmm0
  lea    -0x1(%rax),%edi
  movl   $0xffffffff,(%rsi)
  mov    %rdi,0x18(%rsp)
  addsd  %xmm6,%xmm0
  movsd  %xmm0,(%r15,%r11,1)
  movsd  (%r14,%r11,1),%xmm2
  movq   $0x0,(%r14,%r11,1)
  test   %rax,%rax
  jne    L714
  jmp    L201
L354:
  xorpd  %xmm1,%xmm0
  mov    (%rcx,%rax,4),%esi
  movl   $0xffffffff,(%r10,%rdx,4)
  divsd  %xmm2,%xmm0
  mov    %esi,0x10(%rsp)
  lea    (%rsi,%r13,1),%edi
  mov    0x30(%rsp),%rsi
  movslq %edi,%rdi
  mov    %r8d,(%rsi,%rdi,4)
  mov    0x10(%rsp),%esi
  add    $0x1,%esi
  mov    %esi,(%rcx,%rax,4)
  lea    0x1(%rdx),%rsi
  movsd  %xmm0,(%r9,%rdx,8)
  cmp    0x18(%rsp),%rdx
  je     L201
L0:
  mov    %rsi,%rdx
L714:
  movsd  (%r9,%rdx,8),%xmm0
  mov    %edx,%r8d
  ucomisd %xmm7,%xmm0
  jp     L354
  jne    L354
  movl   $0x1,(%r10,%rdx,4)
  lea    0x1(%rdx),%rsi
  cmp    0x18(%rsp),%rdx
  jne    L0
L201:
  cmp    0x40(%rsp),%rax
  je     L480
  lea    0x1(%rax),%r8
  mov    %r8,0x10(%rsp)
  mov    %r8,%rdx
  jmp    L514
L292:
  xorpd  %xmm3,%xmm0
  mov    (%rcx,%rax,4),%esi
  mov    0x30(%rsp),%r8
  movl   $0xffffffff,(%r10,%rdx,4)
  divsd  %xmm2,%xmm0
  add    %r13d,%esi
  movslq %esi,%rsi
  mov    %edi,(%r8,%rsi,4)
  mov    (%rcx,%rax,4),%esi
  add    $0x1,%esi
  mov    %esi,(%rcx,%rax,4)
  movsd  %xmm0,(%r9,%rdx,8)
  add    $0x1,%rdx
  cmp    %edx,%ebp
  jle    L530
L514:
  movsd  (%r9,%rdx,8),%xmm0
  mov    %edx,%edi
  ucomisd %xmm7,%xmm0
  jp     L292
  jne    L292
  movl   $0x1,(%r10,%rdx,4)
  add    $0x1,%rdx
  cmp    %edx,%ebp
  jg     L514
L530:
  mov    0x10(%rsp),%r8
  mov    0x20(%rsp),%rdi
  add    %ebp,%r13d
  add    %rbx,%r10
  add    %rdi,0x8(%rsp)
  add    0x50(%rsp),%r9
  add    0x28(%rsp),%r11
  mov    %r8,%rax
  jmp    L3
L487:
  lea    -0x1(%rbp),%eax
  pxor   %xmm7,%xmm7
  mov    %eax,0xa8(%rsp)
L480:
  mov    0xa8(%rsp),%eax
  movapd %xmm6,%xmm9
  mov    %r12,%r13
  mov    %ebp,%ebx
  movl   $0x0,0x8c(%rsp)
  mov    %r14,%r12
  xorpd  D34(%rip),%xmm9
  mov    %rax,0x18(%rsp)
  add    $0x1,%rax
  mov    %rax,0xb8(%rsp)
  shl    $0x3,%rax
  mov    %rax,0xc0(%rsp)
L61:
  movapd %xmm7,%xmm11
  movapd %xmm7,%xmm10
  test   %ebx,%ebx
  jle    L659
  mov    0x70(%rsp),%rax
  xor    %r14d,%r14d
  movq   $0x0,0x28(%rsp)
  movapd %xmm7,%xmm11
  movq   $0x0,0x20(%rsp)
  movapd %xmm7,%xmm10
  movq   $0x0,0xa0(%rsp)
  add    $0x1,%rax
  mov    %rax,0xb0(%rsp)
  lea    0x1(%rbx),%eax
  mov    %eax,0xac(%rsp)
  mov    0x30(%rsp),%rax
  add    $0x4,%rax
  mov    %rax,0x40(%rsp)
L95:
  mov    0x20(%rsp),%eax
  mov    0xc0(%rsp),%rdx
  movsd  %xmm9,0xd8(%rsp)
  mov    0x80(%rsp),%rdi
  movsd  %xmm10,0x10(%rsp)
  mov    %eax,0x88(%rsp)
  mov    0x28(%rsp),%rax
  movsd  %xmm7,0xd0(%rsp)
  shl    $0x3,%rax
  movsd  %xmm11,0x8(%rsp)
  lea    (%r12,%rax,1),%rbp
  mov    %rax,0x90(%rsp)
  movsd  %xmm6,0xc8(%rsp)
  mov    %rbp,%rsi
  call   <memcpy@plt>
  mov    0x38(%rsp),%rdx
  mov    0x20(%rsp),%rsi
  movl   $0x0,0x60(%rsp)
  mov    0x28(%rsp),%rdi
  mov    %rbp,0x48(%rsp)
  mov    (%rdx,%rsi,4),%esi
  movsd  0x8(%rsp),%xmm11
  lea    0x0(,%rdi,4),%rax
  movsd  0x10(%rsp),%xmm10
  movsd  0xd8(%rsp),%xmm9
  movsd  0xc8(%rsp),%xmm6
  mov    %esi,0x64(%rsp)
  movsd  0xd0(%rsp),%xmm7
  mov    0x68(%rsp),%rsi
  movq   D1(%rip),%xmm8
  lea    (%rsi,%rax,1),%rdi
  mov    %rdi,0x98(%rsp)
  mov    0x78(%rsp),%rdi
  add    0x90(%rsp),%rdi
  mov    %rdi,0x58(%rsp)
  mov    0x30(%rsp),%rdi
  lea    (%rax,%rdi,1),%r11
L167:
  mov    %r13,0x10(%rsp)
  mov    0x64(%rsp),%r10d
  xor    %esi,%esi
  xor    %ebp,%ebp
  mov    %r11,0x8(%rsp)
  mov    0x98(%rsp),%r9
  xor    %edi,%edi
  mov    0xac(%rsp),%r13d
  jmp    L165
  nopw   0x0(%rax,%rax,1)
L518:
  lea    0x1(%rdi),%rax
  add    $0x4,%r9
  add    %r13d,%ebp
  add    %ebx,%esi
  cmp    0x18(%rsp),%rdi
  je     L155
  mov    %rax,%rdi
L165:
  cmpl   $0xffffffff,(%r9)
  mov    %edi,%r11d
  je     L518
  mov    0x58(%rsp),%rax
  movsd  (%rax,%rdi,8),%xmm1
  test   %r10d,%r10d
  jle    L2
  mov    0x40(%rsp),%rdx
  lea    -0x1(%r10),%eax
  add    0x28(%rsp),%rax
  lea    (%rdx,%rax,4),%r8
  mov    0x8(%rsp),%rdx
  nopw   0x0(%rax,%rax,1)
L125:
  mov    (%rdx),%eax
  add    $0x4,%rdx
  lea    (%rsi,%rax,1),%ecx
  add    %r14d,%eax
  movslq %ecx,%rcx
  cltq
  movsd  (%r15,%rcx,8),%xmm0
  mulsd  (%r12,%rax,8),%xmm0
  subsd  %xmm0,%xmm1
  cmp    %rdx,%r8
  jne    L125
L2:
  comisd %xmm6,%xmm1
  jbe    L501
  subsd  %xmm6,%xmm1
L139:
  movslq %ebp,%rax
  mov    0x30(%rsp),%rdx
  divsd  (%r15,%rax,8),%xmm1
  mov    0x10(%rsp),%rax
  movsd  %xmm1,(%rax,%rdi,8)
  lea    (%r14,%r10,1),%eax
  add    $0x1,%r10d
  cltq
  mov    %r11d,(%rdx,%rax,4)
  mov    0x38(%rsp),%rax
  mov    0x20(%rsp),%rdx
  movl   $0xffffffff,(%r9)
  mov    %r10d,(%rax,%rdx,4)
L556:
  mov    0x48(%rsp),%rax
  movsd  %xmm1,(%rax,%rdi,8)
  jmp    L518
L501:
  comisd %xmm1,%xmm9
  jbe    L282
  addsd  %xmm6,%xmm1
  jmp    L139
L155:
  xor    %ebp,%ebp
  mov    0x10(%rsp),%r13
  mov    0x40(%rsp),%rsi
  mov    %r10d,%eax
  mov    %r10d,0x10(%rsp)
  mov    0x8(%rsp),%r11
  sub    $0x1,%eax
  mov    %ebp,0x8(%rsp)
  add    0x28(%rsp),%rax
  mov    0x78(%rsp),%rbp
  lea    (%rsi,%rax,4),%rdi
  nopl   0x0(%rax)
L325:
  mov    0x10(%rsp),%eax
  mov    %r11,%r9
  movapd %xmm7,%xmm5
  movapd %xmm7,%xmm2
  test   %eax,%eax
  jg     L243
  jmp    L635
  nopl   0x0(%rax,%rax,1)
L108:
  add    $0x4,%r9
  cmp    %r9,%rdi
  je     L635
L243:
  movslq (%r9),%rsi
  cmp    $0xffffffff,%esi
  je     L108
  mov    %ebx,%r8d
  lea    (%r14,%rsi,1),%eax
  imul   %esi,%r8d
  cltq
  lea    (%r12,%rax,8),%r10
  movsd  (%r10),%xmm3
  lea    (%rsi,%r8,1),%edx
  movslq %edx,%rdx
  movapd %xmm3,%xmm1
  movsd  (%r15,%rdx,8),%xmm4
  mov    %r11,%rdx
  mulsd  %xmm4,%xmm1
  addsd  0x0(%rbp,%rax,8),%xmm1
  nopl   0x0(%rax)
L283:
  mov    (%rdx),%eax
  add    $0x4,%rdx
  lea    (%r8,%rax,1),%ecx
  add    %r14d,%eax
  movslq %ecx,%rcx
  cltq
  movsd  (%r15,%rcx,8),%xmm0
  mulsd  (%r12,%rax,8),%xmm0
  subsd  %xmm0,%xmm1
  cmp    %rdx,%rdi
  jne    L283
  comisd %xmm6,%xmm1
  lea    0x0(%r13,%rsi,8),%rax
  jbe    L543
  subsd  %xmm6,%xmm1
  divsd  %xmm4,%xmm1
  addsd  %xmm1,%xmm5
L224:
  movapd %xmm1,%xmm0
  add    $0x4,%r9
  movsd  %xmm1,(%rax)
  subsd  %xmm3,%xmm0
  movsd  %xmm1,(%r10)
  andpd  %xmm8,%xmm0
  addsd  %xmm0,%xmm2
  cmp    %r9,%rdi
  jne    L243
L635:
  divsd  %xmm5,%xmm2
  addl   $0x1,0x8(%rsp)
  mov    0x8(%rsp),%eax
  comisd D0(%rip),%xmm2
  jbe    L535
  cmp    $0x2710,%eax
  jne    L325
L535:
  mov    0x10(%rsp),%edx
  mov    0x10(%rsp),%eax
  test   %edx,%edx
  jle    L147
  mov    0x30(%rsp),%r9
  mov    0x68(%rsp),%r10
  lea    (%r14,%rax,1),%r8d
  xor    %edi,%edi
  mov    %r14d,%ecx
  mov    %r11,%rdx
  jmp    L301
L559:
  add    %r14d,%eax
  add    $0x1,%ecx
  movl   $0xffffffff,(%rdx)
  add    $0x1,%edi
  cltq
  add    $0x4,%rdx
  movl   $0x1,(%r10,%rax,4)
  cmp    %ecx,%r8d
  je     L188
L301:
  movslq (%rdx),%rsi
  ucomisd 0x0(%r13,%rsi,8),%xmm7
  mov    %rsi,%rax
  jp     L590
  je     L559
L590:
  mov    %ecx,%esi
  add    $0x1,%ecx
  add    $0x4,%rdx
  sub    %edi,%esi
  movslq %esi,%rsi
  mov    %eax,(%r9,%rsi,4)
  cmp    %ecx,%r8d
  jne    L301
L188:
  mov    0x10(%rsp),%eax
  sub    %edi,%eax
L147:
  mov    0x20(%rsp),%rdi
  mov    0x38(%rsp),%rsi
  addl   $0x1,0x60(%rsp)
  mov    0x10(%rsp),%edx
  mov    %eax,(%rsi,%rdi,4)
  mov    0x60(%rsp),%edi
  cmp    %edx,0x64(%rsp)
  je     L223
  cmp    $0x270f,%edi
  jg     L223
  mov    %eax,0x64(%rsp)
  jmp    L167
L543:
  comisd %xmm1,%xmm9
  jbe    L395
  addsd  %xmm6,%xmm1
  divsd  %xmm4,%xmm1
  subsd  %xmm1,%xmm5
  jmp    L224
  nopl   0x0(%rax,%rax,1)
L395:
  movapd %xmm7,%xmm1
  jmp    L224
L282:
  mov    0x10(%rsp),%rax
  movapd %xmm7,%xmm1
  movq   $0x0,(%rax,%rdi,8)
  jmp    L556
L223:
  mov    0x88(%rsp),%eax
  cmpq   $0x0,0x20(%rsp)
  mov    0x48(%rsp),%rbp
  lea    0x1(%rax),%r9d
  je     L79
  mov    0x88(%rsp),%eax
  mov    0x90(%rsp),%rdi
  mov    %r15,%rdx
  mov    0x20(%rsp),%r11
  lea    -0x1(%rax),%esi
  mov    0x28(%rsp),%rax
  add    %r15,%rdi
  lea    0x1(%r11),%r8
  add    %rsi,%rax
  lea    0x8(%r15,%rax,8),%r10
L603:
  xor    %eax,%eax
  movapd %xmm7,%xmm0
  nop
L146:
  movsd  0x0(%rbp,%rax,8),%xmm1
  mulsd  (%rdx,%rax,8),%xmm1
  mov    %rax,%rcx
  add    $0x1,%rax
  addsd  %xmm1,%xmm0
  cmp    %rcx,%rsi
  jne    L146
  cmp    %ebx,%r9d
  jge    L554
  mov    %r8,%rax
  nopl   0x0(%rax,%rax,1)
L46:
  movsd  0x0(%rbp,%rax,8),%xmm1
  mulsd  (%rdx,%rax,8),%xmm1
  add    $0x1,%rax
  addsd  %xmm1,%xmm0
  cmp    %eax,%ebx
  jg     L46
L554:
  movsd  %xmm0,(%rdi)
  add    $0x8,%rdi
  movsd  %xmm0,(%rdx,%r11,8)
  add    0x50(%rsp),%rdx
  cmp    %rdi,%r10
  jne    L603
L10:
  cmp    %ebx,%r9d
  jge    L261
  lea    (%r14,%rbx,1),%r9d
  mov    0x88(%rsp),%ecx
  mov    0x50(%rsp),%r11
  movslq %r9d,%rax
  mov    0xa0(%rsp),%rsi
  lea    (%r15,%rax,8),%rdx
  lea    -0x2(%rbx),%eax
  sub    %ecx,%eax
  lea    0x8(%r15,%rsi,8),%rdi
  add    %rsi,%rax
  lea    -0x1(%rcx),%esi
  mov    0x20(%rsp),%rcx
  lea    0x10(%r15,%rax,8),%r10
L529:
  test   %rcx,%rcx
  je     L653
  xor    %eax,%eax
  movapd %xmm7,%xmm0
  nopl   0x0(%rax,%rax,1)
L526:
  movsd  0x0(%rbp,%rax,8),%xmm1
  mulsd  (%rdx,%rax,8),%xmm1
  mov    %rax,%r14
  add    $0x1,%rax
  addsd  %xmm1,%xmm0
  cmp    %r14,%rsi
  jne    L526
L498:
  mov    %r8,%rax
  xchg   %ax,%ax
L347:
  movsd  0x0(%rbp,%rax,8),%xmm1
  mulsd  (%rdx,%rax,8),%xmm1
  add    $0x1,%rax
  addsd  %xmm1,%xmm0
  cmp    %eax,%ebx
  jg     L347
  movsd  %xmm0,(%rdi)
  add    $0x8,%rdi
  movsd  %xmm0,(%rdx,%rcx,8)
  add    %r11,%rdx
  cmp    %rdi,%r10
  jne    L529
L156:
  mov    0x80(%rsp),%rcx
  xor    %eax,%eax
L58:
  movsd  (%rcx,%rax,8),%xmm0
  subsd  0x0(%rbp,%rax,8),%xmm0
  mov    %rax,%rdx
  add    $0x1,%rax
  andpd  %xmm8,%xmm0
  addsd  %xmm0,%xmm10
  cmp    0x18(%rsp),%rdx
  jne    L58
  mov    0xb0(%rsp),%rsi
  mov    0x70(%rsp),%rdi
  addsd  %xmm5,%xmm11
  mov    %r9d,%r14d
  add    %rsi,0xa0(%rsp)
  mov    0x18(%rsp),%rsi
  add    %rdi,0x28(%rsp)
  cmp    %rsi,0x20(%rsp)
  je     L659
  mov    %r8,0x20(%rsp)
  jmp    L95
L653:
  movapd %xmm7,%xmm0
  jmp    L498
L261:
  lea    (%r14,%rbx,1),%r9d
  jmp    L156
L79:
  mov    $0x1,%r8d
  jmp    L10
L659:
  divsd  %xmm11,%xmm10
  addl   $0x1,0x8c(%rsp)
  mov    0x8c(%rsp),%eax
  comisd D0(%rip),%xmm10
  jbe    L145
  cmp    $0x64,%eax
  jne    L61
L145:
  mov    %r12,%r14
  mov    %ebx,%ebp
  mov    %r13,%r12
  test   %ebx,%ebx
  jle    L508
  mov    0x70(%rsp),%rax
  lea    0x8(%r14),%r11
  mov    %r14,%r9
  xor    %r10d,%r10d
  mov    %r11,%r8
  movapd %xmm7,%xmm0
  lea    0x10(%r14),%r13
  xor    %ecx,%ecx
  add    $0x1,%rax
  movq   D34(%rip),%xmm2
  movsd  D51(%rip),%xmm4
  mov    %rax,0x10(%rsp)
  mov    0x50(%rsp),%rax
  movapd %xmm2,%xmm3
  lea    0x8(%rax),%rbx
  sub    %r14,%rax
  mov    %rbx,0x8(%rsp)
  mov    %rax,%rbx
  mov    $0x1,%eax
L672:
  mov    %eax,%esi
  cmp    %eax,%ebp
  jle    L65
  lea    (%r15,%r10,8),%rdi
  mov    %rax,%rdx
L612:
  movsd  (%rdi,%rdx,8),%xmm1
  mulsd  (%r9,%rdx,8),%xmm1
  add    $0x1,%rdx
  addsd  %xmm1,%xmm0
  cmp    %edx,%ebp
  jg     L612
L65:
  movsd  (%r15,%rcx,8),%xmm1
  subsd  %xmm0,%xmm1
  movapd %xmm4,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%r8)
  cmp    $0x1,%esi
  je     L353
  lea    -0x2(%rsi),%edx
  movapd %xmm0,%xmm1
  add    %r10,%rdx
  xorpd  %xmm2,%xmm1
  lea    (%r11,%rdx,8),%rdi
  mov    %r9,%rdx
L176:
  movsd  (%rdx),%xmm5
  add    $0x8,%rdx
  mulsd  %xmm1,%xmm5
  movsd  %xmm5,-0x8(%rdx)
  cmp    %rdx,%rdi
  jne    L176
L353:
  cmp    %rax,0xb8(%rsp)
  je     L508
  mov    0xa8(%rsp),%edx
  xorpd  %xmm3,%xmm0
  sub    %esi,%edx
  add    %rcx,%rdx
  lea    0x0(%r13,%rdx,8),%rsi
  mov    %r8,%rdx
L670:
  movsd  (%rdx),%xmm1
  add    $0x8,%rdx
  mulsd  %xmm0,%xmm1
  movsd  %xmm1,-0x8(%rdx)
  cmp    %rsi,%rdx
  jne    L670
  lea    (%rbx,%r9,1),%rdx
  lea    (%rbx,%r8,1),%rsi
  movapd %xmm7,%xmm0
L445:
  movsd  (%r15,%rdx,1),%xmm1
  mulsd  (%r14,%rdx,1),%xmm1
  add    $0x8,%rdx
  addsd  %xmm1,%xmm0
  cmp    %rsi,%rdx
  jne    L445
  add    $0x1,%rax
  add    0x8(%rsp),%r8
  add    0x10(%rsp),%rcx
  add    0x50(%rsp),%r9
  add    0x70(%rsp),%r10
  jmp    L672
L508:
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  mov    0x68(%rsp),%rdi
  call   <free@plt>
  mov    0x38(%rsp),%rdi
  call   <free@plt>
  mov    %r12,%rdi
  call   <free@plt>
  mov    0x80(%rsp),%rdi
  add    $0xe8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1070 <free@plt>
```

tool_calls: name: unpack_data
arguments: label: D34
type_infered: byte[16]
name: unpack_data
arguments: label: D1
type_infered: qword
name: unpack_data
arguments: label: D0
type_infered: byte[16]
name: unpack_data
arguments: label: D51
type_infered: byte[8]

tool: {"D34": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: D1: 9223372036854775807

tool: {"D0": [0x2d,0x43,0x1c,0xeb,0xe2,0x36,0x1a,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

tool: {"D51": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

assistant: ```c
void hugeglasso(const double *S, double *W, double *T, int d, double ilambda) {
  int d2;
  d2 = d * d;
  int i, j, k;
  int rss_idx, w_idx;
  int tmp_i;
  int tmp_j, tmp_a;
  int gap_int;
  double gap_ext, gap_act;
  double thol_act = 1e-4;
  double thol_ext = 1e-4;
  int MAX_ITER_EXT = 100;
  int MAX_ITER_INT = 10000;
  int MAX_ITER_ACT = 10000;
  int iter_ext, iter_int, iter_act;
  int *idx_a = (int *)malloc((d2) * sizeof(int));
  int *idx_i = (int *)malloc((d2) * sizeof(int));
  int *size_a = (int *)malloc(d * sizeof(int));
  double *w1 = (double *)malloc(d * sizeof(double));
  double *ww = (double *)malloc(d * sizeof(double));
  int size_a_prev;
  int junk_a;
  double r;
  double tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
  for (i = 0; i < d; i++) {
    tmp_i = i * d;
    W[tmp_i + i] = S[tmp_i + i] + ilambda;
    size_a[i] = 0;
    tmp1 = T[tmp_i + i];
    T[tmp_i + i] = 0;
    idx_i[tmp_i + i] = -1;
    for (j = 0; j < i; j++) {
      if (T[tmp_i + j] != 0) {
        idx_a[tmp_i + size_a[i]] = j;
        size_a[i]++;
        idx_i[tmp_i + j] = -1;
        T[tmp_i + j] = -T[tmp_i + j] / tmp1;
      } else
        idx_i[tmp_i + j] = 1;
    }
    for (j = i + 1; j < d; j++) {
      if (T[tmp_i + j] != 0) {
        idx_a[tmp_i + size_a[i]] = j;
        size_a[i]++;
        idx_i[tmp_i + j] = -1;
        T[tmp_i + j] = -T[tmp_i + j] / tmp1;
      } else
        idx_i[tmp_i + j] = 1;
    }
  }
  gap_ext = 1;
  iter_ext = 0;
  while (gap_ext > thol_ext && iter_ext < MAX_ITER_EXT) {
    tmp1 = 0;
    tmp6 = 0;
    tmp5 = 0;
    for (i = 0; i < d; i++) {
      tmp_i = i * d;
      gap_int = 1;
      iter_int = 0;
      for (j = 0; j < d; j++)
        ww[j] = T[tmp_i + j];
      while (gap_int != 0 && iter_int < MAX_ITER_INT) {
        size_a_prev = size_a[i];
        for (j = 0; j < d; j++) {
          if (idx_i[tmp_i + j] != -1) {
            tmp_j = j * d;
            r = S[tmp_i + j];
            for (k = 0; k < size_a[i]; k++) {
              rss_idx = idx_a[tmp_i + k];
              r = r - W[tmp_j + rss_idx] * T[tmp_i + rss_idx];
            }
            if (r > ilambda) {
              w1[j] = (r - ilambda) / W[tmp_j + j];
              idx_a[tmp_i + size_a[i]] = j;
              size_a[i] = size_a[i] + 1;
              idx_i[tmp_i + j] = -1;
            } else if (r < -ilambda) {
              w1[j] = (r + ilambda) / W[tmp_j + j];
              idx_a[tmp_i + size_a[i]] = j;
              size_a[i] = size_a[i] + 1;
              idx_i[tmp_i + j] = -1;
            } else
              w1[j] = 0;
            T[tmp_i + j] = w1[j];
          }
        }
        gap_int = size_a[i] - size_a_prev;
        gap_act = 1;
        iter_act = 0;
        while (gap_act > thol_act && iter_act < MAX_ITER_ACT) {
          tmp3 = 0;
          tmp4 = 0;
          for (j = 0; j < size_a[i]; j++) {
            w_idx = idx_a[tmp_i + j];
            if (w_idx != -1) {
              tmp_a = w_idx * d;
              r = S[tmp_i + w_idx] + T[tmp_i + w_idx] * W[tmp_a + w_idx];
              for (k = 0; k < size_a[i]; k++) {
                rss_idx = idx_a[tmp_i + k];
                r = r - W[tmp_a + rss_idx] * T[tmp_i + rss_idx];
              }
              if (r > ilambda) {
                w1[w_idx] = (r - ilambda) / W[tmp_a + w_idx];
                tmp4 += w1[w_idx];
              } else if (r < -ilambda) {
                w1[w_idx] = (r + ilambda) / W[tmp_a + w_idx];
                tmp4 -= w1[w_idx];
              } else
                w1[w_idx] = 0;
              tmp3 = tmp3 + fabs(w1[w_idx] - T[tmp_i + w_idx]);
              T[tmp_i + w_idx] = w1[w_idx];
            }
          }
          gap_act = tmp3 / tmp4;
          iter_act++;
        }
        junk_a = 0;
        for (j = 0; j < size_a[i]; j++) {
          w_idx = idx_a[tmp_i + j];
          if (w1[w_idx] == 0) {
            junk_a++;
            idx_i[tmp_i + w_idx] = 1;
            idx_a[tmp_i + j] = -1;
          } else
            idx_a[tmp_i + j - junk_a] = w_idx;
        }
        size_a[i] = size_a[i] - junk_a;
        iter_int++;
      }
      for (j = 0; j < i; j++) {
        tmp2 = 0;
        tmp_j = j * d;
        for (k = 0; k < i; k++)
          tmp2 = tmp2 + T[tmp_i + k] * W[tmp_j + k];
        for (k = i + 1; k < d; k++)
          tmp2 = tmp2 + T[tmp_i + k] * W[tmp_j + k];
        W[tmp_i + j] = tmp2;
        W[tmp_j + i] = tmp2;
      }
      for (j = i + 1; j < d; j++) {
        tmp2 = 0;
        tmp_j = j * d;
        for (k = 0; k < i; k++)
          tmp2 = tmp2 + T[tmp_i + k] * W[tmp_j + k];
        for (k = i + 1; k < d; k++)
          tmp2 = tmp2 + T[tmp_i + k] * W[tmp_j + k];
        W[tmp_i + j] = tmp2;
        W[tmp_j + i] = tmp2;
      }
      for (j = 0; j < d; j++)
        tmp5 = tmp5 + fabs(ww[j] - T[tmp_i + j]);
      tmp6 = tmp6 + tmp4;
    }
    gap_ext = tmp5 / tmp6;
    iter_ext++;
  }
  for (i = 0; i < d; i++) {
    tmp2 = 0;
    for (j = 0; j < i; j++)
      tmp2 = tmp2 + W[i * d + j] * T[i * d + j];
    for (j = i + 1; j < d; j++)
      tmp2 = tmp2 + W[i * d + j] * T[i * d + j];
    tmp1 = 1 / (W[i * d + i] - tmp2);
    T[i * d + i] = tmp1;
    for (j = 0; j < i; j++)
      T[i * d + j] = -tmp1 * T[i * d + j];
    for (j = i + 1; j < d; j++)
      T[i * d + j] = -tmp1 * T[i * d + j];
  }
  free(idx_a);
  free(idx_i);
  free(size_a);
  free(w1);
  free(ww);
}
```