// File: /workspace/github_c_makefile_star2_O0/ataradov[P]edbg/dbg_lin.c
// Function: dbg_enumerate
int dbg_enumerate(debugger_t *debuggers, int size)
{
  struct udev *udev;
  struct udev_enumerate *enumerate;
  struct udev_list_entry *devices, *dev_list_entry;
  int rsize = 0;

  udev = udev_new();
  check(udev, "unable to create udev object");

  enumerate = udev_enumerate_new(udev);
  udev_enumerate_add_match_subsystem(enumerate, "usb");
  udev_enumerate_add_match_property(enumerate, "DEVTYPE", "usb_device");

  udev_enumerate_scan_devices(enumerate);
  devices = udev_enumerate_get_list_entry(enumerate);

  udev_list_entry_foreach(dev_list_entry, devices)
  {
    const char *syspath = udev_list_entry_get_name(dev_list_entry);
    struct udev_device *dev = udev_device_new_from_syspath(udev, syspath);
    const char *path = udev_device_get_devnode(dev);
    uint8_t descriptors[4096];

    int fd = open(path, O_RDWR);

    if (fd < 0)
    {
      udev_device_unref(dev);
      continue;
    }

    int res = read(fd, descriptors, sizeof(descriptors));
    check(res > 0, "descriptors read from %s: %d", path, res);

    parse_descriptors(&debuggers[rsize], fd, descriptors, res);

    if (debuggers[rsize].versions)
    {
      debuggers[rsize].path = strdup(path);
      rsize++;
    }

    close(fd);
    udev_device_unref(dev);

    if (rsize == size)
      break;
  }

  udev_enumerate_unref(enumerate);
  udev_unref(udev);

  return rsize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1060, %rsp           # imm = 0x1060
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x34(%rbp)
callq 0x6120
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
setne %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0x53ca(%rip), %rsi      # 0x17d31
xorl %eax, %eax
callq 0x8880
movq -0x18(%rbp), %rdi
callq 0x6160
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x53c8(%rip), %rsi      # 0x17d4e
callq 0x60b0
movq -0x20(%rbp), %rdi
leaq 0x53bc(%rip), %rsi      # 0x17d52
leaq 0x53bd(%rip), %rdx      # 0x17d5a
callq 0x61f0
movq -0x20(%rbp), %rdi
callq 0x6060
movq -0x20(%rbp), %rdi
callq 0x6170
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x12afd
movq -0x30(%rbp), %rdi
callq 0x6200
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x6110
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x6090
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movl $0x2, %esi
movb $0x0, %al
callq 0x6210
movl %eax, -0x1054(%rbp)
cmpl $0x0, -0x1054(%rbp)
jge 0x12a23
movq -0x48(%rbp), %rdi
callq 0x6270
jmp 0x12aeb
movl -0x1054(%rbp), %edi
leaq -0x1050(%rbp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x6140
movl %eax, -0x1058(%rbp)
cmpl $0x0, -0x1058(%rbp)
setg %al
movq -0x50(%rbp), %rdx
movl -0x1058(%rbp), %ecx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x5304(%rip), %rsi      # 0x17d65
xorl %eax, %eax
callq 0x8880
movq -0x8(%rbp), %rdi
movslq -0x34(%rbp), %rax
imulq $0x68, %rax, %rax
addq %rax, %rdi
movl -0x1054(%rbp), %esi
leaq -0x1050(%rbp), %rdx
movl -0x1058(%rbp), %ecx
callq 0x12b20
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x30(%rax)
je 0x12acb
movq -0x50(%rbp), %rdi
callq 0x6290
movq %rax, %rcx
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x1054(%rbp), %edi
callq 0x6130
movq -0x48(%rbp), %rdi
callq 0x6270
movl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x12ae9
jmp 0x12afd
jmp 0x12aeb
movq -0x30(%rbp), %rdi
callq 0x6220
movq %rax, -0x30(%rbp)
jmp 0x129c0
movq -0x20(%rbp), %rdi
callq 0x6080
movq -0x18(%rbp), %rdi
callq 0x61b0
movl -0x34(%rbp), %eax
addq $0x1060, %rsp           # imm = 0x1060
popq %rbp
retq
nopl (%rax,%rax)