// File: /workspace/github_c_makefile_star2_O0/albertito[P]libjio/libjio/journal.c
// Function: journal_new
struct journal_op *journal_new(struct jfs *fs, unsigned int flags)
{
	int fd, id;
	ssize_t rv;
	char *name = NULL;
	struct journal_op *jop = NULL;
	struct on_disk_hdr hdr;
	struct iovec iov[1];

	if (is_broken(fs))
		goto error;

	jop = malloc(sizeof(struct journal_op));
	if (jop == NULL)
		goto error;

	name = (char *) malloc(PATH_MAX);
	if (name == NULL)
		goto error;

	id = get_tid(fs);
	if (id == 0)
		goto error;

	/* open the transaction file */
	get_jtfile(fs, id, name);
	fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0600);
	if (fd < 0)
		goto error;

	if (plockf(fd, F_LOCKW, 0, 0) != 0)
		goto unlink_error;

	jop->id = id;
	jop->fd = fd;
	jop->numops = 0;
	jop->name = name;
	jop->csum = 0;
	jop->fs = fs;

	fiu_exit_on("jio/commit/created_tf");

	/* save the header */
	hdr.ver = 1;
	hdr.trans_id = id;
	hdr.flags = flags;
	hdr_hton(&hdr);

	iov[0].iov_base = (void *) &hdr;
	iov[0].iov_len = sizeof(hdr);
	rv = swritev(fd, iov, 1);
	if (rv != sizeof(hdr))
		goto unlink_error;

	jop->csum = checksum_buf(jop->csum, (unsigned char *) &hdr,
			sizeof(hdr));

	fiu_exit_on("jio/commit/tf_header");

	return jop;

unlink_error:
	unlink(name);
	free_tid(fs, id);
	close(fd);

error:
	free(name);
	free(jop);

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x52a0
cmpl $0x0, %eax
je 0x5102
jmp 0x526f
movl $0x28, %edi
callq 0x23c0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x511c
jmp 0x526f
movl $0x1000, %edi           # imm = 0x1000
callq 0x23c0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x5136
jmp 0x526f
movq -0x10(%rbp), %rdi
callq 0x5300
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x514d
jmp 0x526f
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x22e0
movq -0x30(%rbp), %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x180, %edx            # imm = 0x180
movb $0x0, %al
callq 0x2500
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x5180
jmp 0x526f
movl -0x18(%rbp), %edi
movl $0x110, %esi            # imm = 0x110
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x24d0
cmpq $0x0, %rax
je 0x519f
jmp 0x5252
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl -0x18(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movw $0x1, -0x40(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x14(%rbp), %eax
movw %ax, -0x3e(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5370
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x8, -0x48(%rbp)
movl -0x18(%rbp), %edi
leaq -0x50(%rbp), %rsi
movl $0x1, %edx
callq 0x2460
movq %rax, -0x28(%rbp)
cmpq $0x8, -0x28(%rbp)
je 0x522a
jmp 0x5252
movq -0x38(%rbp), %rax
movl 0x18(%rax), %edi
leaq -0x40(%rbp), %rsi
movl $0x8, %edx
callq 0x2250
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5289
movq -0x30(%rbp), %rdi
callq 0x2090
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x53d0
movl -0x18(%rbp), %edi
callq 0x2240
movq -0x30(%rbp), %rdi
callq 0x2040
movq -0x38(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)