// File: /workspace/github_c_makefile_star2_O2/markpeerdeman[P]mbemm/src/emath/singular.c
// Function: make_B
void make_B(const matrix p, const matrix q, const matrix r, const double beta, 
			const matrix B)
{ /* IN:          matrices p, q, r, B, double beta
   * OUT:         nothing
   * MODIFIES:    matrix B
   * USES:        element data from theElement
   * DESCRIPTION: This one calculates the B matrix
   */

int  k, i; /* counters */
double B1, B2, B3;

   for (k=1; k<=3; k++)
   { for (i=1; i<=3; i++)
	 { B1 = sinA1 * sinA1 / sinA2
		  + beta * sin( 2.0*theElement->alpha3 )
		  - 2.0 * ( sinA3 + sin(2.0*theElement->alpha3+theElement->alpha2) );
       B1 = M(p,k,i) * B1;

	   B2 = beta * sin( theElement->alpha3-theElement->alpha2 )
		  - 2.0 * ( sinA3 - sinA2 );
       B2 = M(q,k,i) * B2;

	   B3 = - sinA1 * sinA1 / sinA3
		  - beta * sin( 2.0*theElement->alpha2 )
		  + 2.0 * ( sinA2 + sin(2.0*theElement->alpha2+theElement->alpha3) );
       B3 = M(r,k,i) * B3;

	   M(B,k,i) = B1 + B2 + B3;
	 } /* for i */
   } /* for k */

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movapd 0x4f63(%rip), %xmm1     # 0xd020
xorpd %xmm0, %xmm1
movapd %xmm0, 0x30(%rsp)
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd %xmm0, 0x20(%rsp)
pushq $0x1
popq %r13
cmpq $0x4, %r13
je 0x82d8
xorl %ebp, %ebp
cmpq $0x3, %rbp
je 0x82d0
movq 0xc6be(%rip), %rax      # 0x147b0
movsd 0x80(%rax), %xmm0
addsd %xmm0, %xmm0
movsd 0xc6b2(%rip), %xmm1     # 0x147b8
movaps %xmm1, 0xa0(%rsp)
movsd 0xc6b2(%rip), %xmm1     # 0x147c8
movaps %xmm1, 0xc0(%rsp)
callq 0x1160
movapd %xmm0, 0xb0(%rsp)
movq 0xc67d(%rip), %rax      # 0x147b0
movsd 0x80(%rax), %xmm0
addsd %xmm0, %xmm0
addsd 0x78(%rax), %xmm0
movsd 0xc68c(%rip), %xmm1     # 0x147d8
movaps %xmm1, (%rsp)
callq 0x1160
movapd %xmm0, 0x80(%rsp)
movq 0x8(%r12), %rax
movq -0x8(%rax,%r13,8), %rax
movq 0xc641(%rip), %rcx      # 0x147b0
movsd 0x80(%rcx), %xmm0
subsd 0x78(%rcx), %xmm0
movsd (%rax,%rbp,8), %xmm1
movaps %xmm1, 0x90(%rsp)
callq 0x1160
movsd 0xc642(%rip), %xmm1     # 0x147d8
movapd %xmm1, 0x70(%rsp)
subsd 0xc624(%rip), %xmm1     # 0x147c8
mulsd 0x30(%rsp), %xmm0
addsd %xmm1, %xmm1
subsd %xmm1, %xmm0
movq 0x8(%r15), %rax
movq -0x8(%rax,%r13,8), %rax
mulsd (%rax,%rbp,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0xc5ea(%rip), %xmm0     # 0x147b8
movaps %xmm0, 0x40(%rsp)
xorps 0x4e46(%rip), %xmm0     # 0xd020
movaps %xmm0, 0x60(%rsp)
movq 0xc5ca(%rip), %rax      # 0x147b0
movsd 0x78(%rax), %xmm0
addsd %xmm0, %xmm0
callq 0x1160
movapd %xmm0, 0x50(%rsp)
movq 0xc5af(%rip), %rax      # 0x147b0
movsd 0x78(%rax), %xmm0
addsd %xmm0, %xmm0
addsd 0x80(%rax), %xmm0
movaps (%rsp), %xmm1
movhps 0xc5ab(%rip), %xmm1     # xmm1 = xmm1[0,1],mem[0,1]
movaps %xmm1, (%rsp)
callq 0x1160
movq 0x8(%r14), %rax
movq -0x8(%rax,%r13,8), %rax
movapd 0xa0(%rsp), %xmm2
movapd %xmm2, %xmm1
unpcklpd 0x40(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
unpcklpd 0x60(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
mulpd %xmm1, %xmm2
movapd 0xc0(%rsp), %xmm1
unpcklpd 0x70(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
divpd %xmm1, %xmm2
movapd 0xb0(%rsp), %xmm1
unpcklpd 0x50(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd 0x20(%rsp), %xmm1
addpd %xmm2, %xmm1
movapd 0x80(%rsp), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
addpd (%rsp), %xmm2
mulpd 0x5f7e(%rip), %xmm2     # 0xe210
addpd %xmm1, %xmm2
movapd 0x90(%rsp), %xmm0
movhpd (%rax,%rbp,8), %xmm0    # xmm0 = xmm0[0],mem[0]
mulpd %xmm2, %xmm0
movsd 0x18(%rsp), %xmm1
addsd %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x8(%rbx), %rax
movq -0x8(%rax,%r13,8), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
jmp 0x80e1
incq %r13
jmp 0x80d5
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq