// File: jliesch[P]ofxget/ofxhome.cc
// Function: ofxget::UploadSuccessfulRequest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
string UploadSuccessfulRequest(const string& api_key, const string& url, const string& request) {
    CURL *curl = curl_easy_init();
    if (! curl) {
      throw string("Could not initialize curl");
    }

    char *api_key_output = curl_easy_escape(curl, api_key.c_str(), api_key.size());
    string anonymized_request = AnonymizeRequest(request);
    char *request_output = curl_easy_escape(curl, anonymized_request.c_str(), anonymized_request.size());
    char *url_output = curl_easy_escape(curl, url.c_str(), url.size());
    if (!api_key_output || !request_output || !url_output) {
      throw string("Could not curl_easy_escape request");
    }
    string output = string("api_key=") + api_key_output + "&url=" + url_output + "&request=" + request_output;
    string response;
#ifdef OFXHOME_DEBUG
    curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/ofxhome/index.php/api/successfulRequest");
#else
    curl_easy_setopt(curl, CURLOPT_URL, "http://www.ofxhome.com/beta/index.php/api/successfulRequest");
#endif
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteToString);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&response);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (long) output.size());
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, output.c_str());

    CURLcode res = curl_easy_perform(curl);
    if (res != CURLE_OK) {
        throw "Curl error: " + std::to_string(res);
    }

    curl_free(api_key_output);
    curl_free(request_output);
    curl_easy_cleanup(curl);

    return response;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x180(%rbp)
