#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ uid_t;
struct vt_stat {
  int v_active;
};
struct termios {
  int /*<<< orphan*/ c_lflag;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ gid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ ECHO;
scalar_t__ EINTR;
int /*<<< orphan*/ LOG_DAEMON;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_PID;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ VT_ACTIVATE;
int /*<<< orphan*/ VT_GETSTATE;
int /*<<< orphan*/ VT_OPENQRY;
int /*<<< orphan*/ VT_WAITACTIVE;
int atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ console_owner(scalar_t__, int);
scalar_t__ errno;
int fchown(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ *fdopen(int, char *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ getgid();
scalar_t__ getuid();
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ seteuid(scalar_t__);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int write(int, char *, int);
int main(int argc, char **argv) {
  int console;
  uid_t uid;
  struct vt_stat origstate;
  int openvtnum;
  char openvtname[256];
  int openvt;
  gid_t gid;
  int chowned;
  FILE *fp;
  struct termios t;
  char pass[256], *nl;
  int outfd, passlen;
  ssize_t wrote;
  console = open("/dev/console", O_RDWR);
  uid = getuid();
  gid = getgid();
  seteuid(uid);
  openlog(argv[0], LOG_PID, LOG_DAEMON);
  if (argc != 4) {
    syslog(LOG_WARNING, "Usage error");
    return 1;
  }
  if (console < 0) {
    syslog(LOG_ERR, "open(/dev/console): %m");
    return 1;
  }
  if (ioctl(console, VT_GETSTATE, &origstate) < 0) {
    syslog(LOG_ERR, "VT_GETSTATE: %m");
    return 1;
  }
  if (uid) {
    if (!console_owner(uid, origstate.v_active)) {
      int i;
      for (i = 0; i < 64; ++i) {
        if (i != origstate.v_active && console_owner(uid, i))
          break;
      }
      if (i == 64) {
        syslog(LOG_WARNING, "run by uid %lu not at console",
               (unsigned long)uid);
        return 1;
      }
    }
  }
  if (ioctl(console, VT_OPENQRY, &openvtnum) < 0) {
    syslog(LOG_ERR, "VT_OPENQRY: %m");
    return 1;
  }
  if (openvtnum == -1) {
    syslog(LOG_ERR, "No free VTs");
    return 1;
  }
  snprintf(openvtname, sizeof openvtname, "/dev/tty%d", openvtnum);
  seteuid(0);
  openvt = open(openvtname, O_RDWR);
  if (openvt < 0) {
    seteuid(uid);
    syslog(LOG_ERR, "open(%s): %m", openvtname);
    return 1;
  }
  chowned = fchown(openvt, uid, gid);
  if (chowned < 0) {
    seteuid(uid);
    syslog(LOG_ERR, "fchown(%s): %m", openvtname);
    return 1;
  }
  close(console);
  if (ioctl(openvt, VT_ACTIVATE, openvtnum) < 0) {
    seteuid(uid);
    syslog(LOG_ERR, "VT_ACTIVATE(%d): %m", openvtnum);
    return 1;
  }
  while (ioctl(openvt, VT_WAITACTIVE, openvtnum) < 0) {
    if (errno != EINTR) {
      ioctl(openvt, VT_ACTIVATE, origstate.v_active);
      seteuid(uid);
      syslog(LOG_ERR, "VT_WAITACTIVE(%d): %m", openvtnum);
      return 1;
    }
  }
  seteuid(uid);
  fp = fdopen(openvt, "r+");
  if (!fp) {
    seteuid(0);
    ioctl(openvt, VT_ACTIVATE, origstate.v_active);
    seteuid(uid);
    syslog(LOG_ERR, "fdopen(%s): %m", openvtname);
    return 1;
  }
  if (tcgetattr(openvt, &t) < 0) {
    seteuid(0);
    ioctl(openvt, VT_ACTIVATE, origstate.v_active);
    seteuid(uid);
    syslog(LOG_ERR, "tcgetattr(%s): %m", openvtname);
    return 1;
  }
  t.c_lflag &= ~ECHO;
  if (tcsetattr(openvt, TCSANOW, &t) < 0) {
    seteuid(0);
    ioctl(openvt, VT_ACTIVATE, origstate.v_active);
    seteuid(uid);
    syslog(LOG_ERR, "tcsetattr(%s): %m", openvtname);
    return 1;
  }
  if (fprintf(fp, "\033[2J\033[H") < 0) {
    seteuid(0);
    ioctl(openvt, VT_ACTIVATE, origstate.v_active);
    seteuid(uid);
    syslog(LOG_ERR, "write error on %s: %m", openvtname);
    return 1;
  }
  if (argv[1][0] && argv[2][0]) {
    if (fprintf(fp, "Password for PPP client %s on server %s: ", argv[1],
                argv[2]) < 0) {
      seteuid(0);
      ioctl(openvt, VT_ACTIVATE, origstate.v_active);
      seteuid(uid);
      syslog(LOG_ERR, "write error on %s: %m", openvtname);
      return 1;
    }
  } else if (argv[1][0] && !argv[2][0]) {
    if (fprintf(fp, "Password for PPP client %s: ", argv[1]) < 0) {
      syslog(LOG_ERR, "write error on %s: %m", openvtname);
      seteuid(0);
      ioctl(openvt, VT_ACTIVATE, origstate.v_active);
      seteuid(uid);
      return 1;
    }
  } else if (!argv[1][0] && argv[2][0]) {
    if (fprintf(fp, "Password for PPP on server %s: ", argv[2]) < 0) {
      seteuid(0);
      ioctl(openvt, VT_ACTIVATE, origstate.v_active);
      seteuid(uid);
      syslog(LOG_ERR, "write error on %s: %m", openvtname);
      return 1;
    }
  } else {
    if (fprintf(fp, "Enter PPP password: ") < 0) {
      seteuid(0);
      ioctl(openvt, VT_ACTIVATE, origstate.v_active);
      seteuid(uid);
      syslog(LOG_ERR, "write error on %s: %m", openvtname);
      return 1;
    }
  }
  if (!fgets(pass, sizeof pass, fp)) {
    seteuid(0);
    ioctl(openvt, VT_ACTIVATE, origstate.v_active);
    seteuid(uid);
    if (ferror(fp)) {
      syslog(LOG_ERR, "read error on %s: %m", openvtname);
    }
    return 1;
  }
  if ((nl = strchr(pass, '\n')))
    *nl = 0;
  passlen = strlen(pass);
  outfd = atoi(argv[3]);
  if ((wrote = write(outfd, pass, passlen)) != passlen) {
    seteuid(0);
    ioctl(openvt, VT_ACTIVATE, origstate.v_active);
    seteuid(uid);
    if (wrote < 0)
      syslog(LOG_ERR, "write error on outpipe: %m");
    else
      syslog(LOG_ERR, "short write on outpipe");
    return 1;
  }
  seteuid(0);
  ioctl(openvt, VT_ACTIVATE, origstate.v_active);
  seteuid(uid);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d70(%rip),%rax
mov    (%rax),%esi
lea    0xd87(%rip),%rdi
call   1130 <open@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   10e0 <getgid@plt>
mov    %eax,-0x138(%rbp)
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2cf0(%rip),%rax
mov    (%rax),%esi
mov    0x2d17(%rip),%rax
mov    (%rax),%edx
call   1160 <openlog@plt>
cmpl   $0x4,-0x8(%rbp)
je     12ed <main+0x9d>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
lea    0xd33(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
cmpl   $0x0,-0x14(%rbp)
jge    131a <main+0xca>
mov    0x2c7a(%rip),%rax
mov    (%rax),%edi
lea    0xd12(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
mov    -0x14(%rbp),%edi
mov    0x2c64(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
mov    $0x0,%al
call   1090 <ioctl@plt>
cmp    $0x0,%rax
jge    135e <main+0x10e>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
lea    0xce5(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
cmpq   $0x0,-0x20(%rbp)
je     141a <main+0x1ca>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10d0 <console_owner@plt>
cmp    $0x0,%rax
jne    1415 <main+0x1c5>
movl   $0x0,-0x268(%rbp)
cmpl   $0x40,-0x268(%rbp)
jge    13dc <main+0x18c>
mov    -0x268(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     13c3 <main+0x173>
mov    -0x20(%rbp),%rdi
mov    -0x268(%rbp),%esi
call   10d0 <console_owner@plt>
cmp    $0x0,%rax
je     13c3 <main+0x173>
jmp    13dc <main+0x18c>
jmp    13c8 <main+0x178>
mov    -0x268(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x268(%rbp)
jmp    1389 <main+0x139>
cmpl   $0x40,-0x268(%rbp)
jne    1410 <main+0x1c0>
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xc43(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
jmp    1415 <main+0x1c5>
jmp    141a <main+0x1ca>
mov    -0x14(%rbp),%edi
mov    0x2ba4(%rip),%rax
mov    (%rax),%esi
lea    -0x2c(%rbp),%rdx
mov    $0x0,%al
call   1090 <ioctl@plt>
cmp    $0x0,%rax
jge    145e <main+0x20e>
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
lea    0xc13(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    148b <main+0x23b>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
lea    0xbf5(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
lea    -0x130(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    $0x100,%esi
lea    0xbd8(%rip),%rdx
call   1080 <snprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
lea    -0x130(%rbp),%rdi
mov    0x2b23(%rip),%rax
mov    (%rax),%esi
call   1130 <open@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jge    150a <main+0x2ba>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x2a91(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xbcb(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
mov    -0x134(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x138(%rbp),%edx
call   1140 <fchown@plt>
mov    %eax,-0x13c(%rbp)
cmpl   $0x0,-0x13c(%rbp)
jge    1565 <main+0x315>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x2a36(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xb32(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    -0x134(%rbp),%edi
mov    0x2a5e(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
cmp    $0x0,%rax
jge    15bf <main+0x36f>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x29d8(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xae7(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
jmp    15c4 <main+0x374>
mov    -0x134(%rbp),%edi
mov    0x2a27(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
cmp    $0x0,%rax
jge    164e <main+0x3fe>
mov    0x29aa(%rip),%rax
mov    (%rax),%rax
mov    0x2998(%rip),%rcx
cmp    (%rcx),%rax
je     1649 <main+0x3f9>
mov    -0x134(%rbp),%edi
mov    0x29ca(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x294e(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xa71(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
jmp    15c4 <main+0x374>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
lea    0xa59(%rip),%rsi
call   1100 <fdopen@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
jne    16d3 <main+0x483>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x2944(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x28c8(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xa00(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
mov    -0x134(%rbp),%edi
lea    -0x150(%rbp),%rsi
call   1110 <tcgetattr@plt>
cmp    $0x0,%rax
jge    1744 <main+0x4f4>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x28d3(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x2857(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0x99e(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
mov    0x286d(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x150(%rbp),%eax
mov    %eax,-0x150(%rbp)
mov    -0x134(%rbp),%edi
mov    0x2857(%rip),%rax
mov    (%rax),%esi
lea    -0x150(%rbp),%rdx
call   1120 <tcsetattr@plt>
cmp    $0x0,%rax
jge    17d6 <main+0x586>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x2841(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x27c5(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0x91e(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
mov    -0x148(%rbp),%rdi
lea    0x90f(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
cmp    $0x0,%rax
jge    184a <main+0x5fa>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x27cd(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x2751(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0x8c4(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     18fb <main+0x6ab>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     18fb <main+0x6ab>
mov    -0x148(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0x881(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
cmp    $0x0,%rax
jge    18f6 <main+0x6a6>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x2721(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x26a5(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0x818(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
jmp    1aca <main+0x87a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     19a1 <main+0x751>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
cmpb   $0x0,(%rax)
jne    19a1 <main+0x751>
mov    -0x148(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0x805(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
cmp    $0x0,%rax
jge    199c <main+0x74c>
mov    0x262a(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0x79d(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x265d(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
jmp    1ac5 <main+0x875>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmpb   $0x0,(%rax)
jne    1a47 <main+0x7f7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1a47 <main+0x7f7>
mov    -0x148(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0x77c(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
cmp    $0x0,%rax
jge    1a42 <main+0x7f2>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x25d5(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x2559(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0x6cc(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
jmp    1ac0 <main+0x870>
mov    -0x148(%rbp),%rdi
lea    0x723(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
cmp    $0x0,%rax
jge    1abb <main+0x86b>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x255c(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    0x24e0(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0x653(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
jmp    1ac0 <main+0x870>
jmp    1ac5 <main+0x875>
jmp    1aca <main+0x87a>
lea    -0x250(%rbp),%rdi
mov    -0x148(%rbp),%rdx
mov    $0x100,%esi
call   10b0 <fgets@plt>
cmp    $0x0,%eax
jne    1b56 <main+0x906>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x24d7(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
mov    -0x148(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1b4a <main+0x8fa>
mov    0x2445(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0x64a(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
lea    -0x250(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x258(%rbp)
cmp    $0x0,%rax
je     1b82 <main+0x932>
mov    -0x258(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x250(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x260(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1150 <atoi@plt>
mov    %eax,-0x25c(%rbp)
mov    -0x25c(%rbp),%edi
lea    -0x250(%rbp),%rsi
mov    -0x260(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x264(%rbp)
cmp    -0x260(%rbp),%eax
je     1c48 <main+0x9f8>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x23f1(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
cmpl   $0x0,-0x264(%rbp)
jge    1c25 <main+0x9d5>
mov    0x2368(%rip),%rax
mov    (%rax),%edi
lea    0x589(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
jmp    1c3c <main+0x9ec>
mov    0x234c(%rip),%rax
mov    (%rax),%edi
lea    0x588(%rip),%rsi
mov    $0x0,%al
call   10f0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1c7a <main+0xa2a>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <seteuid@plt>
mov    -0x134(%rbp),%edi
mov    0x237a(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1090 <ioctl@plt>
mov    -0x20(%rbp),%rdi
call   1170 <seteuid@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%r13
mov    %edi,%ebx
mov    0x2d73(%rip),%r12
mov    (%r12),%esi
lea    0xd88(%rip),%rdi
call   1130 <open@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <getuid@plt>
mov    %rax,%r14
xor    %eax,%eax
call   10e0 <getgid@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x0(%r13),%rdi
mov    0x2cfa(%rip),%rax
mov    (%rax),%esi
mov    0x2d21(%rip),%rax
mov    (%rax),%edx
call   1160 <openlog@plt>
cmp    $0x4,%ebx
jne    141a <main+0x1ca>
test   %ebp,%ebp
js     142c <main+0x1dc>
mov    0x2cba(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebp,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
test   %rax,%rax
js     143e <main+0x1ee>
test   %r14,%r14
je     12fe <main+0xae>
mov    (%rsp),%esi
mov    %r14,%rdi
call   10d0 <console_owner@plt>
test   %rax,%rax
je     1462 <main+0x212>
mov    0x2cc3(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
test   %rax,%rax
js     1450 <main+0x200>
mov    0x4(%rsp),%ecx
cmp    $0xffffffff,%ecx
je     1491 <main+0x241>
lea    0xd47(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1080 <snprintf@plt>
xor    %edi,%edi
call   1170 <seteuid@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1130 <open@plt>
test   %eax,%eax
js     14d6 <main+0x286>
mov    %eax,%r12d
mov    %eax,%edi
mov    %r14,%rsi
mov    %r15d,%edx
call   1140 <fchown@plt>
test   %eax,%eax
js     14f0 <main+0x2a0>
mov    %ebp,%edi
call   10a0 <close@plt>
mov    0x2c53(%rip),%rax
mov    (%rax),%esi
mov    0x4(%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
test   %rax,%rax
js     1516 <main+0x2c6>
mov    0x2c53(%rip),%r15
mov    0x2bec(%rip),%rbp
mov    0x2bdd(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%esi
mov    0x4(%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
test   %rax,%rax
jns    153e <main+0x2ee>
mov    0x0(%rbp),%rax
cmp    (%rbx),%rax
je     13c0 <main+0x170>
mov    0x2bee(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x2b70(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsp),%edx
lea    0xc92(%rip),%rsi
jmp    1532 <main+0x2e2>
mov    0x2b8f(%rip),%rax
mov    (%rax),%edi
lea    0xbe3(%rip),%rsi
jmp    14a1 <main+0x251>
mov    0x2b45(%rip),%rax
mov    (%rax),%edi
lea    0xbdd(%rip),%rsi
jmp    14a1 <main+0x251>
mov    0x2b33(%rip),%rax
mov    (%rax),%edi
lea    0xbe2(%rip),%rsi
jmp    14a1 <main+0x251>
mov    0x2b21(%rip),%rax
mov    (%rax),%edi
lea    0xbfe(%rip),%rsi
jmp    14a1 <main+0x251>
xor    %ebx,%ebx
jmp    1478 <main+0x228>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x40,%ebx
je     14c1 <main+0x271>
cmp    (%rsp),%ebx
je     1470 <main+0x220>
mov    %r14,%rdi
mov    %ebx,%esi
call   10d0 <console_owner@plt>
test   %rax,%rax
je     1470 <main+0x220>
jmp    12fe <main+0xae>
mov    0x2ae0(%rip),%rax
mov    (%rax),%edi
lea    0xbcc(%rip),%rsi
xor    %eax,%eax
call   10f0 <syslog@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ae8(%rip),%rax
mov    (%rax),%edi
lea    0xb6f(%rip),%rsi
mov    %r14,%rdx
jmp    150d <main+0x2bd>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x2a93(%rip),%rax
mov    (%rax),%edi
lea    0xbd4(%rip),%rsi
jmp    1508 <main+0x2b8>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x2a79(%rip),%rax
mov    (%rax),%edi
lea    0xb7c(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   10f0 <syslog@plt>
jmp    14a8 <main+0x258>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x2a53(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsp),%edx
lea    0xb61(%rip),%rsi
xor    %eax,%eax
call   10f0 <syslog@plt>
jmp    14a8 <main+0x258>
mov    %r14,%rdi
call   1170 <seteuid@plt>
lea    0xb70(%rip),%rsi
mov    %r12d,%edi
call   1100 <fdopen@plt>
test   %rax,%rax
je     15f0 <main+0x3a0>
mov    %rax,%r15
lea    0x8(%rsp),%rsi
mov    %r12d,%edi
call   1110 <tcgetattr@plt>
test   %rax,%rax
js     162a <main+0x3da>
mov    0x2a3a(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x8(%rsp)
mov    0x2a33(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r12d,%edi
call   1120 <tcsetattr@plt>
test   %rax,%rax
js     1664 <main+0x414>
lea    0xb47(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <fprintf@plt>
test   %rax,%rax
js     17df <main+0x58f>
mov    0x8(%r13),%rdx
mov    0x10(%r13),%rcx
cmpb   $0x0,(%rdx)
mov    (%rcx),%al
je     169e <main+0x44e>
test   %al,%al
je     16b8 <main+0x468>
lea    0xb30(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1725 <main+0x4d5>
xor    %edi,%edi
call   1170 <seteuid@plt>
mov    0x29da(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x295c(%rip),%rax
mov    (%rax),%edi
lea    0xa9b(%rip),%rsi
jmp    1508 <main+0x2b8>
xor    %edi,%edi
call   1170 <seteuid@plt>
mov    0x29a0(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x2922(%rip),%rax
mov    (%rax),%edi
lea    0xa70(%rip),%rsi
jmp    1508 <main+0x2b8>
xor    %edi,%edi
call   1170 <seteuid@plt>
mov    0x2966(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x28e8(%rip),%rax
mov    (%rax),%edi
lea    0xa48(%rip),%rsi
jmp    1508 <main+0x2b8>
test   %al,%al
je     1714 <main+0x4c4>
lea    0xaaf(%rip),%rsi
mov    %r15,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1725 <main+0x4d5>
lea    0xa7c(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <fprintf@plt>
test   %rax,%rax
jns    172e <main+0x4de>
mov    0x28a3(%rip),%rax
mov    (%rax),%edi
lea    0xa1d(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   10f0 <syslog@plt>
xor    %edi,%edi
call   1170 <seteuid@plt>
mov    0x28e0(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
mov    %r14,%rdi
call   1170 <seteuid@plt>
jmp    14a8 <main+0x258>
lea    0xa5d(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <fprintf@plt>
test   %rax,%rax
js     17df <main+0x58f>
lea    0x110(%rsp),%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   10b0 <fgets@plt>
test   %eax,%eax
je     1819 <main+0x5c9>
lea    0x110(%rsp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1765 <main+0x515>
movb   $0x0,(%rax)
lea    0x110(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
mov    0x18(%r13),%rdi
call   1150 <atoi@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1040 <write@plt>
mov    %eax,%r13d
xor    %ebx,%ebx
xor    %edi,%edi
call   1170 <seteuid@plt>
mov    0x2837(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
mov    %r14,%rdi
call   1170 <seteuid@plt>
cmp    %r15d,%r13d
je     14ad <main+0x25d>
mov    0x27b0(%rip),%rax
mov    (%rax),%edi
test   %r13d,%r13d
js     1875 <main+0x625>
lea    0x9e3(%rip),%rsi
jmp    14a1 <main+0x251>
xor    %edi,%edi
call   1170 <seteuid@plt>
mov    0x27eb(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    0x276d(%rip),%rax
mov    (%rax),%edi
lea    0x8e7(%rip),%rsi
jmp    1508 <main+0x2b8>
xor    %edi,%edi
call   1170 <seteuid@plt>
mov    0x27b1(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edx
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <ioctl@plt>
mov    %r14,%rdi
call   1170 <seteuid@plt>
mov    %r15,%rdi
call   1030 <ferror@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     14ad <main+0x25d>
mov    0x271d(%rip),%rax
mov    (%rax),%edi
lea    0x929(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   10f0 <syslog@plt>
jmp    14ad <main+0x25d>
lea    0x926(%rip),%rsi
jmp    14a1 <main+0x251>

LLVM IR (-O0):
%struct.vt_stat = type { i32 }
%struct.termios = type { i32 }
@.str = [13 x i8] c"/dev/console\00"
@O_RDWR = global i32 0
@LOG_PID = global i32 0
@LOG_DAEMON = global i32 0
@LOG_WARNING = global i32 0
@.str.1 = [12 x i8] c"Usage error\00"
@LOG_ERR = global i32 0
@.str.2 = [23 x i8] c"open(/dev/console): %m\00"
@VT_GETSTATE = global i32 0
@.str.3 = [16 x i8] c"VT_GETSTATE: %m\00"
@.str.4 = [30 x i8] c"run by uid %lu not at console\00"
@VT_OPENQRY = global i32 0
@.str.5 = [15 x i8] c"VT_OPENQRY: %m\00"
@.str.6 = [12 x i8] c"No free VTs\00"
@.str.7 = [11 x i8] c"/dev/tty%d\00"
@.str.8 = [13 x i8] c"open(%s): %m\00"
@.str.9 = [15 x i8] c"fchown(%s): %m\00"
@VT_ACTIVATE = global i32 0
@.str.10 = [20 x i8] c"VT_ACTIVATE(%d): %m\00"
@VT_WAITACTIVE = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@.str.11 = [22 x i8] c"VT_WAITACTIVE(%d): %m\00"
@.str.12 = [3 x i8] c"r+\00"
@.str.13 = [15 x i8] c"fdopen(%s): %m\00"
@.str.14 = [18 x i8] c"tcgetattr(%s): %m\00"
@ECHO = global i32 0
@TCSANOW = global i32 0
@.str.15 = [18 x i8] c"tcsetattr(%s): %m\00"
@.str.16 = [8 x i8] c"\1B[2J\1B[H\00"
@.str.17 = [22 x i8] c"write error on %s: %m\00"
@.str.18 = [42 x i8] c"Password for PPP client %s on server %s: \00"
@.str.19 = [29 x i8] c"Password for PPP client %s: \00"
@.str.20 = [32 x i8] c"Password for PPP on server %s: \00"
@.str.21 = [21 x i8] c"Enter PPP password: \00"
@.str.22 = [21 x i8] c"read error on %s: %m\00"
@.str.23 = [27 x i8] c"write error on outpipe: %m\00"
@.str.24 = [23 x i8] c"short write on outpipe\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca %struct.vt_stat
%9 = alloca i32
%10 = alloca [256 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca %struct.termios
%16 = alloca [256 x i8]
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i32, i32* @O_RDWR
%23 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %22)
store i32 %23, i32* %6
%24 = call i64 (...) @getuid()
store i64 %24, i64* %7
%25 = call i32 (...) @getgid()
store i32 %25, i32* %12
%26 = load i64, i64* %7
%27 = call i32 @seteuid(i64 %26)
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = load i32, i32* @LOG_PID
%32 = load i32, i32* @LOG_DAEMON
%33 = call i32 @openlog(i8* %30, i32 %31, i32 %32)
%34 = load i32, i32* %4
%35 = icmp ne i32 %34, 4
br i1 %35, label %36, label %39
36: ; preds = %2
%37 = load i32, i32* @LOG_WARNING
%38 = call i32 (i32, i8*, ...) @syslog(i32 %37, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %439
39: ; preds = %2
%40 = load i32, i32* %6
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* @LOG_ERR
%44 = call i32 (i32, i8*, ...) @syslog(i32 %43, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %439
45: ; preds = %39
%46 = load i32, i32* %6
%47 = load i32, i32* @VT_GETSTATE
%48 = call i64 (i32, i32, ...) @ioctl(i32 %46, i32 %47, %struct.vt_stat* %8)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = load i32, i32* @LOG_ERR
%52 = call i32 (i32, i8*, ...) @syslog(i32 %51, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %439
53: ; preds = %45
%54 = load i64, i64* %7
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %90
56: ; preds = %53
%57 = load i64, i64* %7
%58 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%59 = load i32, i32* %58
%60 = call i64 @console_owner(i64 %57, i32 %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %89, label %62
62: ; preds = %56
store i32 0, i32* %21
br label %63
63: ; preds = %78, %62
%64 = load i32, i32* %21
%65 = icmp slt i32 %64, 64
br i1 %65, label %66, label %81
66: ; preds = %63
%67 = load i32, i32* %21
%68 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%69 = load i32, i32* %68
%70 = icmp ne i32 %67, %69
br i1 %70, label %71, label %77
71: ; preds = %66
%72 = load i64, i64* %7
%73 = load i32, i32* %21
%74 = call i64 @console_owner(i64 %72, i32 %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %77
76: ; preds = %71
br label %81
77: ; preds = %71, %66
br label %78
78: ; preds = %77
%79 = load i32, i32* %21
%80 = add nsw i32 %79, 1
store i32 %80, i32* %21
br label %63
81: ; preds = %76, %63
%82 = load i32, i32* %21
%83 = icmp eq i32 %82, 64
br i1 %83, label %84, label %88
84: ; preds = %81
%85 = load i32, i32* @LOG_WARNING
%86 = load i64, i64* %7
%87 = call i32 (i32, i8*, ...) @syslog(i32 %85, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %86)
store i32 1, i32* %3
br label %439
88: ; preds = %81
br label %89
89: ; preds = %88, %56
br label %90
90: ; preds = %89, %53
%91 = load i32, i32* %6
%92 = load i32, i32* @VT_OPENQRY
%93 = call i64 (i32, i32, ...) @ioctl(i32 %91, i32 %92, i32* %9)
%94 = icmp slt i64 %93, 0
br i1 %94, label %95, label %98
95: ; preds = %90
%96 = load i32, i32* @LOG_ERR
%97 = call i32 (i32, i8*, ...) @syslog(i32 %96, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %439
98: ; preds = %90
%99 = load i32, i32* %9
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %104
101: ; preds = %98
%102 = load i32, i32* @LOG_ERR
%103 = call i32 (i32, i8*, ...) @syslog(i32 %102, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %439
104: ; preds = %98
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%106 = load i32, i32* %9
%107 = call i32 @snprintf(i8* %105, i32 256, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %106)
%108 = call i32 @seteuid(i64 0)
%109 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%110 = load i32, i32* @O_RDWR
%111 = call i32 @open(i8* %109, i32 %110)
store i32 %111, i32* %11
%112 = load i32, i32* %11
%113 = icmp slt i32 %112, 0
br i1 %113, label %114, label %120
114: ; preds = %104
%115 = load i64, i64* %7
%116 = call i32 @seteuid(i64 %115)
%117 = load i32, i32* @LOG_ERR
%118 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%119 = call i32 (i32, i8*, ...) @syslog(i32 %117, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %118)
store i32 1, i32* %3
br label %439
120: ; preds = %104
%121 = load i32, i32* %11
%122 = load i64, i64* %7
%123 = load i32, i32* %12
%124 = call i32 @fchown(i32 %121, i64 %122, i32 %123)
store i32 %124, i32* %13
%125 = load i32, i32* %13
%126 = icmp slt i32 %125, 0
br i1 %126, label %127, label %133
127: ; preds = %120
%128 = load i64, i64* %7
%129 = call i32 @seteuid(i64 %128)
%130 = load i32, i32* @LOG_ERR
%131 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%132 = call i32 (i32, i8*, ...) @syslog(i32 %130, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %131)
store i32 1, i32* %3
br label %439
133: ; preds = %120
%134 = load i32, i32* %6
%135 = call i32 @close(i32 %134)
%136 = load i32, i32* %11
%137 = load i32, i32* @VT_ACTIVATE
%138 = load i32, i32* %9
%139 = call i64 (i32, i32, ...) @ioctl(i32 %136, i32 %137, i32 %138)
%140 = icmp slt i64 %139, 0
br i1 %140, label %141, label %147
141: ; preds = %133
%142 = load i64, i64* %7
%143 = call i32 @seteuid(i64 %142)
%144 = load i32, i32* @LOG_ERR
%145 = load i32, i32* %9
%146 = call i32 (i32, i8*, ...) @syslog(i32 %144, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %145)
store i32 1, i32* %3
br label %439
147: ; preds = %133
br label %148
148: ; preds = %169, %147
%149 = load i32, i32* %11
%150 = load i32, i32* @VT_WAITACTIVE
%151 = load i32, i32* %9
%152 = call i64 (i32, i32, ...) @ioctl(i32 %149, i32 %150, i32 %151)
%153 = icmp slt i64 %152, 0
br i1 %153, label %154, label %170
154: ; preds = %148
%155 = load i64, i64* @errno
%156 = load i64, i64* @EINTR
%157 = icmp ne i64 %155, %156
br i1 %157, label %158, label %169
158: ; preds = %154
%159 = load i32, i32* %11
%160 = load i32, i32* @VT_ACTIVATE
%161 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%162 = load i32, i32* %161
%163 = call i64 (i32, i32, ...) @ioctl(i32 %159, i32 %160, i32 %162)
%164 = load i64, i64* %7
%165 = call i32 @seteuid(i64 %164)
%166 = load i32, i32* @LOG_ERR
%167 = load i32, i32* %9
%168 = call i32 (i32, i8*, ...) @syslog(i32 %166, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i32 %167)
store i32 1, i32* %3
br label %439
169: ; preds = %154
br label %148
170: ; preds = %148
%171 = load i64, i64* %7
%172 = call i32 @seteuid(i64 %171)
%173 = load i32, i32* %11
%174 = call i32* @fdopen(i32 %173, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
store i32* %174, i32** %14
%175 = load i32*, i32** %14
%176 = icmp ne i32* %175, null
br i1 %176, label %189, label %177
177: ; preds = %170
%178 = call i32 @seteuid(i64 0)
%179 = load i32, i32* %11
%180 = load i32, i32* @VT_ACTIVATE
%181 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%182 = load i32, i32* %181
%183 = call i64 (i32, i32, ...) @ioctl(i32 %179, i32 %180, i32 %182)
%184 = load i64, i64* %7
%185 = call i32 @seteuid(i64 %184)
%186 = load i32, i32* @LOG_ERR
%187 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%188 = call i32 (i32, i8*, ...) @syslog(i32 %186, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i8* %187)
store i32 1, i32* %3
br label %439
189: ; preds = %170
%190 = load i32, i32* %11
%191 = call i64 @tcgetattr(i32 %190, %struct.termios* %15)
%192 = icmp slt i64 %191, 0
br i1 %192, label %193, label %205
193: ; preds = %189
%194 = call i32 @seteuid(i64 0)
%195 = load i32, i32* %11
%196 = load i32, i32* @VT_ACTIVATE
%197 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%198 = load i32, i32* %197
%199 = call i64 (i32, i32, ...) @ioctl(i32 %195, i32 %196, i32 %198)
%200 = load i64, i64* %7
%201 = call i32 @seteuid(i64 %200)
%202 = load i32, i32* @LOG_ERR
%203 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%204 = call i32 (i32, i8*, ...) @syslog(i32 %202, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i8* %203)
store i32 1, i32* %3
br label %439
205: ; preds = %189
%206 = load i32, i32* @ECHO
%207 = xor i32 %206, -1
%208 = getelementptr inbounds %struct.termios, %struct.termios* %15, i32 0, i32 0
%209 = load i32, i32* %208
%210 = and i32 %209, %207
store i32 %210, i32* %208
%211 = load i32, i32* %11
%212 = load i32, i32* @TCSANOW
%213 = call i64 @tcsetattr(i32 %211, i32 %212, %struct.termios* %15)
%214 = icmp slt i64 %213, 0
br i1 %214, label %215, label %227
215: ; preds = %205
%216 = call i32 @seteuid(i64 0)
%217 = load i32, i32* %11
%218 = load i32, i32* @VT_ACTIVATE
%219 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%220 = load i32, i32* %219
%221 = call i64 (i32, i32, ...) @ioctl(i32 %217, i32 %218, i32 %220)
%222 = load i64, i64* %7
%223 = call i32 @seteuid(i64 %222)
%224 = load i32, i32* @LOG_ERR
%225 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%226 = call i32 (i32, i8*, ...) @syslog(i32 %224, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i8* %225)
store i32 1, i32* %3
br label %439
227: ; preds = %205
%228 = load i32*, i32** %14
%229 = call i64 (i32*, i8*, ...) @fprintf(i32* %228, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0))
%230 = icmp slt i64 %229, 0
br i1 %230, label %231, label %243
231: ; preds = %227
%232 = call i32 @seteuid(i64 0)
%233 = load i32, i32* %11
%234 = load i32, i32* @VT_ACTIVATE
%235 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%236 = load i32, i32* %235
%237 = call i64 (i32, i32, ...) @ioctl(i32 %233, i32 %234, i32 %236)
%238 = load i64, i64* %7
%239 = call i32 @seteuid(i64 %238)
%240 = load i32, i32* @LOG_ERR
%241 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%242 = call i32 (i32, i8*, ...) @syslog(i32 %240, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %241)
store i32 1, i32* %3
br label %439
243: ; preds = %227
%244 = load i8**, i8*** %5
%245 = getelementptr inbounds i8*, i8** %244, i64 1
%246 = load i8*, i8** %245
%247 = getelementptr inbounds i8, i8* %246, i64 0
%248 = load i8, i8* %247
%249 = sext i8 %248 to i32
%250 = icmp ne i32 %249, 0
br i1 %250, label %251, label %282
251: ; preds = %243
%252 = load i8**, i8*** %5
%253 = getelementptr inbounds i8*, i8** %252, i64 2
%254 = load i8*, i8** %253
%255 = getelementptr inbounds i8, i8* %254, i64 0
%256 = load i8, i8* %255
%257 = sext i8 %256 to i32
%258 = icmp ne i32 %257, 0
br i1 %258, label %259, label %282
259: ; preds = %251
%260 = load i32*, i32** %14
%261 = load i8**, i8*** %5
%262 = getelementptr inbounds i8*, i8** %261, i64 1
%263 = load i8*, i8** %262
%264 = load i8**, i8*** %5
%265 = getelementptr inbounds i8*, i8** %264, i64 2
%266 = load i8*, i8** %265
%267 = call i64 (i32*, i8*, ...) @fprintf(i32* %260, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.18, i64 0, i64 0), i8* %263, i8* %266)
%268 = icmp slt i64 %267, 0
br i1 %268, label %269, label %281
269: ; preds = %259
%270 = call i32 @seteuid(i64 0)
%271 = load i32, i32* %11
%272 = load i32, i32* @VT_ACTIVATE
%273 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%274 = load i32, i32* %273
%275 = call i64 (i32, i32, ...) @ioctl(i32 %271, i32 %272, i32 %274)
%276 = load i64, i64* %7
%277 = call i32 @seteuid(i64 %276)
%278 = load i32, i32* @LOG_ERR
%279 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%280 = call i32 (i32, i8*, ...) @syslog(i32 %278, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %279)
store i32 1, i32* %3
br label %439
281: ; preds = %259
br label %371
282: ; preds = %251, %243
%283 = load i8**, i8*** %5
%284 = getelementptr inbounds i8*, i8** %283, i64 1
%285 = load i8*, i8** %284
%286 = getelementptr inbounds i8, i8* %285, i64 0
%287 = load i8, i8* %286
%288 = sext i8 %287 to i32
%289 = icmp ne i32 %288, 0
br i1 %289, label %290, label %317
290: ; preds = %282
%291 = load i8**, i8*** %5
%292 = getelementptr inbounds i8*, i8** %291, i64 2
%293 = load i8*, i8** %292
%294 = getelementptr inbounds i8, i8* %293, i64 0
%295 = load i8, i8* %294
%296 = icmp ne i8 %295, 0
br i1 %296, label %317, label %297
297: ; preds = %290
%298 = load i32*, i32** %14
%299 = load i8**, i8*** %5
%300 = getelementptr inbounds i8*, i8** %299, i64 1
%301 = load i8*, i8** %300
%302 = call i64 (i32*, i8*, ...) @fprintf(i32* %298, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* %301)
%303 = icmp slt i64 %302, 0
br i1 %303, label %304, label %316
304: ; preds = %297
%305 = load i32, i32* @LOG_ERR
%306 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%307 = call i32 (i32, i8*, ...) @syslog(i32 %305, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %306)
%308 = call i32 @seteuid(i64 0)
%309 = load i32, i32* %11
%310 = load i32, i32* @VT_ACTIVATE
%311 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%312 = load i32, i32* %311
%313 = call i64 (i32, i32, ...) @ioctl(i32 %309, i32 %310, i32 %312)
%314 = load i64, i64* %7
%315 = call i32 @seteuid(i64 %314)
store i32 1, i32* %3
br label %439
316: ; preds = %297
br label %370
317: ; preds = %290, %282
%318 = load i8**, i8*** %5
%319 = getelementptr inbounds i8*, i8** %318, i64 1
%320 = load i8*, i8** %319
%321 = getelementptr inbounds i8, i8* %320, i64 0
%322 = load i8, i8* %321
%323 = icmp ne i8 %322, 0
br i1 %323, label %352, label %324
324: ; preds = %317
%325 = load i8**, i8*** %5
%326 = getelementptr inbounds i8*, i8** %325, i64 2
%327 = load i8*, i8** %326
%328 = getelementptr inbounds i8, i8* %327, i64 0
%329 = load i8, i8* %328
%330 = sext i8 %329 to i32
%331 = icmp ne i32 %330, 0
br i1 %331, label %332, label %352
332: ; preds = %324
%333 = load i32*, i32** %14
%334 = load i8**, i8*** %5
%335 = getelementptr inbounds i8*, i8** %334, i64 2
%336 = load i8*, i8** %335
%337 = call i64 (i32*, i8*, ...) @fprintf(i32* %333, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.20, i64 0, i64 0), i8* %336)
%338 = icmp slt i64 %337, 0
br i1 %338, label %339, label %351
339: ; preds = %332
%340 = call i32 @seteuid(i64 0)
%341 = load i32, i32* %11
%342 = load i32, i32* @VT_ACTIVATE
%343 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%344 = load i32, i32* %343
%345 = call i64 (i32, i32, ...) @ioctl(i32 %341, i32 %342, i32 %344)
%346 = load i64, i64* %7
%347 = call i32 @seteuid(i64 %346)
%348 = load i32, i32* @LOG_ERR
%349 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%350 = call i32 (i32, i8*, ...) @syslog(i32 %348, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %349)
store i32 1, i32* %3
br label %439
351: ; preds = %332
br label %369
352: ; preds = %324, %317
%353 = load i32*, i32** %14
%354 = call i64 (i32*, i8*, ...) @fprintf(i32* %353, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0))
%355 = icmp slt i64 %354, 0
br i1 %355, label %356, label %368
356: ; preds = %352
%357 = call i32 @seteuid(i64 0)
%358 = load i32, i32* %11
%359 = load i32, i32* @VT_ACTIVATE
%360 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%361 = load i32, i32* %360
%362 = call i64 (i32, i32, ...) @ioctl(i32 %358, i32 %359, i32 %361)
%363 = load i64, i64* %7
%364 = call i32 @seteuid(i64 %363)
%365 = load i32, i32* @LOG_ERR
%366 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%367 = call i32 (i32, i8*, ...) @syslog(i32 %365, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %366)
store i32 1, i32* %3
br label %439
368: ; preds = %352
br label %369
369: ; preds = %368, %351
br label %370
370: ; preds = %369, %316
br label %371
371: ; preds = %370, %281
%372 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%373 = load i32*, i32** %14
%374 = call i32 @fgets(i8* %372, i32 256, i32* %373)
%375 = icmp ne i32 %374, 0
br i1 %375, label %393, label %376
376: ; preds = %371
%377 = call i32 @seteuid(i64 0)
%378 = load i32, i32* %11
%379 = load i32, i32* @VT_ACTIVATE
%380 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%381 = load i32, i32* %380
%382 = call i64 (i32, i32, ...) @ioctl(i32 %378, i32 %379, i32 %381)
%383 = load i64, i64* %7
%384 = call i32 @seteuid(i64 %383)
%385 = load i32*, i32** %14
%386 = call i64 @ferror(i32* %385)
%387 = icmp ne i64 %386, 0
br i1 %387, label %388, label %392
388: ; preds = %376
%389 = load i32, i32* @LOG_ERR
%390 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%391 = call i32 (i32, i8*, ...) @syslog(i32 %389, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0), i8* %390)
br label %392
392: ; preds = %388, %376
store i32 1, i32* %3
br label %439
393: ; preds = %371
%394 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%395 = call i8* @strchr(i8* %394, i8 signext 10)
store i8* %395, i8** %17
%396 = icmp ne i8* %395, null
br i1 %396, label %397, label %399
397: ; preds = %393
%398 = load i8*, i8** %17
store i8 0, i8* %398
br label %399
399: ; preds = %397, %393
%400 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%401 = call i32 @strlen(i8* %400)
store i32 %401, i32* %19
%402 = load i8**, i8*** %5
%403 = getelementptr inbounds i8*, i8** %402, i64 3
%404 = load i8*, i8** %403
%405 = call i32 @atoi(i8* %404)
store i32 %405, i32* %18
%406 = load i32, i32* %18
%407 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%408 = load i32, i32* %19
%409 = call i32 @write(i32 %406, i8* %407, i32 %408)
store i32 %409, i32* %20
%410 = load i32, i32* %19
%411 = icmp ne i32 %409, %410
br i1 %411, label %412, label %430
412: ; preds = %399
%413 = call i32 @seteuid(i64 0)
%414 = load i32, i32* %11
%415 = load i32, i32* @VT_ACTIVATE
%416 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%417 = load i32, i32* %416
%418 = call i64 (i32, i32, ...) @ioctl(i32 %414, i32 %415, i32 %417)
%419 = load i64, i64* %7
%420 = call i32 @seteuid(i64 %419)
%421 = load i32, i32* %20
%422 = icmp slt i32 %421, 0
br i1 %422, label %423, label %426
423: ; preds = %412
%424 = load i32, i32* @LOG_ERR
%425 = call i32 (i32, i8*, ...) @syslog(i32 %424, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.23, i64 0, i64 0))
br label %429
426: ; preds = %412
%427 = load i32, i32* @LOG_ERR
%428 = call i32 (i32, i8*, ...) @syslog(i32 %427, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.24, i64 0, i64 0))
br label %429
429: ; preds = %426, %423
store i32 1, i32* %3
br label %439
430: ; preds = %399
%431 = call i32 @seteuid(i64 0)
%432 = load i32, i32* %11
%433 = load i32, i32* @VT_ACTIVATE
%434 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %8, i32 0, i32 0
%435 = load i32, i32* %434
%436 = call i64 (i32, i32, ...) @ioctl(i32 %432, i32 %433, i32 %435)
%437 = load i64, i64* %7
%438 = call i32 @seteuid(i64 %437)
store i32 0, i32* %3
br label %439
439: ; preds = %430, %429, %392, %356, %339, %304, %269, %231, %215, %193, %177, %158, %141, %127, %114, %101, %95, %84, %50, %42, %36
%440 = load i32, i32* %3
ret i32 %440
}

LLVM IR (-O2):
%struct.vt_stat = type { i32 }
%struct.termios = type { i32 }
@.str = [13 x i8] c"/dev/console\00"
@O_RDWR = global i32 0
@LOG_PID = global i32 0
@LOG_DAEMON = global i32 0
@LOG_WARNING = global i32 0
@.str.1 = [12 x i8] c"Usage error\00"
@LOG_ERR = global i32 0
@.str.2 = [23 x i8] c"open(/dev/console): %m\00"
@VT_GETSTATE = global i32 0
@.str.3 = [16 x i8] c"VT_GETSTATE: %m\00"
@.str.4 = [30 x i8] c"run by uid %lu not at console\00"
@VT_OPENQRY = global i32 0
@.str.5 = [15 x i8] c"VT_OPENQRY: %m\00"
@.str.6 = [12 x i8] c"No free VTs\00"
@.str.7 = [11 x i8] c"/dev/tty%d\00"
@.str.8 = [13 x i8] c"open(%s): %m\00"
@.str.9 = [15 x i8] c"fchown(%s): %m\00"
@VT_ACTIVATE = global i32 0
@.str.10 = [20 x i8] c"VT_ACTIVATE(%d): %m\00"
@VT_WAITACTIVE = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@.str.11 = [22 x i8] c"VT_WAITACTIVE(%d): %m\00"
@.str.12 = [3 x i8] c"r+\00"
@.str.13 = [15 x i8] c"fdopen(%s): %m\00"
@.str.14 = [18 x i8] c"tcgetattr(%s): %m\00"
@ECHO = global i32 0
@TCSANOW = global i32 0
@.str.15 = [18 x i8] c"tcsetattr(%s): %m\00"
@.str.16 = [8 x i8] c"\1B[2J\1B[H\00"
@.str.17 = [22 x i8] c"write error on %s: %m\00"
@.str.18 = [42 x i8] c"Password for PPP client %s on server %s: \00"
@.str.19 = [29 x i8] c"Password for PPP client %s: \00"
@.str.20 = [32 x i8] c"Password for PPP on server %s: \00"
@.str.21 = [21 x i8] c"Enter PPP password: \00"
@.str.22 = [21 x i8] c"read error on %s: %m\00"
@.str.23 = [27 x i8] c"write error on outpipe: %m\00"
@.str.24 = [23 x i8] c"short write on outpipe\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.vt_stat
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca %struct.termios
%7 = alloca [256 x i8]
%8 = bitcast %struct.vt_stat* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = bitcast %struct.termios* %6 to i8*
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = load i32, i32* @O_RDWR
%14 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = tail call i64 (...) @getuid()
%16 = tail call i32 (...) @getgid()
%17 = tail call i32 @seteuid(i64 %15)
%18 = load i8*, i8** %1
%19 = load i32, i32* @LOG_PID
%20 = load i32, i32* @LOG_DAEMON
%21 = tail call i32 @openlog(i8* %18, i32 %19, i32 %20)
%22 = icmp eq i32 %0, 4
br i1 %22, label %26, label %23
23: ; preds = %2
%24 = load i32, i32* @LOG_WARNING
%25 = tail call i32 (i32, i8*, ...) @syslog(i32 %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %270
26: ; preds = %2
%27 = icmp slt i32 %14, 0
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i32, i32* @LOG_ERR
%30 = tail call i32 (i32, i8*, ...) @syslog(i32 %29, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %270
31: ; preds = %26
%32 = load i32, i32* @VT_GETSTATE
%33 = call i64 (i32, i32, ...) @ioctl(i32 %14, i32 %32, %struct.vt_stat* %3)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load i32, i32* @LOG_ERR
%37 = call i32 (i32, i8*, ...) @syslog(i32 %36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %270
38: ; preds = %31
%39 = icmp eq i64 %15, 0
br i1 %39, label %58, label %40
40: ; preds = %38
%41 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%42 = load i32, i32* %41
%43 = call i64 @console_owner(i64 %15, i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %58
45: ; preds = %40, %52
%46 = phi i32 [ %53, %52 ], [ 0, %40 ]
%47 = load i32, i32* %41
%48 = icmp eq i32 %46, %47
br i1 %48, label %52, label %49
49: ; preds = %45
%50 = call i64 @console_owner(i64 %15, i32 %46)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %45, %49
%53 = add nuw nsw i32 %46, 1
%54 = icmp eq i32 %53, 64
br i1 %54, label %55, label %45
55: ; preds = %52
%56 = load i32, i32* @LOG_WARNING
%57 = call i32 (i32, i8*, ...) @syslog(i32 %56, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %15)
br label %270
58: ; preds = %49, %40, %38
%59 = load i32, i32* @VT_OPENQRY
%60 = call i64 (i32, i32, ...) @ioctl(i32 %14, i32 %59, i32* %4)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i32, i32* @LOG_ERR
%64 = call i32 (i32, i8*, ...) @syslog(i32 %63, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %270
65: ; preds = %58
%66 = load i32, i32* %4
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load i32, i32* @LOG_ERR
%70 = call i32 (i32, i8*, ...) @syslog(i32 %69, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %270
71: ; preds = %65
%72 = call i32 @snprintf(i8* %10, i32 256, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %66)
%73 = call i32 @seteuid(i64 0)
%74 = load i32, i32* @O_RDWR
%75 = call i32 @open(i8* %10, i32 %74)
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %71
%78 = call i32 @seteuid(i64 %15)
%79 = load i32, i32* @LOG_ERR
%80 = call i32 (i32, i8*, ...) @syslog(i32 %79, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %10)
br label %270
81: ; preds = %71
%82 = call i32 @fchown(i32 %75, i64 %15, i32 %16)
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %88
84: ; preds = %81
%85 = call i32 @seteuid(i64 %15)
%86 = load i32, i32* @LOG_ERR
%87 = call i32 (i32, i8*, ...) @syslog(i32 %86, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %10)
br label %270
88: ; preds = %81
%89 = call i32 @close(i32 %14)
%90 = load i32, i32* @VT_ACTIVATE
%91 = load i32, i32* %4
%92 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %90, i32 %91)
%93 = icmp slt i64 %92, 0
br i1 %93, label %94, label %99
94: ; preds = %88
%95 = call i32 @seteuid(i64 %15)
%96 = load i32, i32* @LOG_ERR
%97 = load i32, i32* %4
%98 = call i32 (i32, i8*, ...) @syslog(i32 %96, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %97)
br label %270
99: ; preds = %88, %104
%100 = load i32, i32* @VT_WAITACTIVE
%101 = load i32, i32* %4
%102 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %100, i32 %101)
%103 = icmp slt i64 %102, 0
br i1 %103, label %104, label %117
104: ; preds = %99
%105 = load i64, i64* @errno
%106 = load i64, i64* @EINTR
%107 = icmp eq i64 %105, %106
br i1 %107, label %99, label %108
108: ; preds = %104
%109 = load i32, i32* @VT_ACTIVATE
%110 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%111 = load i32, i32* %110
%112 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %109, i32 %111)
%113 = call i32 @seteuid(i64 %15)
%114 = load i32, i32* @LOG_ERR
%115 = load i32, i32* %4
%116 = call i32 (i32, i8*, ...) @syslog(i32 %114, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i32 %115)
br label %270
117: ; preds = %99
%118 = call i32 @seteuid(i64 %15)
%119 = call i32* @fdopen(i32 %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%120 = icmp eq i32* %119, null
br i1 %120, label %121, label %130
121: ; preds = %117
%122 = call i32 @seteuid(i64 0)
%123 = load i32, i32* @VT_ACTIVATE
%124 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%125 = load i32, i32* %124
%126 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %123, i32 %125)
%127 = call i32 @seteuid(i64 %15)
%128 = load i32, i32* @LOG_ERR
%129 = call i32 (i32, i8*, ...) @syslog(i32 %128, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i8* %10)
br label %270
130: ; preds = %117
%131 = call i64 @tcgetattr(i32 %75, %struct.termios* %6)
%132 = icmp slt i64 %131, 0
br i1 %132, label %133, label %142
133: ; preds = %130
%134 = call i32 @seteuid(i64 0)
%135 = load i32, i32* @VT_ACTIVATE
%136 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%137 = load i32, i32* %136
%138 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %135, i32 %137)
%139 = call i32 @seteuid(i64 %15)
%140 = load i32, i32* @LOG_ERR
%141 = call i32 (i32, i8*, ...) @syslog(i32 %140, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i8* %10)
br label %270
142: ; preds = %130
%143 = load i32, i32* @ECHO
%144 = xor i32 %143, -1
%145 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 0
%146 = load i32, i32* %145
%147 = and i32 %146, %144
store i32 %147, i32* %145
%148 = load i32, i32* @TCSANOW
%149 = call i64 @tcsetattr(i32 %75, i32 %148, %struct.termios* %6)
%150 = icmp slt i64 %149, 0
br i1 %150, label %151, label %160
151: ; preds = %142
%152 = call i32 @seteuid(i64 0)
%153 = load i32, i32* @VT_ACTIVATE
%154 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%155 = load i32, i32* %154
%156 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %153, i32 %155)
%157 = call i32 @seteuid(i64 %15)
%158 = load i32, i32* @LOG_ERR
%159 = call i32 (i32, i8*, ...) @syslog(i32 %158, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i8* %10)
br label %270
160: ; preds = %142
%161 = call i64 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0))
%162 = icmp slt i64 %161, 0
br i1 %162, label %163, label %172
163: ; preds = %160
%164 = call i32 @seteuid(i64 0)
%165 = load i32, i32* @VT_ACTIVATE
%166 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%167 = load i32, i32* %166
%168 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %165, i32 %167)
%169 = call i32 @seteuid(i64 %15)
%170 = load i32, i32* @LOG_ERR
%171 = call i32 (i32, i8*, ...) @syslog(i32 %170, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %10)
br label %270
172: ; preds = %160
%173 = getelementptr inbounds i8*, i8** %1, i64 1
%174 = load i8*, i8** %173
%175 = load i8, i8* %174
%176 = icmp eq i8 %175, 0
%177 = getelementptr inbounds i8*, i8** %1, i64 2
%178 = load i8*, i8** %177
%179 = load i8, i8* %178
%180 = icmp eq i8 %179, 0
br i1 %176, label %206, label %181
181: ; preds = %172
br i1 %180, label %194, label %182
182: ; preds = %181
%183 = call i64 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.18, i64 0, i64 0), i8* %174, i8* %178)
%184 = icmp slt i64 %183, 0
br i1 %184, label %185, label %231
185: ; preds = %182
%186 = call i32 @seteuid(i64 0)
%187 = load i32, i32* @VT_ACTIVATE
%188 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%189 = load i32, i32* %188
%190 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %187, i32 %189)
%191 = call i32 @seteuid(i64 %15)
%192 = load i32, i32* @LOG_ERR
%193 = call i32 (i32, i8*, ...) @syslog(i32 %192, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %10)
br label %270
194: ; preds = %181
%195 = call i64 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* %174)
%196 = icmp slt i64 %195, 0
br i1 %196, label %197, label %231
197: ; preds = %194
%198 = load i32, i32* @LOG_ERR
%199 = call i32 (i32, i8*, ...) @syslog(i32 %198, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %10)
%200 = call i32 @seteuid(i64 0)
%201 = load i32, i32* @VT_ACTIVATE
%202 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%203 = load i32, i32* %202
%204 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %201, i32 %203)
%205 = call i32 @seteuid(i64 %15)
br label %270
206: ; preds = %172
br i1 %180, label %219, label %207
207: ; preds = %206
%208 = call i64 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.20, i64 0, i64 0), i8* %178)
%209 = icmp slt i64 %208, 0
br i1 %209, label %210, label %231
210: ; preds = %207
%211 = call i32 @seteuid(i64 0)
%212 = load i32, i32* @VT_ACTIVATE
%213 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%214 = load i32, i32* %213
%215 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %212, i32 %214)
%216 = call i32 @seteuid(i64 %15)
%217 = load i32, i32* @LOG_ERR
%218 = call i32 (i32, i8*, ...) @syslog(i32 %217, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %10)
br label %270
219: ; preds = %206
%220 = call i64 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0))
%221 = icmp slt i64 %220, 0
br i1 %221, label %222, label %231
222: ; preds = %219
%223 = call i32 @seteuid(i64 0)
%224 = load i32, i32* @VT_ACTIVATE
%225 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%226 = load i32, i32* %225
%227 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %224, i32 %226)
%228 = call i32 @seteuid(i64 %15)
%229 = load i32, i32* @LOG_ERR
%230 = call i32 (i32, i8*, ...) @syslog(i32 %229, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %10)
br label %270
231: ; preds = %194, %219, %207, %182
%232 = call i32 @fgets(i8* %12, i32 256, i32* %119)
%233 = icmp eq i32 %232, 0
br i1 %233, label %234, label %246
234: ; preds = %231
%235 = call i32 @seteuid(i64 0)
%236 = load i32, i32* @VT_ACTIVATE
%237 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%238 = load i32, i32* %237
%239 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %236, i32 %238)
%240 = call i32 @seteuid(i64 %15)
%241 = call i64 @ferror(i32* %119)
%242 = icmp eq i64 %241, 0
br i1 %242, label %270, label %243
243: ; preds = %234
%244 = load i32, i32* @LOG_ERR
%245 = call i32 (i32, i8*, ...) @syslog(i32 %244, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0), i8* %10)
br label %270
246: ; preds = %231
%247 = call i8* @strchr(i8* %12, i8 signext 10)
%248 = icmp eq i8* %247, null
br i1 %248, label %250, label %249
249: ; preds = %246
store i8 0, i8* %247
br label %250
250: ; preds = %249, %246
%251 = call i32 @strlen(i8* %12)
%252 = getelementptr inbounds i8*, i8** %1, i64 3
%253 = load i8*, i8** %252
%254 = call i32 @atoi(i8* %253)
%255 = call i32 @write(i32 %254, i8* %12, i32 %251)
%256 = icmp eq i32 %255, %251
%257 = call i32 @seteuid(i64 0)
%258 = load i32, i32* @VT_ACTIVATE
%259 = getelementptr inbounds %struct.vt_stat, %struct.vt_stat* %3, i64 0, i32 0
%260 = load i32, i32* %259
%261 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %258, i32 %260)
%262 = call i32 @seteuid(i64 %15)
br i1 %256, label %270, label %263
263: ; preds = %250
%264 = icmp slt i32 %255, 0
%265 = load i32, i32* @LOG_ERR
br i1 %264, label %266, label %268
266: ; preds = %263
%267 = call i32 (i32, i8*, ...) @syslog(i32 %265, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.23, i64 0, i64 0))
br label %270
268: ; preds = %263
%269 = call i32 (i32, i8*, ...) @syslog(i32 %265, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.24, i64 0, i64 0))
br label %270
270: ; preds = %250, %55, %266, %268, %234, %243, %222, %210, %197, %185, %163, %151, %133, %121, %108, %94, %84, %77, %68, %62, %35, %28, %23
%271 = phi i32 [ 1, %23 ], [ 1, %28 ], [ 1, %35 ], [ 1, %62 ], [ 1, %68 ], [ 1, %77 ], [ 1, %84 ], [ 1, %94 ], [ 1, %108 ], [ 1, %133 ], [ 1, %151 ], [ 1, %163 ], [ 1, %185 ], [ 1, %222 ], [ 1, %210 ], [ 1, %197 ], [ 1, %121 ], [ 1, %243 ], [ 1, %234 ], [ 1, %268 ], [ 1, %266 ], [ 1, %55 ], [ 0, %250 ]
ret i32 %271
}