// File: /workspace/github_cpp_makefile_star2_O3/brunokeymolen[P]ssdp/src/ssdp.cpp
// Function: SSDP::SendSearchRequest(char const*)
int SSDP::SendSearchRequest(const char *target) {
    std::stringstream str;
    str << "M-SEARCH * HTTP/1.1\r\n";
    str << "Mx: " << 5 << "\r\n";
    str << "St: " << target << "\r\n";
    str << "Man: \"ssdp:discover\"\r\n";
    str << "User-Agent: UPnP/1.1 " << mOS << " " << mProduct << "\r\n";
    str << "Connection: close\r\n";
    str << "Host: 239.255.255.250:1900\r\n\r\n";

    str.seekp(0, ios::end);
    stringstream::pos_type length = str.tellp();
    str.seekp(0, ios::beg);

    if(mMulticastSocket != INVALID_SOCKET)
        sendto(mMulticastSocket, str.str().c_str(), (unsigned long)length, 0, (struct sockaddr*)&mDstaddr , sizeof(struct sockaddr));
    else
        printf("invalid socket\n");

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3170
leaq 0x30(%rsp), %r14
leaq 0x3ec5(%rip), %rsi      # 0x82e2
movl $0x15, %edx
movq %r14, %rdi
callq 0x32b0
leaq 0x3ec7(%rip), %rsi      # 0x82f8
movl $0x4, %edx
movq %r14, %rdi
callq 0x32b0
movq %r14, %rdi
movl $0x5, %esi
callq 0x33f0
leaq 0x3f0d(%rip), %rsi      # 0x835f
movl $0x2, %edx
movq %rax, %rdi
callq 0x32b0
leaq 0x3e97(%rip), %rsi      # 0x82fd
movl $0x4, %edx
movq %r14, %rdi
callq 0x32b0
testq %r15, %r15
je 0x4490
movq %r15, %rdi
callq 0x3100
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32b0
jmp 0x44a9
movq 0x30(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x50(%rsp,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x3eaf(%rip), %rsi      # 0x835f
movl $0x2, %edx
movq %r14, %rdi
callq 0x32b0
leaq 0x3e3e(%rip), %rsi      # 0x8302
movl $0x16, %edx
movq %r14, %rdi
callq 0x32b0
leaq 0x3e41(%rip), %rsi      # 0x8319
movl $0x15, %edx
movq %r14, %rdi
callq 0x32b0
movq 0x200(%rbx), %rsi
movq 0x208(%rbx), %rdx
movq %r14, %rdi
callq 0x32b0
movq %rax, %r15
leaq 0x3e28(%rip), %rsi      # 0x832d
movl $0x1, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x220(%rbx), %rsi
movq 0x228(%rbx), %rdx
movq %r15, %rdi
callq 0x32b0
leaq 0x3e30(%rip), %rsi      # 0x835f
movl $0x2, %edx
movq %rax, %rdi
callq 0x32b0
leaq 0x3dec(%rip), %rsi      # 0x832f
movl $0x13, %edx
movq %r14, %rdi
callq 0x32b0
leaq 0x3dec(%rip), %rsi      # 0x8343
movl $0x1e, %edx
movq %r14, %rdi
callq 0x32b0
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x3250
movq %r14, %rdi
callq 0x3200
movq %rax, %r15
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3250
movl 0x8(%rbx), %ebp
cmpl $-0x1, %ebp
je 0x45d9
leaq 0x38(%rsp), %rsi
movq %rsp, %rdi
callq 0x33b0
movq (%rsp), %rsi
addq $0x20, %rbx
movl %ebp, %edi
movq %r15, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
movl $0x10, %r9d
callq 0x3070
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x45e5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x45e5
leaq 0x3dd5(%rip), %rdi      # 0x83b5
callq 0x3380
movq 0x79c4(%rip), %rsi      # 0xbfb0
leaq 0x20(%rsp), %rdi
callq 0x3190
leaq 0xa0(%rsp), %rdi
callq 0x30d0
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x463a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x463a
jmp 0x4637
jmp 0x4637
movq %rax, %rbx
movq 0x796f(%rip), %rsi      # 0xbfb0
leaq 0x20(%rsp), %rdi
callq 0x3190
leaq 0xa0(%rsp), %rdi
callq 0x30d0
movq %rbx, %rdi
callq 0x3410