// File: /workspace/github_cpp_makefile_star2_O2/jliesch[P]ofxget/ofxget_main.cc
// Function: main
int main(int argc, char** argv) {
  CmdArgStr request_filename('r', "request", "request_file", "Request file name under the requests directory. See investment.txt for an example.");
  CmdArgStr passwords_filename('r', "passwords", "passwords_file", "Optional passwords file. If used, supplies passwords for an institution. See example_passwords.txt. Storing passwords in plain text is not safe. This file should only be used for testing purposes.", CmdArg::isOPT);
  CmdArgInt institution('i', "institution", "institution_id", "Institution id. Chooses which institution to read from institutions.txt.");
  CmdLine cmd(argv[0], &request_filename, &institution, &passwords_filename, nullptr);
  cmd.parse(argc, argv);

  OfxGetContext ofxget;
  string request_template = ofxget.GetRequestTemplate("requests/" + string(request_filename));
  ofxget.AddApp("QuickBooks_2008").AddInstitution(institution)
      .AddRequestTemplate(request_template);
  if (passwords_filename.isFound()) {
    ofxget.AddPasswordsForTest(institution, passwords_filename);
  } else {
    ofxget.AddPasswordsForTest(institution, "passwords.txt");
  }

  vector<string> missing_vars = GetMissingRequestVars(request_template,
                                                      ofxget.vars_map_);
  if (!missing_vars.empty()) {
    cout << "Enter missing account info:" << endl;
  }
  for (const string& missing_var : missing_vars) {
    cout << missing_var << ": " << flush;
    string value;
    cin >> value;
    ofxget.vars_map_[missing_var] = value;
  }

  ofxget.PostRequest();
  if (ofxget.is_error()) {
    cout << "ERROR" << ofxget.error_string() << endl;
  } else {
    cout << "REQUEST" << endl << ofxget.request() << endl;
    cout << "RESPONSE" << endl << endl << ofxget.response() << endl;
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, %rbx
movl %edi, %ebp
andq $0x0, (%rsp)
leaq 0x114d(%rip), %rdx      # 0x2a5af
leaq 0x64cf(%rip), %rcx      # 0x2f938
leaq 0x64d5(%rip), %r8       # 0x2f945
leaq 0x1a0(%rsp), %rdi
pushq $0x72
popq %r14
pushq $0xa
popq %r9
movl %r14d, %esi
callq 0x167e2
andq $0x0, (%rsp)
leaq 0x6504(%rip), %rdx      # 0x2f998
leaq 0x6507(%rip), %rcx      # 0x2f9a2
leaq 0x650f(%rip), %r8       # 0x2f9b1
leaq 0xb0(%rsp), %rdi
pushq $0x1
popq %r9
movl %r14d, %esi
callq 0x167e2
andl $0x0, (%rsp)
leaq 0xbf6(%rip), %rdx       # 0x2a0b7
leaq 0x65ae(%rip), %rcx      # 0x2fa76
leaq 0x65b6(%rip), %r8       # 0x2fa85
leaq 0x78(%rsp), %rdi
pushq $0x69
popq %rsi
pushq $0xa
popq %r9
callq 0x1660a
movq (%rbx), %rsi
leaq 0xe8(%rsp), %rdi
leaq 0x1a0(%rsp), %rdx
leaq 0x78(%rsp), %rcx
leaq 0xb0(%rsp), %r8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x17760
leaq 0xe8(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x17a5a
leaq 0x110(%rsp), %rdi
callq 0x707a
leaq 0x1a0(%rsp), %rdi
callq 0x16864
leaq 0x38(%rsp), %rdi
leaq 0x17(%rsp), %rdx
movq %rax, %rsi
callq 0x6700
leaq 0x657f(%rip), %rsi      # 0x2face
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x8355
leaq 0x58(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x77d8
leaq 0x18(%rsp), %rdi
callq 0x68b0
leaq 0x38(%rsp), %rdi
callq 0x68b0
leaq 0xad7(%rip), %rsi       # 0x2a067
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x6700
leaq 0x110(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x71aa
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x166c2
movq %rbx, %rdi
movl %eax, %esi
callq 0x7300
leaq 0x58(%rsp), %rsi
movq %rax, %rdi
callq 0x7952
leaq 0x18(%rsp), %rdi
callq 0x68b0
leaq 0xb0(%rsp), %rdi
callq 0x165de
testb %al, %al
je 0x2961d
leaq 0x78(%rsp), %rdi
callq 0x166c2
movl %eax, %ebx
leaq 0xb0(%rsp), %rdi
callq 0x16864
leaq 0x110(%rsp), %rdi
movl %ebx, %esi
movq %rax, %rdx
callq 0x762e
jmp 0x2963d
leaq 0x78(%rsp), %rdi
callq 0x166c2
leaq 0x64aa(%rip), %rdx      # 0x2fad8
leaq 0x110(%rsp), %rdi
movl %eax, %esi
callq 0x762e
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0x7f05
movq 0x38(%rsp), %r15
movq %r15, %r14
cmpq 0x40(%rsp), %r15
je 0x29688
movq 0x19916(%rip), %rdi     # 0x42f80
leaq 0x6475(%rip), %rsi      # 0x2fae6
callq 0x6430
movq %rax, %rdi
callq 0x6720
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %r15
leaq 0xdf2(%rip), %r12       # 0x2a481
movq 0x19922(%rip), %r13     # 0x42fb8
leaq 0x18(%rsp), %rbp
leaq 0x110(%rsp), %rbx
cmpq %r15, %r14
je 0x2970e
movq 0x198d1(%rip), %rdi     # 0x42f80
movq %r14, %rsi
callq 0x61a0
movq %rax, %rdi
movq %r12, %rsi
callq 0x6430
movq %rax, %rdi
callq 0x6370
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x62d0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8296
movq %rax, %rdi
movq %rbp, %rsi
callq 0x6800
movq %rbp, %rdi
callq 0x68b0
addq $0x20, %r14
jmp 0x296a3
leaq 0x110(%rsp), %rdi
callq 0x7b36
cmpq $0x0, 0x148(%rsp)
je 0x29743
movq 0x19853(%rip), %rdi     # 0x42f80
leaq 0x63ce(%rip), %rsi      # 0x2fb02
callq 0x6430
leaq 0x140(%rsp), %rsi
jmp 0x297bd
movq 0x19836(%rip), %rdi     # 0x42f80
leaq 0x63b7(%rip), %rsi      # 0x2fb08
callq 0x6430
movq %rax, %rdi
callq 0x6720
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x796c
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x61a0
movq %rax, %rdi
callq 0x6720
leaq 0x18(%rsp), %rdi
callq 0x68b0
movq 0x197e7(%rip), %rdi     # 0x42f80
leaq 0x6370(%rip), %rsi      # 0x2fb10
callq 0x6430
movq %rax, %rdi
callq 0x6720
movq %rax, %rdi
callq 0x6720
leaq 0x180(%rsp), %rsi
movq %rax, %rdi
callq 0x61a0
movq %rax, %rdi
callq 0x6720
leaq 0x38(%rsp), %rdi
callq 0x82fc
leaq 0x58(%rsp), %rdi
callq 0x68b0
leaq 0x110(%rsp), %rdi
callq 0x298f4
leaq 0xe8(%rsp), %rdi
callq 0x17cb0
leaq 0x78(%rsp), %rdi
callq 0x16574
leaq 0xb0(%rsp), %rdi
callq 0x1680a
leaq 0x1a0(%rsp), %rdi
callq 0x1680a
xorl %eax, %eax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29887
jmp 0x2988c
jmp 0x29871
jmp 0x29871
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x68b0
jmp 0x2984d
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x298a8
jmp 0x29856
movq %rax, %rbx
jmp 0x298ad
jmp 0x2985d
movq %rax, %rbx
jmp 0x298ba
movq %rax, %rbx
jmp 0x298c7
movq %rax, %rbx
jmp 0x298d1
movq %rax, %rbx
jmp 0x298de
movq %rax, %rbx
jmp 0x298a3
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x68b0
jmp 0x298a3
jmp 0x29887
movq %rax, %rbx
jmp 0x29899
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x68b0
leaq 0x38(%rsp), %rdi
callq 0x82fc
leaq 0x58(%rsp), %rdi
callq 0x68b0
leaq 0x110(%rsp), %rdi
callq 0x298f4
leaq 0xe8(%rsp), %rdi
callq 0x17cb0
leaq 0x78(%rsp), %rdi
callq 0x16574
leaq 0xb0(%rsp), %rdi
callq 0x1680a
leaq 0x1a0(%rsp), %rdi
callq 0x1680a
movq %rbx, %rdi
callq 0x6480
nop