function switch_slot_21() /* entry=392 class_id=0x0A16 slot=0x21 */
{
  var
    referent, /* [BP+00h] type=0x69 */
    okay; /* [BP-01h] type=0x62 */

  set_info(0x0207, *(arg_06));
  okay = MainActor.hasKeycard(Item.getQLo(arg_06));
  if (Item.getFrame(arg_06) == 4) {
    spawn FREE.slot_21(pid, 0x00AD, 0x00000000);
    suspend;
    spawn TRIGGER.slot_20(pid, 0, *(arg_06), arg_06);
    suspend;
    spawn FREE.waitNTimerTicks(pid, 1, 0x00000000);
    suspend;
    return;
  }
  else if (!World.getAlertActive()) {
    spawn FREE.slot_21(pid, 0x0090, 0x00000000);
    suspend;
    if (UCMachine.rndRange(100, 0) <= 50) {
    }
    return;
  }
  else if (!okay) {
    spawn FREE.waitNTimerTicks(pid, 1, 0x00000000);
    suspend;
    spawn TRIGGER.slot_20(pid, 0, *(arg_06), arg_06);
    suspend;
    return;
  }
  else {
    while (!AudioProcess.isSFXPlayingForObject(0x0090, arg_06)) {
      spawn FREE.waitNTimerTicks(pid, 2, 0x00000000);
      suspend;
    }
    spawn FREE.waitNTimerTicks(pid, 1, 0x00000000);
    suspend;
    spawn TRIGGER.slot_20(pid, 1, *(arg_06), arg_06);
    suspend;
  }
  return;
}
