// File: /workspace/github_c_makefile_star2_O0/ataradov[P]edbg/target.c
// Function: target_check_options
void target_check_options(target_options_t *options, int size, int align)
{
  options->file_data = NULL;
  options->file_size = 0;

  if (-1 == options->offset)
    options->offset = 0;

  if (-1 == options->size)
    options->size = size - options->offset;

  if (0 != (options->offset % align))
    error_exit("offset must be a multiple of %d for the selected target", align);

  if (0 != (options->size % align))
    error_exit("size must be a multiple of %d for the selected target", align);

  check(options->size <= size, "size is too big for the selected target");
  check(options->offset < size, "offset is too big for the selected target");

  if (options->program || options->verify)
  {
    options->file_data = buf_alloc(options->size);
    options->file_size = load_file(options->name, options->file_data, options->size);
    memset(&options->file_data[options->file_size], 0xff, options->size - options->file_size);

    check((options->file_size + options->offset) <= size, "file is too big for the selected target");
  }
  else if (options->read)
  {
    options->file_data = buf_alloc(options->size);
    options->file_size = options->size;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x8(%rbp), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl 0x18(%rcx), %eax
jne 0xa632
movq -0x8(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x8(%rbp), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl 0x1c(%rcx), %eax
jne 0xa651
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
subl 0x18(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
cltd
idivl -0x10(%rbp)
xorl %eax, %eax
cmpl %edx, %eax
je 0xa673
movl -0x10(%rbp), %esi
leaq 0xb391(%rip), %rdi      # 0x159fd
movb $0x0, %al
callq 0x8970
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
cltd
idivl -0x10(%rbp)
xorl %eax, %eax
cmpl %edx, %eax
je 0xa695
movl -0x10(%rbp), %esi
leaq 0xb3a7(%rip), %rdi      # 0x15a35
movb $0x0, %al
callq 0x8970
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0xc(%rbp), %eax
setle %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb3bc(%rip), %rsi      # 0x15a6b
xorl %eax, %eax
callq 0x8880
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
cmpl -0xc(%rbp), %eax
setl %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb3c3(%rip), %rsi      # 0x15a93
xorl %eax, %eax
callq 0x8880
movq -0x8(%rbp), %rax
testb $0x1, 0x5(%rax)
jne 0xa6ef
movq -0x8(%rbp), %rax
testb $0x1, 0x6(%rax)
je 0xa783
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x8ae0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %edx
callq 0x8b50
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x8(%rbp), %rax
movslq 0x28(%rax), %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x8(%rbp), %rcx
subl 0x28(%rcx), %eax
movslq %eax, %rdx
movl $0xff, %esi
callq 0x60f0
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x8(%rbp), %rcx
addl 0x18(%rcx), %eax
cmpl -0xc(%rbp), %eax
setle %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb343(%rip), %rsi      # 0x15abd
xorl %eax, %eax
callq 0x8880
jmp 0xa7b4
movq -0x8(%rbp), %rax
testb $0x1, 0x9(%rax)
je 0xa7b2
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x8ae0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
jmp 0xa7b4
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)