// File: /workspace/github_cpp_makefile_star2_O2/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, -0x40(%rbp)
movl %r8d, %r13d
movq %rcx, -0x60(%rbp)
movq %rdx, -0x38(%rbp)
movl %esi, %r15d
movq %rdi, %rbx
movq 0x20(%rbp), %r12
movl %r8d, -0x54(%rbp)
leaq -0x460(%rbp), %rdi
xorl %r14d, %r14d
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x8390
testl %r15d, %r15d
je 0x1f0be
leaq -0x460(%rbp), %rdi
movq %r12, %rsi
callq 0x85c0
movq %r12, %r15
jmp 0x1f119
movl 0xc800(%rbx), %eax
testl %eax, %eax
cmovgl %eax, %r14d
incq %r14
decq %r14
je 0x1f102
leaq 0x100(%rbx), %r15
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x8890
movq %r15, %rbx
testl %eax, %eax
jne 0x1f0cd
addq $0x6300, %r15           # imm = 0x6300
leaq -0x460(%rbp), %rdi
movq %r15, %rsi
callq 0x85c0
leaq -0x460(%rbp), %rdi
callq 0x1a3ea
testl %eax, %eax
movq %r12, %r15
je 0x1f49e
movl $0x100, %r10d           # imm = 0x100
leaq -0x5860(%rbp), %rax
leaq -0x460(%rbp), %rsi
pushq $0x20
popq %rbx
pushq $0x2d
popq %r8
leaq -0x50(%rbp), %r9
xorl %edi, %edi
movl %ebx, %edx
movl %ebx, %ecx
pushq %r10
movl $0x100, %r12d           # imm = 0x100
pushq %rax
callq 0x1a986
popq %rax
popq %rcx
leaq -0x860(%rbp), %r14
movq %r14, %rdi
movq -0x60(%rbp), %rsi
callq 0x85c0
leaq -0x3060(%rbp), %rax
pushq $0x1
popq %rdi
pushq $0x3a
popq %r8
leaq -0x2c(%rbp), %r9
movq %r14, %rsi
movl %ebx, %edx
movl %ebx, %ecx
pushq %r12
pushq %rax
callq 0x1a986
popq %rax
popq %rcx
movl %r13d, %edi
movl %r13d, %r14d
movl -0x40(%rbp), %r13d
movl %r13d, %esi
movl 0x10(%rbp), %r12d
movl %r12d, %edx
callq 0x19b34
movl %eax, %ebx
leaq -0x4c(%rbp), %rcx
leaq -0x48(%rbp), %r8
movl %r14d, %edi
movl %r13d, %esi
movl %r12d, %edx
callq 0x19bd3
leaq -0x54(%rbp), %r13
leaq -0x44(%rbp), %rdx
movl %ebx, %edi
movl %ebx, %r14d
movq %r13, %rsi
callq 0x19c33
leaq -0x2c(%rbp), %r12
movslq (%r12), %rax
shlq $0x8, %rax
leaq (%rax,%rbp), %rdi
addq $-0x3060, %rdi          # imm = 0xCFA0
movl (%r13), %eax
pushq $0xa
popq %rcx
cltd
idivl %ecx
leaq 0x424f8(%rip), %rsi     # 0x616ea
xorl %eax, %eax
callq 0x8110
movslq (%r12), %rax
shlq $0x8, %rax
leaq -0x3060(%rbp), %rbx
leaq (%rax,%rbx), %rdi
addq $0x100, %rdi            # imm = 0x100
movl (%r13), %eax
pushq $0x64
popq %rcx
cltd
idivl %ecx
leaq 0x424ce(%rip), %rsi     # 0x616f2
xorl %eax, %eax
callq 0x8110
movslq (%r12), %rax
shlq $0x8, %rax
leaq (%rax,%rbx), %rdi
addq $0x200, %rdi            # imm = 0x200
movl (%r13), %edx
leaq 0x424b2(%rip), %rsi     # 0x616fb
xorl %eax, %eax
callq 0x8110
movslq (%r12), %rax
shlq $0x8, %rax
leaq (%rax,%rbx), %rdi
addq $0x300, %rdi            # imm = 0x300
leaq -0x44(%rbp), %rax
movl (%rax), %edx
leaq 0x42496(%rip), %rsi     # 0x61706
xorl %eax, %eax
callq 0x8110
movslq (%r12), %rax
shlq $0x8, %rax
leaq (%rax,%rbx), %rdi
addq $0x400, %rdi            # imm = 0x400
leaq 0x4247f(%rip), %rsi     # 0x61710
movl 0x18(%rbp), %edx
xorl %eax, %eax
callq 0x8110
movslq (%r12), %rax
shlq $0x8, %rax
leaq (%rax,%rbx), %rdi
addq $0x500, %rdi            # imm = 0x500
leaq -0x4c(%rbp), %r13
movl (%r13), %edx
leaq 0x4245c(%rip), %rsi     # 0x61719
xorl %eax, %eax
callq 0x8110
movslq (%r12), %rax
shlq $0x8, %rax
leaq (%rax,%rbx), %rdi
addq $0x600, %rdi            # imm = 0x600
movl (%r13), %edx
leaq 0x42441(%rip), %rsi     # 0x61723
xorl %eax, %eax
callq 0x8110
movslq (%r12), %rax
shlq $0x8, %rax
leaq (%rax,%rbx), %rdi
addq $0x700, %rdi            # imm = 0x700
imull $0xa, (%r13), %edx
leaq -0x48(%rbp), %rax
addl (%rax), %edx
leaq 0x42420(%rip), %rsi     # 0x6172e
xorl %eax, %eax
callq 0x8110
movslq (%r12), %rax
shlq $0x8, %rax
leaq (%rax,%rbx), %rdi
addq $0x800, %rdi            # imm = 0x800
leaq 0x4240b(%rip), %rsi     # 0x6173a
movl %r14d, %edx
xorl %eax, %eax
callq 0x8110
addl $0x9, (%r12)
movq %r15, %rdi
callq 0x8290
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x8390
xorl %ebx, %ebx
movslq -0x50(%rbp), %rax
cmpq %rax, %rbx
jge 0x1f46f
movq %rbx, %rax
shlq $0x8, %rax
leaq (%rax,%rbp), %r12
addq $-0x5860, %r12          # imm = 0xA7A0
movq %r12, %rdi
callq 0x1a3ea
testl %eax, %eax
je 0x1f467
movq %r12, %rdi
callq 0x1a947
testb $0x1, %bl
jne 0x1f3a1
movq %r15, %rdi
callq 0x1a3ea
movl %eax, %r13d
jmp 0x1f459
movq %rbx, -0x40(%rbp)
movl -0x2c(%rbp), %ebx
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
shlq $0x8, %rbx
addq $0x100, %rbx            # imm = 0x100
leaq -0x3060(%rbp), %r13
xorl %r15d, %r15d
addq $-0x100, %r15
movq %rbx, %rax
addq %r15, %rax
je 0x1f481
leaq 0x100(%r13), %r14
movq %r12, %rdi
callq 0x8290
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x8300
movq %r14, %r13
testl %eax, %eax
jne 0x1f3c7
movq 0x20(%rbp), %r14
movq %r14, %rdi
callq 0x1a3ea
movl %eax, %r13d
leaq -0x3160(%rbp), %r12
subq %r15, %r12
movq %r12, %rdi
pushq $0x3d
popq %rsi
callq 0x1a5f7
movl %eax, %r15d
leal 0x1(%r15), %ebx
movq %r12, %rdi
callq 0x8290
notl %r15d
addl %eax, %r15d
leaq -0x860(%rbp), %rdi
movq %r12, %rsi
movl %ebx, %edx
movl %r15d, %ecx
movq %r14, %r15
callq 0x1a42f
leaq -0x860(%rbp), %r12
movq -0x40(%rbp), %rbx
movslq %r13d, %rdi
addq %r15, %rdi
movq %r12, %rsi
callq 0x85c0
incq %rbx
jmp 0x1f355
addq $0x5838, %rsp           # imm = 0x5838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x422bc(%rip), %rdi     # 0x61744
movq %r12, %rsi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x8070
pushq $0x1
popq %rdi
callq 0x8790
leaq 0x42211(%rip), %rdi     # 0x616b6
movq -0x38(%rbp), %rsi
xorl %eax, %eax
callq 0x8070
jmp 0x1f496
nop