// File: /workspace/github_c_makefile_star2_O0/kisom[P]rmtmp/rmtmp.c
// Function: remove_tmp
static int
remove_tmp(const char *tmpdir, const char *prefix)
{
	char		 target[PATHMAX];
	size_t		 prefixlen;
	long unsigned	 matched, removed;
	int		 status = -1;
	DIR		*tmp = NULL;
	struct dirent	*entry = NULL;

	prefixlen = strnlen(prefix, PATHMAX);
	tmp = opendir(tmpdir);
	matched = removed = 0;

	if (NULL == tmp)
	    err(EX_OSERR, "couldn't open %s", tmpdir);

	while (NULL != (entry = readdir(tmp))) {
		if (entry->d_type != DT_REG)
			continue;
		if (strncmp(entry->d_name, prefix, prefixlen) != 0)
			continue;
		snprintf(target, sizeof(target), "%s/%s", tmpdir,
		    entry->d_name);
		matched++;

		if (unlink(target) != 0) {
			warn("unlink %s", target);
			continue;
		}

		removed++;
		if (verbose && removed > 0 && (removed % 1000) == 0)
			printf("removed %lu files\n", removed);
	}

	if (closedir(tmp) == -1)
		warn("couldn't close %s", tmpdir);

	printf("removed %lu files\n", removed);
	if (matched == removed)
		status = 0;
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x440, %rsp            # imm = 0x440
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, -0x42c(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x438(%rbp)
movq $0x0, -0x440(%rbp)
movq -0x10(%rbp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x401050
movq %rax, -0x418(%rbp)
movq -0x8(%rbp), %rdi
callq 0x44ee40
movq %rax, -0x438(%rbp)
movq $0x0, -0x428(%rbp)
movq $0x0, -0x420(%rbp)
xorl %eax, %eax
cmpq -0x438(%rbp), %rax
jne 0x401980
movq -0x8(%rbp), %rdx
movl $0x47, %edi
leaq 0x97873(%rip), %rsi     # 0x4991ec
movb $0x0, %al
callq 0x453010
jmp 0x401982
movq -0x438(%rbp), %rdi
callq 0x44f0a0
movq %rax, %rcx
movq %rcx, -0x440(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x401a93
movq -0x440(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x8, %eax
je 0x4019b5
jmp 0x401982
movq -0x440(%rbp), %rdi
addq $0x13, %rdi
movq -0x10(%rbp), %rsi
movq -0x418(%rbp), %rdx
callq 0x401080
cmpl $0x0, %eax
je 0x4019d7
jmp 0x401982
leaq -0x410(%rbp), %rdi
movq -0x8(%rbp), %rcx
movq -0x440(%rbp), %r8
addq $0x13, %r8
movl $0x400, %esi            # imm = 0x400
leaq 0x97804(%rip), %rdx     # 0x4991fd
movb $0x0, %al
callq 0x40baf0
movq -0x420(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x420(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x451490
cmpl $0x0, %eax
je 0x401a3d
leaq -0x410(%rbp), %rsi
leaq 0x977d2(%rip), %rdi     # 0x499203
movb $0x0, %al
callq 0x452d80
jmp 0x401982
movq -0x428(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x428(%rbp)
cmpl $0x0, 0xc989a(%rip)     # 0x4cb2f0
je 0x401a8e
cmpq $0x0, -0x428(%rbp)
jbe 0x401a8e
movq -0x428(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
jne 0x401a8e
movq -0x428(%rbp), %rsi
leaq 0x97786(%rip), %rdi     # 0x49920d
movb $0x0, %al
callq 0x40ba20
jmp 0x401982
movq -0x438(%rbp), %rdi
callq 0x44f070
cmpl $-0x1, %eax
jne 0x401ab6
movq -0x8(%rbp), %rsi
leaq 0x97771(%rip), %rdi     # 0x499220
movb $0x0, %al
callq 0x452d80
movq -0x428(%rbp), %rsi
leaq 0x97749(%rip), %rdi     # 0x49920d
movb $0x0, %al
callq 0x40ba20
movq -0x420(%rbp), %rax
cmpq -0x428(%rbp), %rax
jne 0x401ae5
movl $0x0, -0x42c(%rbp)
movl -0x42c(%rbp), %eax
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop