// File: /workspace/github_cpp_makefile_star2_O3/XxAdi101xX[P]ChamberCrawler/Character/Character.cc
// Function: Character::applyPotion(std::shared_ptr<Potion>)
void Character::applyPotion(const shared_ptr<Potion> potion) {
	PotionType type = potion->getPotionType();
	int potency = potion->getPotency();

	// health based potions
	if (type == PotionType::RestoreHealth
		|| type == PotionType::PoisonHealth) {

		if (this->getHP() + potency <= 0) {
			potency = -(this->getHP() - 1);
		}

		this->addHPViaPotion(potency);
	}

	// attack based potions
	else if (type == PotionType::BoostAttack
		|| type == PotionType::WoundAttack) {

		this->attackBuff += potency;
	}

	// defence based potions
	else if (type == PotionType::BoostDefence
		|| type == PotionType::WoundDefence) {

		this->defenceBuff += potency;
	}

	usedPotions.emplace_back(type);

	// reports what potion was used
	this->addAction(makeMsg(this->name, WORD_USE_PAST_TENSE , potionToText(potion)));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rdi
callq 0x1a3bc
movl %eax, %r15d
movl %eax, 0x4(%rsp)
movq (%r14), %rdi
callq 0x1a3c0
cmpl $0x1, %r15d
ja 0x158ff
movl 0x34(%rbx), %ecx
movl $0x1, %esi
subl %ecx, %esi
addl %eax, %ecx
cmovgl %eax, %esi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
jmp 0x15920
leal -0x2(%r15), %ecx
cmpl $0x3, %ecx
ja 0x15920
leaq 0xa785(%rip), %rdx      # 0x20094
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
addl %eax, 0x3c(%rbx)
jmp 0x15920
addl %eax, 0x44(%rbx)
leaq 0x14771(%rip), %rax     # 0x2a098
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x1593e
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x1594f
leaq 0x14753(%rip), %rdi     # 0x2a098
leaq 0x4(%rsp), %rdx
callq 0x194c2
leaq 0x48(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x1942c
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x159fc(%rip), %rsi     # 0x2b380
movq 0x159fd(%rip), %rdx     # 0x2b388
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x1942c
movq (%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x159c3
movq 0x135f3(%rip), %rcx     # 0x28fa8
cmpb $0x0, (%rcx)
je 0x159bf
incl 0x8(%rax)
jmp 0x159c3
lock
incl 0x8(%rax)
leaq 0x78(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1aa69
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x18(%rsp), %rdx
leaq 0x78(%rsp), %rcx
callq 0x1a5ac
addq $0x68, %rbx
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq %rbx, %rdi
callq 0x5100
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15a1c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5280
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15a3d
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15a4c
callq 0x1235a
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x15a63
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x15a7a
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5280
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15aac
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x15aac
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15ad2
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x15ad2
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15ae1
callq 0x1235a
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x15afd
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x15afd
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x15b14
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5280
movq %rbx, %rdi
callq 0x53e0