// File: /workspace/github_c_makefile_star2_O0/ngkaho1234[P]ext4-extents-tree/buffer.c
// Function: _submit_bh
int __submit_bh(int is_write, struct buffer_head *bh)
{
	struct block_device *bdev = bh->b_bdev;

	if (is_write == 0) {
#ifndef USE_AIO
		int ret;
		sem_wait(&bh->b_event);
		ret = device_read(bdev->bd_fd, bh->b_blocknr, 1,
				   bh->b_size, bh->b_data);
		if (ret < 0)
			bh->b_end_io(bh, 0);
		else
			bh->b_end_io(bh, 1);
#else
		bh->b_aiocb.aio_fildes = bdev->bd_fd;
		bh->b_aiocb.aio_buf = bh->b_data;
		bh->b_aiocb.aio_nbytes = bh->b_size;
		bh->b_aiocb.aio_reqprio = 0;
		bh->b_aiocb.aio_offset = bh->b_blocknr * bh->b_size;
		bh->b_aiocb.aio_sigevent.sigev_notify = SIGEV_THREAD;
		bh->b_aiocb.aio_sigevent.sigev_notify_function = iocb_dispatch;
		bh->b_aiocb.aio_sigevent.sigev_value.sival_ptr = bh;
		sem_wait(&bh->b_event);
		aio_read(&bh->b_aiocb);
#endif
	} else {
#ifndef USE_AIO
		int ret;
		sem_wait(&bh->b_event);
		ret = device_write(bdev->bd_fd, bh->b_blocknr, 1,
				   bh->b_size, bh->b_data);
		if (ret < 0)
			bh->b_end_io(bh, 0);
		else
			bh->b_end_io(bh, 1);
#else
		bh->b_aiocb.aio_fildes = bdev->bd_fd;
		bh->b_aiocb.aio_buf = bh->b_data;
		bh->b_aiocb.aio_nbytes = bh->b_size;
		bh->b_aiocb.aio_reqprio = 0;
		bh->b_aiocb.aio_offset = bh->b_blocknr * bh->b_size;
		bh->b_aiocb.aio_sigevent.sigev_notify = SIGEV_THREAD;
		bh->b_aiocb.aio_sigevent.sigev_notify_function = iocb_dispatch;
		bh->b_aiocb.aio_sigevent.sigev_value.sival_ptr = bh;
		sem_wait(&bh->b_event);
		aio_write(&bh->b_aiocb);
#endif
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0xf0(%rax), %rax
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x3404
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
imulq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x10(%rbp), %rax
movl $0x2, 0x54(%rax)
movq -0x10(%rbp), %rax
leaq -0x102(%rip), %rcx      # 0x32d0
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rdi
addq $0xd0, %rdi
callq 0x2060
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0x2070
jmp 0x349b
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
imulq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x10(%rbp), %rax
movl $0x2, 0x54(%rax)
movq -0x10(%rbp), %rax
leaq -0x19e(%rip), %rcx      # 0x32d0
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rdi
addq $0xd0, %rdi
callq 0x2060
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0x2160
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)