// File: /workspace/github_cpp_makefile_star2_O2/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 $0x200a8, %rsp          # imm = 0x200A8
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x354a
movq 0x10(%rbx), %rdx
incq %rdx
leaq 0x40(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %r14, %rsi
callq 0x2250
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
movq %r12, %rdi
callq 0x2e66
movq %rax, %r14
movl 0x1c(%rax), %edx
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x4262
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %r15
movq %r15, %rsi
callq 0x22a0
movq %r15, %rdi
callq 0x2120
movl 0x20(%r14), %edx
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x432a
movq %rsp, %rdi
leaq 0x80(%rsp), %r15
movq %r15, %rsi
callq 0x22a0
movq %r15, %rdi
callq 0x2120
callq 0x2050
movq %rax, %r15
movq %r12, %rdi
callq 0x2e66
movq %r15, %rdi
movq %rax, %rsi
callq 0x20f0
cmpq $0x0, 0x28(%rsp)
je 0x33e9
movq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x2190
cmpq $0x0, 0x8(%rsp)
je 0x33fd
movq (%rsp), %rsi
movq %r15, %rdi
callq 0x22e0
movq 0x40(%rsp), %rsi
movq %r15, %rdi
callq 0x2150
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x2300
testl %eax, %eax
jne 0x34ca
movq 0x60(%rsp), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x21c0
movl %eax, %ebp
testl %eax, %eax
js 0x34ee
leaq 0xa0(%rsp), %rsi
movl $0x20000, %edx          # imm = 0x20000
movl %ebp, %edi
callq 0x2310
xorl %r13d, %r13d
leaq 0xa0(%rsp), %r12
testq %rax, %rax
jle 0x3483
movq (%rbx), %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2280
cltq
addq %rax, %r13
cmpq 0x30(%r14), %r13
jge 0x3483
movl $0x20000, %edx          # imm = 0x20000
movl %ebp, %edi
movq %r12, %rsi
callq 0x2310
jmp 0x3454
movl %ebp, %edi
callq 0x2430
movq %r15, %rdi
callq 0x2060
movq %rsp, %rdi
callq 0x2120
leaq 0x20(%rsp), %rdi
callq 0x2120
leaq 0x40(%rsp), %rdi
callq 0x2120
leaq 0x60(%rsp), %rdi
callq 0x2120
addq $0x200a8, %rsp          # imm = 0x200A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%rsp), %r14
movq (%rbx), %rdi
callq 0x21e0
leaq 0x2b82(%rip), %rsi      # 0x6060
pushq $0x1
popq %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x23d0
movq 0x60(%rsp), %rdx
leaq 0x2b8a(%rip), %rsi      # 0x6084
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x2210
jmp 0x3519
jmp 0x3519
jmp 0x3519
jmp 0x3519
movq %rax, %rbx
jmp 0x3538
jmp 0x3519
jmp 0x3519
jmp 0x3519
jmp 0x3519
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2120
leaq 0x20(%rsp), %rdi
callq 0x2120
leaq 0x40(%rsp), %rdi
callq 0x2120
leaq 0x60(%rsp), %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x2390