// File: 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
subq $0x58b0, %rsp           # imm = 0x58B0
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x5868(%rbp)
leaq -0x830(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x93d0
cmpl $0x0, -0xc(%rbp)
je 0x3e6e5
leaq -0x830(%rbp), %rdi
movq 0x20(%rbp), %rsi
callq 0x96f0
jmp 0x3e793
movl $0x0, -0x5854(%rbp)
movq -0x5868(%rbp), %rcx
movl -0x5854(%rbp), %eax
cmpl 0xc800(%rcx), %eax
jge 0x3e764
movq -0x5868(%rbp), %rdi
movslq -0x5854(%rbp), %rax
shlq $0x8, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x9a60
cmpl $0x0, %eax
jne 0x3e751
movq -0x5868(%rbp), %rsi
leaq -0x830(%rbp), %rdi
addq $0x6400, %rsi           # imm = 0x6400
movslq -0x5854(%rbp), %rax
shlq $0x8, %rax
addq %rax, %rsi
callq 0x96f0
jmp 0x3e764
jmp 0x3e753
movl -0x5854(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5854(%rbp)
jmp 0x3e6ef
leaq -0x830(%rbp), %rdi
callq 0x33d80
cmpl $0x0, %eax
jne 0x3e791
movq -0x18(%rbp), %rsi
leaq 0x7eef6(%rip), %rdi     # 0xbd676
movb $0x0, %al
callq 0x9090
movl $0x1, %edi
callq 0x9910
jmp 0x3e793
leaq -0x830(%rbp), %rsi
leaq -0x3050(%rbp), %rax
xorl %edi, %edi
movl $0x20, %ecx
movl $0x2d, %r8d
leaq -0x838(%rbp), %r9
movl %ecx, %edx
movq %rax, (%rsp)
movl $0x100, 0x8(%rsp)       # imm = 0x100
callq 0x34900
leaq -0x430(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x96f0
leaq -0x430(%rbp), %rsi
leaq -0x5850(%rbp), %rax
movl $0x1, %edi
movl $0x20, %ecx
movl $0x3a, %r8d
leaq -0x834(%rbp), %r9
movl %ecx, %edx
movq %rax, (%rsp)
movl $0x100, 0x8(%rsp)       # imm = 0x100
callq 0x34900
movl -0x24(%rbp), %edi
movl -0x28(%rbp), %esi
movl 0x10(%rbp), %edx
callq 0x32fe0
movl %eax, -0x83c(%rbp)
movl -0x24(%rbp), %edi
movl -0x28(%rbp), %esi
movl 0x10(%rbp), %edx
leaq -0x840(%rbp), %rcx
leaq -0x844(%rbp), %r8
callq 0x330e0
movl -0x83c(%rbp), %edi
leaq -0x24(%rbp), %rsi
leaq -0x848(%rbp), %rdx
callq 0x33170
movslq -0x834(%rbp), %rax
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl -0x24(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
leaq 0x7ee2d(%rip), %rsi     # 0xbd6aa
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x1, %eax
cltq
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl -0x24(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
leaq 0x7ee03(%rip), %rsi     # 0xbd6b2
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x2, %eax
cltq
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl -0x24(%rbp), %edx
leaq 0x7ede2(%rip), %rsi     # 0xbd6bb
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x3, %eax
cltq
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl -0x848(%rbp), %edx
leaq 0x7edc0(%rip), %rsi     # 0xbd6c6
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x4, %eax
cltq
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl 0x18(%rbp), %edx
leaq 0x7eda0(%rip), %rsi     # 0xbd6d0
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x5, %eax
cltq
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl -0x840(%rbp), %edx
leaq 0x7ed7c(%rip), %rsi     # 0xbd6d9
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x6, %eax
cltq
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl -0x840(%rbp), %edx
leaq 0x7ed59(%rip), %rsi     # 0xbd6e3
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x7, %eax
cltq
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
imull $0xa, -0x840(%rbp), %edx
addl -0x844(%rbp), %edx
leaq 0x7ed30(%rip), %rsi     # 0xbd6ee
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x8, %eax
cltq
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl -0x83c(%rbp), %edx
leaq 0x7ed0f(%rip), %rsi     # 0xbd6fa
movb $0x0, %al
callq 0x9150
movl -0x834(%rbp), %eax
addl $0x9, %eax
movl %eax, -0x834(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0x5870(%rbp)
movq 0x20(%rbp), %rdi
callq 0x92e0
movq -0x5870(%rbp), %rdi
movq %rax, %rdx
shlq $0x0, %rdx
xorl %esi, %esi
callq 0x93d0
movl $0x0, -0x5854(%rbp)
movl -0x5854(%rbp), %eax
cmpl -0x838(%rbp), %eax
jge 0x3eca1
movslq -0x5854(%rbp), %rax
leaq -0x3050(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
callq 0x33d80
cmpl $0x0, %eax
jne 0x3ea6a
jmp 0x3ec8d
movslq -0x5854(%rbp), %rax
leaq -0x3050(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
callq 0x34850
movl -0x5854(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x3ec54
movb $0x0, -0x849(%rbp)
movl $0x0, -0x5858(%rbp)
movl -0x5858(%rbp), %eax
cmpl -0x834(%rbp), %eax
jge 0x3ec18
movslq -0x5858(%rbp), %rcx
leaq -0x5850(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movq %rax, -0x5880(%rbp)
movslq -0x5854(%rbp), %rcx
leaq -0x3050(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movq %rax, -0x5878(%rbp)
movslq -0x5854(%rbp), %rax
leaq -0x3050(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
callq 0x92e0
movq -0x5880(%rbp), %rdi
movq -0x5878(%rbp), %rsi
movq %rax, %rdx
callq 0x9360
cmpl $0x0, %eax
jne 0x3ec02
movb $0x1, -0x849(%rbp)
movq 0x20(%rbp), %rdi
callq 0x33d80
movl %eax, -0x585c(%rbp)
movslq -0x5858(%rbp), %rax
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl $0x3d, %esi
callq 0x340b0
movl %eax, -0x5860(%rbp)
leaq -0x430(%rbp), %rax
movq %rax, -0x5898(%rbp)
movslq -0x5858(%rbp), %rcx
leaq -0x5850(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movq %rax, -0x5890(%rbp)
movl -0x5860(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5884(%rbp)
movslq -0x5858(%rbp), %rax
leaq -0x5850(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
callq 0x92e0
movq -0x5898(%rbp), %rdi
movq -0x5890(%rbp), %rsi
movl -0x5884(%rbp), %edx
movslq -0x5860(%rbp), %rcx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, %ecx
callq 0x33e20
movq 0x20(%rbp), %rdi
movslq -0x585c(%rbp), %rax
addq %rax, %rdi
leaq -0x430(%rbp), %rsi
callq 0x96f0
jmp 0x3ec18
jmp 0x3ec04
movl -0x5858(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5858(%rbp)
jmp 0x3eaac
testb $0x1, -0x849(%rbp)
jne 0x3ec52
movslq -0x5854(%rbp), %rax
leaq -0x3050(%rbp), %rsi
shlq $0x8, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rdx
leaq 0x7eac3(%rip), %rdi     # 0xbd704
movb $0x0, %al
callq 0x9090
movl $0x1, %edi
callq 0x9910
jmp 0x3ec8b
movq 0x20(%rbp), %rdi
callq 0x33d80
movl %eax, -0x585c(%rbp)
movq 0x20(%rbp), %rdi
movslq -0x585c(%rbp), %rax
addq %rax, %rdi
movslq -0x5854(%rbp), %rax
leaq -0x3050(%rbp), %rsi
shlq $0x8, %rax
addq %rax, %rsi
callq 0x96f0
jmp 0x3ec8d
movl -0x5854(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5854(%rbp)
jmp 0x3ea34
addq $0x58b0, %rsp           # imm = 0x58B0
popq %rbp
retq
nopw (%rax,%rax)