// File: jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: getWallCurvatureRadius(pointxy const*)
double getWallCurvatureRadius(const PXYZ *pt)
{
    int ils1;
    double rd1=0.0,rd2=0.0;
    PXYZ pp1,pp2,pp3;
    int nb;
    ils1=getIndexAtWallPoint(pt,nb);
    if(ils1==NWallPts[nb]-1)
    {
        pp1.x = MultiCircle[nb][0].x;
        pp1.y = MultiCircle[nb][0].y;
        pp2.x = MultiCircle[nb][ils1].x;
        pp2.y = MultiCircle[nb][ils1].y;
        pp3.x = MultiCircle[nb][ils1-1].x;
        pp3.y = MultiCircle[nb][ils1-1].y;

        rd1=getRadius(&pp1,&pp2,&pp3);

        return rd1;
    }
    else if(ils1==NWallPts[nb]-2)
    {
        pp1.x = MultiCircle[nb][0].x;
        pp1.y = MultiCircle[nb][0].y;
        pp2.x = MultiCircle[nb][ils1].x;
        pp2.y = MultiCircle[nb][ils1].y;
        pp3.x = MultiCircle[nb][ils1+1].x;
        pp3.y = MultiCircle[nb][ils1+1].y;

        rd1=getRadius(&pp1,&pp2,&pp3);

        pp1.x = MultiCircle[nb][ils1+1].x;
        pp1.y = MultiCircle[nb][ils1+1].y;
        pp2.x = MultiCircle[nb][ils1].x;
        pp2.y = MultiCircle[nb][ils1].y;
        pp3.x = MultiCircle[nb][ils1-1].x;
        pp3.y = MultiCircle[nb][ils1-1].y;

        rd2=getRadius(&pp1,&pp2,&pp3);

        return (0.5*(rd1+rd2));
    }
    else if(ils1==0)
    {
        pp1.x = MultiCircle[nb][0].x;
        pp1.y = MultiCircle[nb][0].y;
        pp2.x = MultiCircle[nb][1].x;
        pp2.y = MultiCircle[nb][1].y;
        pp3.x = MultiCircle[nb][2].x;
        pp3.y = MultiCircle[nb][2].y;
        rd1=getRadius(&pp1,&pp2,&pp3);

        return rd1;
    }
    else
    {
        pp1.x = MultiCircle[nb][ils1+2].x;
        pp1.y = MultiCircle[nb][ils1+2].y;
        pp2.x = MultiCircle[nb][ils1].x;
        pp2.y = MultiCircle[nb][ils1].y;
        pp3.x = MultiCircle[nb][ils1+1].x;
        pp3.y = MultiCircle[nb][ils1+1].y;

        rd1=getRadius(&pp1,&pp2,&pp3);

        pp1.x = MultiCircle[nb][ils1+1].x;
        pp1.y = MultiCircle[nb][ils1+1].y;
        pp2.x = MultiCircle[nb][ils1].x;
        pp2.y = MultiCircle[nb][ils1].y;
        pp3.x = MultiCircle[nb][ils1-1].x;
        pp3.y = MultiCircle[nb][ils1-1].y;

        rd2=getRadius(&pp1,&pp2,&pp3);

        return (0.5*(rd1+rd2));
    }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x6310
leaq 0x20(%rsp), %rdi
callq 0x6310
leaq 0x10(%rsp), %rdi
callq 0x6310
movq 0x58(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x27aa0
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
movslq 0xc(%rsp), %rdx
leaq 0x24144(%rip), %rcx     # 0x4b290
movl (%rcx,%rdx,4), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x27282
movslq 0xc(%rsp), %rcx
leaq 0x242aa(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x2428a(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x24269(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x2423d(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x24210(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x241df(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x285d0
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
jmp 0x2789e
movl 0x54(%rsp), %eax
movslq 0xc(%rsp), %rdx
leaq 0x23ffe(%rip), %rcx     # 0x4b290
movl (%rcx,%rdx,4), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jne 0x27513
movslq 0xc(%rsp), %rcx
leaq 0x24164(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x24144(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x24123(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x240f7(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x240ca(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x24099(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x285d0
movsd %xmm0, 0x48(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x2404d(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x2401c(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23fea(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23fbe(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23f91(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23f60(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x285d0
movsd %xmm0, 0x40(%rsp)
movsd 0x48(%rsp), %xmm1
addsd 0x40(%rsp), %xmm1
movsd 0x17c3c(%rip), %xmm0    # 0x3f140
mulsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
jmp 0x2789e
cmpl $0x0, 0x54(%rsp)
jne 0x2760e
movslq 0xc(%rsp), %rcx
leaq 0x23ee6(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23ec6(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23ea5(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23e84(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23e63(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23e42(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x285d0
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
jmp 0x2789e
movslq 0xc(%rsp), %rcx
leaq 0x23df6(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23dc5(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23d93(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23d67(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23d3a(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23d09(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x285d0
movsd %xmm0, 0x48(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23cbd(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23c8c(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23c5a(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23c2e(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x54(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23c01(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0xc(%rsp), %rcx
leaq 0x23bd0(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x54(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x285d0
movsd %xmm0, 0x40(%rsp)
movsd 0x48(%rsp), %xmm1
addsd 0x40(%rsp), %xmm1
movsd 0x178ac(%rip), %xmm0    # 0x3f140
mulsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x60(%rsp), %xmm0
addq $0x68, %rsp
retq
nopl (%rax)