// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rnxobs/Patterns.cpp
// Function: bamboo::Patterns::m_getPatternName(int, char const*, char const*, int, int, int, int, char*)
void Patterns::m_getPatternName(int ldefined, const char* keyword, const char* param_list, int iyear,
		int imonth, int iday, int ihour, char* name) {
	char varword[1024];
	char form[1024] = { '\0' };
	int npar, nword, mjd, week, wd, idoy;
	bool lfound;
	char word[40][256], param[40][256];
	int i, j, k, index;
	if (ldefined)
		strcpy(form, name);
	else {
		for (i = 0; i < nfile; i++) {
			if (!strcmp(fname[i], keyword)) {
				strcpy(form, fform[i]);
				break;
			}
		}
		if (len_trim(form) == 0) {
			printf("keyword = %s,keyword not defined in panda_file_name",keyword);
			exit(1);
		}
	}
	split_string(false, form, ' ', ' ', '-', &nword, (char*)word, 256);
	strcpy(varword, param_list);
	split_string(true, varword, ' ', ' ', ':', &npar, (char*)param, 256);
	mjd = md_julday(iyear, imonth, iday);
	gpsweek(iyear, imonth, iday, &week, &wd);
	mjd2doy(mjd, &iyear, &idoy);
	sprintf(param[npar], "Y=%1.1d", iyear % 10);
	sprintf(param[npar + 1], "YY=%2.2d", iyear % 100);
	sprintf(param[npar + 2], "YYYY=%4.4d", iyear);
	sprintf(param[npar + 3], "DDD=%3.3d", idoy);
	sprintf(param[npar + 4], "HH=%2.2d", ihour);
	sprintf(param[npar + 5], "WWW=%4.4d", week);
	sprintf(param[npar + 6], "GPSW=%4.4d", week);
	sprintf(param[npar + 7], "WWWWD=%5.5d", week * 10 + wd);
	sprintf(param[npar + 8], "MJD=%5.5d", mjd);
	npar += 9;
	memset(name,0,strlen(name) * sizeof(char));
	for (i = 0; i < nword; i++) {
		if (len_trim(word[i]) == 0)
			continue;
		trim(word[i]);
		if (i % 2 != 0) {
			lfound = false;
			for (j = 0; j < npar; j++) {
				//if (strstr(param[j], word[i]) != NULL) {
				if (!strncmp(param[j], word[i],strlen(word[i]))) {
					lfound = true;
					k = len_trim(name);
					index = index_string(param[j], '=');
					substringEx(varword, param[j], index + 1,
							strlen(param[j]) - index - 1);
					strcpy(name + k, varword);
					break;
				}
			}
			if (!lfound) {
				printf("word = %s,keyword = %s,word is not defined in keyword",word[i],keyword);
				exit(1);
			}
		} else {
			k = len_trim(name);
			strcpy(name + k, word[i]);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5838, %rsp           # imm = 0x5838
movl %r9d, -0x2c(%rbp)
movl %r8d, %r12d
movq %rcx, %r14
movq %rdx, -0x40(%rbp)
movl %esi, %r15d
movq %rdi, %rbx
movq 0x20(%rbp), %r13
movl %r8d, -0x50(%rbp)
leaq -0x460(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x8390
testl %r15d, %r15d
je 0x22c06
leaq -0x460(%rbp), %rdi
movq %r13, %rsi
callq 0x85c0
movq %r13, %r15
jmp 0x22c65
movq %r14, -0x58(%rbp)
movslq 0xc800(%rbx), %r14
testq %r14, %r14
movq %r13, %r15
jle 0x22c4d
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0x8880
testl %eax, %eax
je 0x22c37
addq $0x100, %rbx            # imm = 0x100
decq %r14
jne 0x22c19
jmp 0x22c4d
addq $0x6400, %rbx           # imm = 0x6400
leaq -0x460(%rbp), %rdi
movq %rbx, %rsi
callq 0x85c0
leaq -0x460(%rbp), %rdi
callq 0x1d2ee
testl %eax, %eax
movq -0x58(%rbp), %r14
je 0x23002
movl $0x100, %r10d           # imm = 0x100
leaq -0x5860(%rbp), %rax
leaq -0x460(%rbp), %rsi
leaq -0x30(%rbp), %r9
xorl %edi, %edi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x2d, %r8d
pushq %r10
movl $0x100, %r13d           # imm = 0x100
pushq %rax
callq 0x1d941
addq $0x10, %rsp
leaq -0x860(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x85c0
leaq -0x3060(%rbp), %rax
leaq -0x34(%rbp), %r9
movl $0x1, %edi
movq %rbx, %rsi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x3a, %r8d
pushq %r13
pushq %rax
callq 0x1d941
addq $0x10, %rsp
movl %r12d, %edi
movl %r12d, %r14d
movl -0x2c(%rbp), %r12d
movl %r12d, %esi
movl 0x10(%rbp), %r13d
movl %r13d, %edx
callq 0x1c8ec
movl %eax, %ebx
leaq -0x4c(%rbp), %rcx
leaq -0x48(%rbp), %r8
movl %r14d, %edi
movl %r12d, %esi
movl %r13d, %edx
callq 0x1c9a9
leaq -0x50(%rbp), %r12
leaq -0x44(%rbp), %rdx
movl %ebx, %edi
movq %r12, %rsi
callq 0x1ca2e
leaq -0x34(%rbp), %r13
movslq (%r13), %rax
shlq $0x8, %rax
leaq (%rax,%rbp), %rdi
addq $-0x3060, %rdi          # imm = 0xCFA0
movslq (%r12), %rdx
imulq $0x66666667, %rdx, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
addl %ecx, %eax
addl %eax, %eax
leal (%rax,%rax,4), %eax
subl %eax, %edx
leaq 0x48998(%rip), %rsi     # 0x6b6fa
xorl %eax, %eax
callq 0x8120
movslq (%r13), %rax
shlq $0x8, %rax
leaq -0x3060(%rbp), %r14
leaq (%rax,%r14), %rdi
addq $0x100, %rdi            # imm = 0x100
movslq (%r12), %rdx
imulq $0x51eb851f, %rdx, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rax
addl %ecx, %eax
imull $0x64, %eax, %eax
subl %eax, %edx
leaq 0x4895b(%rip), %rsi     # 0x6b702
xorl %eax, %eax
callq 0x8120
movslq (%r13), %rax
shlq $0x8, %rax
leaq (%rax,%r14), %rdi
addq $0x200, %rdi            # imm = 0x200
movl (%r12), %edx
leaq 0x4893f(%rip), %rsi     # 0x6b70b
xorl %eax, %eax
callq 0x8120
movslq (%r13), %rax
shlq $0x8, %rax
leaq (%rax,%r14), %rdi
addq $0x300, %rdi            # imm = 0x300
leaq -0x44(%rbp), %rax
movl (%rax), %edx
leaq 0x48923(%rip), %rsi     # 0x6b716
xorl %eax, %eax
callq 0x8120
movslq (%r13), %rax
shlq $0x8, %rax
leaq (%rax,%r14), %rdi
addq $0x400, %rdi            # imm = 0x400
leaq 0x4890c(%rip), %rsi     # 0x6b720
movl 0x18(%rbp), %edx
xorl %eax, %eax
callq 0x8120
movslq (%r13), %rax
shlq $0x8, %rax
leaq (%rax,%r14), %rdi
addq $0x500, %rdi            # imm = 0x500
leaq -0x4c(%rbp), %r12
movl (%r12), %edx
leaq 0x488e9(%rip), %rsi     # 0x6b729
xorl %eax, %eax
callq 0x8120
movslq (%r13), %rax
shlq $0x8, %rax
leaq (%rax,%r14), %rdi
addq $0x600, %rdi            # imm = 0x600
movl (%r12), %edx
leaq 0x488ce(%rip), %rsi     # 0x6b733
xorl %eax, %eax
callq 0x8120
movslq (%r13), %rax
shlq $0x8, %rax
leaq (%rax,%r14), %rdi
addq $0x700, %rdi            # imm = 0x700
movl (%r12), %eax
leal (%rax,%rax,4), %edx
addl %edx, %edx
leaq -0x48(%rbp), %rax
addl (%rax), %edx
leaq 0x488a9(%rip), %rsi     # 0x6b73e
xorl %eax, %eax
callq 0x8120
movslq (%r13), %rax
shlq $0x8, %rax
leaq (%rax,%r14), %rdi
addq $0x800, %rdi            # imm = 0x800
leaq 0x48894(%rip), %rsi     # 0x6b74a
movl %ebx, %edx
xorl %eax, %eax
callq 0x8120
addl $0x9, (%r13)
movq %r15, %rdi
callq 0x8290
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x8390
leaq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x22fd1
xorl %r14d, %r14d
movq %r14, %rax
shlq $0x8, %rax
leaq (%rax,%rbp), %rbx
addq $-0x5860, %rbx          # imm = 0xA7A0
movq %rbx, %rdi
callq 0x1d2ee
testl %eax, %eax
je 0x22fc1
movq %rbx, %rdi
callq 0x1d902
testb $0x1, %r14b
jne 0x22f29
movq %r15, %rdi
callq 0x1d2ee
movl %eax, %r13d
jmp 0x22fb3
movslq -0x34(%rbp), %r15
testq %r15, %r15
jle 0x22fe3
movq %rbx, %rdi
callq 0x8290
movq %rax, %r13
leaq -0x3060(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x82f0
testl %eax, %eax
je 0x22f68
addq $0x100, %r12            # imm = 0x100
decq %r15
jne 0x22f48
jmp 0x22fe3
movq 0x20(%rbp), %r15
movq %r15, %rdi
callq 0x1d2ee
movl %eax, %r13d
movq %r12, %rdi
movl $0x3d, %esi
callq 0x1d54b
movl %eax, %ebx
leal 0x1(%rbx), %eax
movl %eax, -0x2c(%rbp)
movq %r12, %rdi
callq 0x8290
notl %ebx
addl %eax, %ebx
leaq -0x860(%rbp), %rdi
movq %r12, %rsi
movl -0x2c(%rbp), %edx
movl %ebx, %ecx
callq 0x1d336
leaq -0x860(%rbp), %rbx
movslq %r13d, %rdi
addq %r15, %rdi
movq %rbx, %rsi
callq 0x85c0
incq %r14
movslq -0x30(%rbp), %rax
cmpq %rax, %r14
jl 0x22ee9
addq $0x5838, %rsp           # imm = 0x5838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4876a(%rip), %rdi     # 0x6b754
movq %rbx, %rsi
movq -0x40(%rbp), %rdx
xorl %eax, %eax
callq 0x8080
movl $0x1, %edi
callq 0x87b0
leaq 0x486bd(%rip), %rdi     # 0x6b6c6
movq -0x40(%rbp), %rsi
xorl %eax, %eax
callq 0x8080
jmp 0x22ff8
nop