// File: obliviousram[P]oblivious-avl-tree/src/ServerStorage.cpp
// Function: ServerStorage::writeBucket(int, Bucket const&)
void ServerStorage::writeBucket(int position, const Bucket& bucket_to_write) {
	if (!this->is_capacity_set) {
		throw new runtime_error("Please call setCapacity before reading or writing any block");
	}

	if (position >= this->capacity || position < 0) {
		throw new runtime_error("You are trying to access Bucket " + to_string(position) + ", but this Server contains only " + to_string(this->capacity) + " buckets.");
	}

	this->buckets.at(position) = bucket_to_write;
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
testb $0x1, 0xa6e3(%rip)      # 0x1e23b
jne 0x13bf4
movl $0x8, %edi
callq 0x30d0
movq %rax, -0x108(%rbp)
movl $0x10, %edi
callq 0x3210
movq %rax, -0x100(%rbp)
jmp 0x13b82
movq -0x100(%rbp), %rdi
leaq 0x28d2(%rip), %rsi      # 0x16462
callq 0x30a0
jmp 0x13b97
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rax
movq %rax, (%rdi)
leaq 0x9f41(%rip), %rsi      # 0x1daf0
xorl %eax, %eax
movl %eax, %edx
callq 0x3370
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13be3
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x10, %esi
callq 0x3220
movq -0x108(%rbp), %rdi
callq 0x3160
jmp 0x13e39
movq -0xf8(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x20(%rcx), %eax
jge 0x13c0d
cmpl $0x0, -0xc(%rbp)
jge 0x13e02
movb $0x1, -0xea(%rbp)
movl $0x8, %edi
callq 0x30d0
movq %rax, -0x118(%rbp)
movl $0x10, %edi
callq 0x3210
movq %rax, -0x110(%rbp)
jmp 0x13c38
movb $0x1, -0xe9(%rbp)
movl -0xc(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x3c10
jmp 0x13c50
leaq 0x2847(%rip), %rsi      # 0x1649e
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0x14330
jmp 0x13c6c
leaq 0x284c(%rip), %rdx      # 0x164bf
leaq -0x88(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x14210
jmp 0x13c88
movq -0xf8(%rbp), %rax
movl 0x20(%rax), %esi
leaq -0xe8(%rbp), %rdi
callq 0x3c10
jmp 0x13ca0
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0x14260
jmp 0x13cb9
leaq 0x2820(%rip), %rdx      # 0x164e0
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x14210
jmp 0x13ccf
movq -0x110(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3330
jmp 0x13ce1
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rax
movb $0x0, -0xe9(%rbp)
movq %rax, (%rdi)
movb $0x0, -0xea(%rbp)
leaq 0x9de9(%rip), %rsi      # 0x1daf0
xorl %eax, %eax
movl %eax, %edx
callq 0x3370
jmp 0x13e42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13de9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13dcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13dbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13db3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13da7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13d9b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13d92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3120
leaq -0x68(%rbp), %rdi
callq 0x3120
leaq -0xe8(%rbp), %rdi
callq 0x3120
leaq -0x88(%rbp), %rdi
callq 0x3120
leaq -0xa8(%rbp), %rdi
callq 0x3120
leaq -0xc8(%rbp), %rdi
callq 0x3120
testb $0x1, -0xe9(%rbp)
jne 0x13dd6
jmp 0x13de7
movq -0x110(%rbp), %rdi
movl $0x10, %esi
callq 0x3220
jmp 0x13de9
testb $0x1, -0xea(%rbp)
jne 0x13df4
jmp 0x13e00
movq -0x118(%rbp), %rdi
callq 0x3160
jmp 0x13e39
movq -0xf8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x120(%rbp)
addq $0x8, %rdi
movslq -0xc(%rbp), %rsi
callq 0x14380
movq -0x120(%rbp), %rsi
movq %rax, %rdi
callq 0x143c0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x33a0
nopw %cs:(%rax,%rax)