// File: jliesch[P]ofxget/ofxget.cc
// Function: ofxget::OfxGetContext::AddInstitution(int)
OfxGetContext& OfxGetContext::AddInstitution(int id) {
  if (is_error()) return *this;
  std::string id_str = std::to_string(id);
  string filename = "institutions.txt";
  pugi::xml_document doc;
  pugi::xml_parse_result result = doc.load_file(filename.c_str());
  if (!result) {
    error_string_ = "Could not parse " + filename;
    return *this;
  }
  auto inst = doc.find_child_by_attribute("institution", "id", id_str.c_str());
  if (inst.empty()) {
    error_string_ = "Could not find institution " + id_str;
    return *this;
  }
  std::vector<string> var_names {"org", "fid", "brokerid", "bankid", "url"};
  for (string name : var_names) {
    auto var = inst.child(name.c_str());
    if (var) {
      for (std::size_t i = 0; i < name.size(); i++) {
        name[i] = toupper(name[i]);
      }
      vars_map_[name] = var.child_value();
    }
  }
  return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3d0, %rsp            # imm = 0x3D0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0xad00
testb $0x1, %al
jne 0x8e98
jmp 0x8ea8
movq -0x2d0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9690
movl -0x14(%rbp), %esi
leaq -0x38(%rbp), %rdi
callq 0xb000
leaq -0x59(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x78f0
movq -0x2d8(%rbp), %rdx
leaq 0x601c3(%rip), %rsi     # 0x69095
leaq -0x58(%rbp), %rdi
callq 0x77b0
jmp 0x8edd
leaq -0x59(%rbp), %rdi
callq 0x7b70
leaq -0x140(%rbp), %rdi
callq 0x476b0
jmp 0x8ef4
leaq -0x58(%rbp), %rdi
callq 0x7100
movq %rax, %rdx
leaq -0x158(%rbp), %rdi
leaq -0x140(%rbp), %rsi
movl $0x74, %ecx
xorl %r8d, %r8d
callq 0x48440
jmp 0x8f1d
leaq -0x158(%rbp), %rdi
callq 0x47550
movb %al, -0x2d9(%rbp)
jmp 0x8f31
movb -0x2d9(%rbp), %al
testb $0x1, %al
jne 0x8fd3
jmp 0x8f41
leaq 0x6015e(%rip), %rsi     # 0x690a6
leaq -0x178(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0xaef0
jmp 0x8f5a
movq -0x2d0(%rbp), %rdi
addq $0x30, %rdi
leaq -0x178(%rbp), %rsi
callq 0x74e0
leaq -0x178(%rbp), %rdi
callq 0x7b88
movq -0x2d0(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x17c(%rbp)
jmp 0x9650
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x7b70
jmp 0x9685
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x967c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x9670
leaq -0x38(%rbp), %rdi
callq 0x7100
movq %rax, %rcx
leaq 0x600d1(%rip), %rsi     # 0x690b7
leaq 0x600f7(%rip), %rdx     # 0x690e4
leaq -0x140(%rbp), %rdi
callq 0x45080
movq %rax, -0x2e8(%rbp)
jmp 0x9002
movq -0x2e8(%rbp), %rax
movq %rax, -0x188(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x420f0
movb %al, -0x2e9(%rbp)
jmp 0x9024
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0x9030
jmp 0x9086
leaq 0x6008c(%rip), %rsi     # 0x690c3
leaq -0x1a8(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0xaef0
jmp 0x9049
movq -0x2d0(%rbp), %rdi
addq $0x30, %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x74e0
leaq -0x1a8(%rbp), %rdi
callq 0x7b88
movq -0x2d0(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x17c(%rbp)
jmp 0x9650
movb $0x1, -0x27e(%rbp)
leaq -0x270(%rbp), %rax
movq %rax, -0x300(%rbp)
movq %rax, -0x278(%rbp)
leaq -0x279(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x78f0
movq -0x300(%rbp), %rdi
movq -0x2f8(%rbp), %rdx
leaq 0x60015(%rip), %rsi     # 0x690df
callq 0x77b0
jmp 0x90d1
leaq -0x250(%rbp), %rax
movq %rax, -0x310(%rbp)
movq %rax, -0x278(%rbp)
leaq -0x27a(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x78f0
movq -0x310(%rbp), %rdi
movq -0x308(%rbp), %rdx
leaq 0x5ffd5(%rip), %rsi     # 0x690e3
callq 0x77b0
jmp 0x9115
leaq -0x230(%rbp), %rax
movq %rax, -0x320(%rbp)
movq %rax, -0x278(%rbp)
leaq -0x27b(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x78f0
movq -0x320(%rbp), %rdi
movq -0x318(%rbp), %rdx
leaq 0x5ff95(%rip), %rsi     # 0x690e7
callq 0x77b0
jmp 0x9159
leaq -0x210(%rbp), %rax
movq %rax, -0x330(%rbp)
movq %rax, -0x278(%rbp)
leaq -0x27c(%rbp), %rdi
movq %rdi, -0x328(%rbp)
callq 0x78f0
movq -0x330(%rbp), %rdi
movq -0x328(%rbp), %rdx
leaq 0x5ff5a(%rip), %rsi     # 0x690f0
callq 0x77b0
jmp 0x919d
leaq -0x1f0(%rbp), %rax
movq %rax, -0x340(%rbp)
movq %rax, -0x278(%rbp)
leaq -0x27d(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x78f0
movq -0x340(%rbp), %rdi
movq -0x338(%rbp), %rdx
leaq 0x5ff93(%rip), %rsi     # 0x6916d
callq 0x77b0
jmp 0x91e1
movb $0x0, -0x27e(%rbp)
leaq -0x270(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq $0x5, -0x1c8(%rbp)
leaq -0x27f(%rbp), %rdi
movq %rdi, -0x348(%rbp)
callq 0xb120
movq -0x348(%rbp), %rcx
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rdx
leaq -0x1c0(%rbp), %rdi
callq 0xb140
jmp 0x9237
leaq -0x27f(%rbp), %rdi
callq 0xb1c0
leaq -0x270(%rbp), %rax
movq %rax, -0x358(%rbp)
addq $0xa0, %rax
movq %rax, -0x350(%rbp)
movq -0x350(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x360(%rbp)
callq 0x7b88
movq -0x358(%rbp), %rcx
movq -0x360(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x350(%rbp)
jne 0x925e
leaq -0x27d(%rbp), %rdi
callq 0x7b70
leaq -0x27c(%rbp), %rdi
callq 0x7b70
leaq -0x27b(%rbp), %rdi
callq 0x7b70
leaq -0x27a(%rbp), %rdi
callq 0x7b70
leaq -0x279(%rbp), %rdi
callq 0x7b70
leaq -0x1c0(%rbp), %rax
movq %rax, -0x288(%rbp)
movq -0x288(%rbp), %rdi
callq 0xb1e0
movq %rax, -0x290(%rbp)
movq -0x288(%rbp), %rdi
callq 0xb210
movq %rax, -0x298(%rbp)
leaq -0x290(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0xb240
testb $0x1, %al
jne 0x931b
jmp 0x961f
leaq -0x290(%rbp), %rdi
callq 0xb280
movq %rax, %rsi
leaq -0x2b8(%rbp), %rdi
callq 0x7110
jmp 0x9338
leaq -0x2b8(%rbp), %rdi
callq 0x7100
movq %rax, %rsi
leaq -0x188(%rbp), %rdi
callq 0x41ed0
movq %rax, -0x368(%rbp)
jmp 0x935c
movq -0x368(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x41c30
movq %rax, -0x370(%rbp)
jmp 0x937f
movq -0x370(%rbp), %rax
cmpq $0x0, %rax
je 0x9602
movq $0x0, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rax
movq %rax, -0x378(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x7290
movq %rax, %rcx
movq -0x378(%rbp), %rax
cmpq %rcx, %rax
jae 0x95ba
movq -0x2c8(%rbp), %rsi
leaq -0x2b8(%rbp), %rdi
callq 0x7ab0
movq %rax, -0x380(%rbp)
jmp 0x93e4
movq -0x380(%rbp), %rax
movsbl (%rax), %edi
callq 0x7190
movb %al, -0x389(%rbp)
movq -0x2c8(%rbp), %rsi
leaq -0x2b8(%rbp), %rdi
callq 0x7ab0
movq %rax, -0x388(%rbp)
jmp 0x9415
movq -0x388(%rbp), %rax
movb -0x389(%rbp), %cl
movb %cl, (%rax)
movq -0x2c8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2c8(%rbp)
jmp 0x939b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x9523
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x9517
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x950b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x94ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x94f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x27f(%rbp), %rdi
callq 0xb1c0
leaq -0x270(%rbp), %rax
movq %rax, -0x3a0(%rbp)
addq $0xa0, %rax
movq %rax, -0x398(%rbp)
movq -0x398(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x7b88
movq -0x3a0(%rbp), %rcx
movq -0x3a8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x398(%rbp)
jne 0x94c0
jmp 0x94f3
leaq -0x27d(%rbp), %rdi
callq 0x7b70
leaq -0x27c(%rbp), %rdi
callq 0x7b70
leaq -0x27b(%rbp), %rdi
callq 0x7b70
leaq -0x27a(%rbp), %rdi
callq 0x7b70
leaq -0x279(%rbp), %rdi
callq 0x7b70
testb $0x1, -0x27e(%rbp)
jne 0x953a
jmp 0x9587
movq -0x278(%rbp), %rax
leaq -0x270(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x3b0(%rbp)
je 0x9585
movq -0x3b0(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x3b8(%rbp)
callq 0x7b88
movq -0x3b8(%rbp), %rax
leaq -0x270(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x3b0(%rbp)
jne 0x9554
jmp 0x9587
jmp 0x9670
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x9642
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x7b88
jmp 0x9642
leaq -0x2c0(%rbp), %rdi
callq 0x42830
movq %rax, -0x3c0(%rbp)
jmp 0x95cf
movq -0x2d0(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0xb2a0
movq %rax, -0x3c8(%rbp)
jmp 0x95eb
movq -0x3c0(%rbp), %rsi
movq -0x3c8(%rbp), %rdi
callq 0x73b0
jmp 0x9600
jmp 0x9602
leaq -0x2b8(%rbp), %rdi
callq 0x7b88
leaq -0x290(%rbp), %rdi
callq 0xb380
jmp 0x92ff
movq -0x2d0(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x17c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xb3a0
jmp 0x9650
leaq -0x1c0(%rbp), %rdi
callq 0xb3a0
jmp 0x9670
leaq -0x140(%rbp), %rdi
callq 0x47810
leaq -0x58(%rbp), %rdi
callq 0x7b88
leaq -0x38(%rbp), %rdi
callq 0x7b88
jmp 0x9690
leaq -0x140(%rbp), %rdi
callq 0x47810
leaq -0x58(%rbp), %rdi
callq 0x7b88
leaq -0x38(%rbp), %rdi
callq 0x7b88
jmp 0x969d
movq -0x8(%rbp), %rax
addq $0x3d0, %rsp            # imm = 0x3D0
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x7600
nopw %cs:(%rax,%rax)