movq %rdi, %rax
movq %rax, -0x178(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
callq 0x7920
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xff09
movb $0x1, -0x3d(%rbp)
movl $0x20, %edi
callq 0x7380
movq %rax, -0x190(%rbp)
movq %rax, -0x198(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x78f0
movq -0x190(%rbp), %rdi
movq -0x188(%rbp), %rdx
leaq 0x592a6(%rip), %rsi     # 0x69157
callq 0x77b0
jmp 0xfeb8
movq -0x198(%rbp), %rdi
movb $0x0, -0x3d(%rbp)
leaq 0x846b6(%rip), %rsi     # 0x94580
movq 0x850cf(%rip), %rdx     # 0x94fa0
callq 0x75e0
jmp 0x10489
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x7b70
testb $0x1, -0x3d(%rbp)
jne 0xfef8
jmp 0xff04
movq -0x198(%rbp), %rdi
callq 0x7840
jmp 0x10480
movq -0x28(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7100
movq %rax, -0x1c0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7290
movq -0x1c8(%rbp), %rdi
movq -0x1c0(%rbp), %rsi
movl %eax, %edx
callq 0x76d0
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0xfc20
movq -0x1b8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, -0x1b0(%rbp)
callq 0x7100
movq -0x1b8(%rbp), %rdi
movq %rax, -0x1a8(%rbp)
callq 0x7290
movq -0x1b0(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
movl %eax, %edx
callq 0x76d0
movq %rax, -0x1a0(%rbp)
jmp 0xffa2
movq -0x1a0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7100
movq %rax, -0x1d8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7290
movq -0x1e0(%rbp), %rdi
movq -0x1d8(%rbp), %rsi
movl %eax, %edx
callq 0x76d0
movq %rax, -0x1d0(%rbp)
jmp 0xffef
movq -0x1d0(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x10013
cmpq $0x0, -0x70(%rbp)
je 0x10013
cmpq $0x0, -0x78(%rbp)
jne 0x100bd
movb $0x1, -0x7a(%rbp)
movl $0x20, %edi
callq 0x7380
movq %rax, -0x1f0(%rbp)
movq %rax, -0x1f8(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x78f0
movq -0x1f0(%rbp), %rdi
movq -0x1e8(%rbp), %rdx
leaq 0x595c9(%rip), %rsi     # 0x6961d
callq 0x77b0
jmp 0x1005b
movq -0x1f8(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
leaq 0x84513(%rip), %rsi     # 0x94580
movq 0x84f2c(%rip), %rdx     # 0x94fa0
callq 0x75e0
jmp 0x10489
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x10477
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x7b70
testb $0x1, -0x7a(%rbp)
jne 0x100ac
jmp 0x100b8
movq -0x1f8(%rbp), %rdi
callq 0x7840
jmp 0x10477
leaq -0x141(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x78f0
movq -0x200(%rbp), %rdx
leaq 0x59562(%rip), %rsi     # 0x69640
leaq -0x140(%rbp), %rdi
callq 0x77b0
jmp 0x100ec
movq -0x48(%rbp), %rdx
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x10d70
jmp 0x10105
leaq 0x5953d(%rip), %rdx     # 0x69649
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x10d70
jmp 0x10121
movq -0x78(%rbp), %rdx
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x10d70
jmp 0x1013a
leaq 0x5950e(%rip), %rdx     # 0x6964f
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x10d70
jmp 0x10156
movq -0x70(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x10d70
jmp 0x1016f
leaq -0xc0(%rbp), %rdi
callq 0x7b88
leaq -0xe0(%rbp), %rdi
callq 0x7b88
leaq -0x100(%rbp), %rdi
callq 0x7b88
leaq -0x120(%rbp), %rdi
callq 0x7b88
leaq -0x140(%rbp), %rdi
callq 0x7b88
leaq -0x141(%rbp), %rdi
callq 0x7b70
movq -0x180(%rbp), %rdi
movb $0x0, -0x142(%rbp)
callq 0x7320
movq -0x28(%rbp), %rdi
leaq 0x59484(%rip), %rdx     # 0x69659
xorl %eax, %eax
movl $0x2712, %esi           # imm = 0x2712
callq 0x7820
jmp 0x101e3
movq -0x28(%rbp), %rdi
leaq -0x139e(%rip), %rdx     # 0xee50
xorl %eax, %eax
movl $0x4e2b, %esi           # imm = 0x4E2B
callq 0x7820
jmp 0x101fc
movq -0x180(%rbp), %rdx
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl $0x2711, %esi           # imm = 0x2711
callq 0x7820
jmp 0x10215
movq -0x28(%rbp), %rax
movq %rax, -0x208(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x7290
movq -0x208(%rbp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl $0x75a8, %esi           # imm = 0x75A8
callq 0x7820
jmp 0x10244
movq -0x28(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x7100
movq -0x210(%rbp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl $0x271f, %esi           # imm = 0x271F
callq 0x7820
jmp 0x10273
movq -0x28(%rbp), %rdi
callq 0x7670
movl %eax, -0x214(%rbp)
jmp 0x10284
movl -0x214(%rbp), %eax
movl %eax, -0x148(%rbp)
cmpl $0x0, -0x148(%rbp)
je 0x103fd
movb $0x1, -0x169(%rbp)
movl $0x20, %edi
callq 0x7380
movq %rax, -0x220(%rbp)
movl -0x148(%rbp), %esi
leaq -0x168(%rbp), %rdi
callq 0xb000
jmp 0x102c9
movq -0x220(%rbp), %rdi
leaq 0x58ed9(%rip), %rsi     # 0x691b0
leaq -0x168(%rbp), %rdx
callq 0xb580
jmp 0x102e5
movq -0x220(%rbp), %rdi
movb $0x0, -0x169(%rbp)
leaq 0x84286(%rip), %rsi     # 0x94580
movq 0x84c9f(%rip), %rdx     # 0x94fa0
callq 0x75e0
jmp 0x10489
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1039c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x10390
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x10384
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x10378
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1036c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x7b88
leaq -0xe0(%rbp), %rdi
callq 0x7b88
leaq -0x100(%rbp), %rdi
callq 0x7b88
leaq -0x120(%rbp), %rdi
callq 0x7b88
leaq -0x140(%rbp), %rdi
callq 0x7b88
leaq -0x141(%rbp), %rdi
callq 0x7b70
jmp 0x10477
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1045f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x103e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x7b88
testb $0x1, -0x169(%rbp)
jne 0x103ef
jmp 0x103fb
movq -0x220(%rbp), %rdi
callq 0x7840
jmp 0x1045f
movq -0x48(%rbp), %rdi
callq 0x7030
jmp 0x10408
movq -0x70(%rbp), %rdi
callq 0x7030
jmp 0x10413
movq -0x28(%rbp), %rdi
callq 0x7120
jmp 0x1041e
movb $0x1, -0x142(%rbp)
testb $0x1, -0x142(%rbp)
jne 0x1043a
movq -0x180(%rbp), %rdi
callq 0x7b88
leaq -0xa0(%rbp), %rdi
callq 0x7b88
leaq -0x68(%rbp), %rdi
callq 0x7b88
movq -0x178(%rbp), %rax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x180(%rbp), %rdi
callq 0x7b88
leaq -0xa0(%rbp), %rdi
callq 0x7b88
leaq -0x68(%rbp), %rdi
callq 0x7b88
movq -0x38(%rbp), %rdi
callq 0x7600
nopl (%rax)