// File: /workspace/github_cpp_makefile_star2_O1/jliesch[P]ofxget/ofxget.cc
// Function: ofxget::OfxGetContext::PostRequest()
OfxGetContext& OfxGetContext::PostRequest() {
  response_.clear();
  if (is_error()) return *this;
    // Fake account
    if (0) { response_ = R"FAKE(OFXHEADER:100
                  DATA:OFXSGML
                  VERSION:102
                  SECURITY:NONE
                  ENCODING:USASCII
                  CHARSET:1252
                  COMPRESSION:NONE
                  OLDFILEUID:NONE
                  NEWFILEUID:20180421105945.000

                  <OFX>
                  <SIGNONMSGSRSV1>
                  <SONRS>
                  <STATUS>
                  <CODE>0
                  <SEVERITY>INFO
                  <MESSAGE>Successful Sign On
                  </STATUS>
                  <DTSERVER>20180421125958[-5:EST]
                  <LANGUAGE>ENG
                  <DTPROFUP>20140605083000
                  <FI>
                  <ORG>Vanguard
                  <FID>15103
                  </FI>
                  <SESSCOOKIE>xxx
                  </SONRS>
                  </SIGNONMSGSRSV1>
                  <SIGNUPMSGSRSV1>
                  <ACCTINFOTRNRS>
                  <TRNUID>20180421105945.000
                  <STATUS>
                  <CODE>0
                  <SEVERITY>INFO
                  <MESSAGE>AcctInfoTrnRsV1 is successful
                  </STATUS>
                  <CLTCOOKIE>1
                  <ACCTINFORS>
                  <DTACCTUP>20180421125958[-5:EST]
                  <ACCTINFO>
                  <DESC>ACCT1
                  <INVACCTINFO>
                  <INVACCTFROM>
                  <BROKERID>vanguard.com
                  <ACCTID>1
                  </INVACCTFROM>
                  <USPRODUCTTYPE>401K
                  <CHECKING>N
                  <SVCSTATUS>ACTIVE
                  <INVACCTTYPE>INDIVIDUAL
                  </INVACCTINFO>
                  </ACCTINFO>
                  <ACCTINFO>
                  <INVACCTINFO>
                  <INVACCTFROM>
                  <BROKERID>vanguard.com
                  <ACCTID>2
                  </INVACCTFROM>
                  <USPRODUCTTYPE>IRA
                  <CHECKING>N
                  <SVCSTATUS>ACTIVE
                  <INVACCTTYPE>INDIVIDUAL
                  </INVACCTINFO>
                  </ACCTINFO>
                  <ACCTINFO>
                  <INVACCTINFO>
                  <INVACCTFROM>
                  <BROKERID>vanguard.com
                  <ACCTID>3
                  </INVACCTFROM>
                  <USPRODUCTTYPE>IRA
                  <CHECKING>N
                  <SVCSTATUS>ACTIVE
                  <INVACCTTYPE>INDIVIDUAL
                  </INVACCTINFO>
                  </ACCTINFO>
                  <ACCTINFO>
                  <INVACCTINFO>
                  <INVACCTFROM>
                  <BROKERID>vanguard.com
                  <ACCTID>4
                  </INVACCTFROM>
                  <USPRODUCTTYPE>IRA
                  <CHECKING>N
                  <SVCSTATUS>ACTIVE
                  <INVACCTTYPE>INDIVIDUAL
                  </INVACCTINFO>
                  </ACCTINFO>
                  <ACCTINFO>
                  <INVACCTINFO>
                  <INVACCTFROM>
                  <BROKERID>vanguard.com
                  <ACCTID>5
                  </INVACCTFROM>
                  <USPRODUCTTYPE>IRA
                  <CHECKING>N
                  <SVCSTATUS>ACTIVE
                  <INVACCTTYPE>INDIVIDUAL
                  </INVACCTINFO>
                  </ACCTINFO>
                  </ACCTINFORS>
                  </ACCTINFOTRNRS>
                  </SIGNUPMSGSRSV1>
                  </OFX>)FAKE"; return *this; }
    // Fake investment
    if (0) { response_ = R"FAKE(OFXHEADER:100
            DATA:OFXSGML
            VERSION:102
            SECURITY:NONE
            ENCODING:USASCII
            CHARSET:1252
            COMPRESSION:NONE
            OLDFILEUID:NONE
            NEWFILEUID:20180321182302.000

            <OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>0<SEVERITY>INFO<MESSAGE>Successful Sign On</STATUS><DTSERVER>20180321202323[-5:EST]<LANGUAGE>ENG<DTPROFUP>20140605083000<FI><ORG>Vanguard<FID>15103</FI><SESSCOOKIE>xx</SONRS></SIGNONMSGSRSV1><INVSTMTMSGSRSV1><INVSTMTTRNRS><TRNUID>20180321182302.000<STATUS><CODE>0<SEVERITY>INFO</STATUS><CLTCOOKIE>4<INVSTMTRS><DTASOF>20180321160000.000[-5:EST]<CURDEF>USD<INVACCTFROM><BROKERID>vanguard.com<ACCTID>123</INVACCTFROM><INVTRANLIST><DTSTART>20160921160000.000[-5:EST]<DTEND>20180321202323.000[-5:EST]<BUYMF><INVBUY><INVTRAN><FITID>88032745229.5132.12212016.0<DTTRADE>20161221160000.000[-5:EST]<DTSETTLE>20161221160000.000[-5:EST]</INVTRAN><SECID><UNIQUEID>921937702<UNIQUEIDTYPE>CUSIP</SECID><UNITS>190.385<UNITPRICE>10.4<TOTAL>-1980.0<SUBACCTSEC>CASH<SUBAC
            CTFUND>OTHER</INVBUY><BUYTYPE>BUY</BUYMF><BUYMF><INVBUY><INVTRAN><FITID>88032745229.5132.01302017.0<DTTRADE>20170130160000.000[-5:EST]<DTSETTLE>20170130160000.000[-5:EST]</INVTRAN><SECID><UNIQUEID>921937702<UNIQUEIDTYPE>CUSIP</SECID><UNITS>671.141<UNITPRICE>10.43<TOTAL>-7000.0<SUBACCTSEC>CASH<SUBACCTFUND>OTHER</INVBUY><BUYTYPE>BUY</BUYMF><BUYMF><INVBUY><INVTRAN><FITID>88032745229.5132.01302017.1<DTTRADE>20170130160000.000[-5:EST]<DTSETTLE>20170130160000.000[-5:EST]</INVTRAN><SECID><UNIQUEID>921937702<UNIQUEIDTYPE>CUSIP</SECID><UNITS>287.632<UNITPRICE>10.43<TOTAL>-3000.0<SUBACCTSEC>CASH<SUBACCTFUND>OTHER</INVBUY><BUYTYPE>BUY</BUYMF><BUYMF><INVBUY><INVTRAN><FITID>88032745229.0569.12212016.0<DTTRADE>20161221160000.000[-5:EST]<DTSETTLE>20161221160000.000[-5:EST]</INVTRAN><SECID><UNIQUEID>921909818<UNIQUEIDTYPE>CUSIP</SECID><UNITS>143.615<UNITPRICE>24.51<TOTAL>-3520.0<SUBACCTSEC>CASH<SUBACCTFUND>OTHER</INVBUY><BUYTYPE>BUY</BUYMF><BUYMF><INVBUY><INVTRAN><FITID>88032745229.0569.12212016.1<DTTRADE>20161221160000.000[
            -5:EST]<DTSETTLE>20161221160000.000[-5:EST]</INVTRAN><SECID><UNIQUEID>921909818<UNIQUEIDTYPE>CUSIP</SECID><UNITS>0.004<UNITPRICE>24.51<TOTAL>-0.11<SUBACCTSEC>CASH<SUBACCTFUND>OTHER</INVBUY><BUYTYPE>BUY</BUYMF><BUYMF><INVBUY><INVTRAN><FITID>88032745229.0569.01162018.0<DTTRADE>20180116160000.000[-5:EST]<DTSETTLE>20180116160000.000[-5:EST]</INVTRAN><SECID><UNIQUEID>921909818<UNIQUEIDTYPE>CUSIP</SECID><UNITS>136.292<UNITPRICE>31.88<TOTAL>-4345.0<SUBACCTSEC>CASH<SUBACCTFUND>OTHER</INVBUY><BUYTYPE>BUY</BUYMF><BUYMF><INVBUY><INVTRAN><FITID>88032745229.0585.01162018.0<DTTRADE>20180116160000.000[-5:EST]<DTSETTLE>20180116160000.000[-5:EST]</INVTRAN><SECID><UNIQUEID>922908728<UNIQUEIDTYPE>CUSIP</SECID><UNITS>16.698<UNITPRICE>69.17<TOTAL>-1155.0<SUBACCTSEC>CASH<SUBACCTFUND>OTHER</INVBUY><BUYTYPE>BUY</BUYMF><BUYMF><INVBUY><INVTRAN><FITID>88032745229.0585.01162018.1<DTTRADE>20180116160000.000[-5:EST]<DTSETTLE>20180116160000.000[-5:EST]</INVTRAN><SECID><UNIQUEID>922908728<UNIQUEIDTYPE>CUSIP</SECID><UNITS>0.022<UNITPRICE>69.)FAKE"; return *this; }
  if (vars_map_.find("URL") == vars_map_.end()) {
    error_string_ = "URL not in vars map";
    return *this;
  }
  if (request_template_.empty()) {
    error_string_ = "no request template was added";
    return *this;
  }

  CURL *curl = curl_easy_init();
  if (!curl) {
    error_string_ = "Could not initialize curl";
    return *this;
  }

  string request_str = request();
  curl_easy_setopt(curl, CURLOPT_URL, vars_map_["URL"].c_str());
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request_str.c_str());

  struct curl_slist *headerlist = NULL;
  headerlist = curl_slist_append(headerlist, "Content-type: application/x-ofx");
  headerlist = curl_slist_append(headerlist, "Accept: */*, application/x-ofx");

  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteToString);
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*) this);
  curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, HeaderCallback);
  curl_easy_setopt(curl, CURLOPT_TIMEOUT, REQUEST_TIMEOUT /* seconds */);

  CURLcode res = curl_easy_perform(curl);

  curl_easy_cleanup(curl);
  curl_slist_free_all(headerlist);

  if (res != CURLE_OK) {
    error_string_ = "Curl error: " + std::to_string(res);
    return *this;
  }
  return *this;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq $0x0, 0x78(%rdi)
