// File: /workspace/github_cpp_makefile_star2_O2/allardlamberink[P]fritz-curl/fritz-curl.cpp
// Function: executeCurlAction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string executeCurlAction(string fburl, string fbport, string upnpaction, string urn, string functionname, string postfields)
{
	stringstream kout;

	CURL *curl;
	//get a curl handle
	curl = curl_easy_init();
	if(curl)
       	{
		CURLcode res;
		res = curl_global_init(CURL_GLOBAL_DEFAULT);
		
		/* Check for errors */
		if(res != CURLE_OK) {
			fprintf(stderr, "curl_global_init() failed: %s\n",
		        curl_easy_strerror(res));
			return "-1";
		}

		curl_easy_setopt(curl, CURLOPT_URL, (fburl + ":" + fbport + upnpaction).c_str());

		struct curl_slist *c_chunk = NULL;

		string s_soapaction = "SoapAction: " + urn + "#" + functionname;

		c_chunk = curl_slist_append(c_chunk, "Content-Type: text/xml; charset=\"utf-8\"");
		c_chunk = curl_slist_append(c_chunk, s_soapaction.c_str());

		curl_easy_setopt(curl, CURLOPT_HTTPHEADER, c_chunk);

		/* Now specify we want to POST data */
        	curl_easy_setopt(curl, CURLOPT_POST, 1L);
		curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, postfields.size());
		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postfields.c_str());
		/* get verbose debug output please */
		if(bDebug) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &kout);

		/* Perform the request, res will get the return code */
		res = curl_easy_perform(curl);
	
		/* Check for errors */
		if(res != CURLE_OK)
      			fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));

		if(c_chunk != NULL)
			curl_slist_free_all(c_chunk);

		curl_easy_cleanup(curl);
	}
	else
	{
		cout << "could not init curl" <<endl;
	}
	if(bDebug) cout << "result=" << kout.str() << endl;
	return kout.str();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %r9, -0x58(%rbp)
movq %r8, %r12
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, -0x30(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x4160
callq 0x4420
movq %rax, %r14
testq %rax, %rax
je 0x498f
pushq $0x3
popq %rdi
callq 0x4120
testl %eax, %eax
jne 0x4a28
leaq 0xa92c(%rip), %rdx      # 0xf12a
leaq -0x78(%rbp), %rdi
movq %r15, %rsi
callq 0x60bc
leaq -0x98(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movq %rbx, %rdx
callq 0x6093
leaq -0x50(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movq %r13, %rdx
callq 0x6093
movq -0x50(%rbp), %rdx
movq %r14, %rdi
movl $0x2712, %esi           # imm = 0x2712
xorl %eax, %eax
callq 0x43b0
leaq -0x50(%rbp), %rdi
callq 0x44c0
leaq -0x98(%rbp), %rdi
callq 0x44c0
leaq -0x78(%rbp), %rdi
callq 0x44c0
leaq 0xa7df(%rip), %rsi      # 0xf047
leaq -0x78(%rbp), %rdi
movq %r12, %rdx
callq 0x611d
leaq 0xa7d9(%rip), %rdx      # 0xf054
leaq -0x98(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x60f4
leaq -0x50(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x6093
leaq -0x98(%rbp), %rdi
callq 0x44c0
leaq -0x78(%rbp), %rdi
callq 0x44c0
leaq 0xa79b(%rip), %rsi      # 0xf056
xorl %edi, %edi
callq 0x42f0
movq -0x50(%rbp), %rsi
movq %rax, %rdi
callq 0x42f0
movq %rax, %r15
movq %r14, %rdi
movl $0x2727, %esi           # imm = 0x2727
movq %rax, %rdx
xorl %eax, %eax
callq 0x43b0
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x43b0
movq 0x10(%rbp), %rbx
movq 0x8(%rbx), %rdx
pushq $0x3c
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x43b0
movq (%rbx), %rdx
movq %r14, %rdi
movl $0x271f, %esi           # imm = 0x271F
xorl %eax, %eax
callq 0x43b0
cmpb $0x1, 0x12963(%rip)     # 0x17284
jne 0x4933
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x43b0
leaq -0x2af(%rip), %rdx      # 0x468b
movq %r14, %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x43b0
leaq -0x220(%rbp), %rdx
movq %r14, %rdi
movl $0x2711, %esi           # imm = 0x2711
xorl %eax, %eax
callq 0x43b0
movq %r14, %rdi
callq 0x4320
testl %eax, %eax
jne 0x4a63
testq %r15, %r15
je 0x497c
movq %r15, %rdi
callq 0x43e0
movq %r14, %rdi
callq 0x40d0
leaq -0x50(%rbp), %rdi
callq 0x44c0
jmp 0x49aa
movq 0x12632(%rip), %rdi     # 0x16fc8
leaq 0xa701(%rip), %rsi      # 0xf09e
callq 0x42a0
movq %rax, %rdi
callq 0x4440
cmpb $0x1, 0x128d3(%rip)     # 0x17284
jne 0x49f6
movq 0x1260e(%rip), %rdi     # 0x16fc8
leaq 0xa6f1(%rip), %rsi      # 0xf0b2
callq 0x42a0
movq %rax, %rbx
leaq -0x208(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x41c0
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x4150
movq %rax, %rdi
callq 0x4440
leaq -0x50(%rbp), %rdi
callq 0x44c0
leaq -0x208(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0x41c0
leaq -0x220(%rbp), %rdi
callq 0x41a0
movq -0x30(%rbp), %rax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x125a9(%rip), %rcx     # 0x16fd8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x4210
leaq 0xa5e5(%rip), %rsi      # 0xf025
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4110
leaq 0xa5f0(%rip), %rsi      # 0xf044
leaq -0x50(%rbp), %rdx
movq -0x30(%rbp), %rdi
callq 0x6058
jmp 0x4a06
movq 0x1256e(%rip), %rcx     # 0x16fd8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x4210
leaq 0xa603(%rip), %rsi      # 0xf07e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4110
jmp 0x496f
jmp 0x4ac5
jmp 0x4ac5
jmp 0x4aa5
jmp 0x4ab6
jmp 0x4ac5
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x44c0
jmp 0x4aa8
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x44c0
jmp 0x4ab9
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x4ad1
jmp 0x4ac5
jmp 0x4aca
jmp 0x4ac5
movq %rax, %rbx
jmp 0x4ad6
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x44c0
leaq -0x220(%rbp), %rdi
callq 0x41a0
movq %rbx, %rdi
callq 0x42e0