void BAOriSessionTearDown(int param_1,byte param_2,byte param_3,char param_4,char param_5)

{
  code *pcVar1;
  int iVar2;
  char *pcVar3;
  uint uVar4;
  uint uVar5;
  uint uVar6;
  undefined1 auStack_38 [4];
  char *local_34;
  byte local_30;
  undefined1 auStack_2f [6];
  byte local_29;
  char local_28;
  
  uVar4 = (uint)param_2;
  uVar5 = (uint)param_3;
  if (0x1f < uVar4) {
    return;
  }
  uVar6 = (uint)*(ushort *)(param_1 + (uVar4 * 0x510 + uVar5 + 0x2e9b4) * 2 + 6);
  if (uVar6 - 1 < 0x7f) {
    if (2 < RTDebugLevel) {
      printk("%s===>Wcid=%d.TID=%d \n","BAOriSessionTearDown",uVar4,uVar5);
    }
    if (2 < RTDebugLevel) {
      printk("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n",uVar6,uVar4,uVar5,
             *(undefined4 *)(uVar6 * 0x38 + param_1 + 0x71374));
    }
    if (((param_4 == '\0') && (iVar2 = uVar6 * 0x38 + param_1, *(byte *)(iVar2 + 0x7136d) == uVar5))
       && (*(int *)(iVar2 + 0x71374) == 3)) {
      os_alloc_mem(0,&local_34,0x668);
      if (local_34 == (char *)0x0) {
        if (RTDebugLevel == 0) {
          return;
        }
        pcVar3 = "%s():alloc memory failed!\n";
        goto LAB_0001fe90;
      }
      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_29 = *(byte *)(iVar2 + 0x7136d);
      local_28 = '\x01';
      local_34[0x648] = '\t';
      local_34[0x649] = '\0';
      local_34[0x64a] = '\0';
      local_34[0x64b] = '\0';
      local_30 = param_2;
      memmove(local_34,&local_30,9)   //possible issue identified - semgrep
      MlmeDELBAAction(param_1,local_34);
      os_free_mem(0,local_34);
    }
    RTMPCancelTimer(param_1 + uVar6 * 0x38 + 0x71378,auStack_38);
    BATableFreeOriEntry(param_1,uVar6);
  }
  else {
    if (param_5 != '\x01') {
      return;
    }
    os_alloc_mem(0,&local_34,0x668);
    if (local_34 == (char *)0x0) {
      if (RTDebugLevel == 0) {
        return;
      }
      pcVar3 = "%s(bForceSend):alloc memory failed!\n";
LAB_0001fe90:
      local_34 = "BAOriSessionTearDown";
      pcVar1 = printk;
    }
    else {
      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 = param_5;
      local_34[0x648] = '\t';
      local_34[0x649] = '\0';
      local_34[0x64a] = '\0';
      local_34[0x64b] = '\0';
      local_30 = param_2;
      local_29 = param_3;
      memmove(local_34,&local_30,9)   //possible issue identified - semgrep
      MlmeDELBAAction(param_1,local_34);
      pcVar3 = (char *)0x0;
      pcVar1 = os_free_mem;
    }
    (*pcVar1)(pcVar3,local_34);
  }
  return;
}