// File: /workspace/github_cpp_makefile_star2_O1/jstaursky[P]hutch/src/Sleigh/memstate.cc
// Function: MemoryBank::setValue(unsigned long, int, unsigned long)
void MemoryBank::setValue(uintb offset,int4 size,uintb val)

{
  uintb alignmask = (uintb)(wordsize-1);
  uintb ind = offset & (~alignmask);
  int4 skip = offset & alignmask;
  int4 size1 = wordsize-skip;
  int4 size2;
  int4 gap;
  uintb val1,val2;

  if (size > size1) {		// We have spill over
    size2 = size - size1;
    val1 = find(ind);
    val2 = find(ind+wordsize);
    gap = wordsize - size2;
  }
  else {
    if (size == wordsize) {
      insert(ind,val);
      return;
    }
    val1 = find(ind);
    val2 = 0;
    gap = size1-size;
    size1 = size;
    size2 = 0;
  }

  skip = skip * 8;		// Convert from byte skip to bit skip
  gap = gap * 8;		// Convert from byte to bits
  if (space->isBigEndian()) {
    if (size2 == 0) {
      val1 &= ~(calc_mask(size1)<<gap);
      val1 |= val << gap;
      insert(ind,val1);
    }
    else {
      val1 &= (~((uintb)0)) << 8*size1;
      val1 |= val >> 8*size2;
      insert(ind,val1);
      val2 &= (~((uintb)0)) >> 8*size2;
      val2 |= val << gap;
      insert(ind+wordsize,val2);
    }
  }
  else {
    if (size2 == 0) {
      val1 &= ~(calc_mask(size1)<<skip);
      val1 |= val << skip;
      insert(ind,val1);
    }
    else {
      val1 &= (~((uintb)0)) >> 8*size1;
      val1 |= val << skip;
      insert(ind,val1);
      val2 &= (~((uintb)0)) << 8*size2;
      val2 |= val >> 8*size1;
      insert(ind+wordsize,val2);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %r14
movl 0x8(%rdi), %eax
leal -0x1(%rax), %esi
movl %eax, %edx
negl %edx
movslq %edx, %r12
andq %r13, %r12
andl %esi, %r13d
movl %eax, %ebp
subl %r13d, %ebp
movl %ebp, %r15d
movq (%rdi), %rdx
subl %ebx, %r15d
jge 0x73176
movq %rcx, 0x8(%rsp)
subl %ebp, %ebx
movq %r14, %rdi
movq %r12, %rsi
callq *0x8(%rdx)
movq %r12, %rcx
movq %rax, %r12
movslq 0x8(%r14), %rsi
movq %rcx, (%rsp)
addq %rcx, %rsi
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movl 0x8(%r14), %r15d
subl %ebx, %r15d
jmp 0x731a6
cmpl %ebx, %eax
jne 0x7318b
movq (%rdx), %rax
movq %r14, %rdi
movq %r12, %rsi
movq %rcx, %rdx
jmp 0x732da
movq %rcx, 0x8(%rsp)
movq %r14, %rdi
movq %r12, (%rsp)
movq %r12, %rsi
callq *0x8(%rdx)
movq %rax, %r12
xorl %eax, %eax
movl %ebx, %ebp
xorl %ebx, %ebx
movq 0x10(%r14), %rcx
testb $0x1, 0x24(%rcx)
jne 0x7321c
shll $0x3, %r13d
testl %ebx, %ebx
je 0x73281
shll $0x3, %ebp
movq %rax, 0x10(%rsp)
movl %ebp, %ecx
shlq %cl, %r12
shrq %cl, %r12
movq 0x8(%rsp), %r15
movq %r15, %rdx
movl %r13d, %ecx
shlq %cl, %rdx
orq %r12, %rdx
movq (%r14), %rax
movq %r14, %rdi
movq (%rsp), %r12
movq %r12, %rsi
callq *(%rax)
shll $0x3, %ebx
movl %ebx, %ecx
movq 0x10(%rsp), %rax
shrq %cl, %rax
shlq %cl, %rax
movl %ebp, %ecx
shrq %cl, %r15
orq %rax, %r15
movslq 0x8(%r14), %rsi
addq %r12, %rsi
movq (%r14), %rax
movq (%rax), %rax
movq %r14, %rdi
movq %r15, %rdx
jmp 0x732da
shll $0x3, %r15d
testl %ebx, %ebx
je 0x7329e
shll $0x3, %ebp
movq %rax, 0x10(%rsp)
movl %ebp, %ecx
shrq %cl, %r12
shlq %cl, %r12
shll $0x3, %ebx
movq 0x8(%rsp), %r13
movq %r13, %rdx
movl %ebx, %ecx
shrq %cl, %rdx
orq %r12, %rdx
movq (%r14), %rax
movq %r14, %rdi
movq (%rsp), %r12
movq %r12, %rsi
callq *(%rax)
movl %ebx, %ecx
movq 0x10(%rsp), %rax
shlq %cl, %rax
shrq %cl, %rax
movl %r15d, %ecx
shlq %cl, %r13
orq %rax, %r13
movslq 0x8(%r14), %rsi
addq %r12, %rsi
movq (%r14), %rax
movq (%rax), %rax
movq %r14, %rdi
movq %r13, %rdx
jmp 0x732da
cmpl $0x8, %ebp
movl $0x8, %eax
cmovll %ebp, %eax
cltq
movq 0x2f93b(%rip), %rcx     # 0xa2bd0
movq (%rcx,%rax,8), %rax
movl %r13d, %ecx
jmp 0x732b9
cmpl $0x8, %ebp
movl $0x8, %eax
cmovll %ebp, %eax
cltq
movq 0x2f91e(%rip), %rcx     # 0xa2bd0
movq (%rcx,%rax,8), %rax
movl %r15d, %ecx
shlq %cl, %rax
movq 0x8(%rsp), %rdx
shlq %cl, %rdx
notq %rax
andq %rax, %r12
orq %r12, %rdx
movq (%r14), %rax
movq (%rax), %rax
movq %r14, %rdi
movq (%rsp), %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax