// File: hantaoyin[P]ffxiv-crafting-mcts/ffxiv-crafting-mcts.C
// Function: State::ApplyBuffChange(Action)
void ApplyBuffChange(Action ac) {
    switch (ac) {
    case Action::DelicateSynthesis:
      buff[Buff2ID(Buff::MuscleMemory)] = 0;
      buff[Buff2ID(Buff::GreatStrides)] = 0;
      break;
    case Action::BasicTouch:
    case Action::ByregotsBlessing:
    case Action::FocusedTouch:
    case Action::HastyTouch:
    case Action::PatientTouch:
    case Action::PreciseTouch:
    case Action::PreparatoryTouch:
    case Action::PrudentTouch:
    case Action::StandardTouch:
      buff[Buff2ID(Buff::GreatStrides)] = 0; break;
    case Action::GreatStrides:
      buff[Buff2ID(Buff::GreatStrides)] = 3; break;
    case Action::Innovation:
      buff[Buff2ID(Buff::Innovation)] = 4; break;
    case Action::Manipulation:
      buff[Buff2ID(Buff::Manipulation)] = 8; break;
    case Action::BasicSynthesis:
    case Action::CarefulSynthesis:
    case Action::FocusedSynthesis:
    case Action::IntensiveSynthesis:
    case Action::RapidSynthesis:
      buff[Buff2ID(Buff::MuscleMemory)] = 0; break;
    case Action::MuscleMemory:
      buff[Buff2ID(Buff::MuscleMemory)] = 5; break;
    case Action::WasteNot:
      buff[Buff2ID(Buff::WasteNot)] = 4; break;
    case Action::WasteNotII:
      buff[Buff2ID(Buff::WasteNot)] = 8; break;
    case Action::Ingenuity:
      buff[Buff2ID(Buff::Ingenuity)] = 5; break;
    case Action::Observe:
      buff[Buff2ID(Buff::Observe)] = 1; break;
    case Action::FinalAppraisal:
      // Reset of FinalAppraisal is done when it's consumed.
      buff[Buff2ID(Buff::FinalAppraisal)] = 5; break;
    default:
      break;
    }
  }

// Assembly:
subq $0x88, %rsp
movb %sil, %al
movq %rdi, 0x80(%rsp)
movb %al, 0x7f(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x68(%rsp)
movzbl 0x7f(%rsp), %eax
movq %rax, 0x70(%rsp)
subq $0x1c, %rax
ja 0x11d22
movq 0x70(%rsp), %rax
leaq 0x1771(%rip), %rcx      # 0x13234
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x58(%rsp)
movl $0x4, %edi
callq 0x6b30
movq 0x58(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movq %rax, %rcx
movq 0x68(%rsp), %rax
movb $0x0, (%rcx)
addq $0xa, %rax
movq %rax, 0x60(%rsp)
movl $0x1, %edi
callq 0x6b30
movq 0x60(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x0, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x50(%rsp)
movl $0x1, %edi
callq 0x6b30
movq 0x50(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x0, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x48(%rsp)
movl $0x1, %edi
callq 0x6b30
movq 0x48(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x3, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x40(%rsp)
movl $0x2, %edi
callq 0x6b30
movq 0x40(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x4, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x38(%rsp)
movl $0x3, %edi
callq 0x6b30
movq 0x38(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x8, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x30(%rsp)
movl $0x4, %edi
callq 0x6b30
movq 0x30(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x0, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x28(%rsp)
movl $0x4, %edi
callq 0x6b30
movq 0x28(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x5, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x20(%rsp)
movl $0x5, %edi
callq 0x6b30
movq 0x20(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x4, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x18(%rsp)
movl $0x5, %edi
callq 0x6b30
movq 0x18(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x8, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x10(%rsp)
movl $0x6, %edi
callq 0x6b30
movq 0x10(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x5, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, 0x8(%rsp)
movl $0x7, %edi
callq 0x6b30
movq 0x8(%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x1, (%rax)
jmp 0x11d24
movq 0x68(%rsp), %rax
addq $0xa, %rax
movq %rax, (%rsp)
movl $0x8, %edi
callq 0x6b30
movq (%rsp), %rdi
movzbl %al, %eax
movl %eax, %esi
callq 0x11d30
movb $0x5, (%rax)
jmp 0x11d24
jmp 0x11d24
addq $0x88, %rsp
retq
nopl (%rax)