// File: /workspace/github_cpp_makefile_star2_O1/chlunde[P]qtar/qtar.cc
// Function: Traverser<CScan>::addfile(us_dirent&)
void addfile(struct us_dirent& file) {
		std::string fq = file.fq();
		char buff[1024 * 128];
		std::string rel = fq.substr(root.length() + 1);
		std::string uname, gname;
		const struct stat& st = file.stat();
		uname = lookup_uname(st.st_uid);
		gname = lookup_gname(st.st_gid);
#if 0
		std::cout << "addfile " << fq << "\t" << file.d_ino << "\t" << file.is_file() << "\t" << uname << "\t" << gname << "\t" << rel << std::endl;
#endif

		struct archive_entry *entry = archive_entry_new();

		archive_entry_copy_stat(entry, &file.stat());
		if (uname.size())
			archive_entry_set_uname(entry, uname.c_str());
		if (gname.size())
			archive_entry_set_gname(entry, gname.c_str());
		archive_entry_set_pathname(entry, rel.c_str());
		int r = archive_write_header(a, entry);
		if (r != ARCHIVE_OK)
			errx(EXIT_FAILURE, "archive_write_header failed: %s, %s", rel.c_str(), archive_error_string(a));

		//std::cout << file.d_name << std::endl;
		int fd = open(fq.c_str(), O_RDONLY);
		if (fd < 0)
			err(EXIT_FAILURE, "open(%s) failed", fq.c_str());

		ssize_t len = read(fd, buff, sizeof(buff));
		ssize_t written = 0;
		while (len > 0) {
			int bytes_written = archive_write_data(a, buff, len);
			written += bytes_written;
			//std::cout << "write " << len << " - " << bytes_written << std::endl;
			if (written < st.st_size)
				len = read(fd, buff, sizeof(buff));
			else
				break;
		}
		close(fd);
		archive_entry_free(entry);
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x200b8, %rsp          # imm = 0x200B8
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x3d9c
movq %rbx, (%rsp)
movq 0x10(%rbx), %rdx
incq %rdx
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
movq $-0x1, %rcx
callq 0x2260
leaq 0x38(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq %r12, %rdi
callq 0x33c4
movq %rax, %r14
movl 0x1c(%rax), %edx
leaq 0x50(%rsp), %rdi
movq (%rsp), %rsi
callq 0x553e
leaq 0x28(%rsp), %rdi
leaq 0x50(%rsp), %r15
movq %r15, %rsi
callq 0x22b0
movq (%r15), %rdi
leaq 0x60(%rsp), %r13
cmpq %r13, %rdi
je 0x3b00
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2250
movl 0x20(%r14), %edx
leaq 0x50(%rsp), %rdi
movq (%rsp), %rsi
callq 0x5688
leaq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %r15
movq %r15, %rsi
callq 0x22b0
movq (%r15), %rdi
cmpq %r13, %rdi
je 0x3b39
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2250
callq 0x2060
movq %rax, %rbx
movq %r12, %rdi
callq 0x33c4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2110
cmpq $0x0, 0x30(%rsp)
je 0x3b69
movq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x21a0
cmpq $0x0, 0x10(%rsp)
je 0x3b7e
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x22d0
movq 0x70(%rsp), %rsi
movq %rbx, %rdi
callq 0x2150
movq (%rsp), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x22f0
testl %eax, %eax
jne 0x3cbd
movq 0x90(%rsp), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x21d0
movl %eax, %ebp
testl %eax, %eax
js 0x3ce7
movq %rbx, 0x48(%rsp)
leaq 0xb0(%rsp), %rsi
movl $0x20000, %edx          # imm = 0x20000
movl %ebp, %edi
callq 0x2300
movq %rax, %r13
xorl %r15d, %r15d
leaq 0xb0(%rsp), %r12
testq %r13, %r13
jle 0x3c20
movq (%rsp), %rax
movq (%rax), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2290
cltq
addq %rax, %r15
movq 0x30(%r14), %rbx
cmpq %rbx, %r15
jge 0x3c1b
movl $0x20000, %edx          # imm = 0x20000
movl %ebp, %edi
movq %r12, %rsi
callq 0x2300
movq %rax, %r13
cmpq %rbx, %r15
jl 0x3be4
movl %ebp, %edi
callq 0x2410
movq 0x48(%rsp), %rdi
callq 0x2070
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3c4d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2250
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3c69
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c8a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3cab
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2250
addq $0x200b8, %rsp          # imm = 0x200B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x70(%rsp), %r14
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x21f0
leaq 0x438b(%rip), %rsi      # 0x8060
movl $0x1, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x23d0
movq 0x90(%rsp), %rdx
leaq 0x438e(%rip), %rsi      # 0x8084
movl $0x1, %edi
xorl %eax, %eax
callq 0x2220
jmp 0x3d17
jmp 0x3d17
jmp 0x3d17
jmp 0x3d17
movq %rax, %rbx
jmp 0x3d73
jmp 0x3d17
jmp 0x3d17
jmp 0x3d17
jmp 0x3d17
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3d36
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2250
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3d52
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3d73
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3d94
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x2390