LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target.c
// Function: target_list
void target_list(void)
{
  message("Supported device families:\n");

  for (int i = 0; i < ARRAY_SIZE(targets); i++)
  {
    char *family_name[MAX_FAMILIES];
    int family_count = 0;

    message("  %s:\n", targets[i].description);

    for (int j = 0; true; j++)
    {
      char *family = targets[i].ops->enumerate(j);
      bool match = false;

      if (NULL == family)
        break;

      for (int k = 0; k < family_count; k++)
      {
        if (0 == strcmp(family_name[k], family))
        {
          match = true;
          break;
        }
      }

      if (!match)
        family_name[family_count++] = family;

      check(family_count < MAX_FAMILIES, "internal: too many families in enumeration");
    }

    message("    ");

    for (int j = 0; j < family_count; j++)
      message("%s ", family_name[j]);

    message("\n\n");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x338, %rsp            # imm = 0x338
leaq 0x8eb4(%rip), %rdi      # 0x11890
xorl %eax, %eax
callq 0x77e1
xorl %eax, %eax
cmpq $0xd, %rax
je 0x8ad3
movq %rax, 0x8(%rsp)
imulq $0x18, %rax, %rax
leaq 0x10ca1(%rip), %rcx     # 0x196a0
movq 0x8(%rax,%rcx), %rsi
movq 0x10(%rax,%rcx), %r15
xorl %r14d, %r14d
leaq 0x8e99(%rip), %rdi      # 0x118ac
xorl %eax, %eax
callq 0x77e1
xorl %ebp, %ebp
movl %ebp, %edi
callq *0x50(%r15)
testq %rax, %rax
je 0x8a7c
movq %rax, %rbx
testl %r14d, %r14d
movl $0x0, %r12d
cmovgl %r14d, %r12d
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x8a55
movq 0x10(%rsp,%r13,8), %rdi
movq %rbx, %rsi
callq 0x6180
incq %r13
testl %eax, %eax
jne 0x8a3a
jmp 0x8a60
movslq %r14d, %rax
incl %r14d
movq %rbx, 0x10(%rsp,%rax,8)
xorl %edi, %edi
cmpl $0x64, %r14d
setl %dil
leaq 0x8e42(%rip), %rsi      # 0x118b3
xorl %eax, %eax
callq 0x793d
incl %ebp
jmp 0x8a1c
leaq 0x8e5b(%rip), %rdi      # 0x118de
xorl %eax, %eax
callq 0x77e1
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
xorl %ebx, %ebx
leaq 0x8e44(%rip), %r15      # 0x118e3
cmpq %rbx, %r14
je 0x8ab8
movq 0x10(%rsp,%rbx,8), %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x77e1
incq %rbx
jmp 0x8a9f
leaq 0x7e1c(%rip), %rdi      # 0x108db
xorl %eax, %eax
callq 0x77e1
movq 0x8(%rsp), %rax
incq %rax
jmp 0x89e5
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target.c
// Function: target_get_ops
target_ops_t *target_get_ops(const char *name)
{
  for (int i = 0; i < ARRAY_SIZE(targets); i++)
  {
    for (int j = 0; true; j++)
    {
      char *family = targets[i].ops->enumerate(j);

      if (NULL == family)
        break;

      if (0 == strcmp(family, name))
        return targets[i].ops;
    }
  }

  // Note: This is deprecated and will be removed in future versions
  for (int i = 0; i < ARRAY_SIZE(targets); i++)
  {
    if (NULL != targets[i].name && 0 == strcmp(targets[i].name, name))
    {
      warning("specifying '%s' as a target name is deprecated; see '-t list' for a list of supported targets", name);
      return targets[i].ops;
    }
  }

  error_exit("unknown target type '%s'; see '-t list' for a list of supported targets", name);

  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
xorl %r12d, %r12d
leaq 0x10ba6(%rip), %r15     # 0x196a0
cmpq $0xd, %r12
je 0x8b2e
imulq $0x18, %r12, %rax
movq 0x10(%rax,%r15), %r14
xorl %ebp, %ebp
movl %ebp, %edi
callq *0x50(%r14)
testq %rax, %rax
je 0x8b29
movq %rax, %rdi
movq %rbx, %rsi
callq 0x6180
incl %ebp
testl %eax, %eax
jne 0x8b0b
jmp 0x8b82
incq %r12
jmp 0x8afa
pushq $0x10
popq %r14
cmpq $0x148, %r14            # imm = 0x148
je 0x8b57
movq -0x10(%r14,%r15), %rdi
testq %rdi, %rdi
je 0x8b51
movq %rbx, %rsi
callq 0x6180
testl %eax, %eax
je 0x8b6d
addq $0x18, %r14
jmp 0x8b32
leaq 0x8de7(%rip), %rdi      # 0x11945
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7a0e
jmp 0x8b82
leaq 0x8d73(%rip), %rdi      # 0x118e7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7878
movq (%r14,%r15), %r14
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq %r14
pushq %rbx
movq %rdi, %rbx
andq $0x0, 0x30(%rdi)
andl $0x0, 0x28(%rdi)
movl %edx, %r14d
movl %esi, %ebp
movl 0x18(%rdi), %eax
cmpl $-0x1, %eax
jne 0x8bb1
andl $0x0, 0x18(%rbx)
xorl %eax, %eax
movl 0x1c(%rbx), %ecx
cmpl $-0x1, %ecx
jne 0x8bc0
movl %ebp, %ecx
subl %eax, %ecx
movl %ecx, 0x1c(%rbx)
cltd
idivl %r14d
testl %edx, %edx
je 0x8bdc
leaq 0x8dbe(%rip), %rdi      # 0x1198d
movl %r14d, %esi
xorl %eax, %eax
callq 0x7a0e
movl 0x1c(%rbx), %ecx
movl %ecx, %eax
cltd
idivl %r14d
testl %edx, %edx
je 0x8bfa
leaq 0x8dd8(%rip), %rdi      # 0x119c5
movl %r14d, %esi
xorl %eax, %eax
callq 0x7a0e
movl 0x1c(%rbx), %ecx
xorl %edi, %edi
cmpl %ebp, %ecx
setle %dil
leaq 0x8df2(%rip), %rsi      # 0x119fb
xorl %eax, %eax
callq 0x793d
xorl %edi, %edi
cmpl %ebp, 0x18(%rbx)
setl %dil
leaq 0x8e03(%rip), %rsi      # 0x11a23
xorl %eax, %eax
callq 0x793d
cmpb $0x0, 0x5(%rbx)
jne 0x8c33
cmpb $0x1, 0x6(%rbx)
jne 0x8c8b
movl 0x1c(%rbx), %edi
callq 0x7b1b
movq %rax, 0x30(%rbx)
movq 0x10(%rbx), %rdi
movl 0x1c(%rbx), %edx
movq %rax, %rsi
callq 0x7b41
movl %eax, 0x28(%rbx)
cltq
movq 0x30(%rbx), %rdi
addq %rax, %rdi
movslq 0x1c(%rbx), %rdx
subq %rax, %rdx
movl $0xff, %esi
callq 0x60e0
movl 0x18(%rbx), %eax
addl 0x28(%rbx), %eax
xorl %edi, %edi
cmpl %ebp, %eax
setle %dil
leaq 0x8dcd(%rip), %rsi      # 0x11a4d
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x793d
cmpb $0x1, 0x9(%rbx)
jne 0x8ca3
movl 0x1c(%rbx), %edi
callq 0x7b1b
movq %rax, 0x30(%rbx)
movl 0x1c(%rbx), %eax
movl %eax, 0x28(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target.c
// Function: extract_value
static uint32_t extract_value(uint8_t *buf, int start, int end)
{
  uint32_t value = 0;
  int bit = start;
  int index = 0;

  do
  {
    int by = bit / 8;
    int bt = bit % 8;

    if (buf[by] & (1 << bt))
      value |= (1 << index);

    bit++;
    index++;
  } while (bit <= end);

  return value;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %r8d
leal -0x1(%rsi), %r11d
xorl %ebx, %ebx
movl $0x8, %ebp
movl $0x1, %r14d
xorl %ecx, %ecx
xorl %r9d, %r9d
leal (%rsi,%rcx), %r10d
movl %r10d, %eax
cltd
idivl %ebp
cltq
movzbl (%rdi,%rax), %eax
andl $0x7, %r10d
movl %r14d, %edx
shll %cl, %edx
btl %r10d, %eax
cmovael %ebx, %edx
orl %edx, %r9d
leal (%r11,%rcx), %eax
incl %eax
incl %ecx
cmpl %r8d, %eax
jl 0x9396
movl %r9d, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm0p.c
// Function: target_select
static void target_select(target_options_t *options)
{
  uint32_t dsu_did, id, rev;
  bool locked;

  reset_with_extension();

  dsu_did = dap_read_word(DSU_DID);
  id = dsu_did & DEVICE_ID_MASK;
  rev = (dsu_did >> DEVICE_REV_SHIFT) & DEVICE_REV_MASK;

  for (int i = 0; i < ARRAY_SIZE(devices); i++)
  {
    if (devices[i].dsu_did != id)
      continue;

    verbose("Target: %s (Rev %c)\n", devices[i].name, 'A' + rev);

    target_device = devices[i];
    target_options = *options;

    target_check_options(&target_options, devices[i].flash_size, FLASH_ROW_SIZE);

    locked = dap_read_byte(DSU_STATUSB) & DSU_STATUSB_PROT;

    if (locked && !options->unlock)
      error_exit("target is locked, unlock is necessary");

    if (!locked)
      finish_reset();

    return;
  }

  error_exit("unknown target device (DSU_DID = 0x%08x)", dsu_did);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x9835
movl $0x41002118, %edi       # imm = 0x41002118
callq 0x6fe1
movl %eax, %ecx
andl $0xfffff0ff, %ecx       # imm = 0xFFFFF0FF
movl %eax, %edx
shrl $0x8, %edx
andl $0xf, %edx
xorl %esi, %esi
leaq 0x103e0(%rip), %r14     # 0x197e0
leaq 0x20(%rsi), %r15
cmpq $0x1160, %r15           # imm = 0x1160
je 0x94a3
cmpl %ecx, (%rsi,%r14)
movq %r15, %rsi
jne 0x9400
movq -0x10(%r15,%r14), %rsi
addl $0x41, %edx
leaq 0x8bed(%rip), %rdi      # 0x12016
xorl %eax, %eax
callq 0x773c
movups -0x20(%r15,%r14), %xmm0
movups -0x10(%r15,%r14), %xmm1
movups %xmm1, 0x76615(%rip)    # 0x7fa58
movups %xmm0, 0x765fe(%rip)    # 0x7fa48
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups %xmm0, 0x7660c(%rip)    # 0x7fa68
movups %xmm1, 0x76615(%rip)    # 0x7fa78
movups %xmm2, 0x7661e(%rip)    # 0x7fa88
movq 0x30(%rbx), %rax
movq %rax, 0x76623(%rip)     # 0x7fa98
leaq 0x765ec(%rip), %rdi     # 0x7fa68
movl -0x8(%r15,%r14), %esi
movl $0x100, %edx            # imm = 0x100
callq 0x8b8e
movl $0x41002102, %edi       # imm = 0x41002102
callq 0x6fba
testb $0x1, %al
jne 0x94b8
popq %rbx
popq %r14
popq %r15
jmp 0x984b
leaq 0x8ba7(%rip), %rdi      # 0x12051
movl %eax, %esi
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x7a0e
cmpb $0x0, 0x8(%rbx)
je 0x94c4
popq %rbx
popq %r14
popq %r15
retq
leaq 0x8b60(%rip), %rdi      # 0x1202b
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x7a0e
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm0p.c
// Function: target_erase
static void target_erase(void)
{
  dap_write_byte(DSU_STATUSA, DSU_STATUSA_DONE);
  dap_write_byte(DSU_CTRL, DSU_CTRL_CE);
  sleep_ms(100);
  while (0 == (dap_read_byte(DSU_STATUSA) & DSU_STATUSA_DONE));

  reset_with_extension();
  finish_reset();
}

// Assembly:
pushq %rax
pushq $0x1
popq %rsi
movl $0x41002101, %edi       # imm = 0x41002101
callq 0x6ff4
pushq $0x10
popq %rsi
movl $0x41002100, %edi       # imm = 0x41002100
callq 0x6ff4
pushq $0x64
popq %rdi
callq 0x7aeb
movl $0x41002101, %edi       # imm = 0x41002101
callq 0x6fba
testb $0x1, %al
je 0x9523
callq 0x9835
popq %rax
jmp 0x984b
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm0p.c
// Function: target_program
static void target_program(void)
{
  uint32_t addr = FLASH_ADDR + target_options.offset;
  uint32_t offs = 0;
  uint32_t number_of_rows;
  uint8_t *buf = target_options.file_data;
  uint32_t size = target_options.file_size;

  number_of_rows = (size + FLASH_ROW_SIZE - 1) / FLASH_ROW_SIZE;

  dap_write_word(NVMCTRL_CTRLB, 0); // Enable automatic write

  for (uint32_t row = 0; row < number_of_rows; row++)
  {
    dap_write_word(NVMCTRL_ADDR, addr >> 1);

    dap_write_half(NVMCTRL_CTRLA, NVMCTRL_CMD_UR); // Unlock Region
    while (0 == (dap_read_byte(NVMCTRL_INTFLAG) & NVMCTRL_INTFLAG_READY));

    dap_write_half(NVMCTRL_CTRLA, NVMCTRL_CMD_ER); // Erase Row
    while (0 == (dap_read_byte(NVMCTRL_INTFLAG) & NVMCTRL_INTFLAG_READY));

    dap_write_block(addr, &buf[offs], FLASH_ROW_SIZE);

    addr += FLASH_ROW_SIZE;
    offs += FLASH_ROW_SIZE;

    if (0 == (row % STATUS_INTERVAL))
      verbose(".");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x76524(%rip), %ebx     # 0x7fa80
movq 0x76535(%rip), %r15     # 0x7fa98
movl $0xff, %ebp
addl 0x76522(%rip), %ebp     # 0x7fa90
shrl $0x8, %ebp
movl $0x41004004, %edi       # imm = 0x41004004
xorl %esi, %esi
callq 0x700c
leaq 0x728b(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpl %ebp, %r13d
je 0x9609
movl %ebx, %esi
shrl %esi
movl $0x4100401c, %edi       # imm = 0x4100401C
callq 0x700c
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa541, %esi           # imm = 0xA541
callq 0x7000
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x6fba
testb $0x1, %al
je 0x95ac
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa502, %esi           # imm = 0xA502
callq 0x7000
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x6fba
testb $0x1, %al
je 0x95c9
leaq (%r15,%r12), %rsi
movl %ebx, %edi
movl $0x100, %edx            # imm = 0x100
callq 0x70ef
testb $0x1f, %r13b
jne 0x95f7
movq %r14, %rdi
xorl %eax, %eax
callq 0x773c
addl $0x100, %ebx            # imm = 0x100
addq $0x100, %r12            # imm = 0x100
incl %r13d
jmp 0x958a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm0p.c
// Function: target_verify
static void target_verify(void)
{
  uint32_t addr = FLASH_ADDR + target_options.offset;
  uint32_t block_size;
  uint32_t offs = 0;
  uint8_t *bufb;
  uint8_t *bufa = target_options.file_data;
  uint32_t size = target_options.file_size;
  int row = 0;

  bufb = buf_alloc(FLASH_ROW_SIZE);

  while (size)
  {
    dap_read_block(addr, bufb, FLASH_ROW_SIZE);

    block_size = (size > FLASH_ROW_SIZE) ? FLASH_ROW_SIZE : size;

    for (int i = 0; i < (int)block_size; i++)
    {
      if (bufa[offs + i] != bufb[i])
      {
        verbose("\nat address 0x%x expected 0x%02x, read 0x%02x\n",
            addr + i, bufa[offs + i], bufb[i]);
        buf_free(bufb);
        error_exit("verification failed");
      }
    }

    addr += FLASH_ROW_SIZE;
    offs += FLASH_ROW_SIZE;
    size -= block_size;

    if (0 == (row++ % STATUS_INTERVAL))
      verbose(".");
  }

  buf_free(bufb);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x76457(%rip), %ebx     # 0x7fa80
movq 0x76468(%rip), %rbp     # 0x7fa98
movl 0x76459(%rip), %r13d    # 0x7fa90
movl $0x100, %edi            # imm = 0x100
callq 0x7b1b
movq %rax, %r14
xorl %r15d, %r15d
xorl %eax, %eax
testl %r13d, %r13d
je 0x96f7
movl %eax, (%rsp)
movl %ebx, %edi
movq %r14, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7018
movl $0x100, %eax            # imm = 0x100
cmpl %eax, %r13d
movl $0x100, %r12d           # imm = 0x100
movl %r13d, 0x4(%rsp)
cmovbl %r13d, %r12d
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x96c2
leal (%r15,%r13), %eax
movzbl (%rbp,%rax), %edx
movzbl (%r14,%r13), %ecx
cmpb %cl, %dl
je 0x96bd
leal (%rbx,%r13), %esi
leaq 0x915d(%rip), %rdi      # 0x127fd
xorl %eax, %eax
callq 0x773c
movq %r14, %rdi
callq 0x7b3c
leaq 0xa3b2(%rip), %rdi      # 0x13a68
xorl %eax, %eax
callq 0x7a0e
incq %r13
jmp 0x967e
movl (%rsp), %eax
testb $0x1f, %al
jne 0x96da
leaq 0x713f(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x773c
movl (%rsp), %eax
addq $0x100, %rbx            # imm = 0x100
movl 0x4(%rsp), %r13d
subl %r12d, %r13d
incl %eax
addq $0x100, %r15            # imm = 0x100
jmp 0x9649
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7b3c
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm0p.c
// Function: target_read
static void target_read(void)
{
  uint32_t addr = FLASH_ADDR + target_options.offset;
  uint32_t offs = 0;
  uint8_t *buf = target_options.file_data;
  uint32_t size = target_options.size;
  int row = 0;

  while (size)
  {
    dap_read_block(addr, &buf[offs], FLASH_ROW_SIZE);

    addr += FLASH_ROW_SIZE;
    offs += FLASH_ROW_SIZE;
    size -= FLASH_ROW_SIZE;

    if (0 == (row++ % STATUS_INTERVAL))
      verbose(".");
  }

  save_file(target_options.name, buf, target_options.size);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x76361(%rip), %r15d    # 0x7fa80
movq 0x76372(%rip), %rbx     # 0x7fa98
movl 0x76358(%rip), %ebp     # 0x7fa84
leaq 0x70dc(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpl %r12d, %ebp
je 0x976e
leal (%r15,%r12), %edi
movl %r12d, %esi
addq %rbx, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7018
testb $0x1f, %r13b
jne 0x9762
movq %r14, %rdi
xorl %eax, %eax
callq 0x773c
addl $0x100, %r12d           # imm = 0x100
incl %r13d
jmp 0x9739
movq 0x76303(%rip), %rdi     # 0x7fa78
movl 0x76309(%rip), %edx     # 0x7fa84
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7bf8
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm0p.c
// Function: target_fuse_write
static void target_fuse_write(int section, uint8_t *data)
{
  check(0 == section, "internal: incorrect section index in target_fuse_write()");

  dap_write_word(NVMCTRL_CTRLB, 0);
  dap_write_word(NVMCTRL_ADDR, USER_ROW_ADDR >> 1);
  dap_write_half(NVMCTRL_CTRLA, NVMCTRL_CMD_EAR);
  while (0 == (dap_read_byte(NVMCTRL_INTFLAG) & NVMCTRL_INTFLAG_READY));

  dap_write_block(USER_ROW_ADDR, data, USER_ROW_SIZE);
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
xorl %eax, %eax
testl %edi, %edi
sete %al
leaq 0x906a(%rip), %rsi      # 0x1282c
movl %eax, %edi
xorl %eax, %eax
callq 0x793d
movl $0x41004004, %edi       # imm = 0x41004004
xorl %esi, %esi
callq 0x700c
movl $0x4100401c, %edi       # imm = 0x4100401C
movl $0x402000, %esi         # imm = 0x402000
callq 0x700c
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa505, %esi           # imm = 0xA505
callq 0x7000
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x6fba
testb $0x1, %al
je 0x97f5
movl $0x804000, %edi         # imm = 0x804000
movq %rbx, %rsi
movl $0x100, %edx            # imm = 0x100
popq %rbx
jmp 0x70ef
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm0p.c
// Function: finish_reset
static void finish_reset(void)
{
  // Stop the core
  dap_write_word(DHCSR, DHCSR_DBGKEY | DHCSR_DEBUGEN | DHCSR_HALT);
  dap_write_word(DEMCR, DEMCR_VC_CORERESET);
  dap_write_word(AIRCR, AIRCR_VECTKEY | AIRCR_SYSRESETREQ);

  // Release the reset
  dap_write_byte(DSU_STATUSA, DSU_STATUSA_CRSTEXT);
}

// Assembly:
pushq %rax
movl $0xe000edf0, %edi       # imm = 0xE000EDF0
movl $0xa05f0003, %esi       # imm = 0xA05F0003
callq 0x700c
pushq $0x1
popq %rsi
movl $0xe000edfc, %edi       # imm = 0xE000EDFC
callq 0x700c
movl $0xe000ed0c, %edi       # imm = 0xE000ED0C
movl $0x5fa0004, %esi        # imm = 0x5FA0004
callq 0x700c
pushq $0x2
popq %rsi
movl $0x41002101, %edi       # imm = 0x41002101
popq %rax
jmp 0x6ff4
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm3.c
// Function: target_erase
static void target_erase(void)
{
  for (int i = 0; i < target_device.n_planes; i++)
    dap_write_word(EEFC_FCR(target_device.plane[i].eefc_base), CMD_EA);

  for (int i = 0; i < target_device.n_planes; i++)
    while (0 == (dap_read_word(EEFC_FSR(target_device.plane[i].eefc_base)) & FSR_FRDY));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0x75fc5(%rip), %rbx     # 0x7fac0
xorl %r14d, %r14d
movslq 0x75fb7(%rip), %rax     # 0x7fabc
cmpq %rax, %r14
jge 0x9b22
movl (%rbx), %edi
addl $0x4, %edi
movl $0x5a000005, %esi       # imm = 0x5A000005
callq 0x700c
incq %r14
addq $0xc, %rbx
jmp 0x9afe
xorl %ebx, %ebx
leaq 0x75f75(%rip), %r14     # 0x7faa0
cltq
cmpq %rax, %rbx
jge 0x9b58
imulq $0xc, %rbx, %rax
leaq (%rax,%r14), %r15
addq $0x20, %r15
movl (%r15), %edi
addl $0x8, %edi
callq 0x6fe1
testb $0x1, %al
je 0x9b3e
incq %rbx
movl 0x75f66(%rip), %eax     # 0x7fabc
jmp 0x9b2b
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm3.c
// Function: target_program
static void target_program(void)
{
  uint32_t addr = target_options.offset;
  uint32_t number_of_pages, eefc_base;
  uint32_t offs = 0;
  uint8_t *buf = target_options.file_data;
  uint32_t size = target_options.file_size;

  number_of_pages = (size + FLASH_PAGE_SIZE - 1) / FLASH_PAGE_SIZE;

  for (uint32_t page = 0; page < number_of_pages; page++)
  {
    eefc_base = get_eefc_base(addr);

    dap_write_block(get_flash_addr(addr), &buf[offs], FLASH_PAGE_SIZE);

    dap_write_word(EEFC_FCR(eefc_base), CMD_EWP | (page << 8));
    while (0 == (dap_read_word(EEFC_FSR(eefc_base)) & FSR_FRDY));

    addr += FLASH_PAGE_SIZE;
    offs += FLASH_PAGE_SIZE;

    verbose(".");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x75f47(%rip), %ebx     # 0x7faf0
movq 0x75f58(%rip), %r12     # 0x7fb08
movl $0xff, %ebp
addl 0x75f45(%rip), %ebp     # 0x7fb00
shrl $0x8, %ebp
xorl %r13d, %r13d
xorl %r14d, %r14d
cmpl %ebp, %r14d
je 0x9c2f
movl %ebx, %edi
callq 0x9e5c
movl %eax, %r15d
movl %ebx, %edi
callq 0x9eaf
leaq (%r12,%r13), %rsi
movl %eax, %edi
movl $0x100, %edx            # imm = 0x100
callq 0x70ef
leal 0x4(%r15), %edi
movl %r14d, %esi
shll $0x8, %esi
orl $0x5a000003, %esi       # imm = 0x5A000003
callq 0x700c
addl $0x8, %r15d
movl %r15d, %edi
callq 0x6fe1
testb $0x1, %al
je 0x9c03
addl $0x100, %ebx            # imm = 0x100
addq $0x100, %r13            # imm = 0x100
leaq 0x6bec(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x773c
incl %r14d
jmp 0x9bc4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm3.c
// Function: target_verify
static void target_verify(void)
{
  uint32_t addr = target_options.offset;
  uint32_t block_size;
  uint32_t offs = 0;
  uint8_t *bufb;
  uint8_t *bufa = target_options.file_data;
  uint32_t size = target_options.file_size;

  bufb = buf_alloc(FLASH_PAGE_SIZE);

  while (size)
  {
    dap_read_block(get_flash_addr(addr), bufb, FLASH_PAGE_SIZE);

    block_size = (size > FLASH_PAGE_SIZE) ? FLASH_PAGE_SIZE : size;

    for (int i = 0; i < (int)block_size; i++)
    {
      if (bufa[offs + i] != bufb[i])
      {
        verbose("\nat address 0x%x expected 0x%02x, read 0x%02x\n",
            addr + i, bufa[offs + i], bufb[i]);
        buf_free(bufb);
        error_exit("verification failed");
      }
    }

    addr += FLASH_PAGE_SIZE;
    offs += FLASH_PAGE_SIZE;
    size -= block_size;

    verbose(".");
  }

  buf_free(bufb);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x75ea1(%rip), %ebx     # 0x7faf0
movq 0x75eb2(%rip), %rbp     # 0x7fb08
movl 0x75ea3(%rip), %r13d    # 0x7fb00
movl $0x100, %edi            # imm = 0x100
callq 0x7b1b
movq %rax, %r14
xorl %r15d, %r15d
testl %r13d, %r13d
je 0x9d15
movl %ebx, %edi
callq 0x9eaf
movl %eax, %edi
movq %r14, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7018
movl $0x100, %eax            # imm = 0x100
cmpl %eax, %r13d
movl $0x100, %r12d           # imm = 0x100
movl %r13d, 0x4(%rsp)
cmovbl %r13d, %r12d
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x9cea
leal (%r15,%r13), %eax
movzbl (%rbp,%rax), %edx
movzbl (%r14,%r13), %ecx
cmpb %cl, %dl
je 0x9ce5
leal (%rbx,%r13), %esi
leaq 0x8b35(%rip), %rdi      # 0x127fd
xorl %eax, %eax
callq 0x773c
movq %r14, %rdi
callq 0x7b3c
leaq 0x9d8a(%rip), %rdi      # 0x13a68
xorl %eax, %eax
callq 0x7a0e
incq %r13
jmp 0x9ca6
movl $0x100, %eax            # imm = 0x100
addq %rax, %rbx
movl 0x4(%rsp), %r13d
subl %r12d, %r13d
leaq 0x6b0e(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x773c
movl $0x100, %eax            # imm = 0x100
addq %rax, %r15
jmp 0x9c6d
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7b3c
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm3.c
// Function: target_read
static void target_read(void)
{
  uint32_t addr = target_options.offset;
  uint32_t offs = 0;
  uint8_t *buf = target_options.file_data;
  uint32_t size = target_options.size;

  while (size)
  {
    dap_read_block(get_flash_addr(addr), &buf[offs], FLASH_PAGE_SIZE);

    addr += FLASH_PAGE_SIZE;
    offs += FLASH_PAGE_SIZE;
    size -= FLASH_PAGE_SIZE;

    verbose(".");
  }

  save_file(target_options.name, buf, target_options.size);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl 0x75db6(%rip), %r15d    # 0x7faf0
movq 0x75dc7(%rip), %rbx     # 0x7fb08
movl 0x75dad(%rip), %ebp     # 0x7faf4
leaq 0x6ac1(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
cmpl %r12d, %ebp
je 0x9d84
leal (%r15,%r12), %edi
callq 0x9eaf
movl %r12d, %esi
addq %rbx, %rsi
movl %eax, %edi
movl $0x100, %edx            # imm = 0x100
callq 0x7018
addl $0x100, %r12d           # imm = 0x100
movq %r14, %rdi
xorl %eax, %eax
callq 0x773c
jmp 0x9d51
movq 0x75d5d(%rip), %rdi     # 0x7fae8
movl 0x75d63(%rip), %edx     # 0x7faf4
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x7bf8
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm3.c
// Function: target_fuse_read
static int target_fuse_read(int section, uint8_t *data)
{
  uint32_t gpnvm;

  if (section > 0)
    return 0;

  dap_write_word(EEFC_FCR(get_eefc_base(0)), CMD_GGPB);
  while (0 == (dap_read_word(EEFC_FSR(get_eefc_base(0))) & FSR_FRDY));
  gpnvm = dap_read_word(EEFC_FRR(get_eefc_base(0)));

  data[0] = gpnvm;

  return GPNVM_SIZE;
}

// Assembly:
xorl %eax, %eax
testl %edi, %edi
jle 0x9da8
retq
pushq %rbx
movq %rsi, %rbx
xorl %edi, %edi
callq 0x9e5c
leal 0x4(%rax), %edi
movl $0x5a00000d, %esi       # imm = 0x5A00000D
callq 0x700c
xorl %edi, %edi
callq 0x9e5c
leal 0x8(%rax), %edi
callq 0x6fe1
testb $0x1, %al
je 0x9dc0
xorl %edi, %edi
callq 0x9e5c
leal 0xc(%rax), %edi
callq 0x6fe1
movb %al, (%rbx)
pushq $0x1
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm3.c
// Function: target_fuse_write
static void target_fuse_write(int section, uint8_t *data)
{
  uint32_t gpnvm = data[0];

  check(0 == section, "internal: incorrect section index in target_fuse_write()");

  for (int i = 0; i < GPNVM_SIZE_BITS; i++)
  {
    if (gpnvm & (1 << i))
      dap_write_word(EEFC_FCR(get_eefc_base(0)), CMD_SGPB | (i << 8));
    else
      dap_write_word(EEFC_FCR(get_eefc_base(0)), CMD_CGPB | (i << 8));
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movzbl (%rsi), %ebx
xorl %eax, %eax
testl %edi, %edi
sete %al
leaq 0x8a2e(%rip), %rsi      # 0x1282c
xorl %ebp, %ebp
movl %eax, %edi
xorl %eax, %eax
callq 0x793d
xorl %r14d, %r14d
cmpl $0x8, %r14d
je 0x9e3b
xorl %edi, %edi
callq 0x9e5c
leal 0x4(%rax), %edi
btl %r14d, %ebx
movl %ebp, %esi
sbbl $-0x1, %esi
addl $0x5a00000b, %esi       # imm = 0x5A00000B
callq 0x700c
incl %r14d
addl $0x100, %ebp            # imm = 0x100
jmp 0x9e0c
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm3.c
// Function: get_eefc_base
static uint32_t get_eefc_base(uint32_t addr)
{
  uint32_t flash_addr = get_flash_addr(addr);

  for (int i = 0; i < target_device.n_planes; i++)
  {
    uint32_t a = target_device.plane[i].addr;
    uint32_t s = target_device.plane[i].size;

    if (a <= flash_addr && flash_addr < (a + s))
      return target_device.plane[i].eefc_base;
  }

  error_exit("internal error in get_eefc_base()");

  return 0;
}

// Assembly:
pushq %rbx
callq 0x9eaf
movl 0x75c54(%rip), %edx     # 0x7fabc
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
imulq $0xc, %rdx, %rdx
leaq 0x75c26(%rip), %rsi     # 0x7faa0
cmpq %rcx, %rdx
je 0x9e95
movl 0x24(%rcx,%rsi), %edi
cmpl %eax, %edi
ja 0x9e8f
addl 0x28(%rcx,%rsi), %edi
cmpl %edi, %eax
jb 0x9ea7
addq $0xc, %rcx
jmp 0x9e7a
leaq 0x8af4(%rip), %rdi      # 0x12990
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x7a0e
jmp 0x9eab
movl 0x20(%rcx,%rsi), %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm3.c
// Function: get_flash_addr
static uint32_t get_flash_addr(uint32_t addr)
{
  uint32_t offs = addr;

  for (int i = 0; i < target_device.n_planes; i++)
  {
    if (offs >= target_device.plane[i].size)
      offs -= target_device.plane[i].size;
    else
      return target_device.plane[i].addr + offs;
  }

  error_exit("internal error in get_flash_addr()");

  return 0;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
movl 0x75c04(%rip), %ecx     # 0x7fabc
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0xc, %rcx, %rdx
leaq 0x75bd6(%rip), %rcx     # 0x7faa0
cmpq %rax, %rdx
je 0x9edf
movl %ebx, %esi
subl 0x28(%rax,%rcx), %esi
jb 0x9ef1
addq $0xc, %rax
movl %esi, %ebx
jmp 0x9eca
leaq 0x8acc(%rip), %rdi      # 0x129b2
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x7a0e
jmp 0x9ef5
addl 0x24(%rax,%rcx), %ebx
movl %ebx, %eax
popq %rbx
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm4.c
// Function: target_erase
static void target_erase(void)
{
  for (uint32_t plane = 0; plane < target_device.n_planes; plane++)
    dap_write_word(EEFC_FCR(plane), CMD_EA);

  for (uint32_t plane = 0; plane < target_device.n_planes; plane++)
    while (0 == (dap_read_word(EEFC_FSR(plane)) & FSR_FRDY));
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
xorl %ebp, %ebp
movl $0x400e0a04, %ebx       # imm = 0x400E0A04
movl 0x759e1(%rip), %eax     # 0x7fb28
cmpl %eax, %ebp
jae 0xa161
movl %ebx, %edi
movl $0x5a000005, %esi       # imm = 0x5A000005
callq 0x700c
incl %ebp
addl $0x200, %ebx            # imm = 0x200
jmp 0xa141
xorl %ebp, %ebp
cmpl %eax, %ebp
jae 0xa187
movl %ebp, %ebx
shll $0x9, %ebx
addl $0x400e0a08, %ebx       # imm = 0x400E0A08
movl %ebx, %edi
callq 0x6fe1
testb $0x1, %al
je 0xa172
incl %ebp
movl 0x759a3(%rip), %eax     # 0x7fb28
jmp 0xa163
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm4.c
// Function: target_program
static void target_program(void)
{
  uint32_t addr = FLASH_START + target_options.offset;
  uint32_t number_of_pages, plane, page_offset;
  uint32_t offs = 0;
  uint8_t *buf = target_options.file_data;
  uint32_t size = target_options.file_size;

  number_of_pages = (size + FLASH_PAGE_SIZE - 1) / FLASH_PAGE_SIZE;
  page_offset = target_options.offset / FLASH_PAGE_SIZE;

  for (uint32_t page = 0; page < number_of_pages; page += PAGES_IN_ERASE_BLOCK)
  {
    plane = (page + page_offset) / (target_device.flash_size / FLASH_PAGE_SIZE);

    dap_write_word(EEFC_FCR(plane), CMD_EPA | (((page_offset + page) | 2) << 8));
    while (0 == (dap_read_word(EEFC_FSR(plane)) & FSR_FRDY));

    verbose(".");
  }

  verbose(",");

  for (uint32_t page = 0; page < number_of_pages; page++)
  {
    dap_write_block(addr, &buf[offs], FLASH_PAGE_SIZE);
    addr += FLASH_PAGE_SIZE;
    offs += FLASH_PAGE_SIZE;

    plane = (page + page_offset) / (target_device.flash_size / FLASH_PAGE_SIZE);

    dap_write_word(EEFC_FCR(plane), CMD_WP | ((page + page_offset) << 8));
    while (0 == (dap_read_word(EEFC_FSR(plane)) & FSR_FRDY));

    verbose(".");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x7599a(%rip), %ebx     # 0x7fb48
movq 0x759ab(%rip), %rax     # 0x7fb60
movq %rax, (%rsp)
movl $0x1ff, %ebp            # imm = 0x1FF
addl 0x75994(%rip), %ebp     # 0x7fb58
shrl $0x9, %ebp
movl $0x200, %ecx            # imm = 0x200
movl %ebx, %eax
cltd
idivl %ecx
movl %eax, %r14d
leaq 0x6634(%rip), %r15      # 0x1080f
xorl %r13d, %r13d
cmpl %ebp, %r13d
jae 0xa236
leal (%r14,%r13), %esi
movl 0x7593f(%rip), %ecx     # 0x7fb2c
shrl $0x9, %ecx
movl %esi, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %r12d
shll $0x9, %r12d
leal 0x400e0a04(%r12), %edi
shll $0x8, %esi
orl $0x5a000207, %esi       # imm = 0x5A000207
callq 0x700c
addl $0x400e0a08, %r12d      # imm = 0x400E0A08
movl %r12d, %edi
callq 0x6fe1
testb $0x1, %al
je 0xa21a
movq %r15, %rdi
xorl %eax, %eax
callq 0x773c
addl $0x10, %r13d
jmp 0xa1de
addl $0x400000, %ebx         # imm = 0x400000
leaq 0x8b79(%rip), %rdi      # 0x12dbc
xorl %eax, %eax
callq 0x773c
xorl %r15d, %r15d
xorl %r13d, %r13d
cmpl %ebp, %r13d
je 0xa2cc
movq (%rsp), %rax
leaq (%rax,%r15), %rsi
movl %ebx, %edi
movl $0x200, %edx            # imm = 0x200
callq 0x70ef
addl $0x200, %ebx            # imm = 0x200
leal (%r14,%r13), %esi
movl 0x758b3(%rip), %ecx     # 0x7fb2c
shrl $0x9, %ecx
movl %esi, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %r12d
shll $0x9, %r12d
leal 0x400e0a04(%r12), %edi
shll $0x8, %esi
orl $0x5a000001, %esi       # imm = 0x5A000001
callq 0x700c
addl $0x400e0a08, %r12d      # imm = 0x400E0A08
movl %r12d, %edi
callq 0x6fe1
testb $0x1, %al
je 0xa2a6
addq $0x200, %r15            # imm = 0x200
leaq 0x654f(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x773c
incl %r13d
jmp 0xa250
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm4.c
// Function: target_verify
static void target_verify(void)
{
  uint32_t addr = FLASH_START + target_options.offset;
  uint32_t block_size;
  uint32_t offs = 0;
  uint8_t *bufb;
  uint8_t *bufa = target_options.file_data;
  uint32_t size = target_options.file_size;

  bufb = buf_alloc(FLASH_PAGE_SIZE);

  while (size)
  {
    dap_read_block(addr, bufb, FLASH_PAGE_SIZE);

    block_size = (size > FLASH_PAGE_SIZE) ? FLASH_PAGE_SIZE : size;

    for (int i = 0; i < (int)block_size; i++)
    {
      if (bufa[offs + i] != bufb[i])
      {
        verbose("\nat address 0x%x expected 0x%02x, read 0x%02x\n",
            addr + i, bufa[offs + i], bufb[i]);
        buf_free(bufb);
        error_exit("verification failed");
      }
    }

    addr += FLASH_PAGE_SIZE;
    offs += FLASH_PAGE_SIZE;
    size -= block_size;

    verbose(".");
  }

  buf_free(bufb);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x400000, %ebx         # imm = 0x400000
addl 0x75857(%rip), %ebx     # 0x7fb48
movq 0x75868(%rip), %rbp     # 0x7fb60
movl 0x75859(%rip), %r13d    # 0x7fb58
movl $0x200, %edi            # imm = 0x200
callq 0x7b1b
movq %rax, %r14
xorl %r15d, %r15d
testl %r13d, %r13d
je 0xa3b0
movl %ebx, %edi
movq %r14, %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x7018
movl $0x200, %eax            # imm = 0x200
cmpl %eax, %r13d
movl $0x200, %r12d           # imm = 0x200
movl %r13d, 0x4(%rsp)
cmovbl %r13d, %r12d
xorl %r13d, %r13d
cmpq %r13, %r12
je 0xa385
leal (%r15,%r13), %eax
movzbl (%rbp,%rax), %edx
movzbl (%r14,%r13), %ecx
cmpb %cl, %dl
je 0xa380
leal (%rbx,%r13), %esi
leaq 0x849a(%rip), %rdi      # 0x127fd
xorl %eax, %eax
callq 0x773c
movq %r14, %rdi
callq 0x7b3c
leaq 0x96ef(%rip), %rdi      # 0x13a68
xorl %eax, %eax
callq 0x7a0e
incq %r13
jmp 0xa341
movl $0x200, %eax            # imm = 0x200
addq %rax, %rbx
movl 0x4(%rsp), %r13d
subl %r12d, %r13d
leaq 0x6473(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x773c
movl $0x200, %eax            # imm = 0x200
addq %rax, %r15
jmp 0xa30f
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7b3c
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm4.c
// Function: target_read
static void target_read(void)
{
  uint32_t addr = FLASH_START + target_options.offset;
  uint32_t offs = 0;
  uint8_t *buf = target_options.file_data;
  uint32_t size = target_options.size;

  while (size)
  {
    dap_read_block(addr, &buf[offs], FLASH_PAGE_SIZE);

    addr += FLASH_PAGE_SIZE;
    offs += FLASH_PAGE_SIZE;
    size -= FLASH_PAGE_SIZE;

    verbose(".");
  }

  save_file(target_options.name, buf, target_options.size);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0x400000, %r15d        # imm = 0x400000
addl 0x7576d(%rip), %r15d    # 0x7fb48
movq 0x7577e(%rip), %rbx     # 0x7fb60
movl 0x75764(%rip), %ebp     # 0x7fb4c
leaq 0x6420(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
cmpl %r12d, %ebp
je 0xa41e
leal (%r15,%r12), %edi
movl %r12d, %esi
addq %rbx, %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x7018
addl $0x200, %r12d           # imm = 0x200
movq %r14, %rdi
xorl %eax, %eax
callq 0x773c
jmp 0xa3f2
movq 0x7571b(%rip), %rdi     # 0x7fb40
movl 0x75721(%rip), %edx     # 0x7fb4c
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x7bf8
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm4.c
// Function: target_fuse_read
static int target_fuse_read(int section, uint8_t *data)
{
  uint32_t gpnvm;

  if (section > 0)
    return 0;

  dap_write_word(EEFC_FCR(0), CMD_GGPB);
  while (0 == (dap_read_word(EEFC_FSR(0)) & FSR_FRDY));
  gpnvm = dap_read_word(EEFC_FRR(0));

  data[0] = gpnvm;

  return GPNVM_SIZE;
}

// Assembly:
xorl %eax, %eax
testl %edi, %edi
jle 0xa442
retq
pushq %rbx
movq %rsi, %rbx
movl $0x400e0a04, %edi       # imm = 0x400E0A04
movl $0x5a00000d, %esi       # imm = 0x5A00000D
callq 0x700c
movl $0x400e0a08, %edi       # imm = 0x400E0A08
callq 0x6fe1
testb $0x1, %al
je 0xa455
movl $0x400e0a0c, %edi       # imm = 0x400E0A0C
callq 0x6fe1
movb %al, (%rbx)
pushq $0x1
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm4.c
// Function: target_fuse_write
static void target_fuse_write(int section, uint8_t *data)
{
  uint32_t gpnvm = data[0];

  check(0 == section, "internal: incorrect section index in target_fuse_write()");

  for (int i = 0; i < GPNVM_SIZE_BITS; i++)
  {
    if (gpnvm & (1 << i))
      dap_write_word(EEFC_FCR(0), CMD_SGPB | (i << 8));
    else
      dap_write_word(EEFC_FCR(0), CMD_CGPB | (i << 8));
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movzbl (%rsi), %ebx
xorl %eax, %eax
testl %edi, %edi
sete %al
leaq 0x83a3(%rip), %rsi      # 0x1282c
xorl %ebp, %ebp
movl %eax, %edi
xorl %eax, %eax
callq 0x793d
xorl %r14d, %r14d
cmpl $0x8, %r14d
je 0xa4c1
btl %r14d, %ebx
movl %ebp, %esi
sbbl $-0x1, %esi
addl $0x5a00000b, %esi       # imm = 0x5A00000B
movl $0x400e0a04, %edi       # imm = 0x400E0A04
callq 0x700c
incl %r14d
addl $0x100, %ebp            # imm = 0x100
jmp 0xa497
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm7.c
// Function: target_deselect
static void target_deselect(void)
{
  dap_write_word(DHCSR, DHCSR_DBGKEY);
  dap_write_word(DEMCR, 0);
  dap_reset_target_hw(1);

  target_free_options(&target_options);
}

// Assembly:
pushq %rax
movl $0xe000edf0, %edi       # imm = 0xE000EDF0
movl $0xa05f0000, %esi       # imm = 0xA05F0000
callq 0x700c
movl $0xe000edfc, %edi       # imm = 0xE000EDFC
xorl %esi, %esi
callq 0x700c
pushq $0x1
popq %rdi
callq 0x6e14
leaq 0x754ab(%rip), %rdi     # 0x7fb88
popq %rax
jmp 0x8ca8
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm7.c
// Function: target_program
static void target_program(void)
{
  uint32_t addr = FLASH_START + target_options.offset;
  uint32_t number_of_pages, page_offset;
  uint32_t offs = 0;
  uint8_t *buf = target_options.file_data;
  uint32_t size = target_options.file_size;

  number_of_pages = (size + FLASH_PAGE_SIZE - 1) / FLASH_PAGE_SIZE;
  page_offset = target_options.offset / FLASH_PAGE_SIZE;

  for (uint32_t page = 0; page < number_of_pages; page += PAGES_IN_ERASE_BLOCK)
  {
    dap_write_word(EEFC_FCR, CMD_EPA | (((page_offset + page) | 2) << 8));
    while (0 == (dap_read_word(EEFC_FSR) & FSR_FRDY));

    verbose(".");
  }

  verbose(",");

  for (uint32_t page = 0; page < number_of_pages; page++)
  {
    dap_write_block(addr, &buf[offs], FLASH_PAGE_SIZE);
    addr += FLASH_PAGE_SIZE;
    offs += FLASH_PAGE_SIZE;

    dap_write_word(EEFC_FCR, CMD_WP | ((page + page_offset) << 8));
    while (0 == (dap_read_word(EEFC_FSR) & FSR_FRDY));

    verbose(".");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x7547d(%rip), %ebx     # 0x7fba0
movq 0x7548e(%rip), %r12     # 0x7fbb8
movl $0x1ff, %ebp            # imm = 0x1FF
addl 0x7547b(%rip), %ebp     # 0x7fbb0
shrl $0x9, %ebp
movl $0x200, %ecx            # imm = 0x200
movl %ebx, %eax
cltd
idivl %ecx
movl %eax, %r14d
leaq 0x60c3(%rip), %r15      # 0x1080f
xorl %r13d, %r13d
cmpl %ebp, %r13d
jae 0xa789
leal (%r14,%r13), %esi
shll $0x8, %esi
orl $0x5a000207, %esi       # imm = 0x5A000207
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x700c
movl $0x400e0c08, %edi       # imm = 0x400E0C08
callq 0x6fe1
testb $0x1, %al
je 0xa76b
movq %r15, %rdi
xorl %eax, %eax
callq 0x773c
addl $0x10, %r13d
jmp 0xa74f
addl $0x400000, %ebx         # imm = 0x400000
leaq 0x8626(%rip), %rdi      # 0x12dbc
xorl %eax, %eax
callq 0x773c
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpl %ebp, %r15d
je 0xa7fd
leaq (%r12,%r13), %rsi
movl %ebx, %edi
movl $0x200, %edx            # imm = 0x200
callq 0x70ef
addl $0x200, %ebx            # imm = 0x200
leal (%r15,%r14), %esi
shll $0x8, %esi
orl $0x5a000001, %esi       # imm = 0x5A000001
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x700c
movl $0x400e0c08, %edi       # imm = 0x400E0C08
callq 0x6fe1
testb $0x1, %al
je 0xa7d5
addq $0x200, %r13            # imm = 0x200
leaq 0x601e(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x773c
incl %r15d
jmp 0xa7a3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm7.c
// Function: target_fuse_read
static int target_fuse_read(int section, uint8_t *data)
{
  uint32_t gpnvm;

  if (section > 0)
    return 0;

  dap_write_word(EEFC_FCR, CMD_GGPB);
  while (0 == (dap_read_word(EEFC_FSR) & FSR_FRDY));
  gpnvm = dap_read_word(EEFC_FRR);

  data[0] = gpnvm;
  data[1] = gpnvm >> 8;

  return GPNVM_SIZE;
}

// Assembly:
xorl %eax, %eax
testl %edi, %edi
jle 0xa973
retq
pushq %rbx
movq %rsi, %rbx
movl $0x400e0c04, %edi       # imm = 0x400E0C04
movl $0x5a00000d, %esi       # imm = 0x5A00000D
callq 0x700c
movl $0x400e0c08, %edi       # imm = 0x400E0C08
callq 0x6fe1
testb $0x1, %al
je 0xa986
movl $0x400e0c0c, %edi       # imm = 0x400E0C0C
callq 0x6fe1
movw %ax, (%rbx)
pushq $0x2
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm7.c
// Function: target_fuse_write
static void target_fuse_write(int section, uint8_t *data)
{
  uint32_t gpnvm = (data[1] << 8) | data[0];

  check(0 == section, "internal: incorrect section index in target_fuse_write()");

  for (int i = 0; i < GPNVM_SIZE_BITS; i++)
  {
    if (gpnvm & (1 << i))
      dap_write_word(EEFC_FCR, CMD_SGPB | (i << 8));
    else
      dap_write_word(EEFC_FCR, CMD_CGPB | (i << 8));
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movzwl (%rsi), %ebx
xorl %eax, %eax
testl %edi, %edi
sete %al
leaq 0x7e71(%rip), %rsi      # 0x1282c
xorl %ebp, %ebp
movl %eax, %edi
xorl %eax, %eax
callq 0x793d
xorl %r14d, %r14d
cmpl $0x9, %r14d
je 0xa9f3
btl %r14d, %ebx
movl %ebp, %esi
sbbl $-0x1, %esi
addl $0x5a00000b, %esi       # imm = 0x5A00000B
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x700c
incl %r14d
addl $0x100, %ebp            # imm = 0x100
jmp 0xa9c9
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm4v2.c
// Function: target_erase
static void target_erase(void)
{
  dap_write_byte(DSU_CTRL, DSU_CTRL_CE); // Chip erase
  sleep_ms(100);
  while (0 == (dap_read_byte(DSU_STATUSA) & DSU_STATUSA_DONE));

  reset_with_extension();
  finish_reset();
}

// Assembly:
pushq %rax
pushq $0x10
popq %rsi
movl $0x41002100, %edi       # imm = 0x41002100
callq 0x6ff4
pushq $0x64
popq %rdi
callq 0x7aeb
movl $0x41002101, %edi       # imm = 0x41002101
callq 0x6fba
testb $0x1, %al
je 0xab5a
callq 0xaf02
popq %rax
jmp 0xaf18
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/target_atmel_cm4v2.c
// Function: target_fuse_write
static void target_fuse_write(int section, uint8_t *data)
{
  uint32_t addr = USER_ROW_ADDR;

  check(0 == section, "internal: incorrect section index in target_fuse_write()");

  dap_write_word(NVMCTRL_ADDR, USER_ROW_ADDR);

  dap_write_half(NVMCTRL_CTRLB, NVMCTRL_CMD_EP);
  while (0 == (dap_read_half(NVMCTRL_STATUS) & NVMCTRL_STATUS_READY));

  dap_write_half(NVMCTRL_CTRLB, NVMCTRL_CMD_PBC);
  while (0 == (dap_read_half(NVMCTRL_STATUS) & NVMCTRL_STATUS_READY));

  for (int i = 0; i < (USER_ROW_SIZE / USER_ROW_PAGE_SIZE); i++)
  {
    dap_write_word(NVMCTRL_ADDR, USER_ROW_ADDR);

    dap_write_block(addr, data, USER_ROW_PAGE_SIZE);

    dap_write_half(NVMCTRL_CTRLB, NVMCTRL_CMD_WQW);
    while (0 == (dap_read_half(NVMCTRL_STATUS) & NVMCTRL_STATUS_READY));

    addr += USER_ROW_PAGE_SIZE;
    data += USER_ROW_PAGE_SIZE;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
xorl %eax, %eax
testl %edi, %edi
sete %al
leaq 0x79fa(%rip), %rsi      # 0x1282c
movl %eax, %edi
xorl %eax, %eax
callq 0x793d
movl $0x41004014, %edi       # imm = 0x41004014
movl $0x804000, %esi         # imm = 0x804000
callq 0x700c
movl $0x41004004, %edi       # imm = 0x41004004
movl $0xa500, %esi           # imm = 0xA500
callq 0x7000
movl $0x41004012, %edi       # imm = 0x41004012
callq 0x6fcd
testb $0x1, %al
je 0xae59
movl $0x41004004, %edi       # imm = 0x41004004
movl $0xa515, %esi           # imm = 0xA515
callq 0x7000
movl $0x41004012, %edi       # imm = 0x41004012
callq 0x6fcd
testb $0x1, %al
je 0xae76
xorl %r15d, %r15d
movl $0x804000, %ebp         # imm = 0x804000
pushq $0x10
popq %r14
cmpl $0x20, %r15d
je 0xaedb
movl $0x41004014, %edi       # imm = 0x41004014
movl $0x804000, %esi         # imm = 0x804000
callq 0x700c
movl %ebp, %edi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x70ef
movl $0x41004004, %edi       # imm = 0x41004004
movl $0xa504, %esi           # imm = 0xA504
callq 0x7000
movl $0x41004012, %edi       # imm = 0x41004012
callq 0x6fcd
testb $0x1, %al
je 0xaec1
addl $0x10, %ebp
addq $0x10, %rbx
incl %r15d
jmp 0xae90
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq