// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../external/HyRec2020/hydrogen.c
// Function: solveTXeqB
void solveTXeqB(double *diag, double *updiag, double *dndiag, double *X, double *B,
                unsigned N, int *error, char error_message[SIZE_ErrorM]){
  int i;
  double denom;
  double *alpha = create_1D_array(N, error, error_message);
  double *gamma = create_1D_array(N, error, error_message);  /* X[i] = gamma[i] - alpha[i] * X[i+1] */

  alpha[0] = updiag[0] / diag[0];
  gamma[0] = B[0] / diag[0];

  for (i = 1; i < N; i++) {
    denom = diag[i] - dndiag[i] * alpha[i-1];
    alpha[i] = updiag[i] / denom;
    gamma[i] = (B[i] - dndiag[i] * gamma[i-1]) / denom;
  }

  X[N-1] = gamma[N-1];
  for (i = N-2; i >= 0; i--) X[i] = gamma[i] - alpha[i] * X[i+1];

  free(alpha);
  free(gamma);
}

// Assembly:
subq $0x48, %rsp
movq 0x58(%rsp), %rax
movq 0x50(%rsp), %rax
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movl %r9d, 0x1c(%rsp)
movl 0x1c(%rsp), %edi
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x1a5690
movq %rax, 0x8(%rsp)
movl 0x1c(%rsp), %edi
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x1a5690
movq %rax, (%rsp)
movq 0x38(%rsp), %rax
movsd (%rax), %xmm0
movq 0x40(%rsp), %rax
divsd (%rax), %xmm0
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
movq 0x40(%rsp), %rax
divsd (%rax), %xmm0
movq (%rsp), %rax
movsd %xmm0, (%rax)
movl $0x1, 0x18(%rsp)
movl 0x18(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jae 0x1aba75
movq 0x40(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x30(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x8(%rsp), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd 0x10(%rsp), %xmm0
movq 0x8(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x30(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq (%rsp), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
divsd 0x10(%rsp), %xmm0
movq (%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x1ab978
movq (%rsp), %rax
movl 0x1c(%rsp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movq 0x28(%rsp), %rax
movl 0x1c(%rsp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsd %xmm0, (%rax,%rcx,8)
movl 0x1c(%rsp), %eax
subl $0x2, %eax
movl %eax, 0x18(%rsp)
cmpl $0x0, 0x18(%rsp)
jl 0x1abb18
movq (%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x8(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x28(%rsp), %rax
movl 0x18(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x28(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x18(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x1abaa5
movq 0x8(%rsp), %rdi
callq 0x8420
movq (%rsp), %rdi
callq 0x8420
addq $0x48, %rsp
retq