LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl 0x76ed2(%rip), %eax     # 0x821e0
addl $0x0, %eax
movl %eax, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movq 0x76ed6(%rip), %rax     # 0x821f8
movq %rax, -0x18(%rbp)
movl 0x76ec4(%rip), %eax     # 0x821f0
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
subl $0x1, %eax
shrl $0x8, %eax
movl %eax, -0xc(%rbp)
movl $0x41004004, %edi       # imm = 0x41004004
xorl %esi, %esi
callq 0x77d0
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0xb413
movl -0x4(%rbp), %esi
shrl %esi
movl $0x4100401c, %edi       # imm = 0x4100401C
callq 0x77d0
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa541, %esi           # imm = 0xA541
callq 0x77a0
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x76e0
movzbl %al, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xb395
jmp 0xb37d
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa502, %esi           # imm = 0xA502
callq 0x77a0
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x76e0
movzbl %al, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xb3bc
jmp 0xb3a4
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x79c0
movl -0x4(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x4(%rbp)
movl -0x8(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x8(%rbp)
movl -0x20(%rbp), %ecx
andl $0x1f, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xb403
leaq 0x9473(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
jmp 0xb405
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xb353
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl 0x76db2(%rip), %eax     # 0x821e0
addl $0x0, %eax
movl %eax, -0x4(%rbp)
movl $0x0, -0xc(%rbp)
movq 0x76db6(%rip), %rax     # 0x821f8
movq %rax, -0x20(%rbp)
movl 0x76da4(%rip), %eax     # 0x821f0
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x8ae0
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0xb56e
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7800
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jbe 0xb492
movl $0x100, %eax            # imm = 0x100
movl %eax, -0x30(%rbp)
jmp 0xb498
movl -0x24(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x8(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0xb521
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0xb514
movl -0x4(%rbp), %esi
addl -0x2c(%rbp), %esi
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %edx
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %ecx
leaq 0xb377(%rip), %rdi      # 0x1686d
movb $0x0, %al
callq 0x8630
movq -0x18(%rbp), %rdi
callq 0x8b30
leaq 0xc5bb(%rip), %rdi      # 0x17ac8
movb $0x0, %al
callq 0x8970
jmp 0xb516
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xb4a5
movl -0x4(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x4(%rbp)
movl -0xc(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x28(%rbp)
movl $0x20, %ecx
cltd
idivl %ecx
xorl %eax, %eax
cmpl %edx, %eax
jne 0xb569
leaq 0x930d(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
jmp 0xb464
movq -0x18(%rbp), %rdi
callq 0x8b30
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl 0x76c52(%rip), %eax     # 0x821e0
addl $0x0, %eax
movl %eax, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movq 0x76c56(%rip), %rax     # 0x821f8
movq %rax, -0x10(%rbp)
movl 0x76c38(%rip), %eax     # 0x821e4
movl %eax, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xb61d
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7800
movl -0x4(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x4(%rbp)
movl -0x8(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x8(%rbp)
movl -0x14(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x18(%rbp)
movl $0x20, %ecx
cltd
idivl %ecx
xorl %eax, %eax
cmpl %edx, %eax
jne 0xb61b
leaq 0x925b(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
jmp 0xb5b6
movq 0x76bb4(%rip), %rdi     # 0x821d8
movq -0x10(%rbp), %rsi
movl 0x76bb6(%rip), %edx     # 0x821e4
callq 0x8c40
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/ataradov[P]edbg/target_atmel_cm0p.c
// Function: target_fuse_read
static int target_fuse_read(int section, uint8_t *data)
{
  if (section > 0)
    return 0;

  dap_read_block(USER_ROW_ADDR, data, USER_ROW_SIZE);

  return USER_ROW_SIZE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jle 0xb65e
movl $0x0, -0x4(%rbp)
jmp 0xb678
movq -0x10(%rbp), %rsi
movl $0x804000, %edi         # imm = 0x804000
movl $0x100, %edx            # imm = 0x100
callq 0x7800
movl $0x100, -0x4(%rbp)      # imm = 0x100
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
cmpl -0x4(%rbp), %eax
sete %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb1e8(%rip), %rsi      # 0x1689c
xorl %eax, %eax
callq 0x8880
movl $0x41004004, %edi       # imm = 0x41004004
xorl %esi, %esi
callq 0x77d0
movl $0x4100401c, %edi       # imm = 0x4100401C
movl $0x402000, %esi         # imm = 0x402000
callq 0x77d0
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa505, %esi           # imm = 0xA505
callq 0x77a0
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x76e0
movzbl %al, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xb6fd
jmp 0xb6e5
movq -0x10(%rbp), %rsi
movl $0x804000, %edi         # imm = 0x804000
movl $0x100, %edx            # imm = 0x100
callq 0x79c0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
movl $0xe000edf0, %edi       # imm = 0xE000EDF0
movl $0xa05f0003, %esi       # imm = 0xA05F0003
callq 0x77d0
movl $0xe000edfc, %edi       # imm = 0xE000EDFC
movl $0x1, %esi
callq 0x77d0
movl $0xe000ed0c, %edi       # imm = 0xE000ED0C
movl $0x5fa0004, %esi        # imm = 0x5FA0004
callq 0x77d0
movl $0x41002101, %edi       # imm = 0x41002101
movl $0x2, %esi
callq 0x7770
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x76704(%rip), %eax     # 0x8221c
jge 0xbb4a
movslq -0x4(%rbp), %rcx
leaq 0x766db(%rip), %rax     # 0x82200
addq $0x20, %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edi
addl $0x4, %edi
movl $0x5a000005, %esi       # imm = 0x5A000005
callq 0x77d0
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xbb0f
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl 0x766c2(%rip), %eax     # 0x8221c
jge 0xbb9c
jmp 0xbb5e
movslq -0x8(%rbp), %rcx
leaq 0x76697(%rip), %rax     # 0x82200
addq $0x20, %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edi
addl $0x8, %edi
callq 0x7740
movl %eax, %eax
movl %eax, %ecx
andq $0x1, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0xbb8f
jmp 0xbb5e
jmp 0xbb91
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0xbb51
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl 0x76642(%rip), %eax     # 0x82250
movl %eax, -0x4(%rbp)
movl $0x0, -0x10(%rbp)
movq 0x76649(%rip), %rax     # 0x82268
movq %rax, -0x18(%rbp)
movl 0x76637(%rip), %eax     # 0x82260
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
subl $0x1, %eax
shrl $0x8, %eax
movl %eax, -0x8(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0xbcde
movl -0x4(%rbp), %edi
callq 0xc060
movl %eax, -0xc(%rbp)
movl -0x4(%rbp), %edi
callq 0xc120
movl %eax, %edi
movq -0x18(%rbp), %rsi
movl -0x10(%rbp), %eax
addq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x79c0
movl -0xc(%rbp), %edi
addl $0x4, %edi
movl -0x20(%rbp), %esi
shll $0x8, %esi
orl $0x5a000003, %esi       # imm = 0x5A000003
callq 0x77d0
movl -0xc(%rbp), %edi
addl $0x8, %edi
callq 0x7740
movl %eax, %eax
movl %eax, %ecx
andq $0x1, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0xbcac
jmp 0xbc90
movl -0x4(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x4(%rbp)
movl -0x10(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x10(%rbp)
leaq 0x8ba6(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbc44
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl 0x76552(%rip), %eax     # 0x82250
movl %eax, -0x4(%rbp)
movl $0x0, -0xc(%rbp)
movq 0x76559(%rip), %rax     # 0x82268
movq %rax, -0x20(%rbp)
movl 0x76547(%rip), %eax     # 0x82260
movl %eax, -0x24(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x8ae0
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0xbe22
movl -0x4(%rbp), %edi
callq 0xc120
movl %eax, %edi
movq -0x18(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7800
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jbe 0xbd5f
movl $0x100, %eax            # imm = 0x100
movl %eax, -0x2c(%rbp)
jmp 0xbd65
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x8(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0xbdee
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0xbde1
movl -0x4(%rbp), %esi
addl -0x28(%rbp), %esi
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %edx
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %ecx
leaq 0xaaaa(%rip), %rdi      # 0x1686d
movb $0x0, %al
callq 0x8630
movq -0x18(%rbp), %rdi
callq 0x8b30
leaq 0xbcee(%rip), %rdi      # 0x17ac8
movb $0x0, %al
callq 0x8970
jmp 0xbde3
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xbd72
movl -0x4(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x4(%rbp)
movl -0xc(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
leaq 0x8a59(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
jmp 0xbd2a
movq -0x18(%rbp), %rdi
callq 0x8b30
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl 0x76402(%rip), %eax     # 0x82250
movl %eax, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movq 0x76409(%rip), %rax     # 0x82268
movq %rax, -0x10(%rbp)
movl 0x763eb(%rip), %eax     # 0x82254
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xbec1
movl -0x4(%rbp), %edi
callq 0xc120
movl %eax, %edi
movq -0x10(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7800
movl -0x4(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x4(%rbp)
movl -0x8(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x8(%rbp)
movl -0x14(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
movl %eax, -0x14(%rbp)
leaq 0x89b7(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
jmp 0xbe6c
movq 0x76380(%rip), %rdi     # 0x82248
movq -0x10(%rbp), %rsi
movl 0x76382(%rip), %edx     # 0x82254
callq 0x8c40
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jle 0xbefe
movl $0x0, -0x4(%rbp)
jmp 0xbf5c
xorl %edi, %edi
callq 0xc060
movl %eax, %edi
addl $0x4, %edi
movl $0x5a00000d, %esi       # imm = 0x5A00000D
callq 0x77d0
xorl %edi, %edi
callq 0xc060
movl %eax, %edi
addl $0x8, %edi
callq 0x7740
movl %eax, %eax
movl %eax, %ecx
andq $0x1, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0xbf36
jmp 0xbf14
xorl %edi, %edi
callq 0xc060
movl %eax, %edi
addl $0xc, %edi
callq 0x7740
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x14(%rbp)
xorl %eax, %eax
cmpl -0x4(%rbp), %eax
sete %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xa8fe(%rip), %rsi      # 0x1689c
xorl %eax, %eax
callq 0x8880
movl $0x0, -0x18(%rbp)
cmpl $0x8, -0x18(%rbp)
jge 0xc011
movl -0x14(%rbp), %eax
movl -0x18(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0xbfe7
xorl %edi, %edi
callq 0xc060
movl %eax, %edi
addl $0x4, %edi
movl -0x18(%rbp), %esi
shll $0x8, %esi
orl $0x5a00000b, %esi       # imm = 0x5A00000B
callq 0x77d0
jmp 0xc004
xorl %edi, %edi
callq 0xc060
movl %eax, %edi
addl $0x4, %edi
movl -0x18(%rbp), %esi
shll $0x8, %esi
orl $0x5a00000c, %esi       # imm = 0x5A00000C
callq 0x77d0
jmp 0xc006
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xbfac
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %edi
callq 0xc120
movl %eax, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl 0x76196(%rip), %eax     # 0x8221c
jge 0xc102
movslq -0x10(%rbp), %rcx
leaq 0x7616d(%rip), %rax     # 0x82200
addq $0x20, %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x14(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0x76151(%rip), %rax     # 0x82200
addq $0x20, %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
ja 0xc0f2
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jae 0xc0f2
movslq -0x10(%rbp), %rcx
leaq 0x76120(%rip), %rax     # 0x82200
addq $0x20, %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc117
jmp 0xc0f4
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xc07d
leaq 0xa8f7(%rip), %rdi      # 0x16a00
movb $0x0, %al
callq 0x8970
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl 0x760db(%rip), %eax     # 0x8221c
jge 0xc1b2
movl -0xc(%rbp), %eax
movslq -0x10(%rbp), %rdx
leaq 0x760af(%rip), %rcx     # 0x82200
addq $0x20, %rcx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jb 0xc184
movslq -0x10(%rbp), %rcx
leaq 0x76094(%rip), %rax     # 0x82200
addq $0x20, %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movl -0xc(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xc(%rbp)
jmp 0xc1a5
movslq -0x10(%rbp), %rcx
leaq 0x76071(%rip), %rax     # 0x82200
addq $0x20, %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc1c7
jmp 0xc1a7
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xc138
leaq 0xa869(%rip), %rdi      # 0x16a22
movb $0x0, %al
callq 0x8970
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x75d60(%rip), %eax     # 0x82288
jae 0xc54b
movl -0x4(%rbp), %edi
shll $0x9, %edi
addl $0x400e0a04, %edi       # imm = 0x400E0A04
movl $0x5a000005, %esi       # imm = 0x5A000005
callq 0x77d0
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xc51f
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl 0x75d2d(%rip), %eax     # 0x82288
jae 0xc58a
jmp 0xc55f
movl -0x8(%rbp), %edi
shll $0x9, %edi
addl $0x400e0a08, %edi       # imm = 0x400E0A08
callq 0x7740
movl %eax, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xc57d
jmp 0xc55f
jmp 0xc57f
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0xc552
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl 0x75b4a(%rip), %eax     # 0x822a8
addl $0x400000, %eax         # imm = 0x400000
movl %eax, -0x4(%rbp)
movl $0x0, -0xc(%rbp)
movq 0x75b4c(%rip), %rax     # 0x822c0
movq %rax, -0x20(%rbp)
movl 0x75b3a(%rip), %eax     # 0x822b8
movl %eax, -0x24(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0x8ae0
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0xc880
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x7800
cmpl $0x200, -0x24(%rbp)     # imm = 0x200
jbe 0xc7bd
movl $0x200, %eax            # imm = 0x200
movl %eax, -0x2c(%rbp)
jmp 0xc7c3
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x8(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0xc84c
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0xc83f
movl -0x4(%rbp), %esi
addl -0x28(%rbp), %esi
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %edx
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %ecx
leaq 0xa04c(%rip), %rdi      # 0x1686d
movb $0x0, %al
callq 0x8630
movq -0x18(%rbp), %rdi
callq 0x8b30
leaq 0xb290(%rip), %rdi      # 0x17ac8
movb $0x0, %al
callq 0x8970
jmp 0xc841
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xc7d0
movl -0x4(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x4(%rbp)
movl -0xc(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
leaq 0x7ffb(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
jmp 0xc78f
movq -0x18(%rbp), %rdi
callq 0x8b30
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl 0x75a0a(%rip), %eax     # 0x822a8
addl $0x400000, %eax         # imm = 0x400000
movl %eax, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movq 0x75a0c(%rip), %rax     # 0x822c0
movq %rax, -0x10(%rbp)
movl 0x759ee(%rip), %eax     # 0x822ac
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xc90f
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x7800
movl -0x4(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x4(%rbp)
movl -0x8(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x8(%rbp)
movl -0x14(%rbp), %eax
subl $0x200, %eax            # imm = 0x200
movl %eax, -0x14(%rbp)
leaq 0x7f69(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
jmp 0xc8c1
movq 0x7598a(%rip), %rdi     # 0x822a0
movq -0x10(%rbp), %rsi
movl 0x7598c(%rip), %edx     # 0x822ac
callq 0x8c40
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jle 0xc94e
movl $0x0, -0x4(%rbp)
jmp 0xc993
movl $0x400e0a04, %edi       # imm = 0x400E0A04
movl $0x5a00000d, %esi       # imm = 0x5A00000D
callq 0x77d0
movl $0x400e0a08, %edi       # imm = 0x400E0A08
callq 0x7740
movl %eax, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xc974
jmp 0xc95d
movl $0x400e0a0c, %edi       # imm = 0x400E0A0C
callq 0x7740
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x14(%rbp)
xorl %eax, %eax
cmpl -0x4(%rbp), %eax
sete %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0x9ece(%rip), %rsi      # 0x1689c
xorl %eax, %eax
callq 0x8880
movl $0x0, -0x18(%rbp)
cmpl $0x8, -0x18(%rbp)
jge 0xca33
movl -0x14(%rbp), %eax
movl -0x18(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0xca10
movl -0x18(%rbp), %esi
shll $0x8, %esi
orl $0x5a00000b, %esi       # imm = 0x5A00000B
movl $0x400e0a04, %edi       # imm = 0x400E0A04
callq 0x77d0
jmp 0xca26
movl -0x18(%rbp), %esi
shll $0x8, %esi
orl $0x5a00000c, %esi       # imm = 0x5A00000C
movl $0x400e0a04, %edi       # imm = 0x400E0A04
callq 0x77d0
jmp 0xca28
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xc9dc
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
movl $0xe000edf0, %edi       # imm = 0xE000EDF0
movl $0xa05f0000, %esi       # imm = 0xA05F0000
callq 0x77d0
movl $0xe000edfc, %edi       # imm = 0xE000EDFC
xorl %esi, %esi
callq 0x77d0
movl $0x1, %edi
callq 0x6ef0
leaq 0x75598(%rip), %rdi     # 0x822e8
callq 0xa7c0
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl 0x75542(%rip), %eax     # 0x82300
addl $0x400000, %eax         # imm = 0x400000
movl %eax, -0x4(%rbp)
movl $0x0, -0x10(%rbp)
movq 0x75544(%rip), %rax     # 0x82318
movq %rax, -0x18(%rbp)
movl 0x75532(%rip), %eax     # 0x82310
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
subl $0x1, %eax
shrl $0x9, %eax
movl %eax, -0x8(%rbp)
movl 0x75508(%rip), %eax     # 0x82300
movl $0x200, %ecx            # imm = 0x200
cltd
idivl %ecx
movl %eax, -0xc(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0xce5e
movl -0xc(%rbp), %esi
addl -0x20(%rbp), %esi
orl $0x2, %esi
shll $0x8, %esi
orl $0x5a000007, %esi       # imm = 0x5A000007
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x77d0
movl $0x400e0c08, %edi       # imm = 0x400E0C08
callq 0x7740
movl %eax, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xce45
jmp 0xce2e
leaq 0x7a23(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
movl -0x20(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x20(%rbp)
jmp 0xce0a
leaq 0x9fc7(%rip), %rdi      # 0x16e2c
movb $0x0, %al
callq 0x8630
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0xcef1
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movl -0x10(%rbp), %eax
addq %rax, %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x79c0
movl -0x4(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x4(%rbp)
movl -0x10(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x10(%rbp)
movl -0x24(%rbp), %esi
addl -0xc(%rbp), %esi
shll $0x8, %esi
orl $0x5a000001, %esi       # imm = 0x5A000001
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x77d0
movl $0x400e0c08, %edi       # imm = 0x400E0C08
callq 0x7740
movl %eax, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xced8
jmp 0xcec1
leaq 0x7990(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xce73
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jle 0xd0fe
movl $0x0, -0x4(%rbp)
jmp 0xd152
movl $0x400e0c04, %edi       # imm = 0x400E0C04
movl $0x5a00000d, %esi       # imm = 0x5A00000D
callq 0x77d0
movl $0x400e0c08, %edi       # imm = 0x400E0C08
callq 0x7740
movl %eax, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xd124
jmp 0xd10d
movl $0x400e0c0c, %edi       # imm = 0x400E0C0C
callq 0x7740
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movl -0x14(%rbp), %eax
shrl $0x8, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x1(%rax)
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl (%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x14(%rbp)
xorl %eax, %eax
cmpl -0x4(%rbp), %eax
sete %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0x9701(%rip), %rsi      # 0x1689c
xorl %eax, %eax
callq 0x8880
movl $0x0, -0x18(%rbp)
cmpl $0x9, -0x18(%rbp)
jge 0xd200
movl -0x14(%rbp), %eax
movl -0x18(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0xd1dd
movl -0x18(%rbp), %esi
shll $0x8, %esi
orl $0x5a00000b, %esi       # imm = 0x5A00000B
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x77d0
jmp 0xd1f3
movl -0x18(%rbp), %esi
shll $0x8, %esi
orl $0x5a00000c, %esi       # imm = 0x5A00000C
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x77d0
jmp 0xd1f5
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xd1a9
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
movl $0x41002100, %edi       # imm = 0x41002100
movl $0x10, %esi
callq 0x7770
movl $0x64, %edi
callq 0x8a90
movl $0x41002101, %edi       # imm = 0x41002101
callq 0x76e0
movzbl %al, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xd435
jmp 0xd41d
callq 0xd980
callq 0xd9a0
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x804000, -0x14(%rbp)  # imm = 0x804000
xorl %eax, %eax
cmpl -0x4(%rbp), %eax
sete %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0x9041(%rip), %rsi      # 0x1689c
xorl %eax, %eax
callq 0x8880
movl $0x41004014, %edi       # imm = 0x41004014
movl $0x804000, %esi         # imm = 0x804000
callq 0x77d0
movl $0x41004004, %edi       # imm = 0x41004004
movl $0xa500, %esi           # imm = 0xA500
callq 0x77a0
movl $0x41004012, %edi       # imm = 0x41004012
callq 0x7710
movzwl %ax, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xd898
jmp 0xd880
movl $0x41004004, %edi       # imm = 0x41004004
movl $0xa515, %esi           # imm = 0xA515
callq 0x77a0
movl $0x41004012, %edi       # imm = 0x41004012
callq 0x7710
movzwl %ax, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xd8bf
jmp 0xd8a7
movl $0x0, -0x18(%rbp)
cmpl $0x20, -0x18(%rbp)
jge 0xd933
movl $0x41004014, %edi       # imm = 0x41004014
movl $0x804000, %esi         # imm = 0x804000
callq 0x77d0
movl -0x14(%rbp), %edi
movq -0x10(%rbp), %rsi
movl $0x10, %edx
callq 0x79c0
movl $0x41004004, %edi       # imm = 0x41004004
movl $0xa504, %esi           # imm = 0xA504
callq 0x77a0
movl $0x41004012, %edi       # imm = 0x41004012
callq 0x7710
movzwl %ax, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xd913
jmp 0xd8fb
movl -0x14(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x10(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xd8c6
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/ataradov[P]edbg/target_mchp_cm23.c
// Function: target_erase
static void target_erase(void)
{
  reset_with_extension();

  sleep_ms(10);

  if (dap_read_byte(DSU_STATUSB) & DSU_STATUSB_BCCD1)
  {
    uint32_t status = dap_read_word(DSU_BCC1);
    warning("BootROM indicated an error (STATUS = 0x%08x), still trying to erase", status);
  }
  else
  {
    bootrom_command(CMD_INIT);
    bootrom_expect(SIG_COMM);
  }

  if (target_device.trust_zone)
  {
    bootrom_command(CMD_CE2);
    bootrom_expect(SIG_CMD_VALID);

    // TODO: Take this value from a command line argument
    bootrom_data(0xffffffff);
    bootrom_data(0xffffffff);
    bootrom_data(0xffffffff);
    bootrom_data(0xffffffff);
  }
  else
  {
    bootrom_command(CMD_CHIPERASE);
    bootrom_expect(SIG_CMD_VALID);
  }

  bootrom_expect(SIG_CMD_SUCCESS);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
callq 0xe270
movl $0xa, %edi
callq 0x8a90
movl $0x41002102, %edi       # imm = 0x41002102
callq 0x76e0
movzbl %al, %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xdbde
movl $0x41002124, %edi       # imm = 0x41002124
callq 0x7740
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %esi
leaq 0x9681(%rip), %rdi      # 0x17256
movb $0x0, %al
callq 0x87a0
jmp 0xdbf2
movl $0x55, %edi
callq 0xe2a0
movl $0x20, %edi
callq 0xe2e0
testb $0x1, 0x7479b(%rip)     # 0x82394
je 0xdc39
movl $0xe2, %edi
callq 0xe2a0
movl $0x24, %edi
callq 0xe2e0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xe3a0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xe3a0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xe3a0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xe3a0
jmp 0xdc4d
movl $0xe3, %edi
callq 0xe2a0
movl $0x24, %edi
callq 0xe2e0
movl $0x21, %edi
callq 0xe2e0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/ataradov[P]edbg/target_mchp_cm23.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;

  bootrom_park();

  if ((dap_read_byte(DSU_STATUSB) & 0x03) != 0x02)
    error_exit("device is locked (DAL is not 2), perform a chip erase before programming");

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

  dap_write_byte(NVMCTRL_CTRLC, 0); // Enable automatic write

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

    dap_write_half(NVMCTRL_CTRLA, NVMCTRL_CMD_ER);
    while (0 == (dap_read_byte(NVMCTRL_STATUS) & NVMCTRL_STATUS_READY));

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

    addr += FLASH_ROW_SIZE;
    offs += FLASH_ROW_SIZE;

    verbose(".");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl 0x7470a(%rip), %eax     # 0x823b8
addl $0x0, %eax
movl %eax, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movq 0x7470e(%rip), %rax     # 0x823d0
movq %rax, -0x18(%rbp)
movl 0x746fc(%rip), %eax     # 0x823c8
movl %eax, -0x1c(%rbp)
callq 0xe3e0
movl $0x41002102, %edi       # imm = 0x41002102
callq 0x76e0
movzbl %al, %eax
andl $0x3, %eax
cmpl $0x2, %eax
je 0xdcf7
leaq 0x9669(%rip), %rdi      # 0x17359
movb $0x0, %al
callq 0x8970
movl -0x1c(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
subl $0x1, %eax
shrl $0x8, %eax
movl %eax, -0xc(%rbp)
movl 0x746d2(%rip), %edi     # 0x823e0
xorl %esi, %esi
callq 0x7770
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0xdda8
movl 0x746ba(%rip), %edi     # 0x823e8
movl -0x4(%rbp), %esi
callq 0x77d0
movl 0x7469c(%rip), %edi     # 0x823d8
movl $0xa502, %esi           # imm = 0xA502
callq 0x77a0
movl 0x74698(%rip), %edi     # 0x823e4
callq 0x76e0
movzbl %al, %ecx
andl $0x4, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xdd5f
jmp 0xdd46
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x79c0
movl -0x4(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x4(%rbp)
movl -0x8(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x8(%rbp)
leaq 0x6adc(%rip), %rdi      # 0x1486f
movb $0x0, %al
callq 0x8630
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xdd1c
addq $0x20, %rsp
popq %rbp
retq
nop