// File: /workspace/github_cpp_makefile_star2_O3/jliesch[P]ofxget/ofxhome.cc
// Function: ofxget::ValidateApiKey(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool ValidateApiKey(const string& api_key) {
    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 output = string("api_key=") + api_key_output;
    string response;
#ifdef OFXHOME_DEBUG
    curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/ofxhome/index.php/api/checkApiKey");
#else
    curl_easy_setopt(curl, CURLOPT_URL, "http://www.ofxhome.com/beta/index.php/api/checkApiKey");
#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_easy_cleanup(curl);

    return response == "success";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdi, %r14
callq 0x66a0
testq %rax, %rax
je 0xc386
movq %rax, %rbx
movq (%r14), %rsi
movl 0x8(%r14), %edx
movq %rax, %rdi
callq 0x64e0
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x24392(%rip), %rsi     # 0x305cc
leaq 0x24393(%rip), %rdx     # 0x305d4
movq %rsp, %rdi
callq 0xa246
movq %rsp, %rdi
movq %r14, %rsi
callq 0x6460
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xc27c
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0xc284
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xc2aa
callq 0x63b0
movq %r15, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
leaq 0x2435e(%rip), %rdx     # 0x30621
movq %rbx, %rdi
movl $0x2712, %esi           # imm = 0x2712
xorl %eax, %eax
callq 0x65e0
leaq -0x145d(%rip), %rdx     # 0xae7c
movq %rbx, %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x65e0
movq %rsp, %rdx
movq %rbx, %rdi
movl $0x2711, %esi           # imm = 0x2711
xorl %eax, %eax
callq 0x65e0
movq 0x28(%rsp), %rdx
movq %rbx, %rdi
movl $0x75a8, %esi           # imm = 0x75A8
xorl %eax, %eax
callq 0x65e0
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl $0x271f, %esi           # imm = 0x271F
xorl %eax, %eax
callq 0x65e0
movq %rbx, %rdi
callq 0x6490
movl %eax, %ebp
testl %eax, %eax
jne 0xc3c6
movq %r14, %rdi
callq 0x6040
movq %rbx, %rdi
callq 0x60c0
leaq 0x2430c(%rip), %rsi     # 0x30657
movq %rsp, %r14
movq %r14, %rdi
callq 0x6630
movl %eax, %ebx
movq (%r14), %rdi
cmpq %r15, %rdi
je 0xc365
callq 0x63b0
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0xc374
callq 0x63b0
testl %ebx, %ebx
sete %al
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x6260
movq %rax, %r14
addq $0x10, %rax
movq %rax, (%r14)
leaq 0x23db6(%rip), %rsi     # 0x30157
leaq 0x23dc8(%rip), %rdx     # 0x30170
movq %r14, %rdi
callq 0xa246
leaq 0x39169(%rip), %rsi     # 0x45520
movq 0x39bda(%rip), %rdx     # 0x45f98
movq %r14, %rdi
callq 0x6420
movl $0x20, %edi
callq 0x6260
movq %rax, %r14
leaq 0x40(%rsp), %rdi
movl %ebp, %esi
callq 0xc4f2
movb $0x1, %bpl
leaq 0x23dc7(%rip), %rsi     # 0x301b0
leaq 0x40(%rsp), %rdx
movq %r14, %rdi
callq 0xc482
xorl %ebp, %ebp
leaq 0x39121(%rip), %rsi     # 0x45520
movq 0x39b92(%rip), %rdx     # 0x45f98
movq %r14, %rdi
callq 0x6420
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc424
callq 0x63b0
testb %bpl, %bpl
jne 0xc42e
jmp 0xc45d
movq %rax, %rbx
movq %r14, %rdi
callq 0x6600
jmp 0xc45d
movq %rax, %rbx
movq %r14, %rdi
callq 0x6600
jmp 0xc47a
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
jne 0xc475
jmp 0xc47a
movq %rax, %rbx
jmp 0xc47a
jmp 0xc45a
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xc46b
callq 0x63b0
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0xc47a
callq 0x63b0
movq %rbx, %rdi
callq 0x6430