// File: /workspace/github_cpp_makefile_star2_O3/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), %rbx
movq %rsi, 0x38(%rsp)
cmpq 0x80(%rsi), %rbx
je 0x467ea
movq %rdx, %r15
movq %rdi, %r13
leaq 0x10(%rsp), %r12
movq %rsp, %rbp
movq (%rbx), %r14
movq %r12, (%rsp)
movq %rbp, %rdi
leaq 0x38b91(%rip), %rsi     # 0x7f1b0
leaq 0x38b8d(%rip), %rdx     # 0x7f1b3
callq 0x3f8a0
movq %r14, %rdi
movq %rbp, %rsi
callq 0x40f80
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x41c90
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x4665e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
andl $-0x4b, 0x60(%rsp,%rax)
leaq 0x48(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
callq 0x41ec0
movq %r12, (%rsp)
movq %rbp, %rdi
leaq 0x389a8(%rip), %rsi     # 0x7f031
leaq 0x389a5(%rip), %rdx     # 0x7f035
callq 0x3f8a0
movq %r14, %rdi
movq %rbp, %rsi
callq 0x40f80
movq (%r13), %rcx
movq %r13, %rdi
movq %rax, %rsi
callq *(%rcx)
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x466c5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x0, (%r15)
je 0x46700
movl (%r14), %r8d
movl 0x10(%r14), %r9d
movb 0xc(%r14), %cl
shll %cl, %r9d
movq (%r13), %rax
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq 0x30(%rsp), %rcx
callq *0x10(%rax)
jmp 0x4674f
movq (%r13), %rax
movq %r13, %rdi
callq *0x20(%rax)
movq %rax, 0x40(%rsp)
cmpl $0x0, 0x8(%r13)
jle 0x4672b
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
incq %rcx
movslq 0x8(%r13), %rdx
cmpq %rdx, %rcx
jl 0x46718
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x46742
movq %rax, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x4674f
movq %rbp, %rdi
leaq 0x40(%rsp), %rdx
callq 0x3f4f0
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
subq %rdi, %rax
je 0x467a4
sarq $0x3, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %edx, %edx
movq (%rdi,%rdx,8), %rsi
movslq (%r14), %r8
movl 0x10(%r14), %r9d
movb 0xc(%r14), %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 0x4676b
addq $0x8, %rbx
jmp 0x467ad
addq $0x8, %rbx
testq %rdi, %rdi
je 0x467ba
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x40880
leaq 0x48(%rsp), %rdi
movq 0x5c54a(%rip), %rsi     # 0xa2d10
callq 0x41450
leaq 0xc0(%rsp), %rdi
callq 0x3f730
movq 0x38(%rsp), %rax
cmpq 0x80(%rax), %rbx
jne 0x4660e
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x467fe
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x46854
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
jmp 0x4684f
movq %rax, %rbx
jmp 0x46872
jmp 0x4681b
movq %rax, %rbx
jmp 0x46854
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x46872
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x46872
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x46854
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
movq 0x5c4b5(%rip), %rsi     # 0xa2d10
leaq 0x48(%rsp), %rdi
callq 0x41450
leaq 0xc0(%rsp), %rdi
callq 0x3f730
movq %rbx, %rdi
callq 0x41f10