// File: /workspace/github_c_makefile_star2_O0/YunyiQian[P]multitel3/./raytrace.c
// Function: inslay
int inslay(double depth,MODEL *m){
	int i,inslay;
	int k;
	double slope;

	if (depth < 0. || depth > m->depth[m->nlay-1]){
		fprintf(stderr,"Input depth is out of range\n");
		return -1;
	}

	for (i=0;i<m->nlay;i++){
		if (m->depth[i] > depth){
			if ( fabs(depth-m->depth[i-1]) < 0.005 ){
				inslay = i-1;
				return inslay;
			}else if( fabs(depth-m->depth[i]) < 0.005 ){
				inslay = i;
				return inslay;
			}else{
				inslay = i;
				m->nlay ++;
				if (m->nlay > MAXLAY){
					fprintf(stderr,"Too many layers in inslay()\n");
					return -1;
				}
				for (k=(m->nlay-1);k>i;k--){
					m->depth[k] = m->depth[k-1];
					m->vp[k]    = m->vp[k-1];
					m->vs[k]    = m->vs[k-1];
					m->rou[k]   = m->rou[k-1];
					m->qp[k]    = m->qp[k-1];
					m->qs[k]    = m->qs[k-1];
				}

				slope = (depth-m->depth[i-1])/(m->depth[i+1] - m->depth[i-1]);
				m->depth[i] = depth;
				m->vp[i]  = slope*m->vp[i+1]  + (1.-slope)*m->vp[i-1];
				m->vs[i]  = slope*m->vs[i+1]  + (1.-slope)*m->vs[i-1];
				m->rou[i] = slope*m->rou[i+1] + (1.-slope)*m->rou[i-1];
				m->qp[i]  = slope*m->qp[i+1]  + (1.-slope)*m->qp[i-1];
				m->qs[i]  = slope*m->qs[i+1]  + (1.-slope)*m->qs[i-1];

				return inslay;
			}	// end of if
		}// end of if
	}// end of i loop 

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movsd %xmm0, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x10(%rbp), %xmm0
ja 0x157b
movsd -0x10(%rbp), %xmm0
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
ucomisd 0x5dc8(%rax,%rcx,8), %xmm0
jbe 0x159f
movq 0x5a76(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x3c37(%rip), %rsi      # 0x51c3
movb $0x0, %al
callq 0x10b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x19cc
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x19cc
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd 0x5dc8(%rax,%rcx,8), %xmm0
ucomisd -0x10(%rbp), %xmm0
jbe 0x19bc
movsd -0x10(%rbp), %xmm1
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
subsd 0x5dc8(%rax,%rcx,8), %xmm1
movaps 0x3afd(%rip), %xmm0     # 0x50f0
pand %xmm0, %xmm1
movsd 0x3a09(%rip), %xmm0     # 0x5008
ucomisd %xmm1, %xmm0
jbe 0x1619
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x19cc
movsd -0x10(%rbp), %xmm1
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
subsd 0x5dc8(%rax,%rcx,8), %xmm1
movaps 0x3aba(%rip), %xmm0     # 0x50f0
pand %xmm0, %xmm1
movsd 0x39c6(%rip), %xmm0     # 0x5008
ucomisd %xmm1, %xmm0
jbe 0x1659
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x19cc
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
cmpl $0x3e8, (%rax)          # imm = 0x3E8
jle 0x169a
movq 0x597b(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x3b59(%rip), %rsi      # 0x51e0
movb $0x0, %al
callq 0x10b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x19cc
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x17a4
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x5dc8(%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, 0x5dc8(%rax,%rcx,8)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x8(%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, 0x8(%rax,%rcx,8)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x1f48(%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, 0x1f48(%rax,%rcx,8)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x3e88(%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, 0x3e88(%rax,%rcx,8)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x7d08(%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, 0x7d08(%rax,%rcx,8)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x9c48(%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, 0x9c48(%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x16a6
movsd -0x10(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
subsd 0x5dc8(%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x5dc8(%rax,%rcx,8), %xmm1
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
subsd 0x5dc8(%rax,%rcx,8), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, 0x5dc8(%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x8(%rax,%rcx,8), %xmm2
movsd 0x37e6(%rip), %xmm1     # 0x5010
subsd -0x30(%rbp), %xmm1
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
mulsd 0x8(%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, 0x8(%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x1f48(%rax,%rcx,8), %xmm2
movsd 0x3795(%rip), %xmm1     # 0x5010
subsd -0x30(%rbp), %xmm1
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
mulsd 0x1f48(%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, 0x1f48(%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x3e88(%rax,%rcx,8), %xmm2
movsd 0x373e(%rip), %xmm1     # 0x5010
subsd -0x30(%rbp), %xmm1
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
mulsd 0x3e88(%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, 0x3e88(%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x7d08(%rax,%rcx,8), %xmm2
movsd 0x36e7(%rip), %xmm1     # 0x5010
subsd -0x30(%rbp), %xmm1
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
mulsd 0x7d08(%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, 0x7d08(%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x9c48(%rax,%rcx,8), %xmm2
movsd 0x3690(%rip), %xmm1     # 0x5010
subsd -0x30(%rbp), %xmm1
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
mulsd 0x9c48(%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, 0x9c48(%rax,%rcx,8)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x19cc
jmp 0x19be
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x15a6
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)