// File: /workspace/github_c_makefile_star2_O0/ngkaho1234[P]ext4-extents-tree/db_bitmap.c
// Function: load_all_bitmap
struct db_bitmap *load_all_bitmap(struct super_block *sb, ext4_fsblk_t nrblocks, ext4_fsblk_t bitmap_block)
{
	int i, err = 0;
	int bitmap_nrblocks = blocks_of_bitmap(sb, nrblocks);
	uint8_t *bitmap = NULL;
	struct db_bitmap_desc *desc = NULL;
	struct db_bitmap *db_bitmap = xzalloc(sizeof(struct db_bitmap));
	if (!db_bitmap)
		return NULL;

	bitmap = xzalloc(bitmap_nrblocks << sb->s_blocksize_bits);
	if (!bitmap) {
		xfree(db_bitmap);
		return NULL;
	}

	desc = xzalloc(sizeof(struct db_bitmap_desc) * bitmap_nrblocks);

	for (i = 0;i < bitmap_nrblocks;i++) {
		struct buffer_head *bh;
		bh = fs_bread(sb, bitmap_block + i, &err);
		if (err)
			goto out;

		memcpy(bitmap + (i << sb->s_blocksize_bits), bh->b_data,
			sb->s_blocksize);
		fs_brelse(bh);
	}
out:
	if (err) {
		if (db_bitmap)
			xfree(db_bitmap);
		if (bitmap)
			xfree(bitmap);
		if (desc)
			xfree(desc);

		db_bitmap = NULL;
	} else {
		db_bitmap->sb = sb;
		db_bitmap->bitmap_count = bitmap_nrblocks;
		db_bitmap->bitmap = bitmap;
		db_bitmap->bitmap_desc = desc;
		db_bitmap->bitmap_block = bitmap_block;
	}
	return db_bitmap;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5460
movl %eax, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x1, %edi
movl $0x28, %esi
callq 0x2140
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x5522
movq $0x0, -0x8(%rbp)
jmp 0x571b
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
shll %cl, %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x2140
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x5587
cmpq $0x0, -0x48(%rbp)
jne 0x556a
movq 0x8aa4(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4b9c(%rip), %rsi      # 0xa0fa
movl $0x1d, %edx
movb $0x0, %al
callq 0x2170
cmpq $0x0, -0x48(%rbp)
je 0x557a
movq -0x48(%rbp), %rdi
callq 0x2030
movq $0x0, -0x8(%rbp)
jmp 0x571b
movslq -0x2c(%rbp), %rsi
shlq $0x2, %rsi
movl $0x1, %edi
callq 0x2140
movq %rax, -0x40(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x560d
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movslq -0x24(%rbp), %rax
addq %rax, %rsi
leaq -0x28(%rbp), %rdx
callq 0x2860
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x55d0
jmp 0x560f
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
shll %cl, %eax
cltq
addq %rax, %rdi
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
callq 0x2180
movq -0x50(%rbp), %rdi
callq 0x2980
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x55a4
jmp 0x560f
cmpl $0x0, -0x28(%rbp)
je 0x56da
cmpq $0x0, -0x48(%rbp)
je 0x5656
cmpq $0x0, -0x48(%rbp)
jne 0x5644
movq 0x89ca(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4ac2(%rip), %rsi      # 0xa0fa
movl $0x30, %edx
movb $0x0, %al
callq 0x2170
cmpq $0x0, -0x48(%rbp)
je 0x5654
movq -0x48(%rbp), %rdi
callq 0x2030
jmp 0x5656
cmpq $0x0, -0x38(%rbp)
je 0x5693
cmpq $0x0, -0x38(%rbp)
jne 0x5681
movq 0x898d(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4a85(%rip), %rsi      # 0xa0fa
movl $0x32, %edx
movb $0x0, %al
callq 0x2170
cmpq $0x0, -0x38(%rbp)
je 0x5691
movq -0x38(%rbp), %rdi
callq 0x2030
jmp 0x5693
cmpq $0x0, -0x40(%rbp)
je 0x56d0
cmpq $0x0, -0x40(%rbp)
jne 0x56be
movq 0x8950(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4a48(%rip), %rsi      # 0xa0fa
movl $0x34, %edx
movb $0x0, %al
callq 0x2170
cmpq $0x0, -0x40(%rbp)
je 0x56ce
movq -0x40(%rbp), %rdi
callq 0x2030
jmp 0x56d0
movq $0x0, -0x48(%rbp)
jmp 0x5713
movq -0x10(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movl -0x2c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)