// File: /workspace/github_c_makefile_star2_O0/hcmiya[P]opuscomment/src/retrieve-tags.c
// Function: rtcopy_delete
static bool rtcopy_delete(FILE *packet_input, void *fptag_) {
	static int idx = 1;
	FILE *fptag = fptag_;
	
	// -dの引数と一つずつ比較していくための準備として、レコード1つを一時ファイルrtcd_srcに書き出す
	rewind(rtcd_src);
	uint32_t srclen = rtchunk(packet_input);
	uint8_t buf[STACK_BUF_LEN];
	size_t len = srclen;
	while (len) {
		// フィールド名を大文字化する
		bool field = true;
		size_t rl = rtfill(buf, len, STACK_BUF_LEN, packet_input);
		test_tag_field(buf, rl, true, &field, &upcase_applied);
		fwrite(buf, 1, rl, rtcd_src);
		len -= rl;
		if (!field) break;
	}
	while (len) {
		// フィールド名を抜けた後のループ
		size_t rl = rtfill(buf, len, STACK_BUF_LEN, packet_input);
		fwrite(buf, 1, rl, rtcd_src);
		len -= rl;
	}
	
	// 削除リストのループ
	rewind(dellist_str); rewind(dellist_len);
	bool matched = false;
	while (fread(buf, 1, 5, dellist_len)) {
		uint32_t cmplen = *(uint32_t*)buf;
		bool field_only = buf[4];
		
		size_t const bufhalf = STACK_BUF_LEN / 2;
		uint8_t *cmp = buf + bufhalf;
		rewind(rtcd_src);
		// 比較
		if (field_only && srclen > cmplen || cmplen == srclen) {
			// フィールド名のみ比較でソースが削除指定より長い または
			// 全比較でソースと削除の長さが一致する時
			matched = true;
			while (cmplen) {
				size_t rl = fill_buffer(buf, cmplen, bufhalf, rtcd_src);
				fread(cmp, 1, rl, dellist_str);
				cmplen -= rl;
				if (memcmp(buf, cmp, rl) != 0) {
					matched = false;
					break;
				}
			}
			if (matched) {
				if (field_only) {
					fread(buf, 1, 1, rtcd_src);
					if (*buf == 0x3d) {
						goto MATCHED;
					}
					matched = false;
				}
				else {
					goto MATCHED;
				}
			}
		}
		// 次の削除チャンクに進む
		while (cmplen) {
			cmplen -= fill_buffer(buf, cmplen, STACK_BUF_LEN, dellist_str);
		}
	}
	// 削除するものと一致しなかったらfptagにコピー
	rewind(rtcd_src);
	*(uint32_t*)buf = oi32(srclen);
	fwrite(buf, 4, 1, fptag);
	check_tagpacket_length(4);
	while (srclen) {
		size_t rl = fill_buffer(buf, srclen, STACK_BUF_LEN, rtcd_src);
		fwrite(buf, 1, rl, fptag);
		srclen -= rl;
		check_tagpacket_length(rl);
	}
	idx++;
MATCHED:
	return !matched;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1070, %rsp           # imm = 0x1070
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq 0x160a6(%rip), %rdi     # 0x1d688
callq 0x2160
movq -0x8(%rbp), %rdi
callq 0x7360
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq %rax, -0x1028(%rbp)
cmpq $0x0, -0x1028(%rbp)
je 0x76a2
movb $0x1, -0x1029(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x1028(%rbp), %rsi
movq -0x8(%rbp), %rcx
movl $0x1000, %edx           # imm = 0x1000
callq 0x7390
movq %rax, -0x1038(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x1038(%rbp), %rsi
movl $0x1, %edx
leaq -0x1029(%rbp), %rcx
leaq 0x16042(%rip), %r8      # 0x1d698
callq 0x6880
leaq -0x1020(%rbp), %rdi
movq -0x1038(%rbp), %rdx
movq 0x16018(%rip), %rcx     # 0x1d688
movl $0x1, %esi
callq 0x2490
movq -0x1038(%rbp), %rcx
movq -0x1028(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x1028(%rbp)
testb $0x1, -0x1029(%rbp)
jne 0x769d
jmp 0x76a2
jmp 0x75fd
jmp 0x76a4
cmpq $0x0, -0x1028(%rbp)
je 0x770a
leaq -0x1020(%rbp), %rdi
movq -0x1028(%rbp), %rsi
movq -0x8(%rbp), %rcx
movl $0x1000, %edx           # imm = 0x1000
callq 0x7390
movq %rax, -0x1040(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x1040(%rbp), %rdx
movq 0x15fa2(%rip), %rcx     # 0x1d688
movl $0x1, %esi
callq 0x2490
movq -0x1040(%rbp), %rcx
movq -0x1028(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x1028(%rbp)
jmp 0x76a4
movq 0x15f6f(%rip), %rdi     # 0x1d680
callq 0x2160
movq 0x15f73(%rip), %rdi     # 0x1d690
callq 0x2160
movb $0x0, -0x1041(%rbp)
leaq -0x1020(%rbp), %rdi
movq 0x15f59(%rip), %rcx     # 0x1d690
movl $0x1, %esi
movl $0x5, %edx
callq 0x20e0
cmpq $0x0, %rax
je 0x78ed
movl -0x1020(%rbp), %eax
movl %eax, -0x1048(%rbp)
cmpb $0x0, -0x101c(%rbp)
setne %al
andb $0x1, %al
movb %al, -0x1049(%rbp)
movq $0x800, -0x1058(%rbp) # imm = 0x800
leaq -0x1020(%rbp), %rax
addq $0x800, %rax            # imm = 0x800
movq %rax, -0x1060(%rbp)
movq 0x15ef4(%rip), %rdi     # 0x1d688
callq 0x2160
testb $0x1, -0x1049(%rbp)
je 0x77ad
movl -0x1c(%rbp), %eax
cmpl -0x1048(%rbp), %eax
ja 0x77bc
movl -0x1048(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x78a9
movb $0x1, -0x1041(%rbp)
cmpl $0x0, -0x1048(%rbp)
je 0x7859
leaq -0x1020(%rbp), %rdi
movl -0x1048(%rbp), %eax
movl %eax, %esi
movq 0x15ea2(%rip), %rcx     # 0x1d688
movl $0x800, %edx            # imm = 0x800
callq 0x6a60
movq %rax, -0x1068(%rbp)
movq -0x1060(%rbp), %rdi
movq -0x1068(%rbp), %rdx
movq 0x15e74(%rip), %rcx     # 0x1d680
movl $0x1, %esi
callq 0x20e0
movq -0x1068(%rbp), %rcx
movl -0x1048(%rbp), %eax
subq %rcx, %rax
movl %eax, -0x1048(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x1060(%rbp), %rsi
movq -0x1068(%rbp), %rdx
callq 0x2230
cmpl $0x0, %eax
je 0x7854
movb $0x0, -0x1041(%rbp)
jmp 0x7859
jmp 0x77c3
testb $0x1, -0x1041(%rbp)
je 0x78a7
testb $0x1, -0x1049(%rbp)
je 0x78a0
leaq -0x1020(%rbp), %rdi
movq 0x15e0f(%rip), %rcx     # 0x1d688
movl $0x1, %edx
movq %rdx, %rsi
callq 0x20e0
movzbl -0x1020(%rbp), %eax
cmpl $0x3d, %eax
jne 0x7897
jmp 0x799e
movb $0x0, -0x1041(%rbp)
jmp 0x78a5
jmp 0x799e
jmp 0x78a7
jmp 0x78a9
jmp 0x78ab
cmpl $0x0, -0x1048(%rbp)
je 0x78e8
leaq -0x1020(%rbp), %rdi
movl -0x1048(%rbp), %eax
movl %eax, %esi
movq 0x15db6(%rip), %rcx     # 0x1d680
movl $0x1000, %edx           # imm = 0x1000
callq 0x6a60
movq %rax, %rcx
movl -0x1048(%rbp), %eax
subq %rcx, %rax
movl %eax, -0x1048(%rbp)
jmp 0x78ab
jmp 0x7729
movq 0x15d94(%rip), %rdi     # 0x1d688
callq 0x2160
movl -0x1c(%rbp), %edi
callq 0x84f0
movl %eax, -0x1020(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x2490
movl $0x4, %edi
callq 0x6cf0
cmpl $0x0, -0x1c(%rbp)
je 0x798f
leaq -0x1020(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
movq 0x15d44(%rip), %rcx     # 0x1d688
movl $0x1000, %edx           # imm = 0x1000
callq 0x6a60
movq %rax, -0x1070(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x1070(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %esi
callq 0x2490
movq -0x1070(%rbp), %rcx
movl -0x1c(%rbp), %eax
subq %rcx, %rax
movl %eax, -0x1c(%rbp)
movq -0x1070(%rbp), %rdi
callq 0x6cf0
jmp 0x792b
movl 0x594b(%rip), %eax      # 0xd2e0
addl $0x1, %eax
movl %eax, 0x5942(%rip)      # 0xd2e0
movb -0x1041(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
addq $0x1070, %rsp           # imm = 0x1070
popq %rbp
retq
nopw %cs:(%rax,%rax)