// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1078, %rsp           # imm = 0x1078
movl %esi, (%rsp)
movq %rdi, 0x60(%rsp)
callq 0x6110
movq %rax, %rbx
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0x4e03(%rip), %rsi      # 0x13d00
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x7bcc
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0x6150
movq %rax, %rbx
leaq 0x4e00(%rip), %rsi      # 0x13d1d
movq %rax, %rdi
callq 0x60a0
leaq 0x4df5(%rip), %rsi      # 0x13d21
leaq 0x4df6(%rip), %rdx      # 0x13d29
movq %rbx, %rdi
callq 0x61e0
movq %rbx, %rdi
callq 0x6050
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
callq 0x6170
testq %rax, %rax
je 0xf2dc
movq %rax, %r13
xorl %ebp, %ebp
movq %r13, %rdi
callq 0x61f0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x6100
movq %rax, %rbx
movq %rax, %rdi
callq 0x6080
movq %rax, %r14
movq %rax, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x6200
testl %eax, %eax
js 0xf29b
movl %eax, %r12d
movq %rbx, 0x10(%rsp)
movl $0x1000, %edx           # imm = 0x1000
movl %eax, %edi
leaq 0x70(%rsp), %rbx
movq %rbx, %rsi
callq 0x6140
movq %rax, %r15
xorl %edi, %edi
testl %r15d, %r15d
setg %dil
leaq 0x4d6d(%rip), %rsi      # 0x13d34
movq %r14, 0x68(%rsp)
movq %r14, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x7bcc
movl %ebp, 0x4(%rsp)
movslq %ebp, %rax
imulq $0x68, %rax, %rax
movq 0x60(%rsp), %rcx
leaq (%rcx,%rax), %rbp
pxor %xmm0, %xmm0
movdqu %xmm0, 0x50(%rcx,%rax)
movdqu %xmm0, 0x40(%rcx,%rax)
movdqu %xmm0, 0x30(%rcx,%rax)
movdqu %xmm0, 0x20(%rcx,%rax)
movdqu %xmm0, 0x10(%rcx,%rax)
movdqu %xmm0, (%rcx,%rax)
movq $0x0, 0x60(%rcx,%rax)
cmpl $0x12, %r15d
jl 0xf27f
movq %rbx, %r14
movzbl (%rbx), %eax
addq %rax, %rbx
subl %eax, %r15d
cmpb $0x1, 0x1(%r14)
jne 0xf01d
movzbl 0x10(%r14), %esi
movl %r12d, %edi
callq 0xf687
movq %rax, 0x10(%rbp)
movzbl 0xe(%r14), %esi
movl %r12d, %edi
callq 0xf687
movq %rax, 0x18(%rbp)
movzbl 0xf(%r14), %esi
movl %r12d, %edi
callq 0xf687
movq %rax, 0x20(%rbp)
movd 0x8(%r14), %xmm0
punpcklwd 0x4c75(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1],xmm0[2],mem[2],xmm0[3],mem[3]
movq %xmm0, 0x28(%rbp)
leaq 0x60(%rbp), %rax
movq %rax, 0x58(%rsp)
leaq 0x64(%rbp), %rax
movq %rax, 0x50(%rsp)
leaq 0x5c(%rbp), %rax
movq %rax, 0x48(%rsp)
leaq 0x58(%rbp), %rax
movq %rax, 0x40(%rsp)
leaq 0x48(%rbp), %rax
movq %rax, 0x38(%rsp)
leaq 0x4c(%rbp), %rax
movq %rax, 0x30(%rsp)
leaq 0x44(%rbp), %rax
movq %rax, 0x28(%rsp)
leaq 0x40(%rbp), %rax
movq %rax, 0x20(%rsp)
cmpl $0x9, %r15d
jl 0xf27f
movq %rbx, %r14
movzbl (%rbx), %eax
addq %rax, %rbx
subl %eax, %r15d
cmpb $0x4, 0x1(%r14)
jne 0xf0c8
cmpb $0x2, 0x4(%r14)
jne 0xf0c8
cmpb $0x0, 0x6(%r14)
jne 0xf0c8
cmpb $0x0, 0x7(%r14)
jne 0xf0c8
movzbl 0x5(%r14), %eax
cmpl $0xff, %eax
je 0xf10b
cmpl $0x3, %eax
jne 0xf0c8
movq 0x20(%rbp), %rdi
leaq 0x4dd0(%rip), %rsi      # 0x13ee6
callq 0x62c0
testq %rax, %rax
jne 0xf141
movzbl 0x8(%r14), %esi
movl %r12d, %edi
callq 0xf687
movq %rax, %rdi
leaq 0x4daf(%rip), %rsi      # 0x13ee6
callq 0x62c0
testq %rax, %rax
je 0xf0c8
movq %rbx, %rdx
cmpl $0x7, %r15d
jl 0xf15c
movzbl (%rdx), %eax
leaq (%rax,%rdx), %rbx
subl %eax, %r15d
cmpb $0x5, 0x1(%rdx)
jne 0xf141
jmp 0xf161
movq %rdx, %rbx
xorl %edx, %edx
cmpl $0x7, %r15d
jl 0xf27f
movq %rbx, %rdi
movzbl (%rbx), %eax
addq %rax, %rbx
subl %eax, %r15d
cmpb $0x5, 0x1(%rdi)
jne 0xf161
testq %rdx, %rdx
je 0xf27f
movzwl 0x4(%rdx), %eax
cmpw 0x4(%rdi), %ax
jne 0xf0c8
cmpl $0x40, %eax
je 0xf1ab
cmpl $0x400, %eax            # imm = 0x400
je 0xf1ab
cmpl $0x200, %eax            # imm = 0x200
jne 0xf0c8
movb 0x2(%rdx), %cl
movb 0x2(%rdi), %sil
movl %esi, %r8d
xorb %cl, %r8b
jns 0xf0c8
movzbl 0x5(%r14), %r8d
cmpl $0xff, %r8d
je 0xf21e
cmpl $0x3, %r8d
jne 0xf0c8
movb 0x3(%rdx), %dl
notb %dl
testb $0x3, %dl
jne 0xf0c8
movb 0x3(%rdi), %dl
notb %dl
testb $0x3, %dl
jne 0xf0c8
testb %cl, %cl
movzbl %sil, %edx
movzbl %cl, %esi
movl %edx, %ecx
cmovnsl %esi, %ecx
cmovnsl %edx, %esi
movl $0x2, %edx
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %r8
movq 0x28(%rsp), %r9
movq 0x20(%rsp), %r10
jmp 0xf260
movb 0x3(%rdx), %dl
andb $0x3, %dl
cmpb $0x2, %dl
jne 0xf0c8
testb %cl, %cl
js 0xf0c8
movb 0x3(%rdi), %r11b
andb $0x3, %r11b
movl $0x4, %edx
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %r8
movq 0x48(%rsp), %r9
movq 0x40(%rsp), %r10
cmpb $0x2, %r11b
jne 0xf0c8
movzbl %cl, %ecx
movl %ecx, (%rdi)
movzbl %sil, %ecx
movl %ecx, (%r8)
movl %eax, (%r9)
movzbl 0x2(%r14), %eax
movl %eax, (%r10)
orl %edx, 0x30(%rbp)
jmp 0xf0c8
cmpl $0x0, 0x30(%rbp)
je 0xf2a5
movq 0x68(%rsp), %rdi
callq 0x6290
movq %rax, (%rbp)
movl 0x4(%rsp), %ebp
incl %ebp
jmp 0xf2a9
movq %rbx, %rdi
callq 0x6260
jmp 0xf2c3
movl 0x4(%rsp), %ebp
movq 0x10(%rsp), %rbx
movl %r12d, %edi
callq 0x6120
movq %rbx, %rdi
callq 0x6260
cmpl (%rsp), %ebp
je 0xf2d9
movq %r13, %rdi
callq 0x6210
movq %rax, %r13
testq %rax, %rax
jne 0xef5e
jmp 0xf2dc
movl (%rsp), %ebp
movq 0x18(%rsp), %rdi
callq 0x6070
movq 0x8(%rsp), %rdi
callq 0x61a0
movl %ebp, %eax
addq $0x1078, %rsp           # imm = 0x1078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq