// File: /workspace/github_cpp_makefile_star2_O1/DavieV[P]virtual-usb-printer/usbip.cc
// Function: handle_device_list(UsbPrinter const&, int)
void handle_device_list(const UsbPrinter& printer, int sockfd) {
  OP_REP_DEVLIST list;
  printf("list devices\n");

  create_op_rep_devlist(printer.device_descriptor(),
                        printer.configuration_descriptor(),
                        printer.interfaces(), &list);

  ssize_t sent = send(sockfd, &list.header, sizeof(list.header), 0);
  if (sent != sizeof(OP_REP_DEVLIST_HEADER)) {
    printf("send error : %s \n", strerror(errno));
    goto cleanup;
  }

  sent = send(sockfd, &list.device, sizeof(list.device), 0);
  if (sent != sizeof(list.device)) {
    printf("send error : %s \n", strerror(errno));
    goto cleanup;
  }

  sent = send(sockfd, list.interfaces,
              sizeof(*list.interfaces) * list.device.bNumInterfaces, 0);
  if (sent != sizeof(*list.interfaces) * list.device.bNumInterfaces) {
    printf("send error : %s \n", strerror(errno));
    goto cleanup;
  }

cleanup:
  free(list.interfaces);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movl %esi, 0xc(%rsp)
movq %rdi, %r15
leaq 0x2b32(%rip), %rdi      # 0x4181
callq 0x11f0
movzwl 0x4(%r15), %eax
movw %ax, 0xa(%rsp)
movb 0x6(%r15), %al
movb %al, 0x9(%rsp)
movzwl 0x8(%r15), %r13d
movzwl 0xa(%r15), %r12d
movzwl 0xc(%r15), %r14d
movb 0x11(%r15), %bl
movb 0x16(%r15), %al
movb %al, 0x8(%rsp)
movb 0x17(%r15), %bpl
addq $0x50, %r15
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x1d4a
leaq 0x66(%rsp), %r15
movl $0x5001101, -0x3a(%r15) # imm = 0x5001101
movabsq $0x100000000000000, %rax # imm = 0x100000000000000
movq %rax, -0x36(%r15)
movl $0xd2, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x1110
movaps 0x2949(%rip), %xmm0     # 0x4010
movups %xmm0, -0x2e(%r15)
movaps 0x294d(%rip), %xmm0     # 0x4020
movups %xmm0, -0x1e(%r15)
movups 0x294f(%rip), %xmm0     # 0x402e
movups %xmm0, -0x10(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0xd2(%r15)
movups %xmm0, 0xe2(%r15)
movl $0x312d31, 0xd2(%r15) # imm = 0x312D31
movabsq $0x200000001000000, %rax # imm = 0x200000001000000
movq %rax, 0xf2(%r15)
movl $0x2000000, 0xfa(%r15) # imm = 0x2000000
rolw $0x8, %r13w
movw %r13w, 0xfe(%r15)
rolw $0x8, %r12w
rolw $0x8, %r14w
movw %r12w, 0x100(%r15)
movw %r14w, 0x102(%r15)
movzwl 0xa(%rsp), %eax
movw %ax, 0x104(%r15)
movb 0x9(%rsp), %al
movb %al, 0x106(%r15)
movb %bl, 0x108(%r15)
movb %bpl, 0x107(%r15)
movb 0x8(%rsp), %al
movb %al, 0x109(%r15)
leaq 0x170(%rsp), %rsi
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x156f
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x17a0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1160
leaq 0x2c(%rsp), %rsi
movl $0xc, %edx
movl 0xc(%rsp), %ebx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x10f0
cmpq $0xc, %rax
jne 0x1804
leaq 0x38(%rsp), %rsi
movl $0x138, %edx            # imm = 0x138
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x10f0
cmpq $0x138, %rax            # imm = 0x138
jne 0x1804
movq 0x170(%rsp), %rsi
movzbl 0x16f(%rsp), %edx
shll $0x2, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x10f0
movzbl 0x16f(%rsp), %ecx
shll $0x2, %ecx
cmpq %rcx, %rax
je 0x1821
callq 0x1040
movl (%rax), %edi
callq 0x10b0
leaq 0x2827(%rip), %rdi      # 0x403e
movq %rax, %rsi
xorl %eax, %eax
callq 0x1050
movq 0x170(%rsp), %rdi
callq 0x1190
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq