undefined4 FUN_00415a0c(int param_1)

{
  char *pcVar1;
  undefined4 *puVar2;
  int iVar3;
  undefined4 *puVar4;
  int iVar5;
  undefined4 uVar6;
  int *piVar7;
  void *__ptr;
  undefined4 *puVar8;
  undefined *puVar9;
  int local_30 [3];
  undefined4 local_24;
  undefined4 local_20;
  
  iVar5 = *(int *)(param_1 + 8);
  if (*(int *)(iVar5 + 8) == 0) {
    puVar9 = &DAT_00429fec;
LAB_00415a54:
    iVar3 = *(int *)(param_1 + 0x14);
    uVar6 = *(undefined4 *)(iVar5 + 0xc);
    if (iVar3 == 1) goto LAB_00415b94;
LAB_00415a68:
    if (iVar3 == 0) {
      pcVar1 = "ACTIVE";
    }
    else if (iVar3 == 2) {
      pcVar1 = "REBIND";
    }
    else {
      pcVar1 = "???";
    }
  }
  else {
    if (*(int *)(iVar5 + 8) == 1) {
      puVar9 = &DAT_00429fe8;
      goto LAB_00415a54;
    }
    iVar3 = *(int *)(param_1 + 0x14);
    puVar9 = &DAT_00427600;
    uVar6 = *(undefined4 *)(iVar5 + 0xc);
    if (iVar3 != 1) goto LAB_00415a68;
LAB_00415b94:
    pcVar1 = "RENEW";
  }
  dprintf(7,"ia_timo","IA timeout for %s-%lu, state=%s",puVar9,uVar6,pcVar1);
  piVar7 = *(int **)(param_1 + 0x1c);
  if (piVar7 != (int *)0x0) {
    if (*piVar7 == 0) {
      *(int *)(piVar7[2] + 0x50) = piVar7[1];
    }
    else {
      *(int *)(*piVar7 + 4) = piVar7[1];
    }
    *(int *)piVar7[1] = *piVar7;
    __ptr = *(void **)(param_1 + 0x1c);
    if (*(code **)((int)__ptr + 0x14) != (code *)0x0) {
      (**(code **)((int)__ptr + 0x14))();
      __ptr = *(void **)(param_1 + 0x1c);
    }
    free(__ptr);
    *(undefined4 *)(param_1 + 0x1c) = 0;
  }
  iVar5 = *(int *)(param_1 + 0x14);
  if (iVar5 == 0) {
    *(undefined4 *)(param_1 + 0x14) = 1;
    if (*(uint *)(param_1 + 0xc) < *(uint *)(param_1 + 0x10)) {
      local_30[0] = *(uint *)(param_1 + 0x10) - *(uint *)(param_1 + 0xc);
    }
    else {
      local_30[0] = 0;
    }
    local_30[1] = 0;
    dhcp6_set_timer(local_30,*(undefined4 *)(param_1 + 0x18));
    uVar6 = 4;
  }
  else {
    if (iVar5 != 1) {
      dprintf(3,"ia_timo","invalid IA state (%d)",iVar5,uVar6,pcVar1);
      return 0;
    }
    *(undefined4 *)(param_1 + 0x14) = 2;
    dhcp6_remove_timer(param_1 + 0x18);
    uVar6 = 5;
  }
  puVar2 = (undefined4 *)dhcp6_create_event(*(undefined4 *)(param_1 + 0x20),uVar6);
  if (puVar2 == (undefined4 *)0x0) {
    dprintf(5,"ia_timo","failed to create a new event");
    return 0;
  }
  iVar5 = *(int *)(param_1 + 0x20);
  puVar2[1] = *(undefined4 *)(iVar5 + 0xc);
  puVar8 = *(undefined4 **)(iVar5 + 0xc);
  *puVar2 = 0;
  *(undefined4 **)(iVar5 + 0xc) = puVar2;
  *puVar8 = puVar2;
  iVar5 = dhcp6_add_timer(client6_timo,puVar2);
  puVar2[3] = iVar5;
  if (iVar5 == 0) {
    dprintf(5,"ia_timo","failed to create a new event timer");
  }
  else {
    puVar8 = (undefined4 *)malloc(0x1c)   //possible issue identified - semgrep
    if (puVar8 != (undefined4 *)0x0) {
      puVar8[1] = 0;
      puVar8[3] = 0;
      puVar8[4] = 0;
      puVar8[5] = 0;
      puVar8[6] = 0;
      iVar5 = *(int *)(param_1 + 0x14);
      puVar8[1] = puVar2[0x14];
      puVar4 = (undefined4 *)puVar2[0x14];
      *puVar8 = 0;
      puVar8[2] = puVar2;
      *puVar4 = puVar8;
      puVar2[0x14] = puVar8;
      if (iVar5 == 1) {
        iVar5 = duidcpy(puVar2 + 4,param_1 + 0x24);
        if (iVar5 != 0) {
          dprintf(5,"ia_timo","failed to copy server ID");
          goto LAB_00415e84;
        }
        iVar5 = *(int *)(param_1 + 0x14);
      }
      local_24 = *(undefined4 *)(param_1 + 0xc);
      local_30[2] = *(undefined4 *)(*(int *)(param_1 + 8) + 0xc);
      local_20 = *(undefined4 *)(param_1 + 0x10);
      if (iVar5 == 1) {
        iVar5 = *(int *)(param_1 + 0x2c);
        if (iVar5 != 0) {
          if ((*(code **)(iVar5 + 0x10) != (code *)0x0) &&
             (iVar5 = (**(code **)(iVar5 + 0x10))(iVar5,local_30 + 2,param_1 + 0x1c,puVar8),
             iVar5 != 0)) {
            dprintf(5,"ia_timo","failed to make renew data");
            goto LAB_00415e84;
          }
        }
      }
      else if ((iVar5 == 2) && (iVar5 = *(int *)(param_1 + 0x2c), iVar5 != 0)) {
        if ((*(code **)(iVar5 + 0x14) != (code *)0x0) &&
           (iVar5 = (**(code **)(iVar5 + 0x14))(iVar5,local_30 + 2,param_1 + 0x1c,puVar8),
           iVar5 != 0)) {
          dprintf(5,"ia_timo","failed to make rebind data");
          goto LAB_00415e84;
        }
      }
      puVar2[0xd] = 0;
      dhcp6_set_timeoparam(puVar2);
      dhcp6_reset_timer(puVar2);
      if (*(int *)(param_1 + 0x30) != 0) {
        iVar5 = copy_authparam();
        puVar2[0x12] = iVar5;
        if (iVar5 == 0) {
          dprintf(4,"ia_timo","failed to copy authparam");
          goto LAB_00415e84;
        }
      }
      *(undefined4 **)(param_1 + 0x1c) = puVar8;
      if (*(int *)(param_1 + 0x14) - 1U < 4) {
        client6_send(puVar2);
        uVar6 = *(undefined4 *)(param_1 + 0x18);
      }
      else {
        uVar6 = *(undefined4 *)(param_1 + 0x18);
      }
      return uVar6;
    }
    dprintf(5,"ia_timo","failed to create a new event data");
  }
LAB_00415e84:
  dhcp6_remove_event(puVar2);
  return 0;
}