LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/ataradov[P]edbg/edbg.c
// Function: load_file
int load_file(char *name, uint8_t *data, int size)
{
  struct stat stat;
  int fd, rsize;

  check(NULL != name, "input file name is not specified");

  fd = open(name, O_RDONLY | O_BINARY);

  if (fd < 0)
    perror_exit("open()");

  fstat(fd, &stat);

  if (stat.st_size < size)
    size = stat.st_size;

  rsize = read(fd, data, size);

  if (rsize < 0)
    perror_exit("read()");

  check(rsize == size, "cannot fully read file");

  close(fd);

  return rsize;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x98, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorl %edi, %edi
testq %rbx, %rbx
setne %dil
leaq 0x8781(%rip), %rsi      # 0x105a0
xorl %eax, %eax
callq 0x7bcc
movq %rbx, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x6200
testl %eax, %eax
js 0x7e99
movl %eax, %ebx
leaq 0x8(%rsp), %r15
movl %eax, %edi
movq %r15, %rsi
callq 0x62b0
movq 0x30(%r15), %rax
movslq %ebp, %r15
cmpq %r15, %rax
cmovll %eax, %r15d
movslq %r15d, %rdx
movl %ebx, %edi
movq %r14, %rsi
callq 0x6140
movq %rax, %r14
testl %r14d, %r14d
js 0x7e9e
xorl %edi, %edi
cmpl %r14d, %r15d
sete %dil
leaq 0x8755(%rip), %rsi      # 0x105cf
xorl %eax, %eax
callq 0x7bcc
movl %ebx, %edi
callq 0x6120
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x63ca
callq 0x63b5
// File: /workspace/github_c_makefile_star2_O3/ataradov[P]edbg/edbg.c
// Function: save_file
void save_file(char *name, uint8_t *data, int size)
{
  int fd, rsize;

  check(NULL != name, "output file name is not specified");

  fd = open(name, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0644);

  if (fd < 0)
    perror_exit("open()");

  rsize = write(fd, data, size);

  if (rsize < 0)
    perror_exit("write()");

  check(rsize == size, "error writing the file");

  close(fd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
xorl %edi, %edi
testq %r15, %r15
setne %dil
leaq 0x8724(%rip), %rsi      # 0x105e6
xorl %eax, %eax
callq 0x7bcc
movq %r15, %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x6200
testl %eax, %eax
js 0x7f1b
movl %eax, %ebp
movslq %ebx, %rdx
movl %eax, %edi
movq %r14, %rsi
callq 0x6060
testl %eax, %eax
js 0x7f20
xorl %edi, %edi
cmpl %ebx, %eax
sete %dil
leaq 0x8705(%rip), %rsi      # 0x10608
xorl %eax, %eax
callq 0x7bcc
movl %ebp, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6120
callq 0x63f4
callq 0x63df
// File: /workspace/github_c_makefile_star2_O3/ataradov[P]edbg/edbg.c
// Function: mem_find
uint8_t *mem_find(uint8_t *haystack, int haystack_size, uint8_t *needle, int needle_size)
{
  if (haystack_size == 0 || needle_size == 0 || haystack_size < needle_size)
    return NULL;

  for (int i = 0; i < (haystack_size - needle_size); i++)
  {
    if (memcmp(haystack + i, needle, needle_size) == 0)
      return haystack + i;
  }

  return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
xorl %ebx, %ebx
cmpl %ecx, %esi
jl 0x7f71
testl %esi, %esi
je 0x7f71
testl %ecx, %ecx
je 0x7f71
subl %ecx, %esi
jle 0x7f6a
movq %rdx, %r14
movq %rdi, %r15
movslq %ecx, %r12
movl %esi, %r13d
xorl %ebx, %ebx
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x61d0
testl %eax, %eax
je 0x7f6e
incq %r15
decq %r13
jne 0x7f4e
jmp 0x7f71
xorl %ebx, %ebx
jmp 0x7f71
movq %r15, %rbx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/ataradov[P]edbg/utils.c
// Function: sha256
void sha256(uint8_t *data, int size, uint8_t *hash)
{
  uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
  uint64_t bit_size = size * 8;
  uint8_t buf[64];

  while (size >= 64)
  {
    sha256_process(H, data);
    data += 64;
    size -= 64;
  }

  memset(buf, 0, sizeof(buf));
  memcpy(buf, data, size);

  buf[size] = 0x80;

  if (size >= 56)
  {
    sha256_process(H, buf);
    memset(buf, 0, sizeof(buf));
  }

  buf[56] = bit_size >> 56;
  buf[57] = bit_size >> 48;
  buf[58] = bit_size >> 40;
  buf[59] = bit_size >> 32;
  buf[60] = bit_size >> 24;
  buf[61] = bit_size >> 16;
  buf[62] = bit_size >> 8;
  buf[63] = bit_size;

  sha256_process(H, buf);

  for (int i = 0; i < 8; i++)
  {
    hash[i*4+0] = H[i] >> 24;
    hash[i*4+1] = H[i] >> 16;
    hash[i*4+2] = H[i] >> 8;
    hash[i*4+3] = H[i];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
movaps 0x898a(%rip), %xmm0     # 0x11380
movaps %xmm0, 0x10(%rsp)
movaps 0x896e(%rip), %xmm0     # 0x11370
movaps %xmm0, (%rsp)
leal (,%r14,8), %ebp
cmpl $0x40, %esi
jl 0x8a37
movq %rsp, %r12
movl %r14d, %r13d
movq %r12, %rdi
movq %r15, %rsi
callq 0x8b08
addq $0x40, %r15
leal -0x40(%r13), %eax
cmpl $0x7f, %r13d
movl %eax, %r13d
ja 0x8a19
jmp 0x8a3a
movl %r14d, %eax
movslq %ebp, %r13
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
movslq %eax, %r12
movq %r15, %rsi
movq %r12, %rdx
callq 0x6190
movb $-0x80, 0x20(%rsp,%r12)
cmpl $0x38, %r12d
jl 0x8a94
movq %rsp, %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x8b08
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movq %r13, %rax
shrq $0x38, %rax
leaq 0x20(%rsp), %rsi
movb %al, 0x38(%rsi)
movq %r13, %rax
shrq $0x30, %rax
movb %al, 0x39(%rsi)
movq %r13, %rax
shrq $0x28, %rax
movb %al, 0x3a(%rsi)
movl %r14d, %eax
sarl $0x1c, %eax
movb %al, 0x3b(%rsi)
movl %r14d, %eax
shrl $0x15, %eax
movb %al, 0x3c(%rsi)
movl %r14d, %eax
shrl $0xd, %eax
movb %al, 0x3d(%rsi)
shrl $0x5, %r14d
movb %r14b, 0x3e(%rsi)
movb %r13b, 0x3f(%rsi)
movq %rsp, %rdi
callq 0x8b08
xorl %eax, %eax
movl (%rsp,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
cmpq $0x8, %rax
jne 0x8ae8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ataradov[P]edbg/utils.c
// Function: sha256_process
static void sha256_process(uint32_t *H, uint8_t *data)
{
  uint32_t W[64];
  uint32_t ah[8]; // Working variables 'a' to 'h'

  for (int t = 0; t < 16; t++)
    W[t] = (data[t*4] << 24) | (data[t*4+1] << 16) | (data[t*4+2] << 8) | (data[t*4+3]);

  for (int t = 16; t < 64; t++)
    W[t] = SL1(W[t-2]) + W[t-7] + SL0(W[t-15]) + W[t-16];

  for(int t = 0; t < 8; t++)
    ah[t] = H[t];

  for (int t = 0; t < 64; t++)
  {
    uint32_t T1 = ah[7] + SU1(ah[4]) + CH(ah[4], ah[5], ah[6]) + K[t] + W[t];
    uint32_t T2 = SU0(ah[0]) + MAJ(ah[0], ah[1], ah[2]);

    ah[7] = ah[6];
    ah[6] = ah[5];
    ah[5] = ah[4];
    ah[4] = ah[3] + T1;
    ah[3] = ah[2];
    ah[2] = ah[1];
    ah[1] = ah[0];
    ah[0] = T1 + T2;
  }

  for (int t = 0; t < 8; t++)
    H[t] += ah[t];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
xorl %eax, %eax
movl (%rsi,%rax,4), %ecx
bswapl %ecx
movl %ecx, -0x60(%rsp,%rax,4)
incq %rax
cmpq $0x10, %rax
jne 0x8b1b
movl $0x10, %eax
movl -0x60(%rsp), %ecx
movl -0x9c(%rsp,%rax,4), %edx
movl -0x68(%rsp,%rax,4), %esi
movl %esi, %r8d
roll $0xf, %r8d
movl %esi, %r9d
roll $0xd, %r9d
xorl %r8d, %r9d
shrl $0xa, %esi
xorl %r9d, %esi
addl -0x7c(%rsp,%rax,4), %esi
movl %edx, %r8d
roll $0x19, %r8d
movl %edx, %r9d
roll $0xe, %r9d
xorl %r8d, %r9d
movl %edx, %r8d
shrl $0x3, %r8d
xorl %r9d, %r8d
addl %ecx, %r8d
addl %esi, %r8d
movl %r8d, -0x60(%rsp,%rax,4)
incq %rax
movl %edx, %ecx
cmpq $0x40, %rax
jne 0x8b36
movdqu (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
movaps %xmm1, -0x70(%rsp)
movdqa %xmm0, -0x80(%rsp)
movl -0x64(%rsp), %ebx
movl -0x70(%rsp), %ebp
movl -0x6c(%rsp), %eax
movl -0x68(%rsp), %ecx
movl -0x80(%rsp), %r9d
movl -0x7c(%rsp), %r10d
movl -0x78(%rsp), %edx
xorl %esi, %esi
movl -0x74(%rsp), %r14d
leaq 0x8bc4(%rip), %r8       # 0x11790
movl %ecx, %r11d
movl %eax, %ecx
movl %ebp, %eax
movl %r14d, %ebp
movl %eax, %r15d
roll $0x1a, %r15d
movl %edx, %r14d
movl %eax, %r12d
roll $0x15, %r12d
movl %r10d, %edx
movl %eax, %r13d
roll $0x7, %r13d
xorl %r15d, %r12d
xorl %r12d, %r13d
addl %ebx, %r13d
movl %ecx, %r10d
xorl %r11d, %r10d
andl %eax, %r10d
addl (%rsi,%r8), %r13d
xorl %r11d, %r10d
addl %r10d, %r13d
addl -0x60(%rsp,%rsi), %r13d
movl %r9d, %r10d
roll $0x1e, %r9d
movl %r10d, %ebx
roll $0x13, %ebx
xorl %r9d, %ebx
movl %r10d, %r15d
roll $0xa, %r15d
xorl %ebx, %r15d
movl %r14d, %ebx
xorl %edx, %ebx
andl %r10d, %ebx
movl %r14d, %r9d
andl %edx, %r9d
xorl %ebx, %r9d
addl %r15d, %r9d
addl %r13d, %ebp
addl %r13d, %r9d
addq $0x4, %rsi
movl %r11d, %ebx
cmpq $0x100, %rsi            # imm = 0x100
jne 0x8bcc
movl %r11d, -0x64(%rsp)
movl %ebp, -0x70(%rsp)
movl %eax, -0x6c(%rsp)
movl %ecx, -0x68(%rsp)
movl %r9d, -0x80(%rsp)
movl %r10d, -0x7c(%rsp)
movl %edx, -0x78(%rsp)
movl %r14d, -0x74(%rsp)
xorl %eax, %eax
movdqu (%rdi,%rax,4), %xmm0
paddd -0x80(%rsp,%rax,4), %xmm0
movdqu %xmm0, (%rdi,%rax,4)
addq $0x4, %rax
cmpq $0x8, %rax
jne 0x8c80
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ataradov[P]edbg/utils.c
// Function: crc32
uint32_t crc32(uint8_t *data, int size)
{
  uint32_t crc = 0xffffffff;

  for (int i = 0; i < size; i++)
    crc = crc32_tab[(crc ^ data[i]) & 0xff] ^ (crc >> 8);

  return crc;
}

// Assembly:
testl %esi, %esi
jle 0x8cdb
movl %esi, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %edx, %edx
leaq 0x86d0(%rip), %rsi      # 0x11390
movb (%rdi,%rdx), %r8b
xorb %al, %r8b
movzbl %r8b, %r8d
shrl $0x8, %eax
xorl (%rsi,%r8,4), %eax
incq %rdx
cmpq %rdx, %rcx
jne 0x8cc0
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/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 0x8b94(%rip), %rdi      # 0x11890
xorl %eax, %eax
callq 0x7b35
xorl %r12d, %r12d
leaq (%r12,%r12,2), %rax
leaq 0xf98f(%rip), %rcx      # 0x186a0
movq 0x8(%rcx,%rax,8), %rsi
movq 0x10(%rcx,%rax,8), %r14
leaq 0x8b8a(%rip), %rdi      # 0x118ac
xorl %eax, %eax
callq 0x7b35
xorl %edi, %edi
callq *0x50(%r14)
testq %rax, %rax
je 0x8dda
movq %rax, %rbx
movq %r12, 0x8(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
testl %r13d, %r13d
jle 0x8d69
movl %r13d, %r15d
xorl %r12d, %r12d
movq 0x10(%rsp,%r12,8), %rdi
movq %rbx, %rsi
callq 0x6180
testl %eax, %eax
je 0x8d74
incq %r12
cmpq %r12, %r15
jne 0x8d50
movslq %r13d, %rax
incl %r13d
movq %rbx, 0x10(%rsp,%rax,8)
xorl %edi, %edi
cmpl $0x64, %r13d
setl %dil
leaq 0x8b2e(%rip), %rsi      # 0x118b3
xorl %eax, %eax
callq 0x7bcc
incl %ebp
movl %ebp, %edi
callq *0x50(%r14)
movq %rax, %rbx
testq %rax, %rax
jne 0x8d45
leaq 0x8b3b(%rip), %rdi      # 0x118de
xorl %eax, %eax
callq 0x7b35
testl %r13d, %r13d
leaq 0x8b2f(%rip), %r15      # 0x118e3
movq 0x8(%rsp), %r12
jle 0x8de8
movl %r13d, %ebx
xorl %r14d, %r14d
movq 0x10(%rsp,%r14,8), %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x7b35
incq %r14
cmpq %r14, %rbx
jne 0x8dc1
jmp 0x8de8
leaq 0x8afd(%rip), %rdi      # 0x118de
xorl %eax, %eax
callq 0x7b35
leaq 0x7aec(%rip), %rdi      # 0x108db
xorl %eax, %eax
callq 0x7b35
incq %r12
cmpq $0xd, %r12
jne 0x8d06
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0xf876(%rip), %r15      # 0x186a0
leaq (%r12,%r12,2), %rax
movq 0x10(%r15,%rax,8), %r14
xorl %edi, %edi
callq *0x50(%r14)
testq %rax, %rax
je 0x8e5f
movl $0x1, %ebp
movq %rax, %rdi
movq %rbx, %rsi
callq 0x6180
testl %eax, %eax
je 0x8ebc
movl %ebp, %edi
callq *0x50(%r14)
incl %ebp
testq %rax, %rax
jne 0x8e43
incq %r12
cmpq $0xd, %r12
jne 0x8e2a
movl $0x10, %r14d
movq -0x10(%r14,%r15), %rdi
testq %rdi, %rdi
je 0x8e84
movq %rbx, %rsi
callq 0x6180
testl %eax, %eax
je 0x8ea7
addq $0x18, %r14
cmpq $0x148, %r14            # imm = 0x148
jne 0x8e6e
leaq 0x8aad(%rip), %rdi      # 0x11945
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7ca5
jmp 0x8ebc
leaq 0x8a39(%rip), %rdi      # 0x118e7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x62f0
movq (%r14,%r15), %r14
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
movq $0x0, 0x30(%rdi)
movl $0x0, 0x28(%rdi)
movl 0x18(%rdi), %eax
cmpl $-0x1, %eax
jne 0x8ef4
movl $0x0, 0x18(%rbx)
xorl %eax, %eax
movl 0x1c(%rbx), %ecx
cmpl $-0x1, %ecx
jne 0x8f03
movl %ebp, %ecx
subl %eax, %ecx
movl %ecx, 0x1c(%rbx)
cltd
idivl %r14d
testl %edx, %edx
je 0x8f1f
leaq 0x8a7b(%rip), %rdi      # 0x1198d
movl %r14d, %esi
xorl %eax, %eax
callq 0x7ca5
movl 0x1c(%rbx), %ecx
movl %ecx, %eax
cltd
idivl %r14d
testl %edx, %edx
je 0x8f3d
leaq 0x8a95(%rip), %rdi      # 0x119c5
movl %r14d, %esi
xorl %eax, %eax
callq 0x7ca5
movl 0x1c(%rbx), %ecx
xorl %edi, %edi
cmpl %ebp, %ecx
setle %dil
leaq 0x8aaf(%rip), %rsi      # 0x119fb
xorl %eax, %eax
callq 0x7bcc
xorl %edi, %edi
cmpl %ebp, 0x18(%rbx)
setl %dil
leaq 0x8ac0(%rip), %rsi      # 0x11a23
xorl %eax, %eax
callq 0x7bcc
cmpb $0x0, 0x5(%rbx)
jne 0x8f76
cmpb $0x1, 0x6(%rbx)
jne 0x8fce
movl 0x1c(%rbx), %edi
callq 0x7dd2
movq %rax, 0x30(%rbx)
movq 0x10(%rbx), %rdi
movl 0x1c(%rbx), %edx
movq %rax, %rsi
callq 0x7dfa
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 0x8a8a(%rip), %rsi      # 0x11a4d
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x7bcc
cmpb $0x1, 0x9(%rbx)
jne 0x8fe6
movl 0x1c(%rbx), %edi
callq 0x7dd2
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_O3/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
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x7013
movl $0xa, %edi
callq 0x7d8c
callq 0x6789
movl $0x41002118, %edi       # imm = 0x41002118
callq 0x721a
movl %eax, %ecx
andl $0xfffff0ff, %ecx       # imm = 0xFFFFF0FF
movl %eax, %edx
shrl $0x8, %edx
andl $0xf, %edx
leaq 0xf052(%rip), %r15      # 0x187e0
cmpl %ecx, (%r14,%r15)
je 0x97b6
addq $0x20, %r14
cmpq $0x1140, %r14           # imm = 0x1140
jne 0x978e
leaq 0x88a9(%rip), %rdi      # 0x12051
movl %eax, %esi
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x7ca5
movq 0x10(%r14,%r15), %rsi
addl $0x41, %edx
leaq 0x8851(%rip), %rdi      # 0x12016
xorl %eax, %eax
callq 0x7a90
movups (%r14,%r15), %xmm0
movups 0x10(%r14,%r15), %xmm1
movups %xmm1, 0x7527a(%rip)    # 0x7ea58
movups %xmm0, 0x75263(%rip)    # 0x7ea48
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups %xmm0, 0x75271(%rip)    # 0x7ea68
movups %xmm1, 0x7527a(%rip)    # 0x7ea78
movups %xmm2, 0x75283(%rip)    # 0x7ea88
movq 0x30(%rbx), %rax
movq %rax, 0x75288(%rip)     # 0x7ea98
leaq 0x75251(%rip), %rdi     # 0x7ea68
movl 0x18(%r14,%r15), %esi
movl $0x100, %edx            # imm = 0x100
callq 0x8ec8
movl $0x41002102, %edi       # imm = 0x41002102
callq 0x71e0
testb $0x1, %al
jne 0x983e
popq %rbx
popq %r14
popq %r15
jmp 0x9bfc
cmpb $0x0, 0x8(%rbx)
je 0x984a
popq %rbx
popq %r14
popq %r15
retq
leaq 0x87da(%rip), %rdi      # 0x1202b
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x7ca5
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x41002101, %edi       # imm = 0x41002101
movl $0x1, %esi
callq 0x7238
movl $0x41002100, %edi       # imm = 0x41002100
movl $0x10, %esi
callq 0x7238
movl $0x64, %edi
callq 0x7d8c
movl $0x41002101, %edi       # imm = 0x41002101
callq 0x71e0
testb $0x1, %al
je 0x98af
xorl %edi, %edi
callq 0x7013
movl $0xa, %edi
callq 0x7d8c
callq 0x6789
popq %rax
jmp 0x9bfc
// File: /workspace/github_c_makefile_star2_O3/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 0x75187(%rip), %ebx     # 0x7ea80
movq 0x75198(%rip), %r15     # 0x7ea98
movl $0xff, %ebp
addl 0x75185(%rip), %ebp     # 0x7ea90
movl $0x41004004, %edi       # imm = 0x41004004
xorl %esi, %esi
callq 0x7269
cmpl $0x100, %ebp            # imm = 0x100
jb 0x99b0
shrl $0x8, %ebp
leaq 0x6ee2(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
xorl %r13d, %r13d
movl %ebx, %esi
shrl %esi
movl $0x4100401c, %edi       # imm = 0x4100401C
callq 0x7269
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa541, %esi           # imm = 0xA541
callq 0x724f
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x71e0
testb $0x1, %al
je 0x9950
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa502, %esi           # imm = 0xA502
callq 0x724f
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x71e0
testb $0x1, %al
je 0x996d
leaq (%r15,%r12), %rsi
movl %ebx, %edi
movl $0x100, %edx            # imm = 0x100
callq 0x73df
testb $0x1f, %r13b
jne 0x999b
movq %r14, %rdi
xorl %eax, %eax
callq 0x7a90
addl $0x100, %ebx            # imm = 0x100
addq $0x100, %r12            # imm = 0x100
incl %r13d
cmpl %ebp, %r13d
jne 0x9933
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movl 0x750ad(%rip), %ebx     # 0x7ea80
movq 0x750be(%rip), %rax     # 0x7ea98
movq %rax, 0x10(%rsp)
movl 0x750aa(%rip), %r15d    # 0x7ea90
movl $0x100, %edi            # imm = 0x100
callq 0x7dd2
movq %rax, %r14
testl %r15d, %r15d
je 0x9ab8
leaq 0xa065(%rip), %r13      # 0x13a68
xorl %r12d, %r12d
xorl %eax, %eax
movl %r12d, 0x8(%rsp)
movl %eax, 0x4(%rsp)
movl %eax, %r12d
addq 0x10(%rsp), %r12
movl %ebx, %edi
movq %r14, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7283
movl $0x100, %eax            # imm = 0x100
cmpl %eax, %r15d
movl $0x100, %ebp            # imm = 0x100
movl %r15d, 0xc(%rsp)
cmovbl %r15d, %ebp
xorl %r15d, %r15d
movzbl (%r12,%r15), %edx
movzbl (%r14,%r15), %ecx
cmpb %cl, %dl
je 0x9a73
leal (%rbx,%r15), %esi
leaq 0x8da3(%rip), %rdi      # 0x127fd
xorl %eax, %eax
callq 0x7a90
movq %r14, %rdi
callq 0x7df5
movq %r13, %rdi
xorl %eax, %eax
callq 0x7ca5
incq %r15
cmpq %r15, %rbp
jne 0x9a41
movl 0x8(%rsp), %r12d
testb $0x1f, %r12b
jne 0x9a94
leaq 0x6d82(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x7a90
addq $0x100, %rbx            # imm = 0x100
movl 0x4(%rsp), %eax
addl $0x100, %eax            # imm = 0x100
movl 0xc(%rsp), %r15d
subl %ebp, %r15d
incl %r12d
testl %r15d, %r15d
jne 0x9a08
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7df5
// File: /workspace/github_c_makefile_star2_O3/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
movq 0x74fb8(%rip), %rbx     # 0x7ea98
movl 0x74f9e(%rip), %ebp     # 0x7ea84
testl %ebp, %ebp
je 0x9b39
movl 0x74f8f(%rip), %r15d    # 0x7ea80
leaq 0x6d17(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
xorl %r13d, %r13d
leal (%r15,%r13), %edi
movl %r13d, %esi
addq %rbx, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7283
testb $0x1f, %r12b
jne 0x9b22
movq %r14, %rdi
xorl %eax, %eax
callq 0x7a90
addl $0x100, %r13d           # imm = 0x100
incl %r12d
cmpl %r13d, %ebp
jne 0x9afe
movl 0x74f4d(%rip), %edx     # 0x7ea84
jmp 0x9b3b
xorl %edx, %edx
movq 0x74f36(%rip), %rdi     # 0x7ea78
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7ea3
// File: /workspace/github_c_makefile_star2_O3/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 0x8ca3(%rip), %rsi      # 0x1282c
movl %eax, %edi
xorl %eax, %eax
callq 0x7bcc
movl $0x41004004, %edi       # imm = 0x41004004
xorl %esi, %esi
callq 0x7269
movl $0x4100401c, %edi       # imm = 0x4100401C
movl $0x402000, %esi         # imm = 0x402000
callq 0x7269
movl $0x41004000, %edi       # imm = 0x41004000
movl $0xa505, %esi           # imm = 0xA505
callq 0x724f
movl $0x41004014, %edi       # imm = 0x41004014
callq 0x71e0
testb $0x1, %al
je 0x9bbc
movl $0x804000, %edi         # imm = 0x804000
movq %rbx, %rsi
movl $0x100, %edx            # imm = 0x100
popq %rbx
jmp 0x73df
// File: /workspace/github_c_makefile_star2_O3/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 0x7269
movl $0xe000edfc, %edi       # imm = 0xE000EDFC
movl $0x1, %esi
callq 0x7269
movl $0xe000ed0c, %edi       # imm = 0xE000ED0C
movl $0x5fa0004, %esi        # imm = 0x5FA0004
callq 0x7269
movl $0x41002101, %edi       # imm = 0x41002101
movl $0x2, %esi
popq %rax
jmp 0x7238
nop
// File: /workspace/github_c_makefile_star2_O3/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:
cmpl $0x0, 0x74c19(%rip)     # 0x7eabc
jle 0x9f12
pushq %r15
pushq %r14
pushq %rbx
leaq 0x74c0f(%rip), %rbx     # 0x7eac0
xorl %r14d, %r14d
movl (%rbx), %edi
addl $0x4, %edi
movl $0x5a000005, %esi       # imm = 0x5A000005
callq 0x7269
incq %r14
movslq 0x74bef(%rip), %rax     # 0x7eabc
addq $0xc, %rbx
cmpq %rax, %r14
jl 0x9eb4
testl %eax, %eax
jle 0x9f0d
xorl %ebx, %ebx
leaq 0x74bbd(%rip), %r14     # 0x7eaa0
leaq (%rbx,%rbx,2), %rax
leaq (%r14,%rax,4), %r15
addq $0x20, %r15
movl (%r15), %edi
addl $0x8, %edi
callq 0x721a
testb $0x1, %al
je 0x9eef
incq %rbx
movslq 0x74bb4(%rip), %rax     # 0x7eabc
cmpq %rax, %rbx
jl 0x9ee3
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 $0xff, %ebp
addl 0x74b96(%rip), %ebp     # 0x7eb00
cmpl $0x100, %ebp            # imm = 0x100
jb 0x9ff1
movq 0x74b8f(%rip), %r12     # 0x7eb08
shrl $0x8, %ebp
movl 0x74b6e(%rip), %ebx     # 0x7eaf0
xorl %r13d, %r13d
xorl %r14d, %r14d
movl %ebx, %edi
callq 0xa23b
movl %eax, %r15d
movl %ebx, %edi
callq 0xa291
leaq (%r12,%r13), %rsi
movl %eax, %edi
movl $0x100, %edx            # imm = 0x100
callq 0x73df
leal 0x4(%r15), %edi
movl %r14d, %esi
shll $0x8, %esi
orl $0x5a000003, %esi       # imm = 0x5A000003
callq 0x7269
addl $0x8, %r15d
movl %r15d, %edi
callq 0x721a
testb $0x1, %al
je 0x9fc2
addl $0x100, %ebx            # imm = 0x100
addq $0x100, %r13            # imm = 0x100
leaq 0x682d(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x7a90
incl %r14d
cmpl %ebp, %r14d
jne 0x9f88
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movl 0x74adc(%rip), %ebx     # 0x7eaf0
movq 0x74aed(%rip), %rax     # 0x7eb08
movq %rax, 0x10(%rsp)
movl 0x74ad9(%rip), %r12d    # 0x7eb00
movl $0x100, %edi            # imm = 0x100
callq 0x7dd2
movq %rax, %r14
testl %r12d, %r12d
je 0xa0ec
leaq 0x9a24(%rip), %r13      # 0x13a68
xorl %r15d, %r15d
movl %r15d, 0x8(%rsp)
movl %r15d, %r15d
addq 0x10(%rsp), %r15
movl %ebx, %edi
callq 0xa291
movl %eax, %edi
movq %r14, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x7283
movl $0x100, %eax            # imm = 0x100
cmpl %eax, %r12d
movl $0x100, %ebp            # imm = 0x100
movl %r12d, 0xc(%rsp)
cmovbl %r12d, %ebp
xorl %r12d, %r12d
movzbl (%r15,%r12), %edx
movzbl (%r14,%r12), %ecx
cmpb %cl, %dl
je 0xa0b5
leal (%rbx,%r12), %esi
leaq 0x8761(%rip), %rdi      # 0x127fd
xorl %eax, %eax
callq 0x7a90
movq %r14, %rdi
callq 0x7df5
movq %r13, %rdi
xorl %eax, %eax
callq 0x7ca5
incq %r12
cmpq %r12, %rbp
jne 0xa083
addq $0x100, %rbx            # imm = 0x100
movl 0x8(%rsp), %r15d
addl $0x100, %r15d           # imm = 0x100
leaq 0x6738(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x7a90
movl 0xc(%rsp), %r12d
subl %ebp, %r12d
jne 0xa047
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7df5
// File: /workspace/github_c_makefile_star2_O3/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
movq 0x749f7(%rip), %rbx     # 0x7eb08
movl 0x749dd(%rip), %ebp     # 0x7eaf4
testl %ebp, %ebp
je 0xa165
movl 0x749ce(%rip), %r15d    # 0x7eaf0
leaq 0x66e6(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
leal (%r15,%r12), %edi
callq 0xa291
movl %r12d, %esi
addq %rbx, %rsi
movl %eax, %edi
movl $0x100, %edx            # imm = 0x100
callq 0x7283
addl $0x100, %r12d           # imm = 0x100
movq %r14, %rdi
xorl %eax, %eax
callq 0x7a90
cmpl %r12d, %ebp
jne 0xa12c
movl 0x74991(%rip), %edx     # 0x7eaf4
jmp 0xa167
xorl %edx, %edx
movq 0x7497a(%rip), %rdi     # 0x7eae8
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x7ea3
// File: /workspace/github_c_makefile_star2_O3/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 0xa185
retq
pushq %rbx
movq %rsi, %rbx
xorl %edi, %edi
callq 0xa23b
leal 0x4(%rax), %edi
movl $0x5a00000d, %esi       # imm = 0x5A00000D
callq 0x7269
xorl %edi, %edi
callq 0xa23b
leal 0x8(%rax), %edi
callq 0x721a
testb $0x1, %al
je 0xa19d
xorl %edi, %edi
callq 0xa23b
leal 0xc(%rax), %edi
callq 0x721a
movb %al, (%rbx)
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x864f(%rip), %rsi      # 0x1282c
xorl %ebp, %ebp
movl %eax, %edi
xorl %eax, %eax
callq 0x7bcc
xorl %r14d, %r14d
xorl %edi, %edi
callq 0xa23b
leal 0x4(%rax), %edi
btl %r14d, %ebx
movl %ebp, %esi
sbbl $-0x1, %esi
addl $0x5a00000b, %esi       # imm = 0x5A00000B
callq 0x7269
incl %r14d
addl $0x100, %ebp            # imm = 0x100
cmpl $0x800, %ebp            # imm = 0x800
jne 0xa1eb
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0xa291
movslq 0x74874(%rip), %rcx     # 0x7eabc
testq %rcx, %rcx
jle 0xa277
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rdx
xorl %ecx, %ecx
leaq 0x74842(%rip), %rsi     # 0x7eaa0
movl 0x24(%rcx,%rsi), %edi
cmpl %eax, %edi
ja 0xa26e
addl 0x28(%rcx,%rsi), %edi
cmpl %edi, %eax
jb 0xa289
addq $0xc, %rcx
cmpq %rcx, %rdx
jne 0xa25e
leaq 0x8712(%rip), %rdi      # 0x12990
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x7ca5
jmp 0xa28d
movl 0x20(%rcx,%rsi), %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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
movslq 0x74823(%rip), %rax     # 0x7eabc
testq %rax, %rax
jle 0xa2c4
movl %edi, %ebx
shlq $0x2, %rax
leaq (%rax,%rax,2), %rcx
xorl %eax, %eax
leaq 0x747ef(%rip), %rdx     # 0x7eaa0
movl %edi, %esi
subl 0x28(%rax,%rdx), %esi
jb 0xa2d6
addq $0xc, %rax
movl %esi, %ebx
cmpq %rax, %rcx
jne 0xa2b3
leaq 0x86e7(%rip), %rdi      # 0x129b2
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x7ca5
jmp 0xa2da
addl 0x24(%rax,%rdx), %ebx
movl %ebx, %eax
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O3/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:
cmpl $0x0, 0x745ee(%rip)     # 0x7eb28
je 0xa590
pushq %rbp
pushq %rbx
pushq %rax
xorl %ebp, %ebp
movl $0x400e0a04, %ebx       # imm = 0x400E0A04
movl %ebx, %edi
movl $0x5a000005, %esi       # imm = 0x5A000005
callq 0x7269
incl %ebp
movl 0x745ce(%rip), %eax     # 0x7eb28
addl $0x200, %ebx            # imm = 0x200
cmpl %eax, %ebp
jb 0xa546
testl %eax, %eax
je 0xa58a
xorl %ebp, %ebp
movl %ebp, %ebx
shll $0x9, %ebx
addl $0x400e0a08, %ebx       # imm = 0x400E0A08
movl %ebx, %edi
callq 0x721a
testb $0x1, %al
je 0xa575
incl %ebp
cmpl 0x745a0(%rip), %ebp     # 0x7eb28
jb 0xa56a
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movl 0x7441d(%rip), %ebx     # 0x7eb48
movq 0x7442e(%rip), %rax     # 0x7eb60
movq %rax, 0x10(%rsp)
movl 0x7441a(%rip), %r12d    # 0x7eb58
movl $0x200, %edi            # imm = 0x200
callq 0x7dd2
movq %rax, %r14
testl %r12d, %r12d
je 0xa7ff
addl $0x400000, %ebx         # imm = 0x400000
leaq 0x9307(%rip), %r13      # 0x13a68
xorl %ebp, %ebp
movl %ebp, 0x8(%rsp)
movl %ebp, %ebp
addq 0x10(%rsp), %rbp
movl %ebx, %edi
movq %r14, %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x7283
movl $0x200, %eax            # imm = 0x200
cmpl %eax, %r12d
movl $0x200, %r15d           # imm = 0x200
movl %r12d, 0xc(%rsp)
cmovbl %r12d, %r15d
xorl %r12d, %r12d
movzbl (%rbp,%r12), %edx
movzbl (%r14,%r12), %ecx
cmpb %cl, %dl
je 0xa7ca
leal (%rbx,%r12), %esi
leaq 0x804c(%rip), %rdi      # 0x127fd
xorl %eax, %eax
callq 0x7a90
movq %r14, %rdi
callq 0x7df5
movq %r13, %rdi
xorl %eax, %eax
callq 0x7ca5
incq %r12
cmpq %r12, %r15
jne 0xa797
addq $0x200, %rbx            # imm = 0x200
movl 0x8(%rsp), %ebp
addl $0x200, %ebp            # imm = 0x200
leaq 0x6025(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x7a90
movl 0xc(%rsp), %r12d
subl %r15d, %r12d
jne 0xa763
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7df5
// File: /workspace/github_c_makefile_star2_O3/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
movq 0x7433c(%rip), %rbx     # 0x7eb60
movl 0x74322(%rip), %ebp     # 0x7eb4c
testl %ebp, %ebp
je 0xa877
movl $0x400000, %r15d        # imm = 0x400000
addl 0x7430d(%rip), %r15d    # 0x7eb48
leaq 0x5fcd(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
leal (%r15,%r12), %edi
movl %r12d, %esi
addq %rbx, %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x7283
addl $0x200, %r12d           # imm = 0x200
movq %r14, %rdi
xorl %eax, %eax
callq 0x7a90
cmpl %r12d, %ebp
jne 0xa845
movl 0x742d7(%rip), %edx     # 0x7eb4c
jmp 0xa879
xorl %edx, %edx
movq 0x742c0(%rip), %rdi     # 0x7eb40
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x7ea3
// File: /workspace/github_c_makefile_star2_O3/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 0xa897
retq
pushq %rbx
movq %rsi, %rbx
movl $0x400e0a04, %edi       # imm = 0x400E0A04
movl $0x5a00000d, %esi       # imm = 0x5A00000D
callq 0x7269
movl $0x400e0a08, %edi       # imm = 0x400E0A08
callq 0x721a
testb $0x1, %al
je 0xa8aa
movl $0x400e0a0c, %edi       # imm = 0x400E0A0C
callq 0x721a
movb %al, (%rbx)
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x7f4c(%rip), %rsi      # 0x1282c
xorl %ebp, %ebp
movl %eax, %edi
xorl %eax, %eax
callq 0x7bcc
xorl %r14d, %r14d
btl %r14d, %ebx
movl %ebp, %esi
sbbl $-0x1, %esi
addl $0x5a00000b, %esi       # imm = 0x5A00000B
movl $0x400e0a04, %edi       # imm = 0x400E0A04
callq 0x7269
incl %r14d
addl $0x100, %ebp            # imm = 0x100
cmpl $0x800, %ebp            # imm = 0x800
jne 0xa8ee
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x7269
movl $0xe000edfc, %edi       # imm = 0xE000EDFC
xorl %esi, %esi
callq 0x7269
movl $0x1, %edi
callq 0x7013
leaq 0x74046(%rip), %rdi     # 0x7eb88
popq %rax
jmp 0x8feb
// File: /workspace/github_c_makefile_star2_O3/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 0x74018(%rip), %ebx     # 0x7eba0
movl $0x1ff, %r13d           # imm = 0x1FF
leal (%rbx,%r13), %r15d
addl 0x74017(%rip), %r13d    # 0x7ebb0
testl %ebx, %ebx
cmovnsl %ebx, %r15d
cmpl $0x200, %r13d           # imm = 0x200
jae 0xabc4
leaq 0x820d(%rip), %rdi      # 0x12dbc
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7a90
addl $0x400000, %ebx         # imm = 0x400000
movq 0x73fe7(%rip), %rax     # 0x7ebb8
movq %rax, (%rsp)
movl %r13d, %ebp
shrl $0x9, %ebp
sarl $0x9, %r15d
leaq 0x5c29(%rip), %r14      # 0x1080f
xorl %r12d, %r12d
leal (%r12,%r15), %esi
shll $0x8, %esi
orl $0x5a000207, %esi       # imm = 0x5A000207
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x7269
movl $0x400e0c08, %edi       # imm = 0x400E0C08
callq 0x721a
testb $0x1, %al
je 0xac00
movq %r14, %rdi
xorl %eax, %eax
callq 0x7a90
addl $0x10, %r12d
cmpl %ebp, %r12d
jb 0xabe9
leaq 0x8194(%rip), %rdi      # 0x12dbc
xorl %eax, %eax
callq 0x7a90
cmpl $0x200, %r13d           # imm = 0x200
movq (%rsp), %r12
jb 0xac9a
xorl %r13d, %r13d
xorl %r14d, %r14d
leaq (%r12,%r13), %rsi
movl %ebx, %edi
movl $0x200, %edx            # imm = 0x200
callq 0x73df
addl $0x200, %ebx            # imm = 0x200
leal (%r14,%r15), %esi
shll $0x8, %esi
orl $0x5a000001, %esi       # imm = 0x5A000001
movl $0x400e0c04, %edi       # imm = 0x400E0C04
callq 0x7269
movl $0x400e0c08, %edi       # imm = 0x400E0C08
callq 0x721a
testb $0x1, %al
je 0xac6f
addq $0x200, %r13            # imm = 0x200
leaq 0x5b84(%rip), %rdi      # 0x1080f
xorl %eax, %eax
callq 0x7a90
incl %r14d
cmpl %ebp, %r14d
jne 0xac42
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq