// File: /workspace/github_cpp_makefile_star2_O3/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 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x3d7a
movq 0x10(%rbx), %rdx
incq %rdx
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
movq $-0x1, %rcx
callq 0x2260
leaq 0x30(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x10(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq %r12, %rdi
callq 0x33d8
movq %rax, %r14
movl 0x1c(%rax), %edx
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x54fc
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %r15
movq %r15, %rsi
callq 0x22b0
movq (%r15), %rdi
leaq 0x50(%rsp), %r13
cmpq %r13, %rdi
je 0x3b0f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2250
movl 0x20(%r14), %edx
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x5642
movq %rsp, %rdi
leaq 0x40(%rsp), %r15
movq %r15, %rsi
callq 0x22b0
movq (%r15), %rdi
cmpq %r13, %rdi
je 0x3b45
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2250
callq 0x2060
movq %rax, %r15
movq %r12, %rdi
callq 0x33d8
movq %r15, %rdi
movq %rax, %rsi
callq 0x2110
cmpq $0x0, 0x28(%rsp)
je 0x3b75
movq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x21a0
cmpq $0x0, 0x8(%rsp)
je 0x3b89
movq (%rsp), %rsi
movq %r15, %rdi
callq 0x22d0
movq 0x60(%rsp), %rsi
movq %r15, %rdi
callq 0x2150
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x22f0
testl %eax, %eax
jne 0x3ca6
movq 0x80(%rsp), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x21d0
movl %eax, %ebp
testl %eax, %eax
js 0x3ccc
leaq 0xa0(%rsp), %rsi
movl $0x20000, %edx          # imm = 0x20000
movl %ebp, %edi
callq 0x2300
xorl %r13d, %r13d
leaq 0xa0(%rsp), %r12
testq %rax, %rax
jle 0x3c12
movq (%rbx), %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2290
cltq
addq %rax, %r13
cmpq 0x30(%r14), %r13
jge 0x3c12
movl $0x20000, %edx          # imm = 0x20000
movl %ebp, %edi
movq %r12, %rsi
callq 0x2300
jmp 0x3be3
movl %ebp, %edi
callq 0x2410
movq %r15, %rdi
callq 0x2070
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3c3c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2250
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3c58
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c73
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c94
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x2250
addq $0x200a8, %rsp          # imm = 0x200A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x60(%rsp), %r14
movq (%rbx), %rdi
callq 0x21f0
leaq 0x43a6(%rip), %rsi      # 0x8060
movl $0x1, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x23d0
movq 0x80(%rsp), %rdx
leaq 0x43a9(%rip), %rsi      # 0x8084
movl $0x1, %edi
xorl %eax, %eax
callq 0x2220
jmp 0x3cfc
jmp 0x3cfc
jmp 0x3cfc
jmp 0x3cfc
movq %rax, %rbx
jmp 0x3d51
jmp 0x3cfc
jmp 0x3cfc
jmp 0x3cfc
jmp 0x3cfc
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3d1a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2250
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3d36
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3d51
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3d72
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x2390