undefined4 RTMPAllocTxRxRingMemory(undefined4 *param_1)

{
  undefined4 *puVar1;
  int *piVar2;
  undefined4 *puVar3;
  undefined4 *puVar4;
  int iVar5;
  int iVar6;
  int *piVar7;
  int iVar8;
  int iVar9;
  undefined4 uVar10;
  int iVar11;
  int iVar12;
  
  if (2 < RTDebugLevel) {
    printk("--> RTMPAllocTxRxRingMemory\n");
  }
  local_bh_disable();
  RTInitializeCmdQ(param_1 + 0xa6f);
  local_bh_enable();
  iVar11 = 0;
  puVar3 = param_1;
  do {
    puVar3[0x51] = 0x400;
    RTMP_AllocateTxDescMemory
              (*(undefined4 *)*param_1,iVar11,0x400,0,param_1 + iVar11 * 3 + 0x52,
               param_1 + iVar11 * 3 + 0x53);
    if ((void *)puVar3[0x52] == (void *)0x0) goto LAB_00055afc;
    memset((void *)puVar3[0x52],0,puVar3[0x51]);
    puVar3[0x3f] = 0x1800;
    iVar12 = puVar3[0x53];
    iVar9 = puVar3[0x52];
    RTMP_AllocateFirstTxBuffer
              (*(undefined4 *)*param_1,iVar11,0x1800,0,param_1 + iVar11 * 3 + 0x40,
               param_1 + iVar11 * 3 + 0x41);
    if ((void *)puVar3[0x40] == (void *)0x0) goto LAB_00055afc;
    memset((void *)puVar3[0x40],0,puVar3[0x3f]);
    iVar6 = puVar3[0x41];
    puVar4 = param_1 + iVar11 * 0x203 + 0x60;
    iVar8 = puVar3[0x40];
    piVar7 = puVar4 + 1;
    iVar5 = 0;
    puVar1 = puVar4;
    do {
      piVar2 = (int *)(iVar9 + iVar5);
      puVar4[2] = iVar5 + iVar12;
      puVar4[6] = iVar8;
      puVar4[7] = iVar6;
      *puVar1 = 0x10;
      puVar4[3] = 0;
      puVar4[4] = 0;
      *piVar7 = (int)piVar2;
      puVar4[5] = 0x60;
      *piVar2 = iVar6;
      iVar5 = iVar5 + 0x10;
      *(byte *)((int)piVar2 + 7) = *(byte *)((int)piVar2 + 7) & 0x7f | 0x80;
      iVar6 = iVar6 + 0x60;
      iVar8 = iVar8 + 0x60;
      puVar4 = puVar4 + 8;
      puVar1 = puVar1 + 8;
      piVar7 = piVar7 + 8;
    } while (iVar5 != 0x400);
    if (2 < RTDebugLevel) {
      printk("TxRing[%d]: total %d entry allocated\n",iVar11,0x40);
    }
    iVar11 = iVar11 + 1;
    puVar3 = puVar3 + 3;
  } while (iVar11 != 5);
  param_1[0xa9b] = 0x800;
  RTMP_AllocateMgmtDescMemory(*(undefined4 *)*param_1,0x800,0,param_1 + 0xa9c,param_1 + 0xa9d);
  if ((void *)param_1[0xa9c] == (void *)0x0) {
LAB_00055afc:
    printk("ERROR!!! ");
    printk("Failed to allocate a big buffer\n");
    uVar10 = 3;
  }
  else {
    memset((void *)param_1[0xa9c],0,param_1[0xa9b]);
    iVar12 = param_1[0xa9d];
    iVar9 = param_1[0xa9c];
    iVar11 = 0;
    puVar3 = param_1;
    do {
      iVar5 = iVar9 + iVar11;
      puVar3[0xaa0] = iVar11 + iVar12;
      puVar3[0xaa1] = 0;
      puVar3[0xaa2] = 0;
      puVar3[0xa9e] = 0x10;
      puVar3[0xa9f] = iVar5;
      iVar11 = iVar11 + 0x10;
      *(byte *)(iVar5 + 7) = *(byte *)(iVar5 + 7) & 0x7f | 0x80;
      puVar3 = puVar3 + 8;
    } while (iVar11 != 0x800);
    if (RTDebugLevel < 3) {
      puVar3 = (undefined4 *)*param_1;
    }
    else {
      printk("MGMT Ring: total %d entry allocated\n",0x80);
      puVar3 = (undefined4 *)*param_1;
    }
    param_1[0x4e] = 0x800;
    RTMP_AllocateRxDescMemory(*puVar3,0x800,0,param_1 + 0x4f,param_1 + 0x50);
    if ((void *)param_1[0x4f] == (void *)0x0) {
      printk("ERROR!!! ");
      printk("Failed to allocate a big buffer\n");
      uVar10 = 3;
    }
    else {
      memset((void *)param_1[0x4f],0,param_1[0x4e]);
      printk("RX DESC %p  size = %ld\n",param_1[0x4f],param_1[0x4e]);
      iVar12 = param_1[0x50];
      iVar11 = param_1[0x4f];
      iVar9 = 0;
      puVar3 = param_1;
      do {
        puVar3[0xea3] = iVar11;
        puVar3[0xea4] = iVar12;
        puVar3[0xea2] = 0x10;
        puVar3[0xea7] = 0xf00;
        uVar10 = RTMP_AllocateRxPacketBuffer
                           (param_1,*(undefined4 *)*param_1,0xf00,0,param_1 + iVar9 * 8 + 0xea8,
                            param_1 + (iVar9 + 0x1d5) * 8 + 1);
        puVar3[0xea5] = uVar10;
        iVar12 = iVar12 + 0x10;
        iVar11 = iVar11 + 0x10;
        if ((void *)puVar3[0xea8] == (void *)0x0) {
          printk("ERROR!!! ");
          printk("Failed to allocate RxRing\'s 1st buffer\n");
          uVar10 = 3;
          goto LAB_00055d24;
        }
        memset((void *)puVar3[0xea8],0,puVar3[0xea7]);
        puVar1 = (undefined4 *)puVar3[0xea3];
        iVar9 = iVar9 + 1;
        *puVar1 = puVar3[0xea9];
        puVar3 = puVar3 + 8;
        *(byte *)((int)puVar1 + 7) = *(byte *)((int)puVar1 + 7) & 0x7f;
      } while (iVar9 != 0x80);
      uVar10 = 0;
LAB_00055d24:
      if (2 < RTDebugLevel) {
        printk("Rx Ring: total %d entry allocated\n",iVar9);
      }
    }
  }
  memset(param_1 + 0x1d995,0,0x10)   //possible issue identified - semgrep
  iVar11 = RTMP_AllocateFragPacketBuffer(param_1,0xf00);
  param_1[0x1d995] = iVar11;
  if (iVar11 == 0) {
    uVar10 = 3;
  }
  if (2 < RTDebugLevel) {
    printk("--> NICInitTxRxRingAndBacklogQueue\n");
  }
  iVar11 = 0;
  puVar3 = param_1;
  puVar1 = param_1;
  do {
    iVar11 = iVar11 + 1;
    puVar1[0xa8d] = 0;
    puVar1[0xa8c] = 0;
    puVar1[0xa8e] = 0;
    puVar3[0x262] = 0;
    puVar3[0x260] = 0;
    puVar1 = puVar1 + 3;
    puVar3 = puVar3 + 0x203;
  } while (iVar11 != 5);
  param_1[0x1da23] = 0;
  param_1[0x12a2] = 0x7f;
  param_1[0x12a4] = 0;
  param_1[0xea0] = 0;
  param_1[0xe9e] = 0;
  if (2 < RTDebugLevel) {
    printk("<-- NICInitTxRxRingAndBacklogQueue\n");
  }
  printk("<-- RTMPAllocTxRxRingMemory, Status=%x\n",uVar10);
  return uVar10;
}