// File: /workspace/github_c_makefile_star2_O0/ataradov[P]edbg/target.c
// Function: process_fuse_commands
static char *process_fuse_commands(target_ops_t *ops, char *cmd)
{
  bool use_file = false;
  bool full_range = false;
  bool read = false;
  bool write = false;
  bool verify = false;
  int section = 0;
  int end = 0;
  int start = 0;
  char *name = NULL;
  uint32_t value = 0;
  uint8_t data[MAX_FUSE_SIZE];
  int size;

  while (*cmd)
  {
    if ('r' == *cmd)
      read = true;
    else if ('w' == *cmd)
      write = true;
    else if ('v' == *cmd)
      verify = true;
    else
      break;

    cmd++;
  }

  check(read || write || verify, "no fuse operations spefified");

  if (',' != *cmd)
  {
    section = strtoul(cmd, &cmd, 0);
  }

  if (',' == *cmd)
  {
    cmd++;

    if ('*' == *cmd)
    {
      cmd++;
      use_file = true;
    }
    else if (':' == *cmd)
    {
      cmd++;
      full_range = true;
    }
    else
    {
      end = strtoul(cmd, &cmd, 0);
      start = end;

      if (':' == *cmd)
      {
        cmd++;
        start = strtoul(cmd, &cmd, 0);
      }
    }
  }
  else
  {
    error_exit("fuse index is required");
  }

  if (',' == *cmd)
  {
    cmd++;

    if (use_file)
      name = get_file_name(&cmd);
    else
      value = strtoul(cmd, &cmd, 0);
  }
  else if (write || verify)
  {
    error_exit("value or name is required for fuse write and verify operations");
  }

  check(end >= start, "bit range must be specified in a descending order");
  check((end - start) <= 32, "bit range must be 32 bits or less");

  if (use_file && read && (write || verify))
    error_exit("mutually exclusive fuse actions specified");

  // Perform fuse operations
  size = ops->fread(section, data);

  check(size > 0, "requested section (%d) does not exist on the target", section);

  if (read)
  {
    if (use_file)
    {
      verbose("  saving %d byte(s) from section %d into file '%s': ", size, section, name);
      save_file(name, data, size);
      verbose("OK\n");
    }
    else if (full_range)
    {
      verbose("  reading %d byte(s) from section %d: ", size, section);

      for (int i = 0; i < size; i++)
        message("0x%02x ", data[i]);

      message("\n");
    }
    else
    {
      uint32_t v = extract_value(data, start, end);

      if (start == end)
        verbose("  reading bit %d from section %d: ", start, section);
      else
        verbose("  reading bits %d:%d from section %d: ", end, start, section);

      message("0x%x (%u)\n", v, v);
    }
  }

  if (write)
  {
    if (use_file)
    {
      uint8_t file_data[MAX_FUSE_SIZE];
      int rsize;

      verbose("  writing %d byte(s) to section %d from file '%s': ", size, section, name);

      rsize = load_file(name, file_data, size);

      check(rsize == size, "file size (%d byte(s)) is less than section size (%d byte(s))", rsize, size);

      memcpy(data, file_data, size);
    }
    else if (full_range)
    {
      error_exit("write operation requires a bit or a bit range specification");
    }
    else
    {
      if (start == end)
        verbose("  writing value 0x%x to bit %d in section %d: ", value, start, section);
      else
        verbose("  writing value 0x%x to bits %d:%d in section %d: ", value, end, start, section);

      apply_value(data, value, start, end);
    }

    ops->fwrite(section, data);

    verbose("OK\n");
  }

  if (verify)
  {
    ops->fread(section, data);

    if (use_file)
    {
      uint8_t file_data[MAX_FUSE_SIZE];
      int rsize;

      rsize = load_file(name, file_data, size);

      verbose("  verifying %d byte(s) from section %d using file '%s': ", rsize, section, name);

      for (int i = 0; i < rsize; i++)
      {
        if (data[i] != file_data[i])
          error_exit("at offset %d expected 0x%02x, got 0x%02x", i, file_data[i], data[i]);
      }
    }
    else if (full_range)
    {
      error_exit("verify operation requires a bit or a bit range specification");
    }
    else
    {
      uint32_t v = extract_value(data, start, end);

      if (start == end)
        verbose("  verifying bit %d from section %d: ", start, section);
      else
        verbose("  verifying bits %d:%d from section %d: ", end, start, section);

      if (value != v)
        error_exit("expected 0x%x (%u), got 0x%x (%u)", value, value, v, v);
    }

    verbose("OK\n");
  }

  return cmd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1870, %rsp           # imm = 0x1870
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movb $0x0, -0x12(%rbp)
movb $0x0, -0x13(%rbp)
movb $0x0, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0xa8fa
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x72, %eax
cmpl %ecx, %eax
jne 0xa8ba
movb $0x1, -0x13(%rbp)
jmp 0xa8ec
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x77, %eax
cmpl %ecx, %eax
jne 0xa8d0
movb $0x1, -0x14(%rbp)
jmp 0xa8ea
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x76, %eax
cmpl %ecx, %eax
jne 0xa8e6
movb $0x1, -0x15(%rbp)
jmp 0xa8e8
jmp 0xa8fa
jmp 0xa8ea
jmp 0xa8ec
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0xa89b
movb $0x1, %al
testb $0x1, -0x13(%rbp)
movb %al, -0x186d(%rbp)
jne 0xa91f
movb $0x1, %al
testb $0x1, -0x14(%rbp)
movb %al, -0x186d(%rbp)
jne 0xa91f
movb -0x15(%rbp), %al
movb %al, -0x186d(%rbp)
movb -0x186d(%rbp), %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb353(%rip), %rsi      # 0x15c85
xorl %eax, %eax
callq 0x8880
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x2c, %eax
cmpl %ecx, %eax
je 0xa95b
movq -0x10(%rbp), %rdi
leaq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x6250
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x2c, %eax
cmpl %ecx, %eax
jne 0xaa0b
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x2a, %eax
cmpl %ecx, %eax
jne 0xa99d
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movb $0x1, -0x11(%rbp)
jmp 0xaa09
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x3a, %eax
cmpl %ecx, %eax
jne 0xa9bf
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movb $0x1, -0x12(%rbp)
jmp 0xaa07
movq -0x10(%rbp), %rdi
leaq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x6250
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x3a, %eax
cmpl %ecx, %eax
jne 0xaa05
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x6250
movl %eax, -0x24(%rbp)
jmp 0xaa07
jmp 0xaa09
jmp 0xaa19
leaq 0xb290(%rip), %rdi      # 0x15ca2
movb $0x0, %al
callq 0x8970
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x2c, %eax
cmpl %ecx, %eax
jne 0xaa5e
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
testb $0x1, -0x11(%rbp)
je 0xaa4a
leaq -0x10(%rbp), %rdi
callq 0xaf00
movq %rax, -0x30(%rbp)
jmp 0xaa5c
movq -0x10(%rbp), %rdi
leaq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x6250
movl %eax, -0x34(%rbp)
jmp 0xaa7a
testb $0x1, -0x14(%rbp)
jne 0xaa6a
testb $0x1, -0x15(%rbp)
je 0xaa78
leaq 0xb248(%rip), %rdi      # 0x15cb9
movb $0x0, %al
callq 0x8970
jmp 0xaa7a
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
setge %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb268(%rip), %rsi      # 0x15cf8
xorl %eax, %eax
callq 0x8880
movl -0x20(%rbp), %eax
subl -0x24(%rbp), %eax
cmpl $0x20, %eax
setle %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb27a(%rip), %rsi      # 0x15d2a
xorl %eax, %eax
callq 0x8880
testb $0x1, -0x11(%rbp)
je 0xaadd
testb $0x1, -0x13(%rbp)
je 0xaadd
testb $0x1, -0x14(%rbp)
jne 0xaacf
testb $0x1, -0x15(%rbp)
je 0xaadd
leaq 0xb276(%rip), %rdi      # 0x15d4c
movb $0x0, %al
callq 0x8970
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x1c(%rbp), %edi
leaq -0x840(%rbp), %rsi
callq *%rax
movl %eax, -0x844(%rbp)
cmpl $0x0, -0x844(%rbp)
setg %al
movl -0x1c(%rbp), %edx
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb265(%rip), %rsi      # 0x15d76
xorl %eax, %eax
callq 0x8880
testb $0x1, -0x13(%rbp)
je 0xac4a
testb $0x1, -0x11(%rbp)
je 0xab6c
movl -0x844(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x30(%rbp), %rcx
leaq 0xb26e(%rip), %rdi      # 0x15daa
movb $0x0, %al
callq 0x8630
movq -0x30(%rbp), %rdi
leaq -0x840(%rbp), %rsi
movl -0x844(%rbp), %edx
callq 0x8c40
leaq 0xb27f(%rip), %rdi      # 0x15ddf
movb $0x0, %al
callq 0x8630
jmp 0xac48
testb $0x1, -0x12(%rbp)
je 0xabdf
movl -0x844(%rbp), %esi
movl -0x1c(%rbp), %edx
leaq 0xb261(%rip), %rdi      # 0x15de3
movb $0x0, %al
callq 0x8630
movl $0x0, -0x848(%rbp)
movl -0x848(%rbp), %eax
cmpl -0x844(%rbp), %eax
jge 0xabcf
movslq -0x848(%rbp), %rax
movzbl -0x840(%rbp,%rax), %esi
leaq 0xb253(%rip), %rdi      # 0x15e0a
movb $0x0, %al
callq 0x86f0
movl -0x848(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x848(%rbp)
jmp 0xab93
leaq 0x9d66(%rip), %rdi      # 0x1493c
movb $0x0, %al
callq 0x86f0
jmp 0xac46
leaq -0x840(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x20(%rbp), %edx
callq 0xafa0
movl %eax, -0x84c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0xac15
movl -0x24(%rbp), %esi
movl -0x1c(%rbp), %edx
leaq 0xb206(%rip), %rdi      # 0x15e12
movb $0x0, %al
callq 0x8630
jmp 0xac2c
movl -0x20(%rbp), %esi
movl -0x24(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0xb210(%rip), %rdi      # 0x15e35
movb $0x0, %al
callq 0x8630
movl -0x84c(%rbp), %esi
movl -0x84c(%rbp), %edx
leaq 0xb21d(%rip), %rdi      # 0x15e5c
movb $0x0, %al
callq 0x86f0
jmp 0xac48
jmp 0xac4a
testb $0x1, -0x14(%rbp)
je 0xad6b
testb $0x1, -0x11(%rbp)
je 0xace0
movl -0x844(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x30(%rbp), %rcx
leaq 0xb1f5(%rip), %rdi      # 0x15e67
movb $0x0, %al
callq 0x8630
movq -0x30(%rbp), %rdi
leaq -0x1050(%rbp), %rsi
movl -0x844(%rbp), %edx
callq 0x8b50
movl %eax, -0x1054(%rbp)
movl -0x1054(%rbp), %eax
cmpl -0x844(%rbp), %eax
sete %al
movl -0x1054(%rbp), %edx
movl -0x844(%rbp), %ecx
movzbl %al, %edi
andl $0x1, %edi
leaq 0xb1de(%rip), %rsi      # 0x15e9b
xorl %eax, %eax
callq 0x8880
leaq -0x840(%rbp), %rdi
leaq -0x1050(%rbp), %rsi
movslq -0x844(%rbp), %rdx
callq 0x61a0
jmp 0xad49
testb $0x1, -0x12(%rbp)
je 0xacf6
leaq 0xb1ec(%rip), %rdi      # 0x15ed9
movb $0x0, %al
callq 0x8970
jmp 0xad47
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0xad17
movl -0x34(%rbp), %esi
movl -0x24(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0xb207(%rip), %rdi      # 0x15f15
movb $0x0, %al
callq 0x8630
jmp 0xad32
movl -0x34(%rbp), %esi
movl -0x20(%rbp), %edx
movl -0x24(%rbp), %ecx
movl -0x1c(%rbp), %r8d
leaq 0xb219(%rip), %rdi      # 0x15f44
movb $0x0, %al
callq 0x8630
leaq -0x840(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x24(%rbp), %edx
movl -0x20(%rbp), %ecx
callq 0xb030
jmp 0xad49
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x1c(%rbp), %edi
leaq -0x840(%rbp), %rsi
callq *%rax
leaq 0xb07b(%rip), %rdi      # 0x15ddf
movb $0x0, %al
callq 0x8630
testb $0x1, -0x15(%rbp)
je 0xaeef
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x1c(%rbp), %edi
leaq -0x840(%rbp), %rsi
callq *%rax
testb $0x1, -0x11(%rbp)
je 0xae4e
movq -0x30(%rbp), %rdi
leaq -0x1860(%rbp), %rsi
movl -0x844(%rbp), %edx
callq 0x8b50
movl %eax, -0x1864(%rbp)
movl -0x1864(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x30(%rbp), %rcx
leaq 0xb1b4(%rip), %rdi      # 0x15f77
movb $0x0, %al
callq 0x8630
movl $0x0, -0x1868(%rbp)
movl -0x1868(%rbp), %eax
cmpl -0x1864(%rbp), %eax
jge 0xae49
movslq -0x1868(%rbp), %rax
movzbl -0x840(%rbp,%rax), %eax
movslq -0x1868(%rbp), %rcx
movzbl -0x1860(%rbp,%rcx), %ecx
cmpl %ecx, %eax
je 0xae36
movl -0x1868(%rbp), %esi
movslq -0x1868(%rbp), %rax
movzbl -0x1860(%rbp,%rax), %edx
movslq -0x1868(%rbp), %rax
movzbl -0x840(%rbp,%rax), %ecx
leaq 0xb181(%rip), %rdi      # 0x15fb0
movb $0x0, %al
callq 0x8970
jmp 0xae38
movl -0x1868(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1868(%rbp)
jmp 0xadd4
jmp 0xaee1
testb $0x1, -0x12(%rbp)
je 0xae64
leaq 0xb17e(%rip), %rdi      # 0x15fd9
movb $0x0, %al
callq 0x8970
jmp 0xaedf
leaq -0x840(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x20(%rbp), %edx
callq 0xafa0
movl %eax, -0x186c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0xae9a
movl -0x24(%rbp), %esi
movl -0x1c(%rbp), %edx
leaq 0xb185(%rip), %rdi      # 0x16016
movb $0x0, %al
callq 0x8630
jmp 0xaeb1
movl -0x20(%rbp), %esi
movl -0x24(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0xb191(%rip), %rdi      # 0x1603b
movb $0x0, %al
callq 0x8630
movl -0x34(%rbp), %eax
cmpl -0x186c(%rbp), %eax
je 0xaedd
movl -0x34(%rbp), %esi
movl -0x34(%rbp), %edx
movl -0x186c(%rbp), %ecx
movl -0x186c(%rbp), %r8d
leaq 0xb18e(%rip), %rdi      # 0x16064
movb $0x0, %al
callq 0x8970
jmp 0xaedf
jmp 0xaee1
leaq 0xaef7(%rip), %rdi      # 0x15ddf
movb $0x0, %al
callq 0x8630
movq -0x10(%rbp), %rax
addq $0x1870, %rsp           # imm = 0x1870
popq %rbp
retq
nopl (%rax)