// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]eph_converter/src/B2bDecoder.cpp
// Function: B2b::m_geneph_brd()
void B2b::m_geneph_brd(){
	FILE* fp = NULL;
	char filename[256] = {0};
	int mjd,iyear,imon,iday,ih,im,gweek,gd;
	double dx[6],length,A[3],Cr[3],R[3],dxx[6],sec;
	double sod,dintv = 900,dt,dtmin,dtlimit =120,xsat_out[6],xsat[6];
	/******** generate the ephemeris here *****************/
	cout << "begin to recover ephemeris ..." << endl;
	mjd = mjd0;
	sod = sod0;
	sod = ((int)(sod / dintv)) * dintv; /**force it to the epoch**/
	mjd2date(mjd,sod,&iyear,&imon,&iday,&ih,&im,&sec);
	gpsweek(iyear,imon,iday,&gweek,&gd);
	sprintf(filename,"cov%04d%d.sp3",gweek,gd);
	if(!(fp = fopen(filename,"w"))){cout << "can't open file " << filename << " to write!" << endl;exit(1);}
	m_wtephheader(fp);
	while(true){
		mjd2date(mjd,sod,&iyear,&imon,&iday,&ih,&im,&sec);
		fprintf(fp,"*   %4d%3d%3d%3d%3d%12.8lf\n",iyear,imon,iday,ih,im,sec);
		for(auto& cprn : cprn_list){
			/*************get the minus ssr*****************/
			if(!(nav.v_readOrbit(cprn.c_str(),mjd,sod,xsat_out))){
				cout << "ssr do not match ephemeris for " << cprn << " " << mjd << " " << sod << endl;
				continue;
			}
			for (int i = 0; i < 6; i++) {
				xsat[i] = xsat_out[i];
			}
			/**************write it into orbit file *********/
			fprintf(fp,"P%s%14.6lf%14.6lf%14.6lf%14.6lf\n",cprn.c_str(), xsat[0] / 1000.0 , xsat[1] / 1000.0,xsat[2] / 1000.0,999.0);
		}
		timinc(mjd,sod,dintv,&mjd,&sod);
		if( (mjd - mjd1) * 86400.0 + sod - sod1 >= 0.0)
			break;
	}
	fclose(fp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdi, %rbx
leaq -0x1b0(%rbp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x31b0
movq 0xd119(%rip), %r14      # 0x11fd8
leaq 0x8271(%rip), %rsi      # 0xd137
movl $0x1e, %edx
movq %r14, %rdi
callq 0x3330
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31f0
movl (%rbx), %r13d
movl %r13d, -0x2c(%rbp)
movsd 0x10(%rbx), %xmm0
movsd 0x8142(%rip), %xmm1     # 0xd050
divsd %xmm1, %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, (%rsp)
leaq -0x4c(%rbp), %r14
leaq -0x48(%rbp), %r15
leaq -0x44(%rbp), %r12
leaq -0x40(%rbp), %r8
leaq -0x3c(%rbp), %r9
movl %r13d, %edi
movapd %xmm0, -0x70(%rbp)
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0xbdb1
movl (%r14), %edi
movl (%r15), %esi
movl (%r12), %edx
leaq -0x80(%rbp), %r14
leaq -0x7c(%rbp), %r15
movq %r14, %rcx
movq %r15, %r8
callq 0xaa75
movl (%r14), %edx
movl (%r15), %ecx
leaq 0x81d7(%rip), %rsi      # 0xd156
leaq -0x1b0(%rbp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x3080
leaq 0x81cd(%rip), %rsi      # 0xd164
movq %r14, %rdi
callq 0x3350
testq %rax, %rax
je 0x51d0
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4d8a
leaq 0x20(%rbx), %r15
movq %rbx, %r12
movapd -0x70(%rbp), %xmm0
movq %rbx, -0x78(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, (%rsp)
movl %r13d, %edi
leaq -0x4c(%rbp), %rsi
leaq -0x48(%rbp), %rdx
leaq -0x44(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0x3c(%rbp), %r9
callq 0xbdb1
movl -0x4c(%rbp), %edx
movl -0x48(%rbp), %ecx
movl -0x44(%rbp), %r8d
movl -0x40(%rbp), %r9d
movl -0x3c(%rbp), %eax
movsd -0x58(%rbp), %xmm0
movl %eax, (%rsp)
movq %r14, %rdi
leaq 0x8164(%rip), %rsi      # 0xd171
movb $0x1, %al
callq 0x33e0
movq 0xd78(%r12), %rbx
movq 0xd80(%r12), %r12
cmpq %r12, %rbx
leaq -0xb0(%rbp), %r13
movq %r12, -0x70(%rbp)
je 0x515c
movq (%rbx), %rsi
movl -0x2c(%rbp), %edx
movsd -0x38(%rbp), %xmm0
movq %r15, %rdi
movq %r13, %rcx
callq 0xa4d6
testl %eax, %eax
je 0x509f
movsd -0xb0(%rbp), %xmm0
movsd -0xa8(%rbp), %xmm1
movsd -0xa0(%rbp), %xmm2
movq (%rbx), %rdx
movsd 0x7feb(%rip), %xmm3     # 0xd060
divsd %xmm3, %xmm0
divsd %xmm3, %xmm1
divsd %xmm3, %xmm2
movq %r14, %rdi
leaq 0x8102(%rip), %rsi      # 0xd18d
movsd 0x7fc5(%rip), %xmm3     # 0xd058
movb $0x4, %al
callq 0x33e0
jmp 0x514f
movl $0x1f, %edx
movq 0xcf2d(%rip), %r13      # 0x11fd8
movq %r13, %rdi
leaq 0x80f9(%rip), %rsi      # 0xd1ae
callq 0x3330
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r13, %rdi
callq 0x3330
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %r12
movq %r14, %r15
leaq 0x8f89(%rip), %r14      # 0xe06a
movq %r14, %rsi
callq 0x3330
movl -0x2c(%rbp), %esi
movq %r13, %rdi
callq 0x3480
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %r14
movq %r12, %r15
movq -0x70(%rbp), %r12
callq 0x3330
movsd -0x38(%rbp), %xmm0
movq %r13, %rdi
callq 0x3440
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %r13, %rdi
leaq -0xb0(%rbp), %r13
callq 0x3030
movq %rax, %rdi
callq 0x31f0
addq $0x20, %rbx
cmpq %r12, %rbx
jne 0x5038
movl -0x2c(%rbp), %edi
movsd -0x38(%rbp), %xmm0
movsd 0x7ee4(%rip), %xmm1     # 0xd050
leaq -0x2c(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0xb5a9
movl -0x2c(%rbp), %r13d
movl %r13d, %eax
movq -0x78(%rbp), %r12
subl 0x4(%r12), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd -0x38(%rbp), %xmm0
mulsd 0x7e93(%rip), %xmm1     # 0xd030
addsd %xmm0, %xmm1
subsd 0x18(%r12), %xmm1
ucomisd 0x7e98(%rip), %xmm1     # 0xd048
jb 0x4fc6
movq %r14, %rdi
callq 0x32c0
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xce01(%rip), %rdi      # 0x11fd8
leaq 0x7ee5(%rip), %rsi      # 0xd0c3
callq 0x32b0
leaq -0x1b0(%rbp), %rsi
movq %rax, %rdi
callq 0x32b0
leaq 0x7f6d(%rip), %rsi      # 0xd166
movq %rax, %rdi
callq 0x32b0
movq %rax, %rdi
callq 0x3170
movl $0x1, %edi
callq 0x3370
nop