// File: auton1[P]viterbi/header.cpp
// Function: header::add_FILTER_descriptor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
int header::add_FILTER_descriptor(const string &in, int index)
{
	size_t found_end=in.find_last_of(">");
	string details = in.substr(0, found_end);
	vector<string> tokens;
	tokenize(details, ',', tokens);
	if (tokens.size() < 2)
		LOG.error("Expected at least 2 parts in FILTER definition: " + in);

	string Description;
	Field_description I;
	I.Field = "FILTER";
	vector<string> entry;

	for (unsigned int ui=0; ui<tokens.size(); ui++)
	{
		tokenize(tokens[ui], '=', entry);
		if (entry[0] == "ID") I.ID = entry[1];
		else if (entry[0] == "Description")
		{
			I.Description = entry[1];
		}
		else if (entry[0] == "IDX")
		{
			has_idx = true;
			I.idx = str2int(entry[1]);
		}
		else
		{
			if (I.Other != "")
				I.Other += ",";
			I.Other += tokens[ui];
		}
	}

	if (I.ID == "") LOG.error("ID required in FILTER field description: " + in);
	if (I.Description == "") LOG.error("Description required in FILTER field description: " + in);
	if ((I.idx == -1) && (has_idx)) LOG.error("Missing index in FILTER field description: " + in);
	if (I.ID != "PASS") parsed_lines.push_back(I);

	if (I.idx != -1)
	{
		FILTER_map[I.idx] = I;
		FILTER_reverse_map[I.ID] = I.idx;
		return 0;
	}
	else
	{
		if ( INFO_reverse_map.find( I.ID ) != INFO_reverse_map.end() )
		{
			FILTER_map[ INFO_reverse_map[ I.ID ] ] = I;
			FILTER_reverse_map[I.ID] = INFO_reverse_map[ I.ID ];
			return 0;
		}
		else if ( FORMAT_reverse_map.find( I.ID ) != FORMAT_reverse_map.end() )
		{
			FILTER_map[ FORMAT_reverse_map[ I.ID ] ] = I;
			FILTER_reverse_map[I.ID] = FORMAT_reverse_map[ I.ID ];
			return 0;
		}
		else if ( FILTER_reverse_map.find( I.ID ) != FILTER_reverse_map.end() )
			return 0;
		else
		{
			FILTER_map[index] = I;
			FILTER_reverse_map[I.ID] = index;
			return 1;
		}
	}
}

