// File: /workspace/github_c_makefile_star2_O1/findstr[P]version-database/release.c
// Function: release
void
release(struct release_args *args)
{
	dr_t *list, head;
	int i, n, keep, del;
	struct release prevrel;
	struct tree prevtree, tree;
	n = dir_scan(str(args->fromdir), &list, 1);
	head = db_readhead(&prevrel, &prevtree);
	tree_sort(&prevtree, ref_namecmp);
	tree.refn = n;
	tree.refs = malloc(sizeof(struct ref) * (n+1));
	memset(tree.refs, 0, sizeof(struct ref) * (n+1));
	keep = 0;
	for (i = 0; i < n; i++) {
		dr_t d, name;
		struct ref *r, *f;
		r = &tree.refs[i];
		r->name = name = list[i];
		d = dir_readfile(str(name), args->fromdir);
		r->hash = db_write(name, d);
		dr_unref(d);
		f = tree_search(&prevtree, r, ref_namecmp);
		if (f && dr_cmp(f->hash, r->hash) == 0) {
			dr_unref(f->hash);
			f->hash= NULL;
			keep += 1;
		}
	}
	del = 0;
	if (keep == n) {
		int x = prevtree.refn;
		for (i = 0; i < x; i++) {
			struct ref *r = &prevtree.refs[i];
			dr_t hash = r->hash;
			if (hash== NULL)
				continue;
			if (strcmp(str(r->name), FINGERPRINT_NAME) != 0)
				++del;
		}
		if (del == 0)
			printf("clean workspace\n");
	}
	if (keep != n || del != 0) {
		struct release rel;
		dr_t treeobj;//, finger;
		dr_t relhash;
		dr_t treehash;
		rel.time = time(NULL);
		rel.prev = dr_ref(head);
		rel.ver = dr_ref(args->version);
		rel.note = dr_ref(args->describe);
		tree_sort(&tree, ref_hashcmp);
#if ENABLE_FINGERPRINT
		rel.finger = fingerprint(&tree);
#endif
		treeobj = tree_marshal(&tree);
		treehash = db_write(rel.ver, treeobj);
		rel.tree = dr_ref(treehash);
		relhash = db_writehead(&rel);
		release_destroy(&rel);
		if (args->checkout != NULL)
			checkout(relhash, args->checkout);
		dr_unref(treeobj);
		dr_unref(relhash);
		dr_unref(treehash);
		printf("release total:%d changed:%d del:%d\n", n, n-keep, del);
	}
	free(list);
	dr_unref(head);
	release_destroy(&prevrel);
	tree_destroy(&prevtree);
	tree_destroy(&tree);
	return ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8c8, %rsp            # imm = 0x8C8
movq %rdi, -0x48(%rbp)
movq 0x10(%rdi), %rdi
addq $0x8, %rdi
leaq -0x70(%rbp), %rsi
movl $0x1, %edx
callq 0x4f04
movl %eax, %r14d
leaq -0xe8(%rbp), %rdi
leaq -0x80(%rbp), %rbx
movq %rbx, %rsi
callq 0x5ba6
movq %rax, -0x68(%rbp)
leaq 0x2cc9(%rip), %rsi      # 0x5e74
movq %rbx, %rdi
callq 0x61bb
movl %r14d, -0x58(%rbp)
movslq %r14d, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbx
addq $0x18, %rbx
movq %rbx, %rdi
callq 0x21f0
movq %rax, -0x50(%rbp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2140
movl $0x0, -0x38(%rbp)
movl %r14d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x32e6
movl -0x2c(%rbp), %eax
movq %rax, -0x40(%rbp)
xorl %r14d, %r14d
movl $0x8, %ebx
movl $0x0, -0x38(%rbp)
movq -0x50(%rbp), %r13
movq -0x70(%rbp), %rax
movq (%rax,%r14,8), %r12
movq %r12, (%r13,%rbx)
leaq 0x8(%r12), %rdi
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x51ea
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x5963
movq %rax, -0x8(%r13,%rbx)
testq %r15, %r15
je 0x3262
movl (%r15), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%r15)
cmpl $0x1, %ecx
jg 0x3262
testl %eax, %eax
jne 0x3771
movq %r15, %rdi
callq 0x2030
leaq (%rbx,%r13), %r12
addq $-0x8, %r12
leaq -0x80(%rbp), %rdi
movq %r12, %rsi
leaq 0x2bfc(%rip), %rdx      # 0x5e74
callq 0x61d7
testq %rax, %rax
je 0x32d5
movq %rax, %r15
movq (%rax), %r13
movq (%r12), %rsi
movslq 0x4(%r13), %rdx
cmpl 0x4(%rsi), %edx
jne 0x32d5
leaq 0x8(%r13), %rdi
addq $0x8, %rsi
callq 0x2200
testl %eax, %eax
jne 0x32d5
testq %r13, %r13
je 0x32cb
movl (%r13), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%r13)
cmpl $0x1, %ecx
jg 0x32cb
testl %eax, %eax
jne 0x3771
movq %r13, %rdi
callq 0x2030
movq $0x0, (%r15)
incl -0x38(%rbp)
incq %r14
addq $0x18, %rbx
cmpq %r14, -0x40(%rbp)
jne 0x3209
movl -0x38(%rbp), %eax
cmpl %eax, -0x2c(%rbp)
movl $0x0, %r13d
jne 0x3354
movslq -0x80(%rbp), %rax
testq %rax, %rax
jle 0x3340
movq -0x78(%rbp), %r14
shlq $0x3, %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
leaq 0x703e(%rip), %rbx      # 0xa351
xorl %r13d, %r13d
cmpq $0x0, (%r14,%r12)
je 0x3335
movq 0x8(%r14,%r12), %rdi
addq $0x8, %rdi
movq %rbx, %rsi
callq 0x2180
cmpl $0x1, %eax
sbbl $-0x1, %r13d
addq $0x18, %r12
cmpq %r12, %r15
jne 0x3316
jmp 0x3343
xorl %r13d, %r13d
testl %r13d, %r13d
jne 0x3354
leaq 0x6e94(%rip), %rdi      # 0xa1e3
callq 0x20a0
movl -0x2c(%rbp), %eax
subl -0x38(%rbp), %eax
jne 0x3365
testl %r13d, %r13d
je 0x371a
movl %eax, -0x5c(%rbp)
xorl %edi, %edi
callq 0x21d0
movq %rax, -0xb8(%rbp)
movq -0x68(%rbp), %rax
testq %rax, %rax
je 0x3381
incl (%rax)
movq %rax, -0xb0(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x3396
incl (%rax)
movl %r13d, -0x60(%rbp)
movq %rax, -0xa0(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x33b0
incl (%rax)
movq %rax, -0x98(%rbp)
leaq 0x2a9e(%rip), %rsi      # 0x5e5c
leaq -0x58(%rbp), %rbx
movq %rbx, %rdi
callq 0x61bb
movl $0x80c, %edi            # imm = 0x80C
callq 0x21f0
movq %rax, %r13
movabsq $0x80000000001, %rax    # imm = 0x80000000001
movq %rax, (%r13)
movb $0x0, 0x808(%r13)
cmpl $0x0, (%rbx)
jle 0x3535
leaq -0x8f0(%rbp), %r12
xorl %ecx, %ecx
xorl %ebx, %ebx
movq -0x50(%rbp), %rax
movq %rcx, -0x40(%rbp)
leaq (%rcx,%rcx,2), %rdx
movq (%rax,%rdx,8), %rcx
movq 0x8(%rax,%rdx,8), %r8
addq $0x8, %rcx
addq $0x8, %r8
movl $0x800, %esi            # imm = 0x800
movq %r12, %rdi
leaq 0x6d75(%rip), %rdx      # 0xa1a2
xorl %eax, %eax
callq 0x2120
cmpl $0x800, %eax            # imm = 0x800
jae 0x3790
movl 0x4(%r13), %r14d
movq %rbx, -0x38(%rbp)
movq %rax, -0x88(%rbp)
leal (%rax,%rbx), %r15d
cmpl %r15d, %r14d
jge 0x34e8
movq %r13, %rbx
movslq %r14d, %rax
leaq (%rax,%rax), %r14
movl (%rbx), %r12d
leaq 0xc(,%rax,2), %rsi
cmpl $0x1, %r12d
jne 0x3487
movq %rbx, %rdi
callq 0x2210
movq %rax, %r13
movl %r14d, 0x4(%rax)
jmp 0x34dc
movq %rsi, %rdi
callq 0x21f0
movq %rax, %r13
movl $0x1, (%rax)
movl %r14d, 0x4(%rax)
movb $0x0, 0x8(%rax,%r14)
movl 0x4(%rbx), %eax
cmpl %r14d, %eax
cmovgel %r14d, %eax
leaq 0x8(%r13), %rdi
movl %eax, 0x4(%rbx)
leaq 0x8(%rbx), %rsi
movslq %eax, %rdx
callq 0x21c0
leal -0x1(%r12), %eax
movl %eax, (%rbx)
cmpl $0x1, %r12d
jg 0x34dc
testl %eax, %eax
jne 0x3771
movq %rbx, %rdi
callq 0x2030
movq %r13, %rbx
cmpl %r15d, %r14d
jl 0x345e
movl -0x88(%rbp), %ebx
leaq 0x8(%r13), %r14
movslq -0x38(%rbp), %rax
leaq (%rax,%r13), %r15
addq $0x8, %r15
movq %r15, %rdi
leaq -0x8f0(%rbp), %r12
movq %r12, %rsi
movq %rbx, %rdx
callq 0x21c0
addl %r15d, %ebx
subl %r14d, %ebx
movq -0x40(%rbp), %rcx
incq %rcx
movslq -0x58(%rbp), %rax
cmpq %rax, %rcx
jl 0x3401
movl %ecx, %eax
movq %rax, -0x40(%rbp)
jmp 0x353f
xorl %ebx, %ebx
movq $0x0, -0x40(%rbp)
movl (%r13), %r15d
movslq %ebx, %r12
leaq 0xc(%r12), %rsi
cmpl $0x1, %r15d
jne 0x3561
movq %r13, %rdi
callq 0x2210
movq %rax, %r14
movl %ebx, 0x4(%rax)
jmp 0x35b8
movq %rsi, %rdi
callq 0x21f0
movq %rax, %r14
movl $0x1, (%rax)
movl %r12d, 0x4(%rax)
movb $0x0, 0x8(%rax,%r12)
movl 0x4(%r13), %eax
cmpl %r12d, %eax
cmovll %eax, %ebx
leaq 0x8(%r14), %rdi
movl %ebx, 0x4(%r13)
leaq 0x8(%r13), %rsi
movslq %ebx, %rdx
callq 0x21c0
leal -0x1(%r15), %eax
movl %eax, (%r13)
cmpl $0x1, %r15d
jg 0x35b8
testl %eax, %eax
jne 0x3771
movq %r13, %rdi
callq 0x2030
movq -0x50(%rbp), %r15
movq -0x40(%rbp), %rax
leaq (%rax,%rax,2), %rbx
movl $0x18, %edi
callq 0x21f0
movabsq $0xc00000001, %rcx      # imm = 0xC00000001
movq %rcx, (%rax)
movabsq $0x707265676e69665f, %rcx # imm = 0x707265676E69665F
movq %rcx, 0x8(%rax)
movl $0x746e6972, 0x10(%rax) # imm = 0x746E6972
movb $0x0, 0x14(%rax)
movq %rax, 0x8(%r15,%rbx,8)
movq %rax, %rdi
movq %r14, %rsi
callq 0x5963
movq %rax, (%r15,%rbx,8)
incl -0x58(%rbp)
testq %r14, %r14
movl -0x60(%rbp), %r13d
je 0x3632
movl (%r14), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%r14)
cmpl $0x1, %ecx
jg 0x3632
testl %eax, %eax
jne 0x3771
movq %r14, %rdi
callq 0x2030
leaq (%r15,%rbx,8), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x3640
incl (%rax)
movq %rax, -0x90(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x5eb4
movq %rax, %r14
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x5963
movq %rax, %rbx
testq %rax, %rax
je 0x366c
incl (%rbx)
leaq -0xb8(%rbp), %r12
movq %rbx, 0x10(%r12)
movq %r12, %rdi
callq 0x5c2a
movq %rax, %r15
movq %r12, %rdi
callq 0x6574
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rsi
testq %rsi, %rsi
je 0x36a0
movq %r15, %rdi
callq 0x4de8
testq %r14, %r14
je 0x36c3
movl (%r14), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%r14)
cmpl $0x1, %ecx
jg 0x36c3
testl %eax, %eax
jne 0x3771
movq %r14, %rdi
callq 0x2030
testq %r15, %r15
je 0x36e6
movl (%r15), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%r15)
cmpl $0x1, %ecx
jg 0x36e6
testl %eax, %eax
jne 0x3771
movq %r15, %rdi
callq 0x2030
testq %rbx, %rbx
je 0x3703
movl (%rbx), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%rbx)
cmpl $0x1, %ecx
jg 0x3703
testl %eax, %eax
jne 0x3771
movq %rbx, %rdi
callq 0x2030
leaq 0x6a74(%rip), %rdi      # 0xa17e
movl -0x2c(%rbp), %esi
movl -0x5c(%rbp), %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2110
movq -0x70(%rbp), %rdi
callq 0x2030
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x3741
movl (%rdi), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%rdi)
cmpl $0x1, %ecx
jg 0x3741
testl %eax, %eax
jne 0x3771
callq 0x2030
leaq -0xe8(%rbp), %rdi
callq 0x6574
leaq -0x80(%rbp), %rdi
callq 0x6100
leaq -0x58(%rbp), %rdi
callq 0x6100
addq $0x8c8, %rsp            # imm = 0x8C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6909(%rip), %rdi      # 0xa081
leaq 0x690e(%rip), %rsi      # 0xa08d
leaq 0x690e(%rip), %rcx      # 0xa094
movl $0x2d, %edx
callq 0x2130
leaq 0x6a12(%rip), %rdi      # 0xa1a9
leaq 0x6a1b(%rip), %rsi      # 0xa1b9
leaq 0x6a1e(%rip), %rcx      # 0xa1c3
movl $0x1b, %edx
callq 0x2130
nop