// File: jstaursky[P]hutch/src/Sleigh/memstate.cc
// Function: MemoryBank::getValue(unsigned long, int) const
uintb MemoryBank::getValue(uintb offset,int4 size) const

{
    uintb res;

    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 {
        val1 = find (ind);
        val2 = 0;
        if (size == wordsize)
            return val1;
        gap = size1 - size;
        size1 = size;
        size2 = 0;
    }

    if (space->isBigEndian ()) {
        if (size2 == 0)
            res = val1 >> (8 * gap);
        else
            res = (val1 << (8 * size2)) | (val2 >> (8 * gap));
    } else {
        if (size2 == 0)
            res = val1 >> (skip * 8);
        else
            res = (val1 >> (skip * 8)) | (val2 << (size1 * 8));
    }
    res &= (uintb)calc_mask (size);
    return res;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movl %edx, 0x4c(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x8(%rax), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq %rcx, 0x38(%rsp)
movq 0x50(%rsp), %rcx
movq 0x38(%rsp), %rdx
xorq $-0x1, %rdx
andq %rdx, %rcx
movq %rcx, 0x30(%rsp)
movq 0x50(%rsp), %rcx
andq 0x38(%rsp), %rcx
movl %ecx, 0x2c(%rsp)
movl 0x8(%rax), %eax
subl 0x2c(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x28(%rsp), %eax
jle 0x165235
movq 0x8(%rsp), %rdi
movl 0x4c(%rsp), %eax
subl 0x28(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0x30(%rsp), %rsi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x8(%rsp), %rdi
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rsi
movslq 0x8(%rdi), %rax
addq %rax, %rsi
movq (%rdi), %rax
callq *0x8(%rax)
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x10(%rsp)
movl 0x8(%rax), %eax
subl 0x24(%rsp), %eax
movl %eax, 0x20(%rsp)
jmp 0x16528c
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x8(%rsp), %rcx
movq %rax, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x8(%rcx), %eax
jne 0x165270
movq 0x18(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0x165359
movl 0x28(%rsp), %eax
subl 0x4c(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0xddec0
testb $0x1, %al
jne 0x1652a0
jmp 0x1652ee
cmpl $0x0, 0x24(%rsp)
jne 0x1652bf
movq 0x18(%rsp), %rax
movl 0x20(%rsp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, 0x40(%rsp)
jmp 0x1652ec
movq 0x18(%rsp), %rax
movl 0x24(%rsp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
shlq %cl, %rax
movq 0x10(%rsp), %rdx
movl 0x20(%rsp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x40(%rsp)
jmp 0x16533c
cmpl $0x0, 0x24(%rsp)
jne 0x16530d
movq 0x18(%rsp), %rax
movl 0x2c(%rsp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, 0x40(%rsp)
jmp 0x16533a
movq 0x18(%rsp), %rax
movl 0x2c(%rsp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movq 0x10(%rsp), %rdx
movl 0x28(%rsp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
shlq %cl, %rdx
movq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x40(%rsp)
jmp 0x16533c
movl 0x4c(%rsp), %edi
callq 0xcfa60
andq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)