// File: dannycalegari[P]circle_pack/./Packing.cc
// Function: angle_at_C(double, double, double, char)
double angle_at_C(double a, double b, double c, char geometry){	
	// in a triangle with side lengths a,b,c, what is the angle at C (i.e. opposite c)?
	double t,u;
	if(geometry=='E'){	// Euclidean geometry
		// Euclidean cosine rule: c*c = a*a + b*b - 2*a*b*cos(C)
		// so C = acos((a*a + b*b - c*c)/(2*a*b));
		t=(a*a+b*b-c*c)/(2.0*a*b);
		return(acos(t));
	} else if(geometry=='S'){	// Spherical geometry
		// Spherical cosine rule: cos(c) = cos(a)*cos(b)+sin(a)*sin(b)*cos(C)
		// so C=acos((cos(c)-cos(a)*cos(b))/(sin(a)*sin(b)))
		u=sin(a)*sin(b);
		t=(cos(c)-(cos(a)*cos(b)))/u;
		return(acos(t));
	} else if(geometry=='H'){	// Hyperbolic geometry
		// Hyperbolic cosine rule: cosh(c) = cosh(a)*cosh(b)-sinh(a)*sinh(b)*cos(C)
		// so C=acos((cosh(c)-cosh(a)*cosh(b))/(sinh(a)*sinh(b)))
		u=-sinh(a)*sinh(b);
		t=(cosh(c)-(cosh(a)*cosh(b)))/u;
		return(acos(t));
	};
	return(0.0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %dil, %al
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
movb %al, -0x21(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x45, %eax
jne 0x415a
movsd -0x10(%rbp), %xmm1
movsd -0x10(%rbp), %xmm2
movsd -0x18(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x20(%rbp), %xmm0
movsd -0x20(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0xced5(%rip), %xmm1     # 0x11008
mulsd -0x10(%rbp), %xmm1
mulsd -0x18(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x21d0
movsd %xmm0, -0x8(%rbp)
jmp 0x42cc
movsbl -0x21(%rbp), %eax
cmpl $0x53, %eax
jne 0x4203
movsd -0x10(%rbp), %xmm0
callq 0x2060
movsd %xmm0, -0x50(%rbp)
movsd -0x18(%rbp), %xmm0
callq 0x2060
movaps %xmm0, %xmm1
movsd -0x50(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x23f0
movsd %xmm0, -0x48(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x23f0
movsd %xmm0, -0x40(%rbp)
movsd -0x18(%rbp), %xmm0
callq 0x23f0
movsd -0x48(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
divsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x21d0
movsd %xmm0, -0x8(%rbp)
jmp 0x42cc
movsbl -0x21(%rbp), %eax
cmpl $0x48, %eax
jne 0x42c0
movsd -0x10(%rbp), %xmm0
callq 0x21c0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x18(%rbp), %xmm0
callq 0x21c0
movaps %xmm0, %xmm1
movsd -0x68(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x22c0
movsd %xmm0, -0x60(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x22c0
movsd %xmm0, -0x58(%rbp)
movsd -0x18(%rbp), %xmm0
callq 0x22c0
movsd -0x60(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x58(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
divsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x21d0
movsd %xmm0, -0x8(%rbp)
jmp 0x42cc
jmp 0x42c2
jmp 0x42c4
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)