undefined4 FUN_004035c0(int param_1,int param_2,int param_3)

{
  int iVar1;
  undefined4 *__ptr;
  undefined4 *puVar2;
  undefined4 *puVar3;
  int *piVar4;
  int local_38 [4];
  
  dhcp6_remove_evdata(param_3);
  if (param_2 != 0) {
    piVar4 = *(int **)(param_1 + 0x50);
    if (piVar4 != (int *)0x0) {
      do {
        while (piVar4[4] == 0) {
          local_38[1] = 0;
          local_38[2] = 0;
          local_38[0] = piVar4[3];
          if (piVar4[2] != 0) {
            if (piVar4[2] != 1) {
              dprintf(3,"construct_reqdata","internal error");
                    /* WARNING: Subroutine does not return */
              exit(1);
            }
            iVar1 = dhcp6_find_listval(param_2 + 0x30,6,local_38,0);
            if (iVar1 != 0) {
              __ptr = (undefined4 *)malloc(8)   //possible issue identified - semgrep
              if (__ptr == (undefined4 *)0x0) goto LAB_00403870;
              *__ptr = 0;
              __ptr[1] = __ptr;
              iVar1 = dhcp6_add_listval(__ptr,6,local_38,iVar1 + 0x28);
              if ((iVar1 != 0) && (puVar2 = (undefined4 *)malloc(0x1c), puVar2 != (undefined4 *)0x0)   //possible issue identified - semgrep
                 ) {
                puVar3 = *(undefined4 **)(param_3 + 0x50);
                *puVar2 = 0;
                *(undefined4 **)(param_3 + 0x50) = puVar2;
                puVar2[4] = __ptr;
                puVar2[6] = 0;
                puVar2[3] = 1;
                *puVar3 = puVar2;
                goto LAB_00403724;
              }
LAB_00403858:
              free(__ptr);
LAB_00403870:
              dhcp6_remove_event(param_3);
              return 0xffffffff;
            }
            break;
          }
          iVar1 = dhcp6_find_listval(param_2 + 0x28,4,local_38,0);
          if (iVar1 == 0) break;
          __ptr = (undefined4 *)malloc(8)   //possible issue identified - semgrep
          if (__ptr == (undefined4 *)0x0) goto LAB_00403870;
          *__ptr = 0;
          __ptr[1] = __ptr;
          iVar1 = dhcp6_add_listval(__ptr,4,local_38,iVar1 + 0x28);
          if ((iVar1 == 0) || (puVar2 = (undefined4 *)malloc(0x1c), puVar2 == (undefined4 *)0x0))   //possible issue identified - semgrep
          goto LAB_00403858;
          puVar3 = *(undefined4 **)(param_3 + 0x50);
          *puVar2 = 0;
          *(undefined4 **)(param_3 + 0x50) = puVar2;
          puVar2[4] = __ptr;
          puVar2[6] = 0;
          puVar2[3] = 0;
          *puVar3 = puVar2;
LAB_00403724:
          piVar4 = (int *)*piVar4;
          puVar2[2] = param_3;
          puVar2[5] = &DAT_00403534;
          puVar2[1] = puVar3;
          if (piVar4 == (int *)0x0) {
            return 0;
          }
        }
        piVar4 = (int *)*piVar4;
      } while (piVar4 != (int *)0x0);
    }
  }
  return 0;
}