movq 0x70(%rdi), %rax
movb $0x0, (%rax)
cmpq $0x0, 0x38(%rdi)
jne 0x96a6
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x27c9a(%rip), %rsi     # 0x31121
leaq 0x27c96(%rip), %rdx     # 0x31124
leaq 0x28(%rsp), %rdi
callq 0xa06a
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0xa858
movq %rax, %r14
leaq 0x8(%rbx), %r15
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x94bb
callq 0x63b0
cmpq %r15, %r14
je 0x965c
cmpq $0x0, 0x58(%rbx)
je 0x9673
callq 0x66a0
testq %rax, %rax
je 0x968a
movq %rax, %r14
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x9206
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x27c24(%rip), %rsi     # 0x31121
leaq 0x27c20(%rip), %rdx     # 0x31124
leaq 0x8(%rsp), %rdi
callq 0xa06a
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x9c7a
movq (%rax), %rdx
movq %r14, %rdi
movl $0x2712, %esi           # imm = 0x2712
xorl %eax, %eax
callq 0x65e0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x953c
callq 0x63b0
movq 0x28(%rsp), %rdx
movq %r14, %rdi
movl $0x271f, %esi           # imm = 0x271F
xorl %eax, %eax
callq 0x65e0
leaq 0x27c1a(%rip), %rsi     # 0x31171
xorl %edi, %edi
callq 0x6440
leaq 0x27c2c(%rip), %rsi     # 0x31191
movq %rax, %rdi
callq 0x6440
movq %rax, %r12
movq %r14, %rdi
movl $0x2727, %esi           # imm = 0x2727
movq %rax, %rdx
xorl %eax, %eax
callq 0x65e0
leaq 0x25e(%rip), %rdx       # 0x97e7
movq %r14, %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x65e0
movq %r14, %rdi
movl $0x2711, %esi           # imm = 0x2711
movq %rbx, %rdx
xorl %eax, %eax
callq 0x65e0
leaq 0x345(%rip), %rdx       # 0x98f6
movq %r14, %rdi
movl $0x4e6f, %esi           # imm = 0x4E6F
xorl %eax, %eax
callq 0x65e0
movq %r14, %rdi
movl $0xd, %esi
movl $0xa, %edx
xorl %eax, %eax
callq 0x65e0
movq %r14, %rdi
callq 0x6490
movl %eax, %r15d
movq %r14, %rdi
callq 0x60c0
movq %r12, %rdi
callq 0x6620
testl %r15d, %r15d
je 0x9783
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r14d
cmpl $0xa, %ebp
jb 0x96c1
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0x96b8
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x96be
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x96c1
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x961d
addl $-0x3, %r14d
jmp 0x96c1
leaq 0x30(%rbx), %rdi
movq 0x38(%rbx), %rdx
leaq 0x27aba(%rip), %rcx     # 0x31125
movl $0x13, %r8d
jmp 0x969f
leaq 0x30(%rbx), %rdi
movq 0x38(%rbx), %rdx
leaq 0x27ab7(%rip), %rcx     # 0x31139
movl $0x1d, %r8d
jmp 0x969f
leaq 0x30(%rbx), %rdi
movq 0x38(%rbx), %rdx
leaq 0x27abe(%rip), %rcx     # 0x31157
movl $0x19, %r8d
xorl %esi, %esi
callq 0x6350
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl $-0x2, %r14d
jmp 0x96c1
decl %r14d
shrl $0x1f, %r15d
leal (%r14,%r15), %esi
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x48(%rsp), %rdi
movl $0x2d, %edx
callq 0x6400
movl %r15d, %edi
leaq 0x48(%rsp), %r15
addq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x9f6c
leaq 0x27ab2(%rip), %rcx     # 0x311b0
movl $0xc, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6110
leaq 0x18(%rsp), %r15
movq %r15, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x9738
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x973f
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x30(%rbx), %rdi
movq %r14, %rsi
callq 0x6370
movq (%r14), %rdi
cmpq %r15, %rdi
je 0x9774
callq 0x63b0
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x9783
callq 0x63b0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x96a6
callq 0x63b0
jmp 0x96a6
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
jne 0x97bd
jmp 0x97d0
jmp 0x97cd
jmp 0x97cd
jmp 0x97cd
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x97d0
callq 0x63b0
jmp 0x97d0
jmp 0x97cd
jmp 0x97cd
movq %rax, %rbx
jmp 0x97df
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x97df
callq 0x63b0
movq %rbx, %rdi
callq 0x6430