// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/image.c
// Function: image_create
image_t *image_create(device_type_t dec_device, int unit, int forced_data_size) {
	int block_count;
	image_t *_this;
	_this = malloc(sizeof(image_t));
	pthread_mutex_init(&_this->mutex, NULL);
	_this->open = 0;
	_this->changed = 0;
	_this->changedblocks = NULL;
	_this->host_fpath = NULL;
	_this->pdp_filesystem = NULL;
	_this->hostdir = NULL;
	_this->dec_filesystem = fsNONE;
	_this->dec_device = dec_device;
	_this->unit = unit;
	_this->device_info = (device_info_t*) search_tagged_array(device_info_table,
			sizeof(device_info_t), dec_device);
	assert(_this->device_info);

	// create data buffer, not yet extended
	_this->blocksize = 512; // all devices

	_this->forced_blockcount = NEEDED_BLOCKS(_this->blocksize, forced_data_size);

	if (_this->forced_blockcount) { // correct range
		if (_this->forced_blockcount < _this->device_info->block_count)
			_this->forced_blockcount = _this->device_info->block_count;
		else if (_this->forced_blockcount > _this->device_info->max_block_count)
			_this->forced_blockcount = _this->device_info->max_block_count;
		block_count = _this->forced_blockcount;
	} else
		block_count = _this->device_info->block_count;
	_this->data_size = block_count * _this->blocksize;
	_this->data = malloc(_this->data_size);
	_this->changedblocks = boolarray_create(IMAGE_MAX_BLOCKS);

	return _this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl $0x128, %edi            # imm = 0x128
callq 0x33a0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3590
movq -0x18(%rbp), %rax
movb $0x0, 0xf4(%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0xf5(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0xf8(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0xe0(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0xd8(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x10c(%rax)
movl -0x4(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x108(%rax)
movl -0x8(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x4(%rbp), %edx
leaq 0x1a0e3(%rip), %rdi     # 0x23750
movl $0x20, %esi
callq 0xe300
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xe8(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0xe8(%rax)
je 0x9695
jmp 0x96b4
leaq 0x126f4(%rip), %rdi     # 0x1bd90
leaq 0x12700(%rip), %rsi     # 0x1bda3
movl $0x74, %edx
leaq 0x126fc(%rip), %rcx     # 0x1bdab
callq 0x3200
movq -0x18(%rbp), %rax
movl $0x200, 0xf0(%rax)      # imm = 0x200
movl -0xc(%rbp), %eax
movq -0x18(%rbp), %rcx
addl 0xf0(%rcx), %eax
subl $0x1, %eax
movq -0x18(%rbp), %rcx
cltd
idivl 0xf0(%rcx)
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0x9758
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0xe8(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jge 0x971e
movq -0x18(%rbp), %rax
movq 0xe8(%rax), %rax
movl 0x18(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x40(%rax)
jmp 0x974c
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0xe8(%rcx), %rcx
cmpl 0x1c(%rcx), %eax
jle 0x974a
movq -0x18(%rbp), %rax
movq 0xe8(%rax), %rax
movl 0x1c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x40(%rax)
jmp 0x974c
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x10(%rbp)
jmp 0x9769
movq -0x18(%rbp), %rax
movq 0xe8(%rax), %rax
movl 0x18(%rax), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %ecx
movq -0x18(%rbp), %rax
imull 0xf0(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x110(%rax)
movq -0x18(%rbp), %rax
movl 0x110(%rax), %eax
movl %eax, %edi
callq 0x33a0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x118(%rax)
movl $0xf4240, %edi          # imm = 0xF4240
callq 0xe380
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xf8(%rax)
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)