/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

undefined4 Set_TpcReq_Proc(int param_1,undefined4 param_2)

{
  uint uVar1;
  int iVar2;
  int iVar3;
  char *pcVar4;
  undefined4 *puVar5;
  undefined4 *puVar6;
  char *pcVar7;
  char *pcVar8;
  int iVar9;
  char *pcVar10;
  char *__s;
  
  uVar1 = RandomByte();
  iVar2 = simple_strtol(param_2,0,0x10);
  if (2 < RTDebugLevel) {
    printk("%s::Aid = %d\n","Set_TpcReq_Proc",iVar2);
  }
  if (0x1e < iVar2 - 1U) {
    if (RTDebugLevel == 0) {
      return 1;
    }
    printk("%s: unknow sta of Aid(%d)\n","Set_TpcReq_Proc",iVar2);
    return 1;
  }
  pcVar10 = *(char **)(param_1 + 0x16e1c);
  if (pcVar10 == (char *)0x0) {
    if (RTDebugLevel != 0) {
      printk("%s: pTpcReqTab doesn\'t exist.\n","TpcReqInsert");
    }
    goto LAB_00046220;
  }
  iVar3 = TpcReqLookUp(param_1,uVar1);
  if (iVar3 != 0) goto LAB_00046220;
  iVar3 = 0;
  local_bh_disable();
  pcVar4 = pcVar10;
  do {
    iVar9 = iVar3 * 0xc;
    __s = pcVar10 + iVar9 + 0x84;
    if (pcVar4[0x8c] == '\x01') {
      if ((*(int *)(pcVar4 + 0x88) + 500) - _jiffies < 0) {
        pcVar4 = *(char **)(pcVar10 + ((byte)pcVar10[iVar9 + 0x8d] & 0x1f) * 4 + 4);
        pcVar8 = (char *)0x0;
        goto LAB_000460e8;
      }
    }
    else if (pcVar4[0x8c] == '\0') goto LAB_00046180;
    iVar3 = iVar3 + 1;
    pcVar4 = pcVar4 + 0xc;
  } while (iVar3 != 0x20);
LAB_000461c0:
  if (RTDebugLevel != 0) {
    printk("%s: pTpcReqTab tab full.\n","TpcReqInsert");
  }
  goto LAB_00046210;
  while (pcVar4 = *(char **)pcVar7, pcVar8 = pcVar7, *(char **)pcVar7 != (char *)0x0) {
LAB_000460e8:
    pcVar7 = pcVar4;
    if (pcVar7 == __s) {
      if (pcVar8 == (char *)0x0) {
        *(undefined4 *)(pcVar10 + ((byte)pcVar10[iVar9 + 0x8d] & 0x1f) * 4 + 4) =
             *(undefined4 *)(pcVar10 + iVar3 * 0xc + 0x84);
      }
      else {
        *(undefined4 *)pcVar8 = *(undefined4 *)(pcVar10 + iVar3 * 0xc + 0x84);
      }
      break;
    }
  }
  memset(__s,0,0xc)   //possible issue identified - semgrep
  *pcVar10 = *pcVar10 + -1;
  if (0x1f < iVar3) goto LAB_000461c0;
LAB_00046180:
  *(int *)(pcVar10 + iVar9 + 0x88) = _jiffies;
  pcVar10[iVar9 + 0x8c] = '\x01';
  pcVar10[iVar9 + 0x8d] = (char)uVar1;
  puVar5 = *(undefined4 **)(pcVar10 + (uVar1 & 0x1f) * 4 + 4);
  *pcVar10 = *pcVar10 + '\x01';
  if (puVar5 == (undefined4 *)0x0) {
    *(char **)(pcVar10 + (uVar1 & 0x1f) * 4 + 4) = __s;
  }
  else {
    do {
      puVar6 = puVar5;
      puVar5 = (undefined4 *)*puVar6;
    } while (puVar5 != (undefined4 *)0x0);
    *puVar6 = __s;
  }
LAB_00046210:
  local_bh_enable();
LAB_00046220:
  EnqueueTPCReq(param_1,param_1 + iVar2 * 0xa20 + 0x5d190,uVar1);
  return 1;
}