undefined4 Set_ATE_TSSI_CALIBRATION_Proc(int param_1,undefined4 param_2)

{
  char cVar1;
  byte bVar2;
  undefined1 uVar3;
  code *pcVar4;
  uint uVar5;
  uint uVar6;
  uint uVar7;
  int iVar8;
  int iVar9;
  byte local_30 [2];
  ushort local_2e;
  undefined4 local_2c;
  undefined2 local_28;
  
  uVar3 = simple_strtol(param_2,0,10);
  if ((((*(uint *)(param_1 + 0x4a94) != 0x28720200) || (*(char *)(param_1 + 0x4bd4) != '\v')) &&
      (uVar5 = *(uint *)(param_1 + 0x4a94) & 0xffff0000, uVar5 != 0x33520000)) &&
     (uVar5 != 0x33900000)) {
    if (RTDebugLevel != 0) {
      printk("Not support TSSI calibration since not 3370/3390/3350/3352 chip !!!\n");
    }
    return 0;
  }
  local_28 = 0x6655;
  local_2c = 0x44332211;
  RT30xxReadRFRegister(param_1,0x1b,local_30);
  local_30[0] = local_30[0] & 0x77 | 0x88;
  RT30xxWriteRFRegister(param_1,0x1b,local_30[0]);
  RT30xxReadRFRegister(param_1,0x1c,local_30);
  local_30[0] = local_30[0] & 0x9f;
  RT30xxWriteRFRegister(param_1,0x1c,local_30[0]);
  iVar9 = 0;
  cVar1 = *(char *)(param_1 + 0xec)   //possible issue identified - semgrep
  while( true ) {
    uVar5 = 0;
    if (cVar1 == '\0') {
      uVar5 = *(uint *)(*(int *)(param_1 + 0xdc) + 0x101c);
    }
    if ((uVar5 & 0x20000) == 0) {
      if (cVar1 == '\0') {
        *(undefined4 *)(*(int *)(param_1 + 0xdc) + 0x101c) = 0xb3100;
      }
      iVar8 = 1;
      while( true ) {
        uVar5 = 0;
        if (*(char *)(param_1 + 0xec) == '\0') {
          uVar5 = *(uint *)(*(int *)(param_1 + 0xdc) + 0x101c);
        }
        if (((uVar5 & 0x20000) == 0) || (iVar8 == 100)) break;
        iVar8 = iVar8 + 1;
      }
      if ((uVar5 & 0x2ff00) == 0x3100) {
        uVar6 = uVar5 & 0xff;
        goto LAB_000aad40;
      }
    }
    iVar9 = iVar9 + 1;
    if (iVar9 == 100) break;
    cVar1 = *(char *)(param_1 + 0xec)   //possible issue identified - semgrep
  }
  uVar6 = 0;
LAB_000aad40:
  if ((int)(uVar5 << 0xe) < 0) {
    if (RTDebugLevel == 0) {
      bVar2 = *(byte *)(param_1 + 0x4afa);
    }
    else {
      printk("BBP read R%d fail\n",0x31);
      bVar2 = *(byte *)(param_1 + 0x4afa);
    }
    uVar6 = (uint)bVar2;
    cVar1 = *(char *)(param_1 + 0xec)   //possible issue identified - semgrep
  }
  else {
    cVar1 = *(char *)(param_1 + 0xec)   //possible issue identified - semgrep
  }
  uVar5 = uVar6 | 0x80;
  iVar9 = 0;
  do {
    uVar7 = 0;
    if (cVar1 == '\0') {
      uVar7 = *(uint *)(*(int *)(param_1 + 0xdc) + 0x101c);
    }
    if ((uVar7 & 0x20000) == 0) {
      if (cVar1 == '\0') {
        *(uint *)(*(int *)(param_1 + 0xdc) + 0x101c) = uVar6 | 0xa3180;
      }
      *(char *)(param_1 + 0x4afa) = (char)uVar5;
      if (iVar9 != 100) goto LAB_000aae24;
      break;
    }
    iVar9 = iVar9 + 1;
  } while (iVar9 != 100);
  if (RTDebugLevel != 0) {
    printk("BBP write R%d fail\n",0x31);
  }
LAB_000aae24:
  memset((void *)(param_1 + 0x76a0c),0,0xf8)   //possible issue identified - semgrep
  *(undefined4 *)(param_1 + 0x76a40) = 100000;
  *(undefined4 *)(param_1 + 0x76a3c) = 0x400;
  *(undefined1 *)(param_1 + 0x76a38) = 1;
  memcpy((void *)(param_1 + 0x76a26),&BROADCAST_ADDR,6)   //possible issue identified - semgrep
  memcpy((void *)(param_1 + 0x76a2c),(void *)(param_1 + 0x1696d),6)   //possible issue identified - semgrep
  memcpy((void *)(param_1 + 0x76a32),&local_2c,6)   //possible issue identified - semgrep
  Set_ATE_TX_MODE_Proc(param_1,&_LC218);
  Set_ATE_TX_MCS_Proc(param_1,&_LC219);
  Set_ATE_TX_BW_Proc(param_1,&_LC220);
  *(undefined1 *)(param_1 + 0x76a0f) = uVar3;
  if (RTDebugLevel < 3) {
    pcVar4 = *(code **)(param_1 + 0x10);
  }
  else {
    printk("(Calibrated) Tx.Power0= 0x%x\n");
    pcVar4 = *(code **)(param_1 + 0x10);
  }
  (*pcVar4)(param_1,0x3a,&local_2e);
  *(uint *)(param_1 + 0x76a48) = (uint)(byte)local_2e;
  Set_ATE_Proc(param_1,"TXFRAME");
  RTMPusecDelay(500000);
  if (2 < RTDebugLevel) {
    printk("Read  BBP_R49\n");
  }
  iVar9 = 0;
  cVar1 = *(char *)(param_1 + 0xec)   //possible issue identified - semgrep
  do {
    uVar6 = 0;
    if (cVar1 == '\0') {
      uVar6 = *(uint *)(*(int *)(param_1 + 0xdc) + 0x101c);
    }
    if ((uVar6 & 0x20000) == 0) {
      if (cVar1 == '\0') {
        *(undefined4 *)(*(int *)(param_1 + 0xdc) + 0x101c) = 0xb3100;
      }
      iVar8 = 1;
      while( true ) {
        uVar6 = 0;
        if (*(char *)(param_1 + 0xec) == '\0') {
          uVar6 = *(uint *)(*(int *)(param_1 + 0xdc) + 0x101c);
        }
        if (((uVar6 & 0x20000) == 0) || (iVar8 == 100)) break;
        iVar8 = iVar8 + 1;
      }
      if ((uVar6 & 0x2ff00) == 0x3100) {
        uVar5 = uVar6 & 0xff;
LAB_000ab04c:
        if ((int)(uVar6 << 0xe) < 0) {
          if (RTDebugLevel == 0) {
            bVar2 = *(byte *)(param_1 + 0x4afa);
          }
          else {
            printk("BBP read R%d fail\n",0x31);
            bVar2 = *(byte *)(param_1 + 0x4afa);
          }
          uVar5 = (uint)bVar2;
        }
        if (RTDebugLevel < 3) {
          pcVar4 = *(code **)(param_1 + 0x10);
        }
        else {
          printk("BBP R49 = 0x%x\n",uVar5);
          pcVar4 = *(code **)(param_1 + 0x10);
        }
        (*pcVar4)(param_1,0x6e,&local_2e);
        local_2e = (ushort)uVar5 & 0x1f | local_2e & 0xff00;
        if (2 < RTDebugLevel) {
          printk("Write  E2P 0x6e: 0x%x\n");
        }
        (**(code **)(param_1 + 0x14))(param_1,0x6e,local_2e);
        RTMPusecDelay(10);
        Set_ATE_Proc(param_1,"ATESTART");
        return 1;
      }
    }
    iVar9 = iVar9 + 1;
    if (iVar9 == 100) goto LAB_000ab04c;
    cVar1 = *(char *)(param_1 + 0xec)   //possible issue identified - semgrep
  } while( true );
}