void RTMPAPIoctlMAC(int param_1,uint *param_2)
{
byte bVar1;
byte bVar2;
bool bVar3;
char cVar4;
char *pcVar5;
size_t sVar6;
size_t sVar7;
uint uVar8;
uint uVar9;
char *pcVar10;
undefined4 uVar11;
int iVar12;
char *pcVar13;
char *__s;
int unaff_gp;
int local_50;
char *local_4c;
byte local_48;
byte local_47;
byte local_46;
byte local_45;
char acStack_39 [8];
char local_31 [9];
os_alloc_mem(0,&local_50,0x110c);
if (local_50 != 0) {
__s = (char *)(local_50 + 3U & 0xfffffffc);
bVar1 = *(byte *)((int)param_2 + 6);
pcVar13 = __s + 0x1000;
memset(__s,0,0x1000) //possible issue identified - semgrep
memset(pcVar13,0,0x100) //possible issue identified - semgrep
uVar8 = (uint)(ushort)param_2[1];
if (1 < uVar8) {
sVar7 = 0xff //possible issue identified - semgrep
if (uVar8 < 0x100) {
sVar7 = uVar8;
}
memmove(pcVar13,(void *)*param_2,sVar7) //possible issue identified - semgrep
local_4c = pcVar13;
sprintf(__s,"\n") //possible issue identified - semgrep
LAB_00087484:
do {
pcVar13 = strsep(&local_4c,",");
if (pcVar13 == (char *)0x0) goto LAB_00087530;
if (*pcVar13 != '\0') {
pcVar5 = strchr(pcVar13,0x3d);
if (pcVar5 == (char *)0x0) {
LAB_00087044:
sVar7 = strlen(pcVar13);
if (4 < sVar7) goto LAB_00087530;
sVar7 = strlen(pcVar13);
pcVar5 = pcVar13 + sVar7;
while (0 < (int)sVar7) {
pcVar10 = pcVar5 + -1;
sVar7 = sVar7 - 1 //possible issue identified - semgrep
pcVar5 = pcVar5 + -1;
if (0x36 < (byte)(*pcVar10 - 0x30U)) goto LAB_000875f4;
}
sVar6 = strlen(pcVar13);
pcVar10 = pcVar13 + sVar6;
sVar7 = sVar6;
pcVar5 = pcVar13;
while( true ) {
pcVar10 = pcVar10 + -1;
if ((int)sVar7 < 1) break;
sVar7 = sVar7 - 1 //possible issue identified - semgrep
pcVar5[3] = *pcVar10;
pcVar5 = pcVar5 + -1;
}
pcVar5 = pcVar13 + (3 - sVar6);
while (bVar3 = (int)sVar6 < 4, sVar6 = sVar6 + 1, bVar3) { //possible issue identified - semgrep
*pcVar5 = '0';
pcVar5 = pcVar5 + -1;
}
pcVar13[4] = '\0';
sVar7 = strlen(pcVar13);
if (sVar7 != 4) goto LAB_00087484;
AtoH(pcVar13,&local_48,2);
iVar12 = (uint)local_48 * 0x100 + (uint)local_47;
if (iVar12 == 0xffff) goto LAB_00087530;
uVar11 = 0;
if (*(char *)(param_1 + 0xec) == '\0') {
uVar11 = *(undefined4 *)(*(int *)(param_1 + 0xdc) + iVar12);
}
if (((bVar1 & 1) == 0) && (RTDebugLevel != 0)) {
printk("MacAddr=0x%x, MacValue=0x%x\n",iVar12,uVar11);
}
}
else {
pcVar10 = pcVar5 + 1;
*pcVar5 = '\0';
if ((pcVar10 == (char *)0x0) || (pcVar5[1] == '\0')) goto LAB_00087044;
sVar7 = strlen(pcVar10);
memmove(acStack_39 + 1,pcVar10,sVar7) //possible issue identified - semgrep
sVar7 = strlen(pcVar10);
acStack_39[sVar7 + 1] = '\0';
sVar7 = strlen(pcVar13);
if ((4 < sVar7) || (sVar7 = strlen(acStack_39 + 1), 8 < sVar7)) goto LAB_00087530 //possible issue identified - semgrep
sVar7 = strlen(pcVar13);
pcVar5 = pcVar13 + sVar7;
while (0 < (int)sVar7) {
pcVar10 = pcVar5 + -1;
sVar7 = sVar7 - 1 //possible issue identified - semgrep
pcVar5 = pcVar5 + -1;
if (0x36 < (byte)(*pcVar10 - 0x30U)) goto LAB_000875f4;
}
sVar7 = strlen(acStack_39 + 1) //possible issue identified - semgrep
pcVar5 = acStack_39 + 1 + (sVar7 - 1);
while (0 < (int)sVar7) {
cVar4 = *pcVar5;
sVar7 = sVar7 - 1 //possible issue identified - semgrep
pcVar5 = pcVar5 + -1;
if (0x36 < (byte)(cVar4 - 0x30U)) goto LAB_000875f4;
}
sVar6 = strlen(pcVar13);
pcVar10 = pcVar13 + sVar6;
sVar7 = sVar6;
pcVar5 = pcVar13;
while( true ) {
pcVar10 = pcVar10 + -1;
if ((int)sVar7 < 1) break;
sVar7 = sVar7 - 1 //possible issue identified - semgrep
pcVar5[3] = *pcVar10;
pcVar5 = pcVar5 + -1;
}
pcVar5 = pcVar13 + (3 - sVar6);
while (bVar3 = (int)sVar6 < 4, sVar6 = sVar6 + 1, bVar3) { //possible issue identified - semgrep
*pcVar5 = '0';
pcVar5 = pcVar5 + -1;
}
pcVar13[4] = '\0';
sVar6 = strlen(acStack_39 + 1) //possible issue identified - semgrep
pcVar10 = acStack_39 + 1 + (sVar6 - 1);
pcVar5 = local_31;
for (sVar7 = sVar6; 0 < (int)sVar7; sVar7 = sVar7 - 1) { //possible issue identified - semgrep
*pcVar5 = *pcVar10;
pcVar10 = pcVar10 + -1;
pcVar5 = pcVar5 + -1;
}
pcVar5 = local_31 + -sVar6;
while (bVar3 = (int)sVar6 < 8, sVar6 = sVar6 + 1, bVar3) { //possible issue identified - semgrep
*pcVar5 = '0';
pcVar5 = pcVar5 + -1;
}
local_31[1] = 0;
AtoH(pcVar13,&local_48,2);
iVar12 = (uint)local_48 * 0x100 + (uint)local_47;
AtoH(acStack_39 + 1,&local_48,4);
uVar8 = (((uint)local_48 * 0x100 + (uint)local_47) * 0x100 + (uint)local_46) * 0x100 +
(uint)local_45;
if (iVar12 == 0x77f4) {
if ((uVar8 & 0xff) == 0) {
bVar2 = *(byte *)(param_1 + 0x4be0);
*(undefined1 *)(param_1 + 0x4bca) = 0;
if (bVar2 < 0xf) {
cVar4 = *(char *)(param_1 + 0x50e4) //possible issue identified - semgrep
}
else if (bVar2 < 0x41) {
cVar4 = *(char *)(param_1 + 0x50e5) //possible issue identified - semgrep
}
else if (bVar2 < 0x81) {
cVar4 = *(char *)(param_1 + 0x50e6) //possible issue identified - semgrep
}
else {
cVar4 = *(char *)(param_1 + 0x50e7) //possible issue identified - semgrep
}
if ((bVar1 & 1) != 0) {
return;
}
if (RTDebugLevel == 0) {
return;
}
printk("turn off R66 tuning, restore to 0x%02x\n",cVar4 + '&');
return;
}
*(undefined1 *)(param_1 + 0x4bca) = 1;
if (RTDebugLevel == 0) {
return;
}
pcVar13 = "turn on R17 tuning\n";
goto LAB_00087624;
}
if ((bVar1 & 1) == 0) {
if (RTDebugLevel == 0) {
cVar4 = *(char *)(param_1 + 0xec) //possible issue identified - semgrep
}
else {
printk("MacAddr=%02x, MacValue=0x%x\n",iVar12,uVar8);
cVar4 = *(char *)(param_1 + 0xec) //possible issue identified - semgrep
}
}
else {
cVar4 = *(char *)(param_1 + 0xec) //possible issue identified - semgrep
}
if (cVar4 == '\0') {
*(uint *)(*(int *)(param_1 + 0xdc) + iVar12) = uVar8;
}
}
sVar7 = strlen(__s);
sprintf(__s + sVar7,"[0x%08x]:%08x ") //possible issue identified - semgrep
}
} while( true );
}
uVar9 = 0;
uVar8 = 0;
do {
if ((uVar8 == 0) && (2 < RTDebugLevel)) {
printk("\n0x%04x: ",uVar9);
}
uVar11 = 0;
if (*(char *)(param_1 + 0xec) == '\0') {
uVar11 = *(undefined4 *)(*(int *)(param_1 + 0xdc) + uVar9);
}
uVar9 = uVar9 + 4;
if (2 < RTDebugLevel) {
printk("%08x ",uVar11);
}
uVar8 = uVar9 & 0xf;
} while (uVar9 != 0x1504);
LAB_00087530:
sVar7 = strlen(__s);
if (sVar7 == 1) {
sVar7 = strlen(__s);
sprintf(__s + sVar7,"===>Error command format!") //possible issue identified - semgrep
}
sVar7 = strlen(__s);
uVar8 = sVar7 & 0xffff;
uVar9 = *param_2;
*(short *)(param_2 + 1) = (short)sVar7;
if (((uVar9 + uVar8 | uVar9 | uVar8) & *(uint *)(unaff_gp + 0x18)) == 0) {
__copy_user(uVar9,__s);
}
if ((uVar8 != 0) && (2 < RTDebugLevel)) {
printk("%s: copy_to_user() fail\n","RTMPAPIoctlMAC");
}
LAB_000875f4:
os_free_mem(0,local_50);
if (((bVar1 & 1) == 0) && (2 < RTDebugLevel)) {
pcVar13 = "<==RTMPIoctlMAC\n\n";
LAB_00087624:
printk(pcVar13);
}
}
return;
}