// File: /workspace/github_cpp_makefile_star2_O2/jstaursky[P]hutch/src/Sleigh/globalcontext.cc
// Function: ContextInternal::restoreContext(Element const*, Address const&, Address const&)
void ContextInternal::restoreContext(const Element *el,const Address &addr1,const Address &addr2)

{
  const List &list(el->getChildren());
  List::const_iterator iter = list.begin();

  while(iter != list.end()) {
    const Element *subel = *iter;
    istringstream s(subel->getAttributeValue("val"));
    s.unsetf(ios::dec | ios::hex | ios::oct);
    uintm val;
    s >> val;
    ContextBitRange &var(getVariable(subel->getAttributeValue("name")));
    vector<uintm *> vec;
    if (addr1.isInvalid()) {		// Invalid addr1, indicates we should set default value
      uintm *defaultBuffer = getDefaultValue();
      for(int4 i=0;i<size;++i)
	defaultBuffer[i] = 0;
      vec.push_back(defaultBuffer);
    }
    else
      getRegionForSet(vec,addr1,addr2,var.getWord(),var.getMask()<<var.getShift());
    for(int4 i=0;i<vec.size();++i)
      var.setValue(vec[i],val);
    ++iter;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rcx, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq %rdi, %r12
movq %rsi, 0x48(%rsp)
movq 0x78(%rsi), %r15
leaq 0x8(%rsp), %rbx
leaq 0x58(%rsp), %r13
movq 0x48(%rsp), %rax
cmpq 0x80(%rax), %r15
je 0x5535c
movq %r15, 0x50(%rsp)
movq (%r15), %r15
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x30f96(%rip), %rsi     # 0x861b0
movq %rbx, %rdx
callq 0x515e0
movq %r15, %rdi
movq %r14, %rsi
callq 0x50230
movq %r13, %r14
movq %r13, %rdi
movq %rax, %rsi
pushq $0x8
popq %rdx
callq 0x51500
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x4e020
movq 0x58(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0x70(%rsp,%rax)
movq %r14, %rdi
leaq 0x4(%rsp), %rsi
callq 0x51830
movq %rbp, %rdi
leaq 0x30dc1(%rip), %rsi     # 0x86031
movq %rbx, %rdx
callq 0x515e0
movq 0x40(%rsp), %r14
movq %r15, %rdi
movq %rbp, %rsi
callq 0x50230
movq (%r12), %rcx
movq %r12, %rdi
movq %rax, %rsi
callq *(%rcx)
movq %rax, %r15
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x4e020
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
cmpq $0x0, (%r14)
je 0x552dd
movl (%r15), %r8d
movl 0x10(%r15), %r9d
movb 0xc(%r15), %cl
shll %cl, %r9d
movq (%r12), %rax
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x38(%rsp), %rcx
callq *0x10(%rax)
jmp 0x5530c
movq (%r12), %rax
movq %r12, %rdi
callq *0x20(%rax)
movq %rax, 0x8(%rsp)
xorl %ecx, %ecx
movslq 0x8(%r12), %rdx
cmpq %rdx, %rcx
jge 0x55301
andl $0x0, (%rax,%rcx,4)
incq %rcx
jmp 0x552ee
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x4db50
xorl %ebx, %ebx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x55339
movq (%rax,%rbx,8), %rsi
movl 0x4(%rsp), %edx
movq %r15, %rdi
callq 0x51ba0
incq %rbx
jmp 0x5530e
movq 0x50(%rsp), %r15
addq $0x8, %r15
movq %rbp, %rdi
callq 0x50a60
movq %r13, %rdi
callq 0x4e070
leaq 0x8(%rsp), %rbx
jmp 0x551f1
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x55370
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x50a60
jmp 0x55398
movq %rax, %rbx
jmp 0x553b1
jmp 0x55386
movq %rax, %rbx
jmp 0x55398
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4e020
leaq 0x58(%rsp), %rdi
callq 0x4e070
jmp 0x553b1
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4e020
movq %rbx, %rdi
callq 0x518c0
nop