// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1c8, %rsp            # imm = 0x1C8
movq %rcx, 0x30(%rsp)
movq 0x78(%rsi), %r13
movq %rsi, 0x38(%rsp)
cmpq 0x80(%rsi), %r13
je 0x46871
movq %rdx, %r14
movq %rdi, %r12
leaq 0x10(%rsp), %r15
movq %rsp, %rbp
movq (%r13), %rbx
movq %r15, (%rsp)
movq %rbp, %rdi
leaq 0x38b04(%rip), %rsi     # 0x7f1b0
leaq 0x38b00(%rip), %rdx     # 0x7f1b3
callq 0x3f8a0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x40f70
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x41c80
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x466eb
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0x60(%rsp,%rax)
leaq 0x48(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
callq 0x41eb0
movq %r15, (%rsp)
movq %rbp, %rdi
leaq 0x3891b(%rip), %rsi     # 0x7f031
leaq 0x38918(%rip), %rdx     # 0x7f035
callq 0x3f8a0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x40f70
movq (%r12), %rcx
movq %r12, %rdi
movq %rax, %rsi
callq *(%rcx)
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x46752
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x0, (%r14)
je 0x4678c
movl (%rbx), %r8d
movl 0x10(%rbx), %r9d
movb 0xc(%rbx), %cl
shll %cl, %r9d
movq (%r12), %rax
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x30(%rsp), %rcx
callq *0x10(%rax)
jmp 0x467dd
movq (%r12), %rax
movq %r12, %rdi
callq *0x20(%rax)
movq %rax, 0x40(%rsp)
cmpl $0x0, 0x8(%r12)
jle 0x467b9
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
incq %rcx
movslq 0x8(%r12), %rdx
cmpq %rdx, %rcx
jl 0x467a5
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x467d0
movq %rax, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x467dd
movq %rbp, %rdi
leaq 0x40(%rsp), %rdx
callq 0x3f4f0
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
subq %rdi, %rax
je 0x4682b
sarq $0x3, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %edx, %edx
movq (%rdi,%rdx,8), %rsi
movslq (%rbx), %r8
movl 0x10(%rbx), %r9d
movb 0xc(%rbx), %cl
movl %r9d, %r10d
shll %cl, %r10d
notl %r10d
andl (%rsi,%r8,4), %r10d
andl 0x2c(%rsp), %r9d
shll %cl, %r9d
orl %r10d, %r9d
movl %r9d, (%rsi,%r8,4)
incq %rdx
cmpq %rdx, %rax
jne 0x467f9
testq %rdi, %rdi
je 0x4683d
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x40870
addq $0x8, %r13
leaq 0x48(%rsp), %rdi
movq 0x5c4c3(%rip), %rsi     # 0xa2d10
callq 0x41440
leaq 0xc0(%rsp), %rdi
callq 0x3f730
movq 0x38(%rsp), %rax
cmpq 0x80(%rax), %r13
jne 0x4669a
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x46885
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x468db
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
jmp 0x468d6
movq %rax, %rbx
jmp 0x468f9
jmp 0x468a2
movq %rax, %rbx
jmp 0x468db
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x468f9
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x468f9
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x468db
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
movq 0x5c42e(%rip), %rsi     # 0xa2d10
leaq 0x48(%rsp), %rdi
callq 0x41440
leaq 0xc0(%rsp), %rdi
callq 0x3f730
movq %rbx, %rdi
callq 0x41f00
nop