/* WARNING: Restarted to delay deadcode elimination for space: register */

void RTMPIoctlGetSiteSurvey(int param_1,uint *param_2)

{
  char cVar1;
  size_t sVar2;
  int iVar3;
  uint uVar4;
  int iVar5;
  char *pcVar6;
  int iVar7;
  int *unaff_gp;
  char *local_48;
  undefined1 auStack_44 [8];
  undefined4 local_3c;
  int local_38;
  undefined *local_34;
  undefined4 *****local_30;
  undefined4 *****local_2c;
  
  os_alloc_mem(0,&local_48,0x1ae4);
  if (local_48 == (char *)0x0) {
    if (2 < RTDebugLevel) {
      printk("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n");
    }
    return;
  }
  memset(local_48,0,0x1ae4)   //possible issue identified - semgrep
  sprintf(local_48,"%s",&_LC89)   //possible issue identified - semgrep
  pcVar6 = local_48;
  sVar2 = strlen(local_48);
  sprintf(pcVar6 + sVar2,"%-4s%-33s%-20s%-23s%-9s%-7s%-7s%-3s\n",&_LC140,&_LC141,"BSSID","Security",
          "Siganl(%)","W-Mode"," ExtCH",&_LC147)   //possible issue identified - semgrep
  iVar7 = 0;
LAB_0003ab30:
  for (; (iVar3 = ScanRunning(param_1), iVar3 == 1 && (iVar7 != 200)); iVar7 = iVar7 + 1) {
    if ((unaff_gp[5] & 0x7ffff00U) == 0) {
      __init_waitqueue_head(auStack_44,0x10000);
      iVar3 = 0;
      local_38 = *unaff_gp;
      do {
        iVar5 = 1;
        local_3c = 0;
        local_34 = &autoremove_wake_function;
        local_30 = &local_30;
        local_2c = &local_30;
        do {
          prepare_to_wait(auStack_44,&local_3c,1);
          if ((*(uint *)(*(int *)(*unaff_gp + 4) + 8) & 2) != 0) break;
          iVar5 = schedule_timeout(iVar5);
        } while (iVar5 != 0);
        iVar3 = iVar3 + 1;
        finish_wait(auStack_44,&local_3c);
        if (iVar3 == 0x7d) goto code_r0x0003ab2c;
        local_38 = *unaff_gp;
      } while( true );
    }
    RTMPusecDelay(500000);
  }
  pcVar6 = (char *)(param_1 + 0x4833a);
  iVar7 = 0;
  while ((iVar7 < (int)(uint)*(byte *)(param_1 + 0x48330) &&
         (cVar1 = *pcVar6, pcVar6 = pcVar6 + 0x520, cVar1 != '\0'))) {
    sVar2 = strlen(local_48);
    iVar3 = iVar7 * 0x520;
    iVar7 = iVar7 + 1;
    if (0xfff < sVar2 + 100) break;
    RTMPCommSiteSurveyData(local_48,param_1 + iVar3 + 0x48334,0x1ae4);
  }
  sVar2 = strlen(local_48);
  uVar4 = *param_2;
  *(short *)(param_2 + 1) = (short)sVar2;
  if ((((sVar2 & 0xffff) + uVar4 | uVar4 | sVar2 & 0xffff) & unaff_gp[6]) == 0) {
    __copy_user(uVar4,local_48);
  }
  if (2 < RTDebugLevel) {
    printk("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n",(short)param_2[1]);
  }
  os_free_mem(0,local_48);
  return;
code_r0x0003ab2c:
  iVar7 = iVar7 + 1;
  goto LAB_0003ab30;
}