// File: flastest[P]HW2_Systems_flaster_strand/test_cache_lib.cc
// Function: testEvictorEvictingSameItemTwice(bool)
bool testEvictorEvictingSameItemTwice(bool DEBUG_PRINT_MESSAGES)
{
    if (DEBUG_PRINT_MESSAGES) std::cout<<"testing what happens when the same key is in the evictor twice, and we need to remove things twice."<<std::endl;
    auto my_cache = makeCache(9);
    char value[]{ "six" };
    my_cache->set("apple", value, 4);

    //try adding something, see if it's in the cache and that the other thing's been removed

    char number_of_bananas[]{ "three" };
    Cache::size_type size;
    my_cache->set("banana", number_of_bananas, 6);

    //make sure bananas is in the cache
    auto bananas_from_cache = (my_cache->get("banana", size));
    std::string bananas(bananas_from_cache);
    int banana_num = size;

    auto apples_from_cache = (my_cache->get("apple", size));

    //check that apples is not in the cache
    if (DEBUG_PRINT_MESSAGES && !(apples_from_cache == nullptr && bananas == "three" && size == 6)) std::cout<<"the first evict failed"<<std::endl;

    //now for the second evict
    char number_of_oranges[]{ "two" };
    my_cache->set("orange", number_of_oranges, 4);

    auto orange_from_cache = (my_cache->get("orange", size));
    std::string oranges(orange_from_cache);
    int orange_num = size;
    //now check to make sure oranges is in the cache and that bananas is nullptr

    if(DEBUG_PRINT_MESSAGES) std::cout<<"this also tests that evictor tries again if there still isn't room for the next item"<<std::endl;

    return (oranges == "two" && size ==4);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movb %dil, %al
andb $0x1, %al
movb %al, -0x1(%rbp)
testb $0x1, -0x1(%rbp)
je 0x779b
movq 0x9858(%rip), %rdi      # 0x10fd8
leaq 0x3c0c(%rip), %rsi      # 0xb393
callq 0x21b0
movq %rax, %rdi
movq 0x982a(%rip), %rsi      # 0x10fc0
callq 0x21e0
movl $0x9, %edi
callq 0x6430
movq %rax, -0x10(%rbp)
movl $0x786973, -0x14(%rbp)  # imm = 0x786973
movq -0x10(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x22e0
movq -0x190(%rbp), %rdx
leaq 0x38e4(%rip), %rsi      # 0xb0bd
leaq -0x38(%rbp), %rdi
callq 0x80f0
jmp 0x77e4
movq -0x198(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x14(%rbp), %rdx
movl $0x4, %ecx
callq 0x25c0
jmp 0x77ff
leaq -0x38(%rbp), %rdi
callq 0x2100
leaq -0x39(%rbp), %rdi
callq 0x2200
movw $0x65, -0x50(%rbp)
movl $0x65726874, -0x54(%rbp) # imm = 0x65726874
movq -0x10(%rbp), %rax
movq %rax, -0x1a8(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x22e0
movq -0x1a0(%rbp), %rdx
leaq 0x3bb6(%rip), %rsi      # 0xb3fd
leaq -0x78(%rbp), %rdi
callq 0x80f0
jmp 0x7852
movq -0x1a8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x54(%rbp), %rdx
movl $0x6, %ecx
callq 0x25c0
jmp 0x786d
leaq -0x78(%rbp), %rdi
callq 0x2100
leaq -0x79(%rbp), %rdi
callq 0x2200
movq -0x10(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x22e0
movq -0x1b0(%rbp), %rdx
leaq 0x3b52(%rip), %rsi      # 0xb3fd
leaq -0xa8(%rbp), %rdi
callq 0x80f0
jmp 0x78b9
movq -0x1b8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x2640
movq %rax, -0x1c0(%rbp)
jmp 0x78d9
leaq -0xa8(%rbp), %rdi
callq 0x2100
leaq -0xa9(%rbp), %rdi
callq 0x2200
movq -0x1c0(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x22e0
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0x80f0
jmp 0x793c
leaq -0xd1(%rbp), %rdi
callq 0x2200
movl -0x58(%rbp), %eax
movl %eax, -0xd8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x22e0
movq -0x1d8(%rbp), %rdx
leaq 0x3740(%rip), %rsi      # 0xb0bd
leaq -0x100(%rbp), %rdi
callq 0x80f0
jmp 0x798b
movq -0x1e0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x2640
movq %rax, -0x1e8(%rbp)
jmp 0x79ab
leaq -0x100(%rbp), %rdi
callq 0x2100
leaq -0x101(%rbp), %rdi
callq 0x2200
movq -0x1e8(%rbp), %rax
movq %rax, -0xe0(%rbp)
testb $0x1, -0x1(%rbp)
je 0x7b4a
cmpq $0x0, -0xe0(%rbp)
jne 0x7a16
leaq 0x3a0b(%rip), %rsi      # 0xb3f7
leaq -0xd0(%rbp), %rdi
callq 0x81a0
movb %al, -0x1e9(%rbp)
jmp 0x7a00
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x7a0c
jmp 0x7a16
cmpl $0x6, -0x58(%rbp)
je 0x7b4a
movq 0x95bb(%rip), %rdi      # 0x10fd8
leaq 0x39e0(%rip), %rsi      # 0xb404
callq 0x21b0
movq %rax, -0x1f8(%rbp)
jmp 0x7a32
movq -0x1f8(%rbp), %rdi
movq 0x9580(%rip), %rsi      # 0x10fc0
callq 0x21e0
jmp 0x7a47
jmp 0x7b4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7a6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2100
leaq -0x39(%rbp), %rdi
callq 0x2200
jmp 0x7dfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7aa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2100
leaq -0x79(%rbp), %rdi
callq 0x2200
jmp 0x7dfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7ad4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2100
leaq -0xa9(%rbp), %rdi
callq 0x2200
jmp 0x7dfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xd1(%rbp), %rdi
callq 0x2200
jmp 0x7dfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7b28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x2100
leaq -0x101(%rbp), %rdi
callq 0x2200
jmp 0x7df0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7df0
movl $0x6f7774, -0x108(%rbp) # imm = 0x6F7774
movq -0x10(%rbp), %rax
movq %rax, -0x208(%rbp)
leaq -0x129(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x22e0
movq -0x200(%rbp), %rdx
leaq 0x389f(%rip), %rsi      # 0xb41f
leaq -0x128(%rbp), %rdi
callq 0x80f0
jmp 0x7b8e
movq -0x208(%rbp), %rdi
leaq -0x128(%rbp), %rsi
leaq -0x108(%rbp), %rdx
movl $0x4, %ecx
callq 0x25c0
jmp 0x7baf
leaq -0x128(%rbp), %rdi
callq 0x2100
leaq -0x129(%rbp), %rdi
callq 0x2200
movq -0x10(%rbp), %rax
movq %rax, -0x218(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x22e0
movq -0x210(%rbp), %rdx
leaq 0x382c(%rip), %rsi      # 0xb41f
leaq -0x158(%rbp), %rdi
callq 0x80f0
jmp 0x7c01
movq -0x218(%rbp), %rdi
leaq -0x158(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x2640
movq %rax, -0x220(%rbp)
jmp 0x7c21
leaq -0x158(%rbp), %rdi
callq 0x2100
leaq -0x159(%rbp), %rdi
callq 0x2200
movq -0x220(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x22e0
movq -0x230(%rbp), %rsi
movq -0x228(%rbp), %rdx
leaq -0x180(%rbp), %rdi
callq 0x80f0
jmp 0x7c84
leaq -0x181(%rbp), %rdi
callq 0x2200
movl -0x58(%rbp), %eax
movl %eax, -0x188(%rbp)
testb $0x1, -0x1(%rbp)
je 0x7d7e
movq 0x932e(%rip), %rdi      # 0x10fd8
leaq 0x3775(%rip), %rsi      # 0xb426
callq 0x21b0
movq %rax, -0x238(%rbp)
jmp 0x7cbf
movq -0x238(%rbp), %rdi
movq 0x92f3(%rip), %rsi      # 0x10fc0
callq 0x21e0
jmp 0x7cd4
jmp 0x7d7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7cff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x2100
leaq -0x129(%rbp), %rdi
callq 0x2200
jmp 0x7df0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7d36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x2100
leaq -0x159(%rbp), %rdi
callq 0x2200
jmp 0x7df0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x181(%rbp), %rdi
callq 0x2200
jmp 0x7df0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x2100
jmp 0x7df0
leaq 0x3696(%rip), %rsi      # 0xb41b
leaq -0x180(%rbp), %rdi
callq 0x81a0
movb %al, -0x239(%rbp)
jmp 0x7d99
movb -0x239(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x23a(%rbp)
jne 0x7dae
jmp 0x7dbb
cmpl $0x4, -0x58(%rbp)
sete %al
movb %al, -0x23a(%rbp)
movb -0x23a(%rbp), %al
movb %al, -0x23b(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x2100
leaq -0xd0(%rbp), %rdi
callq 0x2100
movb -0x23b(%rbp), %al
andb $0x1, %al
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
leaq -0xd0(%rbp), %rdi
callq 0x2100
movq -0x48(%rbp), %rdi
callq 0x22d0
nopw %cs:(%rax,%rax)