int * xmldb_set_value(undefined4 param_1,undefined4 param_2,char *param_3,uint param_4)

{
  int iVar1;
  int *piVar2;
  char *pcVar3;
  int *piVar4;
  
  if (((param_4 & 1) == 0) || (iVar1 = xmldb_find_node(param_1,param_2,0,1), iVar1 == 0)) {
    piVar2 = (int *)xmldb_find_node(param_1,param_2,1,1);
    if (piVar2 != (int *)0x0) {
      if ((void *)piVar2[8] != (void *)0x0) {
        free((void *)piVar2[8]);
      }
      piVar2[8] = 0;
      iVar1 = FUN_00404aa4(piVar2,&DAT_00422550);
      if (iVar1 == 0) {
        if ((param_3 != (char *)0x0) && (*param_3 != '\0')) {
          pcVar3 = strdup(param_3)   //possible issue identified - semgrep
          piVar2[8] = (int)pcVar3;
        }
      }
      else {
        lxmldbc_system("%s %s",iVar1,param_3)   //possible issue identified - semgrep
      }
    }
  }
  else {
    piVar2 = (int *)FUN_00404fb0();
    if (piVar2 != (int *)0x0) {
      pcVar3 = strdup(*(char **)(iVar1 + 0x1c))   //possible issue identified - semgrep
      piVar2[6] = *(int *)(iVar1 + 0x18);
      piVar2[7] = (int)pcVar3;
      pcVar3 = strdup(param_3)   //possible issue identified - semgrep
      iVar1 = *(int *)(iVar1 + 0x18);
      piVar2[8] = (int)pcVar3;
      piVar4 = *(int **)(iVar1 + 0xc);
      *piVar2 = iVar1 + 8;
      *piVar4 = (int)piVar2;
      *(int **)(iVar1 + 0xc) = piVar2;
      piVar2[1] = (int)piVar4;
    }
  }
  return piVar2;
}