void BARecSessionTearDown(int param_1,byte param_2,byte param_3,char param_4)

{
  int iVar1;
  uint *puVar2;
  int iVar3;
  uint uVar4;
  uint uVar5;
  uint uVar6;
  undefined1 auStack_38 [4];
  void *local_34;
  byte local_30;
  undefined1 auStack_2f [6];
  byte local_29;
  undefined1 local_28;
  
  uVar4 = (uint)param_2;
  uVar5 = (uint)param_3;
  if ((uVar4 < 0x20) &&
     (uVar6 = (uint)*(ushort *)(param_1 + (uVar4 * 0x510 + uVar5 + 0x2e9ac) * 2 + 6), uVar6 != 0)) {
    if (2 < RTDebugLevel) {
      printk("%s===>Wcid=%d.TID=%d \n","BARecSessionTearDown",uVar4,uVar5);
    }
    if (2 < RTDebugLevel) {
      printk("\t===>Idx = %ld, Wcid=%d.TID=%d, REC_BA_Status = %d \n",uVar6,uVar4,uVar5,
             *(undefined4 *)(uVar6 * 0x4c + param_1 + 0x72fa8));
    }
    iVar1 = param_1 + uVar6 * 0x4c;
    if ((*(byte *)(iVar1 + 0x72f6d) == uVar5) && (*(int *)(iVar1 + 0x72fa8) == 3)) {
      RTMPCancelTimer(param_1 + uVar6 * 0x4c + 0x72f74,auStack_38);
      if (param_4 == '\0') {
        os_alloc_mem(0,&local_34,0x668);
        if (local_34 == (void *)0x0) {
          if (RTDebugLevel == 0) {
            return;
          }
          printk("%s():alloc memory failed!\n","BARecSessionTearDown");
          return;
        }
        memset(&local_30,0,9)   //possible issue identified - semgrep
        memset(local_34,0,0x668)   //possible issue identified - semgrep
        memcpy(auStack_2f,(void *)(param_1 + uVar4 * 0xa20 + 0x5d190),6)   //possible issue identified - semgrep
        local_28 = 0;
        *(undefined4 *)((int)local_34 + 0x648) = 9;
        local_30 = param_2;
        local_29 = param_3;
        memmove(local_34,&local_30,9)   //possible issue identified - semgrep
        MlmeDELBAAction(param_1,local_34);
        os_free_mem(0,local_34);
      }
      ba_refresh_reordering_mpdus(param_1,param_1 + uVar6 * 0x4c + 0x72f6c);
      iVar3 = param_1 + uVar6 * 0x4c;
      local_bh_disable();
      iVar1 = uVar4 * 0xa20 + param_1;
      *(undefined2 *)(iVar3 + 0x72f70) = 0xffff;
      *(undefined1 *)(iVar3 + 0x72f6e) = 0;
      *(ushort *)(iVar1 + 0x5d356) =
           ~(ushort)(1 << (*(byte *)(iVar3 + 0x72f6d) & 0x1f)) & *(ushort *)(iVar1 + 0x5d356);
      *(undefined2 *)(param_1 + (uVar4 * 0x510 + uVar5 + 0x2e9ac) * 2 + 6) = 0;
      if (*(char *)(param_1 + 0xec) == '\0') {
        puVar2 = (uint *)(*(int *)(param_1 + 0xdc) + uVar4 * 8 + 0x1804);
        *puVar2 = *puVar2 & ~(0x10000 << (uVar5 & 0x1f));
      }
      local_bh_enable();
    }
    BATableFreeRecEntry(param_1,uVar6);
  }
  return;
}