// File: 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
subq $0x390, %rsp            # imm = 0x390
movq %r9, -0x308(%rbp)
movq %r8, -0x300(%rbp)
movq %rcx, -0x2f8(%rbp)
movq %rdx, -0x2f0(%rbp)
movq %rsi, -0x2e8(%rbp)
movq %rdi, -0x2e0(%rbp)
movq %rdi, %rax
movq %rax, -0x2d8(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x4250
callq 0x45a0
movq %rax, -0x2c8(%rbp)
jmp 0x4bcc
movq -0x2c8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
cmpq $0x0, -0x1c0(%rbp)
je 0x50ca
movl $0x3, %edi
callq 0x41b0
movl %eax, -0x30c(%rbp)
jmp 0x4bfa
movl -0x30c(%rbp), %eax
movl %eax, -0x1d0(%rbp)
cmpl $0x0, -0x1d0(%rbp)
je 0x4cd8
movq 0x243b6(%rip), %rax     # 0x28fd0
movq (%rax), %rax
movq %rax, -0x320(%rbp)
movl -0x1d0(%rbp), %edi
callq 0x4320
movq %rax, -0x318(%rbp)
jmp 0x4c38
movq -0x318(%rbp), %rdx
movq -0x320(%rbp), %rdi
leaq 0x183cc(%rip), %rsi     # 0x1d019
xorl %eax, %eax
callq 0x41a0
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x328(%rbp)
callq 0x4590
movq -0x2e0(%rbp), %rdi
movq -0x328(%rbp), %rdx
leaq 0x183bc(%rip), %rsi     # 0x1d038
callq 0x72c0
jmp 0x4c83
leaq -0x1d1(%rbp), %rdi
callq 0x4670
movl $0x1, -0x1d8(%rbp)
jmp 0x51b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x51d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x1d1(%rbp), %rdi
callq 0x4670
jmp 0x51d5
movq -0x2e8(%rbp), %rsi
movq -0x1c0(%rbp), %rax
movq %rax, -0x330(%rbp)
leaq 0x1842a(%rip), %rdx     # 0x1d11e
leaq -0x238(%rbp), %rdi
callq 0x73c0
jmp 0x4d02
movq -0x2f0(%rbp), %rdx
leaq -0x218(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x7370
jmp 0x4d1e
movq -0x2f8(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x7370
jmp 0x4d3a
leaq -0x1f8(%rbp), %rdi
callq 0x4110
movq -0x330(%rbp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl $0x2712, %esi           # imm = 0x2712
callq 0x44f0
jmp 0x4d5e
leaq -0x1f8(%rbp), %rdi
callq 0x4688
leaq -0x218(%rbp), %rdi
callq 0x4688
leaq -0x238(%rbp), %rdi
callq 0x4688
movq -0x300(%rbp), %rdx
movq $0x0, -0x240(%rbp)
leaq 0x182a0(%rip), %rsi     # 0x1d03b
leaq -0x2a0(%rbp), %rdi
callq 0x7490
jmp 0x4da9
leaq 0x18298(%rip), %rdx     # 0x1d048
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x7440
jmp 0x4dc5
movq -0x308(%rbp), %rdx
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x7370
jmp 0x4de1
leaq -0x280(%rbp), %rdi
callq 0x4688
leaq -0x2a0(%rbp), %rdi
callq 0x4688
movq -0x240(%rbp), %rdi
leaq 0x18243(%rip), %rsi     # 0x1d04a
callq 0x4400
movq %rax, -0x338(%rbp)
jmp 0x4e15
movq -0x338(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rax
movq %rax, -0x348(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x4110
movq -0x348(%rbp), %rdi
movq %rax, %rsi
callq 0x4400
movq %rax, -0x340(%rbp)
jmp 0x4e55
movq -0x340(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x1c0(%rbp), %rdi
movq -0x240(%rbp), %rdx
xorl %eax, %eax
movl $0x2727, %esi           # imm = 0x2727
callq 0x44f0
jmp 0x4e7f
movq -0x1c0(%rbp), %rdi
xorl %eax, %eax
movl $0x2f, %esi
movl $0x1, %edx
callq 0x44f0
jmp 0x4e99
movq -0x2d0(%rbp), %rdi
movq -0x1c0(%rbp), %rax
movq %rax, -0x350(%rbp)
callq 0x4220
movq -0x350(%rbp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl $0x3c, %esi
callq 0x44f0
jmp 0x4ecb
movq -0x2d0(%rbp), %rdi
movq -0x1c0(%rbp), %rax
movq %rax, -0x358(%rbp)
callq 0x4110
movq -0x358(%rbp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl $0x271f, %esi           # imm = 0x271F
callq 0x44f0
jmp 0x4efd
testb $0x1, 0x24478(%rip)     # 0x2937c
je 0x4ff2
movq -0x1c0(%rbp), %rdi
xorl %eax, %eax
movl $0x29, %esi
movl $0x1, %edx
callq 0x44f0
jmp 0x4f24
jmp 0x4ff2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x4f7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x4f6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x4688
leaq -0x218(%rbp), %rdi
callq 0x4688
leaq -0x238(%rbp), %rdi
callq 0x4688
jmp 0x51d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x4fbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x4688
leaq -0x2a0(%rbp), %rdi
callq 0x4688
jmp 0x51d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x4688
jmp 0x51d5
movq -0x1c0(%rbp), %rdi
leaq -0x6e0(%rip), %rdx      # 0x4920
xorl %eax, %eax
movl $0x4e2b, %esi           # imm = 0x4E2B
callq 0x44f0
jmp 0x500e
movq -0x1c0(%rbp), %rdi
xorl %eax, %eax
movl $0x2711, %esi           # imm = 0x2711
leaq -0x1b8(%rbp), %rdx
callq 0x44f0
jmp 0x502a
movq -0x1c0(%rbp), %rdi
callq 0x4430
movl %eax, -0x35c(%rbp)
jmp 0x503e
movl -0x35c(%rbp), %eax
movl %eax, -0x1d0(%rbp)
cmpl $0x0, -0x1d0(%rbp)
je 0x5094
movq 0x23f76(%rip), %rax     # 0x28fd0
movq (%rax), %rax
movq %rax, -0x370(%rbp)
movl -0x1d0(%rbp), %edi
callq 0x4320
movq %rax, -0x368(%rbp)
jmp 0x5078
movq -0x368(%rbp), %rdx
movq -0x370(%rbp), %rdi
leaq 0x17fe5(%rip), %rsi     # 0x1d072
movb $0x0, %al
callq 0x41a0
cmpq $0x0, -0x240(%rbp)
je 0x50ae
movq -0x240(%rbp), %rdi
callq 0x4520
jmp 0x50ac
jmp 0x50ae
movq -0x1c0(%rbp), %rdi
callq 0x4150
jmp 0x50bc
leaq -0x260(%rbp), %rdi
callq 0x4688
jmp 0x50fd
movq 0x23eef(%rip), %rdi     # 0x28fc0
leaq 0x17fba(%rip), %rsi     # 0x1d092
callq 0x43b0
movq %rax, -0x378(%rbp)
jmp 0x50e6
movq -0x378(%rbp), %rdi
movq 0x23ef4(%rip), %rsi     # 0x28fe8
callq 0x45d0
jmp 0x50fb
jmp 0x50fd
testb $0x1, 0x24278(%rip)     # 0x2937c
je 0x519a
movq 0x23eaf(%rip), %rdi     # 0x28fc0
leaq 0x17f8e(%rip), %rsi     # 0x1d0a6
callq 0x43b0
movq %rax, -0x380(%rbp)
jmp 0x5126
leaq -0x2c0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x4450
jmp 0x513b
movq -0x380(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0x4240
movq %rax, -0x388(%rbp)
jmp 0x5157
movq -0x388(%rbp), %rdi
movq 0x23e83(%rip), %rsi     # 0x28fe8
callq 0x45d0
jmp 0x516c
leaq -0x2c0(%rbp), %rdi
callq 0x4688
jmp 0x519a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x4688
jmp 0x51d5
movq -0x2e0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x4450
jmp 0x51af
movl $0x1, -0x1d8(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x42a0
movq -0x2d8(%rbp), %rax
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
leaq -0x1b8(%rbp), %rdi
callq 0x42a0
movq -0x1c8(%rbp), %rdi
callq 0x43f0
nopl (%rax)