// File: /workspace/github_c_makefile_star2_O0/YunyiQian[P]multitel3/./raytrace.c
// Function: mhrv_interp
void mhrv_interp(MODEL *m,int P){
	int i;
	int k=0;
	double tmp,tmp1;
	
	m->radius[0] = Rearth - m->depth[0];
	if ( P == 1 || m->vs[0] < SMALL ){
		m->p[0] = m->radius[0]/m->vp[0];
		m->Q[0] = m->qp[0];
	}else{
		m->p[0] = m->radius[0]/m->vs[0];
		m->Q[0] = m->qs[0];
	}
/*
	if ( P == 1 ){
		m->p[0] = m->radius[0]/m->vp[0];
		m->Q[0] = m->qp[0];
	}else if ( m->vs[0] < SMALL ){
		m->p[0] = m->radius[0]/SMALL;
		m->Q[0] = SMALL;
	}else{
		m->p[0] = m->radius[0]/m->vs[0];
		m->Q[0] = m->qs[0];
	}
*/
	for (i=1;i<m->nlay;i++){
		m->radius[i] = Rearth - m->depth[i];
		if (m->radius[i] < 0.001){	// the center of earth
			m->p[i]   = 0.00001;
			m->Q[i]   = 100000;
			m->B[i-1] = 1.;
			m->B[i]   = 1.;
			return;
		}else{
			tmp = log(m->radius[i-1]/m->radius[i]);
		}

		if ( P == 1 ){
			m->p[i] = m->radius[i]/m->vp[i];
			m->Q[i] = m->qp[i];
			tmp1 = log(m->vp[i-1]/m->vp[i]);
		}else if( m->vs[i] < SMALL ){
			m->Q[i] = m->qp[i];
			if ( k == 1 ){
				m->p[i] = m->radius[i]/m->vp[i];
				tmp1 = log(m->vp[i-1]/m->vp[i]);
			}else{
//				m->p[i] = m->radius[i]/m->vp[i];
				m->p[i] = BIG;
				tmp1 = log(m->vs[i-1]/m->vp[i]);
				k = 1;
			}
		}else{
			m->p[i] = m->radius[i]/m->vs[i];
			m->Q[i] = m->qs[i];
			tmp1 = log(m->vs[i-1]/m->vs[i]);
		}

/*		if ( P == 1 ){
			m->p[i] = m->radius[i]/m->vp[i];
			m->Q[i] = m->qp[i];
			tmp1 = log(m->vp[i-1]/m->vp[i]);
		}else{
			if ( m->vs[i] < SMALL ){
				m->vs[i] = SMALL;
			}
			m->p[i] = m->radius[i]/m->vs[i];
			m->Q[i] = m->qs[i];
			tmp1 = log(m->vs[i-1]/m->vs[i]);
		}
*/
		if (fabs(tmp) < 1.0e-4){	//discontinuity
			m->B[i-1] = 0.;
		}else{
			tmp = tmp1/tmp;
			m->B[i-1] = 1./(1.-tmp);
		}
	}
	m->B[i] = 1.;

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rax
movsd 0x3616(%rip), %xmm0     # 0x5018
subsd 0x5dc8(%rax), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0xbb88(%rax)
cmpl $0x1, -0xc(%rbp)
je 0x1a32
movq -0x8(%rbp), %rax
movsd 0x35f8(%rip), %xmm0     # 0x5020
ucomisd 0x1f48(%rax), %xmm0
jbe 0x1a6d
movq -0x8(%rbp), %rax
movsd 0xbb88(%rax), %xmm0
movq -0x8(%rbp), %rax
divsd 0x8(%rax), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0xfa08(%rax)
movq -0x8(%rbp), %rax
movsd 0x7d08(%rax), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x11948(%rax)
jmp 0x1aa9
movq -0x8(%rbp), %rax
movsd 0xbb88(%rax), %xmm0
movq -0x8(%rbp), %rax
divsd 0x1f48(%rax), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0xfa08(%rax)
movq -0x8(%rbp), %rax
movsd 0x9c48(%rax), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x11948(%rax)
movl $0x1, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1e35
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x3549(%rip), %xmm0     # 0x5018
subsd 0x5dc8(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, 0xbb88(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x352f(%rip), %xmm0     # 0x5028
ucomisd 0xbb88(%rax,%rcx,8), %xmm0
jbe 0x1b72
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x3534(%rip), %xmm0     # 0x5048
movsd %xmm0, 0xfa08(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x3513(%rip), %xmm0     # 0x5040
movsd %xmm0, 0x11948(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x34c5(%rip), %xmm0     # 0x5010
movsd %xmm0, 0xdac8(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x34ac(%rip), %xmm0     # 0x5010
movsd %xmm0, 0xdac8(%rax,%rcx,8)
jmp 0x1e4e
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0xbb88(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
divsd 0xbb88(%rax,%rcx,8), %xmm0
callq 0x1080
movsd %xmm0, -0x20(%rbp)
cmpl $0x1, -0xc(%rbp)
jne 0x1c2f
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0xbb88(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
divsd 0x8(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, 0xfa08(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x7d08(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, 0x11948(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x8(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
divsd 0x8(%rax,%rcx,8), %xmm0
callq 0x1080
movsd %xmm0, -0x28(%rbp)
jmp 0x1dae
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x33e1(%rip), %xmm0     # 0x5020
ucomisd 0x1f48(%rax,%rcx,8), %xmm0
jbe 0x1d26
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x7d08(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, 0x11948(%rax,%rcx,8)
cmpl $0x1, -0x14(%rbp)
jne 0x1cd3
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0xbb88(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
divsd 0x8(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, 0xfa08(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x8(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
divsd 0x8(%rax,%rcx,8), %xmm0
callq 0x1080
movsd %xmm0, -0x28(%rbp)
jmp 0x1d21
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x334d(%rip), %xmm0     # 0x5030
movsd %xmm0, 0xfa08(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x1f48(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
divsd 0x8(%rax,%rcx,8), %xmm0
callq 0x1080
movsd %xmm0, -0x28(%rbp)
movl $0x1, -0x14(%rbp)
jmp 0x1dac
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0xbb88(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
divsd 0x1f48(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, 0xfa08(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x9c48(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, 0x11948(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x1f48(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
divsd 0x1f48(%rax,%rcx,8), %xmm0
callq 0x1080
movsd %xmm0, -0x28(%rbp)
jmp 0x1dae
movsd -0x20(%rbp), %xmm1
movaps 0x3336(%rip), %xmm0     # 0x50f0
pand %xmm0, %xmm1
movsd 0x3272(%rip), %xmm0     # 0x5038
ucomisd %xmm1, %xmm0
jbe 0x1de7
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0xdac8(%rax,%rcx,8)
jmp 0x1e25
movsd -0x28(%rbp), %xmm0
divsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd 0x3212(%rip), %xmm1     # 0x5010
subsd -0x20(%rbp), %xmm1
movsd 0x3205(%rip), %xmm0     # 0x5010
divsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, 0xdac8(%rax,%rcx,8)
jmp 0x1e27
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1ab0
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd 0x31cb(%rip), %xmm0     # 0x5010
movsd %xmm0, 0xdac8(%rax,%rcx,8)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)