// File: chlunde[P]qtar/qtar.cc
// Function: Traverser<CScan>::heapwalk(us_dirent&)
void heapwalk(struct us_dirent& dirent) {
//		std::cout << "heapwalk " << dirent.d_ino << "\t" << dirent.d_name << std::endl;

		if (dirent.is_file() || dirent.is_link()) {
			queuefile(dirent);
			return;
		}

		std::string path;
		if (dirent.d_name != ".") {
			path = dirent.parent + "/" + dirent.d_name;
		} else  {
			path = dirent.parent;
		}

#if 0
		static long long a;
		std::cout << (long long)(dirent.d_ino - a) << std::endl;
		a = dirent.d_ino;
#endif
		if (dirent.is_unknown()) {
			struct stat& buf = dirent.stat();

			if (S_ISDIR(buf.st_mode)) {
				dirent.set_is_dir();
			} else {
				dirent.set_is_file();
				queuefile(dirent);
				return;
			}
		}

		std::vector<struct us_dirent> l;
		if (dir_read(path, l) < 0) {
			//dirent.set_is_file();
			//addfile(dirent);
			std::cerr << "Error!" << std::endl;
			return;
		}

		sort(l.begin(), l.end());

		addpath(dirent);

		dirent.set_is_dir();
		//queue.push_back(dirent);

		for (std::vector<struct us_dirent>::iterator it = l.begin(); it != l.end(); ++it) {
			if (it->d_name == "." || it->d_name == "..")
				continue;

			if (!use_getdents_type)
				it->set_is_unknown();

			if (it->is_file()) {
				queuefile(*it);
			} else {
				dirheap.push(*it);
			}
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6f40
testb $0x1, %al
jne 0x591a
movq -0x10(%rbp), %rdi
callq 0x6f60
testb $0x1, %al
jne 0x591a
jmp 0x592f
movq -0x1b8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6f80
jmp 0x5cf7
leaq -0x30(%rbp), %rdi
callq 0x33a0
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
leaq 0x7717(%rip), %rsi      # 0xd05e
callq 0x7080
movb %al, -0x1b9(%rbp)
jmp 0x5954
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x5960
jmp 0x59dd
movq -0x10(%rbp), %rsi
addq $0x28, %rsi
leaq 0x76e5(%rip), %rdx      # 0xd054
leaq -0x80(%rbp), %rdi
callq 0x6290
jmp 0x597a
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x6240
jmp 0x5991
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3370
leaq -0x60(%rbp), %rdi
callq 0x31c0
leaq -0x80(%rbp), %rdi
callq 0x31c0
jmp 0x59f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x5d0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31c0
jmp 0x5d0c
movq -0x10(%rbp), %rsi
addq $0x28, %rsi
leaq -0x30(%rbp), %rdi
callq 0x3030
jmp 0x59f0
jmp 0x59f2
movq -0x10(%rbp), %rdi
callq 0x70b0
movb %al, -0x1ba(%rbp)
jmp 0x5a03
movb -0x1ba(%rbp), %al
testb $0x1, %al
jne 0x5a0f
jmp 0x5a7e
movq -0x10(%rbp), %rdi
callq 0x5440
movq %rax, -0x1c8(%rbp)
jmp 0x5a21
movq -0x1c8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movl 0x18(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x5a50
movq -0x10(%rbp), %rdi
callq 0x5420
jmp 0x5a7c
movq -0x10(%rbp), %rdi
callq 0x70d0
jmp 0x5a5b
movq -0x1b8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6f80
jmp 0x5a6d
movl $0x1, -0x8c(%rbp)
jmp 0x5cee
jmp 0x5a7e
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x70f0
movq -0x1d8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xbd70
movl %eax, -0x1cc(%rbp)
jmp 0x5aa9
movl -0x1cc(%rbp), %eax
cmpl $0x0, %eax
jge 0x5b05
movq 0xd535(%rip), %rdi      # 0x12ff0
leaq 0x7594(%rip), %rsi      # 0xd056
callq 0x32a0
movq %rax, -0x1e0(%rbp)
jmp 0x5ad0
movq -0x1e0(%rbp), %rdi
movq 0xd4e2(%rip), %rsi      # 0x12fc0
callq 0x32f0
jmp 0x5ae5
movl $0x1, -0x8c(%rbp)
jmp 0x5ce2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x5d00
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x7150
movq -0x1e8(%rbp), %rdi
movq %rax, -0xb0(%rbp)
callq 0x7180
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x7110
jmp 0x5b47
movq -0x1b8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x71b0
jmp 0x5b59
movq -0x10(%rbp), %rdi
callq 0x5420
leaq -0xa8(%rbp), %rdi
callq 0x7150
movq %rax, -0xc0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7180
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x74d0
testb $0x1, %al
jne 0x5ba4
jmp 0x5cd8
leaq -0xc0(%rbp), %rdi
callq 0x7510
movq %rax, %rdi
addq $0x8, %rdi
leaq 0x74a0(%rip), %rsi      # 0xd05e
callq 0x39a0
testb $0x1, %al
jne 0x5bec
leaq -0xc0(%rbp), %rdi
callq 0x7510
movq %rax, %rdi
addq $0x8, %rdi
leaq 0x747c(%rip), %rsi      # 0xd05d
callq 0x39a0
testb $0x1, %al
jne 0x5bec
jmp 0x5bf1
jmp 0x5cc7
testb $0x1, 0xd6b8(%rip)      # 0x132b0
jne 0x5c12
leaq -0xc0(%rbp), %rdi
callq 0x7510
movq %rax, %rdi
callq 0x7530
jmp 0x5c10
jmp 0x5c12
leaq -0xc0(%rbp), %rdi
callq 0x7510
movq %rax, %rdi
callq 0x6f40
movb %al, -0x1e9(%rbp)
jmp 0x5c2e
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x5c3a
jmp 0x5c59
leaq -0xc0(%rbp), %rdi
callq 0x7550
movq -0x1b8(%rbp), %rdi
movq %rax, %rsi
callq 0x6f80
jmp 0x5c57
jmp 0x5cc5
movq -0x1b8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x1f8(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x7550
movq %rax, %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x5540
jmp 0x5c88
movq -0x1f8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x5510
jmp 0x5c9d
leaq -0x1b0(%rbp), %rdi
callq 0x4700
jmp 0x5cc5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x4700
jmp 0x5d00
jmp 0x5cc7
leaq -0xc0(%rbp), %rdi
callq 0x7570
jmp 0x5b75
movl $0x0, -0x8c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7590
leaq -0x30(%rbp), %rdi
callq 0x31c0
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
leaq -0xa8(%rbp), %rdi
callq 0x7590
leaq -0x30(%rbp), %rdi
callq 0x31c0
movq -0x38(%rbp), %rdi
callq 0x3480
nop