// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/hostdir.c
// Function: snapshot_scan_hostdir
static int snapshot_scan_hostdir(hostdir_t *_this) {
	int i;
	struct stat sb;
	DIR *dfd;
	struct dirent *dp;
	char pathbuff[4096];
	char file_to_delete[4096];
	hostdir_file_t *f;

	// set all files "deleted", found files are overwritten with other state
	// only deleted files remain "deleted"
	for (i = 0; i < _this->snapshot.file_count; i++)
		_this->snapshot.file[i].state[side_host] = fs_missing;

	dfd = opendir(_this->path); // error checking done, compact code
	// make list of regular files
	file_to_delete[0] = 0;
	while ((dp = readdir(dfd))) {
		sprintf(pathbuff, "%s/%s", _this->path, dp->d_name);
		// beware of . and .., not regular file
		if (stat(pathbuff, &sb))
			break;
		if (S_ISREG(sb.st_mode)) {
			// file create on both sides handled
			char *pdp_filename_ext;
			// convert to PDP conventions. Then perhaps not unique!
			pdp_filename_ext = filesystem_filename_from_host(_this->pdp_fs, dp->d_name, NULL,
			NULL);
			// Find entries with same pdp filename, but different host fname.
			// These are the cases were truncing the hostname leads double PDP name
			// Delete those hostfiles.
			f = snapshot_file_register(&_this->snapshot, pdp_filename_ext, side_host);
			if (strlen(f->hostfilename) && strcasecmp(f->hostfilename, dp->d_name)
					&& file_exists(_this->path, f->hostfilename)) {
				// duplicate PDP file with different hostnames
				fprintf(ferr,
						"Host file \"%s\" maps to duplicate PDP filename \"%s\", will be deleted\n",
						dp->d_name, pdp_filename_ext);
				strcpy(file_to_delete, pathbuff);
			} else {
				strcpy(f->hostfilename, dp->d_name);
				if (f->state[side_host] != fs_created) {
					if (f->host_len != sb.st_size || f->host_mtime != STAT_ST_MTIM(sb).tv_sec)
						f->state[side_host] = fs_changed;
					else
						f->state[side_host] = fs_unchanged;
				}
				// update to newest state
				f->host_len = sb.st_size;
				f->host_mtime = STAT_ST_MTIM(sb).tv_sec;
			}
		}
	}
	closedir(dfd);
	// delete only one hostfile per round ... in fact a whole file list should be maintained
	if (strlen(file_to_delete))
		unlink(file_to_delete);
	return ERROR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20c0, %rsp           # imm = 0x20C0
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1018(%rcx), %eax
jge 0xc606
movq -0x8(%rbp), %rax
addq $0x1010, %rax           # imm = 0x1010
addq $0x10, %rax
movslq -0xc(%rbp), %rcx
imulq $0x150, %rcx, %rcx      # imm = 0x150
addq %rcx, %rax
movl $0x1, 0x12c(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xc5c6
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
callq 0x3160
movq %rax, -0xa8(%rbp)
movb $0x0, -0x20b0(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x3380
movq %rax, -0xb0(%rbp)
cmpq $0x0, %rax
je 0xc81e
leaq -0x10b0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0x4, %rdx
movq -0xb0(%rbp), %rcx
addq $0x13, %rcx
leaq 0xfd16(%rip), %rsi      # 0x1c375
movb $0x0, %al
callq 0x3520
leaq -0x10b0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3310
cmpl $0x0, %eax
je 0xc683
jmp 0xc81e
movl -0x88(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0xc819
movq -0x8(%rbp), %rax
movq 0x1008(%rax), %rdi
movq -0xb0(%rbp), %rsi
addq $0x13, %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0xf570
movq %rax, -0x20c0(%rbp)
movq -0x8(%rbp), %rdi
addq $0x1010, %rdi           # imm = 0x1010
movq -0x20c0(%rbp), %rsi
movl $0x1, %edx
callq 0xb1a0
movq %rax, -0x20b8(%rbp)
movq -0x20b8(%rbp), %rdi
addq $0x28, %rdi
callq 0x3190
cmpq $0x0, %rax
je 0xc77a
movq -0x20b8(%rbp), %rdi
addq $0x28, %rdi
movq -0xb0(%rbp), %rsi
addq $0x13, %rsi
callq 0x3050
cmpl $0x0, %eax
je 0xc77a
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movq -0x20b8(%rbp), %rsi
addq $0x28, %rsi
callq 0xdc00
cmpl $0x0, %eax
je 0xc77a
leaq 0x18df1(%rip), %rax     # 0x25530
movq (%rax), %rdi
movq -0xb0(%rbp), %rdx
addq $0x13, %rdx
movq -0x20c0(%rbp), %rcx
leaq 0xfe2d(%rip), %rsi      # 0x1c588
movb $0x0, %al
callq 0x3300
leaq -0x20b0(%rbp), %rdi
leaq -0x10b0(%rbp), %rsi
callq 0x30c0
jmp 0xc817
movq -0x20b8(%rbp), %rdi
addq $0x28, %rdi
movq -0xb0(%rbp), %rsi
addq $0x13, %rsi
callq 0x30c0
movq -0x20b8(%rbp), %rax
cmpl $0x3, 0x12c(%rax)
je 0xc7f3
movq -0x20b8(%rbp), %rax
movq 0x130(%rax), %rax
cmpq -0x70(%rbp), %rax
jne 0xc7cd
movq -0x20b8(%rbp), %rax
movq 0x138(%rax), %rax
cmpq -0x48(%rbp), %rax
je 0xc7e0
movq -0x20b8(%rbp), %rax
movl $0x2, 0x12c(%rax)
jmp 0xc7f1
movq -0x20b8(%rbp), %rax
movl $0x0, 0x12c(%rax)
jmp 0xc7f3
movq -0x70(%rbp), %rcx
movq -0x20b8(%rbp), %rax
movq %rcx, 0x130(%rax)
movq -0x48(%rbp), %rcx
movq -0x20b8(%rbp), %rax
movq %rcx, 0x138(%rax)
jmp 0xc819
jmp 0xc621
movq -0xa8(%rbp), %rdi
callq 0x3270
leaq -0x20b0(%rbp), %rdi
callq 0x3190
cmpq $0x0, %rax
je 0xc848
leaq -0x20b0(%rbp), %rdi
callq 0x3080
xorl %eax, %eax
addq $0x20c0, %rsp           # imm = 0x20C0
popq %rbp
retq
nopw %cs:(%rax,%rax)