// Assembly:
subq $0x398, %rsp            # imm = 0x398
movq %rdi, 0x388(%rsp)
movq %rsi, 0x380(%rsp)
movl %edx, 0x37c(%rsp)
movq 0x388(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x380(%rsp), %rdi
leaq 0x478c9(%rip), %rsi     # 0x74b06
movq $-0x1, %rdx
callq 0x64f0
movq %rax, 0x370(%rsp)
movq 0x380(%rsp), %rsi
movq 0x370(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq 0x350(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x6580
leaq 0x338(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x10260
movq 0xd0(%rsp), %rdi
movq 0xd8(%rsp), %rdx
movl $0x2c, %esi
callq 0x2fa70
jmp 0x2d2ab
leaq 0x338(%rsp), %rdi
callq 0x10270
cmpq $0x2, %rax
jae 0x2d349
movq 0x380(%rsp), %rdx
leaq 0x47b5f(%rip), %rsi     # 0x74e30
leaq 0x308(%rsp), %rdi
callq 0xe8d0
jmp 0x2d2e0
leaq 0x66319(%rip), %rdi     # 0x93600
leaq 0x308(%rsp), %rsi
movl $0x1, %edx
callq 0x712f0
jmp 0x2d2fb
leaq 0x308(%rsp), %rdi
callq 0x6b50
jmp 0x2d349
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x2dcac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x308(%rsp), %rdi
callq 0x6b50
jmp 0x2dcac
leaq 0x2e8(%rsp), %rdi
callq 0x67e0
leaq 0x198(%rsp), %rdi
callq 0x30960
jmp 0x2d365
leaq 0x476db(%rip), %rsi     # 0x74a47
leaq 0x198(%rsp), %rdi
callq 0x67b0
jmp 0x2d37b
leaq 0x180(%rsp), %rdi
callq 0x10260
movl $0x0, 0x17c(%rsp)
movl 0x17c(%rsp), %eax
movq %rax, 0xc0(%rsp)
leaq 0x338(%rsp), %rdi
callq 0x10270
movq %rax, %rcx
movq 0xc0(%rsp), %rax
cmpq %rcx, %rax
jae 0x2d5fb
movl 0x17c(%rsp), %eax
movl %eax, %esi
leaq 0x338(%rsp), %rdi
callq 0x10290
movq %rax, %rdi
movl $0x3d, %esi
leaq 0x180(%rsp), %rdx
callq 0x2fa70
jmp 0x2d3f0
xorl %eax, %eax
movl %eax, %esi
leaq 0x180(%rsp), %rdi
callq 0x10290
movq %rax, %rdi
leaq 0x4759f(%rip), %rsi     # 0x749aa
callq 0xea20
movb %al, 0xbf(%rsp)
jmp 0x2d419
movb 0xbf(%rsp), %al
testb $0x1, %al
jne 0x2d426
jmp 0x2d49a
leaq 0x180(%rsp), %rdi
movl $0x1, %esi
callq 0x10290
movq %rax, %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x6060
jmp 0x2d44a
jmp 0x2d5e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x2dc9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x2dc92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x2dc85
xorl %eax, %eax
movl %eax, %esi
leaq 0x180(%rsp), %rdi
callq 0x10290
movq %rax, %rdi
leaq 0x47706(%rip), %rsi     # 0x74bbb
callq 0xea20
movb %al, 0xbe(%rsp)
jmp 0x2d4c3
movb 0xbe(%rsp), %al
testb $0x1, %al
jne 0x2d4d0
jmp 0x2d4f9
leaq 0x180(%rsp), %rdi
movl $0x1, %esi
callq 0x10290
movq %rax, %rsi
leaq 0x228(%rsp), %rdi
callq 0x6060
jmp 0x2d4f4
jmp 0x2d5e1
xorl %eax, %eax
movl %eax, %esi
leaq 0x180(%rsp), %rdi
callq 0x10290
movq %rax, %rdi
leaq 0x476c2(%rip), %rsi     # 0x74bd6
callq 0xea20
movb %al, 0xbd(%rsp)
jmp 0x2d522
movb 0xbd(%rsp), %al
testb $0x1, %al
jne 0x2d52f
jmp 0x2d573
movq 0xc8(%rsp), %rax
movb $0x1, 0x8(%rax)
leaq 0x180(%rsp), %rdi
movl $0x1, %esi
callq 0x10290
movq %rax, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x2fb70
movl %eax, 0xb8(%rsp)
jmp 0x2d563
movl 0xb8(%rsp), %eax
movl %eax, 0x1d8(%rsp)
jmp 0x2d5df
leaq 0x2c8(%rsp), %rdi
leaq 0x487a7(%rip), %rsi     # 0x75d29
callq 0x30930
movb %al, 0xb7(%rsp)
jmp 0x2d590
movb 0xb7(%rsp), %al
testb $0x1, %al
jne 0x2d59d
jmp 0x2d5b5
leaq 0x2c8(%rsp), %rdi
leaq 0x4762e(%rip), %rsi     # 0x74bda
callq 0x6510
jmp 0x2d5b3
jmp 0x2d5b5
movl 0x17c(%rsp), %eax
movl %eax, %esi
leaq 0x338(%rsp), %rdi
callq 0x10290
movq %rax, %rsi
leaq 0x2c8(%rsp), %rdi
callq 0x6730
jmp 0x2d5dd
jmp 0x2d5df
jmp 0x2d5e1
jmp 0x2d5e3
jmp 0x2d5e5
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x2d393
leaq 0x1b8(%rsp), %rdi
leaq 0x4871f(%rip), %rsi     # 0x75d29
callq 0xea20
movb %al, 0xb6(%rsp)
jmp 0x2d618
movb 0xb6(%rsp), %al
testb $0x1, %al
jne 0x2d625
jmp 0x2d693
movq 0x380(%rsp), %rdx
leaq 0x4782d(%rip), %rsi     # 0x74e61
leaq 0x158(%rsp), %rdi
callq 0xe8d0
jmp 0x2d643
leaq 0x65fb6(%rip), %rdi     # 0x93600
leaq 0x158(%rsp), %rsi
movl $0x1, %edx
callq 0x712f0
jmp 0x2d65e
leaq 0x158(%rsp), %rdi
callq 0x6b50
jmp 0x2d693
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x6b50
jmp 0x2dc85
leaq 0x228(%rsp), %rdi
leaq 0x48687(%rip), %rsi     # 0x75d29
callq 0xea20
movb %al, 0xb5(%rsp)
jmp 0x2d6b0
movb 0xb5(%rsp), %al
testb $0x1, %al
jne 0x2d6bd
jmp 0x2d72b
movq 0x380(%rsp), %rdx
leaq 0x477bf(%rip), %rsi     # 0x74e8b
leaq 0x138(%rsp), %rdi
callq 0xe8d0
jmp 0x2d6db
leaq 0x65f1e(%rip), %rdi     # 0x93600
leaq 0x138(%rsp), %rsi
movl $0x1, %edx
callq 0x712f0
jmp 0x2d6f6
leaq 0x138(%rsp), %rdi
callq 0x6b50
jmp 0x2d72b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x6b50
jmp 0x2dc85
cmpl $-0x1, 0x1d8(%rsp)
jne 0x2d7b1
movq 0xc8(%rsp), %rax
testb $0x1, 0x8(%rax)
je 0x2d7b1
movq 0x380(%rsp), %rdx
leaq 0x4776c(%rip), %rsi     # 0x74ebe
leaq 0x118(%rsp), %rdi
callq 0xe8d0
jmp 0x2d761
leaq 0x65e98(%rip), %rdi     # 0x93600
leaq 0x118(%rsp), %rsi
movl $0x1, %edx
callq 0x712f0
jmp 0x2d77c
leaq 0x118(%rsp), %rdi
callq 0x6b50
jmp 0x2d7b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x6b50
jmp 0x2dc85
leaq 0x1b8(%rsp), %rdi
leaq 0x46d64(%rip), %rsi     # 0x74524
callq 0x30930
movb %al, 0xb4(%rsp)
jmp 0x2d7ce
movb 0xb4(%rsp), %al
testb $0x1, %al
jne 0x2d7db
jmp 0x2d7f8
movq 0xc8(%rsp), %rdi
addq $0x40, %rdi
leaq 0x198(%rsp), %rsi
callq 0x30e70
jmp 0x2d7f6
jmp 0x2d7f8
cmpl $-0x1, 0x1d8(%rsp)
je 0x2d8a3
movq 0xc8(%rsp), %rdi
addq $0x90, %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x30ef0
movq %rax, 0xa8(%rsp)
jmp 0x2d82c
movq 0xa8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x22b00
jmp 0x2d843
movq 0xc8(%rsp), %rdi
movl 0x1d8(%rsp), %eax
movl %eax, 0x9c(%rsp)
addq $0x150, %rdi            # imm = 0x150
leaq 0x1b8(%rsp), %rsi
callq 0x30fe0
movq %rax, 0xa0(%rsp)
jmp 0x2d877
movq 0xa0(%rsp), %rax
movl 0x9c(%rsp), %ecx
movl %ecx, (%rax)
movl $0x0, 0x394(%rsp)
movl $0x1, 0x114(%rsp)
jmp 0x2dc35
movq 0xc8(%rsp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x1b8(%rsp), %rsi
callq 0x310f0
movq %rax, 0x90(%rsp)
jmp 0x2d8c9
movq 0xc8(%rsp), %rdi
movq 0x90(%rsp), %rax
movq %rax, 0x108(%rsp)
addq $0x180, %rdi            # imm = 0x180
callq 0x31120
movq %rax, 0x100(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x310d0
testb $0x1, %al
jne 0x2d913
jmp 0x2d9f1
movq 0xc8(%rsp), %rdi
movq %rdi, %rax
addq $0x90, %rax
movq %rax, 0x80(%rsp)
addq $0x180, %rdi            # imm = 0x180
leaq 0x1b8(%rsp), %rsi
callq 0x30fe0
movq %rax, 0x88(%rsp)
jmp 0x2d94a
movq 0x88(%rsp), %rsi
movq 0x80(%rsp), %rdi
callq 0x30ef0
movq %rax, 0x78(%rsp)
jmp 0x2d966
movq 0x78(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x22b00
jmp 0x2d97a
movq 0xc8(%rsp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x1b8(%rsp), %rsi
callq 0x30fe0
movq %rax, 0x70(%rsp)
jmp 0x2d99d
movq 0xc8(%rsp), %rdi
movq 0x70(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x64(%rsp)
addq $0x150, %rdi            # imm = 0x150
leaq 0x1b8(%rsp), %rsi
callq 0x30fe0
movq %rax, 0x68(%rsp)
jmp 0x2d9cb
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
movl %ecx, (%rax)
movl $0x0, 0x394(%rsp)
movl $0x1, 0x114(%rsp)
jmp 0x2dc35
movq 0xc8(%rsp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
leaq 0x1b8(%rsp), %rsi
callq 0x310f0
movq %rax, 0x58(%rsp)
jmp 0x2da14
movq 0xc8(%rsp), %rdi
movq 0x58(%rsp), %rax
movq %rax, 0xf8(%rsp)
addq $0x1b0, %rdi            # imm = 0x1B0
callq 0x31120
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x310d0
testb $0x1, %al
jne 0x2da5b
jmp 0x2db2d
movq 0xc8(%rsp), %rdi
movq %rdi, %rax
addq $0x90, %rax
movq %rax, 0x48(%rsp)
addq $0x1b0, %rdi            # imm = 0x1B0
leaq 0x1b8(%rsp), %rsi
callq 0x30fe0
movq %rax, 0x50(%rsp)
jmp 0x2da8c
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x30ef0
movq %rax, 0x40(%rsp)
jmp 0x2daa2
movq 0x40(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x22b00
jmp 0x2dab6
movq 0xc8(%rsp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
leaq 0x1b8(%rsp), %rsi
callq 0x30fe0
movq %rax, 0x38(%rsp)
jmp 0x2dad9
movq 0xc8(%rsp), %rdi
movq 0x38(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
addq $0x150, %rdi            # imm = 0x150
leaq 0x1b8(%rsp), %rsi
callq 0x30fe0
movq %rax, 0x30(%rsp)
jmp 0x2db07
movq 0x30(%rsp), %rax
movl 0x2c(%rsp), %ecx
movl %ecx, (%rax)
movl $0x0, 0x394(%rsp)
movl $0x1, 0x114(%rsp)
jmp 0x2dc35
movq 0xc8(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
leaq 0x1b8(%rsp), %rsi
callq 0x310f0
movq %rax, 0x20(%rsp)
jmp 0x2db50
movq 0xc8(%rsp), %rdi
movq 0x20(%rsp), %rax
movq %rax, 0xe8(%rsp)
addq $0x150, %rdi            # imm = 0x150
callq 0x31120
movq %rax, 0xe0(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x310d0
testb $0x1, %al
jne 0x2db94
jmp 0x2dbaf
movl $0x0, 0x394(%rsp)
movl $0x1, 0x114(%rsp)
jmp 0x2dc35
movq 0xc8(%rsp), %rdi
addq $0x90, %rdi
leaq 0x37c(%rsp), %rsi
callq 0x30ef0
movq %rax, 0x18(%rsp)
jmp 0x2dbd2
movq 0x18(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x22b00
jmp 0x2dbe6
movq 0xc8(%rsp), %rdi
movl 0x37c(%rsp), %eax
movl %eax, 0xc(%rsp)
addq $0x150, %rdi            # imm = 0x150
leaq 0x1b8(%rsp), %rsi
callq 0x30fe0
movq %rax, 0x10(%rsp)
jmp 0x2dc14
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movl $0x1, 0x394(%rsp)
movl $0x1, 0x114(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x10cc0
leaq 0x198(%rsp), %rdi
callq 0x22620
leaq 0x2e8(%rsp), %rdi
callq 0x6b50
leaq 0x338(%rsp), %rdi
callq 0x10cc0
leaq 0x350(%rsp), %rdi
callq 0x6b50
movl 0x394(%rsp), %eax
addq $0x398, %rsp            # imm = 0x398
retq
leaq 0x180(%rsp), %rdi
callq 0x10cc0
leaq 0x198(%rsp), %rdi
callq 0x22620
leaq 0x2e8(%rsp), %rdi
callq 0x6b50
leaq 0x338(%rsp), %rdi
callq 0x10cc0
leaq 0x350(%rsp), %rdi
callq 0x6b50
movq 0x330(%rsp), %rdi
callq 0x69e0
nopw %cs:(%rax,%rax)