// File: /workspace/github_c_makefile_star2_O0/albertito[P]libjio/libjio/trans.c
// Function: jmove_journal
int jmove_journal(struct jfs *fs, const char *newpath)
{
	int ret;
	char *oldpath, jlockfile[PATH_MAX], oldjlockfile[PATH_MAX];

	/* we try to be sure that all lingering transactions have been
	 * applied, so when we try to remove the journal directory, only the
	 * lockfile is there; however, we do this just to be nice, the caller
	 * must be sure there are no in-flight transactions or any other kind
	 * of operation around when he calls this function */
	jsync(fs);

	oldpath = fs->jdir;
	snprintf(oldjlockfile, PATH_MAX, "%s/lock", fs->jdir);

	fs->jdir = malloc(strlen(newpath) + 1);
	if (fs->jdir == NULL)
		return -1;
	strcpy(fs->jdir, newpath);

	ret = rename(oldpath, newpath);
	if (ret == -1 && (errno == ENOTEMPTY || errno == EEXIST) ) {
		/* rename() failed, the dest. directory is not empty, so we
		 * have to reload everything */

		close(fs->jdirfd);
		fs->jdirfd = open(newpath, O_RDONLY);
		if (fs->jdirfd < 0)
			goto exit;

		snprintf(jlockfile, PATH_MAX, "%s/lock", newpath);
		ret = rename(oldjlockfile, jlockfile);
		if (ret < 0)
			goto exit;

		/* remove the journal directory, if possible */
		unlink(oldjlockfile);
		ret = rmdir(oldpath);
		if (ret == -1) {
			/* we couldn't remove it, something went wrong
			 * (possibly it had some files left) */
			goto exit;
		}

		ret = 0;
	}

exit:
	free(oldpath);
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2030, %rsp           # imm = 0x2030
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2320
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0x2030(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x2a75(%rip), %rdx      # 0x7018
movb $0x0, %al
callq 0x21c0
movq -0x18(%rbp), %rdi
callq 0x2140
movq %rax, %rdi
addq $0x1, %rdi
callq 0x23c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x45e1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46c6
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x20a0
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2530
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x46b5
callq 0x2070
cmpl $0x27, (%rax)
je 0x4624
callq 0x2070
cmpl $0x11, (%rax)
jne 0x46b5
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edi
callq 0x2240
movq -0x18(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x2500
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jge 0x4652
jmp 0x46b7
leaq -0x1030(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x29af(%rip), %rdx      # 0x7018
movb $0x0, %al
callq 0x21c0
leaq -0x2030(%rbp), %rdi
leaq -0x1030(%rbp), %rsi
callq 0x2530
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x468e
jmp 0x46b7
leaq -0x2030(%rbp), %rdi
callq 0x2090
movq -0x28(%rbp), %rdi
callq 0x2130
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x46ae
jmp 0x46b7
movl $0x0, -0x1c(%rbp)
jmp 0x46b7
movq -0x28(%rbp), %rdi
callq 0x2040
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2030, %rsp           # imm = 0x2030
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)