undefined4 openpty(int *param_1,int *param_2,char *param_3,termios *param_4,int param_5)

{
  int __fd;
  int iVar1;
  char acStack_1028 [4100];
  
  __fd = posix_openpt(2);
  if (__fd != -1) {
    iVar1 = grantpt(__fd);
    if ((iVar1 == 0) && (iVar1 = unlockpt(__fd), iVar1 == 0)) {
      iVar1 = ptsname_r(__fd,acStack_1028,0x1000)   //possible issue identified - semgrep
      if ((iVar1 == 0) && (iVar1 = open(acStack_1028,0x802), iVar1 != -1)) {   //possible issue identified - semgrep
        if (param_4 != (termios *)0x0) {
          tcsetattr(iVar1,0x5410,param_4);
        }
        if (param_5 != 0) {
          ioctl(iVar1,0x80087467,param_5);
        }
        *param_1 = __fd;
        *param_2 = iVar1;
        if (param_3 == (char *)0x0) {
          return 0;
        }
        strcpy(param_3,acStack_1028)   //possible issue identified - semgrep
        return 0;
      }
    }
    close(__fd);
  }
  return 0xffffffff;
}