#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 */
struct utmp {
  scalar_t__ ut_type;
  char *ut_line;
  int /*<<< orphan*/ ut_user;
};
struct stat {
  scalar_t__ st_uid;
};
struct passwd {
  scalar_t__ pw_uid;
  char *pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ STDIN_FILENO;
scalar_t__ USER_PROCESS;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
struct passwd *getpwnam(char *);
struct utmp *getutent();
int open(char *, int /*<<< orphan*/);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ setutent();
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ usage(char **);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  static char ttyname[12];
  struct passwd *pwdent;
  int ofd = -1;
  static char buf[255];
  int n;
  if ((argc > 3) || (argc < 2)) {
    usage(argv);
  }
  if ((pwdent = getpwnam(argv[1])) == NULL) {
    fprintf(stderr, "%s: No such user %s\n", argv[0], argv[1]);
    exit(1);
  }
  if (argc == 3) {
    struct stat sbuf;
    strncpy(ttyname, "/dev/", 6);
    strncat(ttyname, argv[2], 6);
    ttyname[11] = '\0';
    if (stat(ttyname, &sbuf) != 0) {
      fprintf(stderr, "%s: No such tty %s\n", argv[0], ttyname);
      exit(1);
    }
    if (pwdent->pw_uid != sbuf.st_uid) {
      fprintf(stderr, "%s: User %s is not logged onto %s\n", argv[0], argv[1],
              argv[2]);
      exit(1);
    }
    if ((ofd = open(ttyname, O_WRONLY)) < 0) {
      fprintf(stderr, "%s: %s has messages disabled on %s\n", argv[0], argv[1],
              argv[2]);
      exit(1);
    }
  } else {
    struct utmp *utmp;
    setutent();
    while ((utmp = getutent()) != NULL) {
      if ((strcmp(pwdent->pw_name, utmp->ut_user) == 0) &&
          (utmp->ut_type == USER_PROCESS)) {
        strncpy(ttyname, "/dev/", 6);
        strncat(ttyname, utmp->ut_line, 6);
        ttyname[11] = '\0';
        if ((ofd = open(ttyname, O_WRONLY)) >= 0) {
          break;
        }
      }
    }
    if (ofd < 0) {
      fprintf(stderr, "%s: User %s not logged in, or has messages disabled\n",
              argv[0], argv[1]);
      exit(1);
    }
  }
  if ((pwdent = getpwnam(argv[1])) == NULL) {
    fprintf(stderr, "%s: Who are you?\n", argv[0]);
    exit(1);
  }
  write(ofd, "Message from ", 13);
  write(ofd, pwdent->pw_name, strlen(pwdent->pw_name));
  write(ofd, "\n", 1);
  while ((n = read(STDIN_FILENO, buf, 254)) > 0) {
    buf[254] = '\0';
    write(ofd, buf, n);
  }
  write(ofd, "EOF\n", 4);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jg     1211 <main+0x31>
cmpl   $0x2,-0x8(%rbp)
jge    121a <main+0x3a>
mov    -0x10(%rbp),%rdi
call   10d0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1265 <main+0x85>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    1397 <main+0x1b7>
lea    0x2e2a(%rip),%rdi
lea    0xd98(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0x2e0a(%rip),%rdi
mov    $0x6,%edx
call   1060 <strncat@plt>
movb   $0x0,0x2e04(%rip)
lea    0x2df2(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0x0,%rax
je     12f0 <main+0x110>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd43(%rip),%rsi
lea    0x2dc1(%rip),%rcx
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmp    -0x28(%rbp),%rax
je     1339 <main+0x159>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
lea    0xd07(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2c80(%rip),%rax
mov    (%rax),%esi
lea    0x2d57(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1392 <main+0x1b2>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
lea    0xcd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    148f <main+0x2af>
mov    $0x0,%al
call   10e0 <setutent@plt>
mov    $0x0,%al
call   10c0 <getutent@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1450 <main+0x270>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%esi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    144b <main+0x26b>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    0x2c09(%rip),%rcx
cmp    (%rcx),%rax
jne    144b <main+0x26b>
lea    0x2cb1(%rip),%rdi
lea    0xc1f(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0x2c91(%rip),%rdi
mov    $0x6,%edx
call   1060 <strncat@plt>
movb   $0x0,0x2c8b(%rip)
mov    0x2b99(%rip),%rax
mov    (%rax),%esi
lea    0x2c70(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jl     1446 <main+0x266>
jmp    1450 <main+0x270>
jmp    144b <main+0x26b>
jmp    139e <main+0x1be>
cmpl   $0x0,-0x1c(%rbp)
jge    148a <main+0x2aa>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xbfd(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    148f <main+0x2af>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    14d2 <main+0x2f2>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xbea(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x1c(%rbp),%edi
lea    0xbe1(%rip),%rsi
mov    $0xd,%edx
call   1040 <write@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x1c(%rbp),%edi
lea    0xb9e(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    0x2aa2(%rip),%rax
mov    (%rax),%edi
lea    0x2b79(%rip),%rsi
mov    $0xfe,%edx
call   1070 <read@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    156b <main+0x38b>
movb   $0x0,0x2c5a(%rip)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%edx
lea    0x2b4f(%rip),%rsi
call   1040 <write@plt>
jmp    1527 <main+0x347>
mov    -0x1c(%rbp),%edi
lea    0xb56(%rip),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
xor    %edi,%edi
call   1100 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    -0x4(%rbp),%eax
cmp    $0xfffffffd,%eax
ja     1203 <main+0x23>
mov    %r14,%rdi
call   10d0 <usage@plt>
mov    0x8(%r14),%rdi
call   1090 <getpwnam@plt>
test   %rax,%rax
jne    122d <main+0x4d>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xdd8(%rip),%rsi
jmp    13ba <main+0x1da>
mov    %rax,%rbx
cmp    $0x3,%ebp
jne    12cd <main+0xed>
lea    0x2e60(%rip),%rbp
lea    0xdce(%rip),%rsi
mov    %rbp,%rdi
mov    $0x6,%edx
call   1030 <strncpy@plt>
mov    0x10(%r14),%rsi
mov    %rbp,%rdi
mov    $0x6,%edx
call   1060 <strncat@plt>
movb   $0x0,0x2e3f(%rip)
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   10b0 <stat@plt>
test   %rax,%rax
jne    137d <main+0x19d>
mov    (%rbx),%rax
cmp    0x10(%rsp),%rax
jne    13cb <main+0x1eb>
mov    0x2d29(%rip),%rax
mov    (%rax),%esi
lea    0x2e00(%rip),%rdi
call   10f0 <open@plt>
test   %eax,%eax
jns    13f7 <main+0x217>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
mov    0x10(%r14),%r8
lea    0xd8a(%rip),%rsi
jmp    13e6 <main+0x206>
mov    %r14,0x8(%rsp)
xor    %eax,%eax
call   10e0 <setutent@plt>
xor    %eax,%eax
call   10c0 <getutent@plt>
test   %rax,%rax
je     139e <main+0x1be>
mov    %rax,%rbp
mov    $0xffffffff,%r13d
mov    0x2cef(%rip),%r14
lea    0x2da0(%rip),%r15
mov    0x2cb9(%rip),%r12
jmp    131f <main+0x13f>
nopl   0x0(%rax)
xor    %eax,%eax
call   10c0 <getutent@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1399 <main+0x1b9>
mov    0x8(%rbx),%rdi
mov    0x10(%rbp),%esi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1310 <main+0x130>
mov    0x0(%rbp),%rax
cmp    (%r14),%rax
jne    1310 <main+0x130>
mov    %r15,%rdi
lea    0xcd2(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
mov    0x8(%rbp),%rsi
mov    %r15,%rdi
mov    $0x6,%edx
call   1060 <strncat@plt>
movb   $0x0,0x2d46(%rip)
mov    (%r12),%esi
mov    %r15,%rdi
call   10f0 <open@plt>
mov    %eax,%r13d
test   %eax,%eax
js     1310 <main+0x130>
jmp    13ff <main+0x21f>
mov    0x2c54(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc8b(%rip),%rsi
lea    0x2d09(%rip),%rcx
jmp    13ba <main+0x1da>
test   %r13d,%r13d
jns    13ff <main+0x21f>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rax
mov    (%rax),%rdx
mov    0x8(%rax),%rcx
lea    0xcbc(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
mov    0x10(%r14),%r8
lea    0xc49(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    %eax,%r13d
mov    %r14,0x8(%rsp)
mov    0x8(%rsp),%rbp
mov    0x8(%rbp),%rdi
call   1090 <getpwnam@plt>
test   %rax,%rax
jne    1437 <main+0x257>
mov    0x2bbf(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xc85(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    %rax,%rbx
lea    0xc7c(%rip),%rsi
mov    %r13d,%edi
mov    $0xd,%edx
call   1040 <write@plt>
mov    0x8(%rbx),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
lea    0xc4d(%rip),%rsi
mov    %r13d,%edi
mov    $0x1,%edx
call   1040 <write@plt>
mov    0x2b4e(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0x2c24(%rip),%rsi
mov    $0xfe,%edx
call   1070 <read@plt>
test   %eax,%eax
jle    14d8 <main+0x2f8>
lea    0x2c0f(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x0,0x2cf7(%rip)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0xfe,%edx
call   1070 <read@plt>
test   %eax,%eax
jg     14b0 <main+0x2d0>
lea    0xbec(%rip),%rsi
mov    %r13d,%edi
mov    $0x4,%edx
call   1040 <write@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i64, i8* }
%struct.stat = type { i64 }
%struct.utmp = type { i64, i8*, i32 }
@main.ttyname = internal global [12 x i8] zeroinitializer
@main.buf = internal global [255 x i8] zeroinitializer
@stderr = global i32 0
@.str = [21 x i8] c"%s: No such user %s\0A\00"
@.str.1 = [6 x i8] c"/dev/\00"
@.str.2 = [20 x i8] c"%s: No such tty %s\0A\00"
@.str.3 = [35 x i8] c"%s: User %s is not logged onto %s\0A\00"
@O_WRONLY = global i32 0
@.str.4 = [36 x i8] c"%s: %s has messages disabled on %s\0A\00"
@USER_PROCESS = global i64 0
@.str.5 = [53 x i8] c"%s: User %s not logged in, or has messages disabled\0A\00"
@.str.6 = [18 x i8] c"%s: Who are you?\0A\00"
@.str.7 = [14 x i8] c"Message from \00"
@.str.8 = [2 x i8] c"\0A\00"
@STDIN_FILENO = global i32 0
@.str.9 = [5 x i8] c"EOF\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.stat
%10 = alloca %struct.utmp*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %7
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 3
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %19
16: ; preds = %13, %2
%17 = load i8**, i8*** %5
%18 = call i32 @usage(i8** %17)
br label %19
19: ; preds = %16, %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call %struct.passwd* @getpwnam(i8* %22)
store %struct.passwd* %23, %struct.passwd** %6
%24 = icmp eq %struct.passwd* %23, null
br i1 %24, label %25, label %35
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %29, i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %19
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 3
br i1 %37, label %38, label %91
38: ; preds = %35
%39 = call i32 @strncpy(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6)
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @strncat(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i8* %42, i32 6)
store i8 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 11)
%44 = call i64 @stat(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), %struct.stat* %9)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %53
46: ; preds = %38
%47 = load i32, i32* @stderr
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 0
%50 = load i8*, i8** %49
%51 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %50, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %38
%54 = load %struct.passwd*, %struct.passwd** %6
%55 = getelementptr inbounds %struct.passwd, %struct.passwd* %54, i32 0, i32 0
%56 = load i64, i64* %55
%57 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%58 = load i64, i64* %57
%59 = icmp ne i64 %56, %58
br i1 %59, label %60, label %73
60: ; preds = %53
%61 = load i32, i32* @stderr
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %64, i8* %67, i8* %70)
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %53
%74 = load i32, i32* @O_WRONLY
%75 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i32 %74)
store i32 %75, i32* %7
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %90
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 0
%81 = load i8*, i8** %80
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 1
%84 = load i8*, i8** %83
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 2
%87 = load i8*, i8** %86
%88 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %81, i8* %84, i8* %87)
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %73
br label %137
91: ; preds = %35
%92 = call i32 (...) @setutent()
br label %93
93: ; preds = %122, %91
%94 = call %struct.utmp* (...) @getutent()
store %struct.utmp* %94, %struct.utmp** %10
%95 = icmp ne %struct.utmp* %94, null
br i1 %95, label %96, label %123
96: ; preds = %93
%97 = load %struct.passwd*, %struct.passwd** %6
%98 = getelementptr inbounds %struct.passwd, %struct.passwd* %97, i32 0, i32 1
%99 = load i8*, i8** %98
%100 = load %struct.utmp*, %struct.utmp** %10
%101 = getelementptr inbounds %struct.utmp, %struct.utmp* %100, i32 0, i32 2
%102 = load i32, i32* %101
%103 = call i64 @strcmp(i8* %99, i32 %102)
%104 = icmp eq i64 %103, 0
br i1 %104, label %105, label %122
105: ; preds = %96
%106 = load %struct.utmp*, %struct.utmp** %10
%107 = getelementptr inbounds %struct.utmp, %struct.utmp* %106, i32 0, i32 0
%108 = load i64, i64* %107
%109 = load i64, i64* @USER_PROCESS
%110 = icmp eq i64 %108, %109
br i1 %110, label %111, label %122
111: ; preds = %105
%112 = call i32 @strncpy(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6)
%113 = load %struct.utmp*, %struct.utmp** %10
%114 = getelementptr inbounds %struct.utmp, %struct.utmp* %113, i32 0, i32 1
%115 = load i8*, i8** %114
%116 = call i32 @strncat(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i8* %115, i32 6)
store i8 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 11)
%117 = load i32, i32* @O_WRONLY
%118 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i32 %117)
store i32 %118, i32* %7
%119 = icmp sge i32 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %111
br label %123
121: ; preds = %111
br label %122
122: ; preds = %121, %105, %96
br label %93
123: ; preds = %120, %93
%124 = load i32, i32* %7
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %136
126: ; preds = %123
%127 = load i32, i32* @stderr
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 0
%130 = load i8*, i8** %129
%131 = load i8**, i8*** %5
%132 = getelementptr inbounds i8*, i8** %131, i64 1
%133 = load i8*, i8** %132
%134 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %127, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i8* %130, i8* %133)
%135 = call i32 @exit(i32 1)
unreachable
136: ; preds = %123
br label %137
137: ; preds = %136, %90
%138 = load i8**, i8*** %5
%139 = getelementptr inbounds i8*, i8** %138, i64 1
%140 = load i8*, i8** %139
%141 = call %struct.passwd* @getpwnam(i8* %140)
store %struct.passwd* %141, %struct.passwd** %6
%142 = icmp eq %struct.passwd* %141, null
br i1 %142, label %143, label %150
143: ; preds = %137
%144 = load i32, i32* @stderr
%145 = load i8**, i8*** %5
%146 = getelementptr inbounds i8*, i8** %145, i64 0
%147 = load i8*, i8** %146
%148 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %147)
%149 = call i32 @exit(i32 1)
unreachable
150: ; preds = %137
%151 = load i32, i32* %7
%152 = call i32 @write(i32 %151, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 13)
%153 = load i32, i32* %7
%154 = load %struct.passwd*, %struct.passwd** %6
%155 = getelementptr inbounds %struct.passwd, %struct.passwd* %154, i32 0, i32 1
%156 = load i8*, i8** %155
%157 = load %struct.passwd*, %struct.passwd** %6
%158 = getelementptr inbounds %struct.passwd, %struct.passwd* %157, i32 0, i32 1
%159 = load i8*, i8** %158
%160 = call i32 @strlen(i8* %159)
%161 = call i32 @write(i32 %153, i8* %156, i32 %160)
%162 = load i32, i32* %7
%163 = call i32 @write(i32 %162, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
br label %164
164: ; preds = %168, %150
%165 = load i32, i32* @STDIN_FILENO
%166 = call i32 @read(i32 %165, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @main.buf, i64 0, i64 0), i32 254)
store i32 %166, i32* %8
%167 = icmp sgt i32 %166, 0
br i1 %167, label %168, label %172
168: ; preds = %164
store i8 0, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @main.buf, i64 0, i64 254)
%169 = load i32, i32* %7
%170 = load i32, i32* %8
%171 = call i32 @write(i32 %169, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @main.buf, i64 0, i64 0), i32 %170)
br label %164
172: ; preds = %164
%173 = load i32, i32* %7
%174 = call i32 @write(i32 %173, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%175 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.passwd = type { i64, i8* }
%struct.utmp = type { i64, i8*, i32 }
@main.ttyname = internal global [12 x i8] zeroinitializer
@main.buf = internal global [255 x i8] zeroinitializer
@stderr = global i32 0
@.str = [21 x i8] c"%s: No such user %s\0A\00"
@.str.1 = [6 x i8] c"/dev/\00"
@.str.2 = [20 x i8] c"%s: No such tty %s\0A\00"
@.str.3 = [35 x i8] c"%s: User %s is not logged onto %s\0A\00"
@O_WRONLY = global i32 0
@.str.4 = [36 x i8] c"%s: %s has messages disabled on %s\0A\00"
@USER_PROCESS = global i64 0
@.str.5 = [53 x i8] c"%s: User %s not logged in, or has messages disabled\0A\00"
@.str.6 = [18 x i8] c"%s: Who are you?\0A\00"
@.str.7 = [14 x i8] c"Message from \00"
@.str.8 = [2 x i8] c"\0A\00"
@STDIN_FILENO = global i32 0
@.str.9 = [5 x i8] c"EOF\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.stat
%4 = add i32 %0, -4
%5 = icmp ult i32 %4, -2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @usage(i8** %1)
br label %8
8: ; preds = %2, %6
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call %struct.passwd* @getpwnam(i8* %10)
%12 = icmp eq %struct.passwd* %11, null
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %1
%16 = load i8*, i8** %9
%17 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %8
%20 = icmp eq i32 %0, 3
br i1 %20, label %21, label %59
21: ; preds = %19
%22 = bitcast %struct.stat* %3 to i8*
%23 = tail call i32 @strncpy(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6)
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @strncat(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i8* %25, i32 6)
store i8 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 11)
%27 = call i64 @stat(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), %struct.stat* %3)
%28 = icmp eq i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %1
%32 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %21
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 0
%36 = load i64, i64* %35
%37 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%38 = load i64, i64* %37
%39 = icmp eq i64 %36, %38
br i1 %39, label %47, label %40
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %1
%43 = load i8*, i8** %9
%44 = load i8*, i8** %24
%45 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %42, i8* %43, i8* %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %34
%48 = load i32, i32* @O_WRONLY
%49 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i32 %48)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %47
%52 = load i32, i32* @stderr
%53 = load i8*, i8** %1
%54 = load i8*, i8** %9
%55 = load i8*, i8** %24
%56 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %53, i8* %54, i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %47
br label %98
59: ; preds = %19
%60 = tail call i32 (...) @setutent()
%61 = tail call %struct.utmp* (...) @getutent()
%62 = icmp eq %struct.utmp* %61, null
br i1 %62, label %92, label %63
63: ; preds = %59
%64 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 1
br label %65
65: ; preds = %63, %86
%66 = phi %struct.utmp* [ %61, %63 ], [ %88, %86 ]
%67 = phi i32 [ -1, %63 ], [ %87, %86 ]
%68 = load i8*, i8** %64
%69 = getelementptr inbounds %struct.utmp, %struct.utmp* %66, i64 0, i32 2
%70 = load i32, i32* %69
%71 = tail call i64 @strcmp(i8* %68, i32 %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %86
73: ; preds = %65
%74 = getelementptr inbounds %struct.utmp, %struct.utmp* %66, i64 0, i32 0
%75 = load i64, i64* %74
%76 = load i64, i64* @USER_PROCESS
%77 = icmp eq i64 %75, %76
br i1 %77, label %78, label %86
78: ; preds = %73
%79 = tail call i32 @strncpy(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6)
%80 = getelementptr inbounds %struct.utmp, %struct.utmp* %66, i64 0, i32 1
%81 = load i8*, i8** %80
%82 = tail call i32 @strncat(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i8* %81, i32 6)
store i8 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 11)
%83 = load i32, i32* @O_WRONLY
%84 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.ttyname, i64 0, i64 0), i32 %83)
%85 = icmp sgt i32 %84, -1
br i1 %85, label %98, label %86
86: ; preds = %78, %73, %65
%87 = phi i32 [ %84, %78 ], [ %67, %73 ], [ %67, %65 ]
%88 = tail call %struct.utmp* (...) @getutent()
%89 = icmp eq %struct.utmp* %88, null
br i1 %89, label %90, label %65
90: ; preds = %86
%91 = icmp slt i32 %87, 0
br i1 %91, label %92, label %98
92: ; preds = %59, %90
%93 = load i32, i32* @stderr
%94 = load i8*, i8** %1
%95 = load i8*, i8** %9
%96 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i8* %94, i8* %95)
%97 = tail call i32 @exit(i32 1)
unreachable
98: ; preds = %78, %90, %58
%99 = phi i32 [ %49, %58 ], [ %87, %90 ], [ %84, %78 ]
%100 = load i8*, i8** %9
%101 = call %struct.passwd* @getpwnam(i8* %100)
%102 = icmp eq %struct.passwd* %101, null
br i1 %102, label %103, label %108
103: ; preds = %98
%104 = load i32, i32* @stderr
%105 = load i8*, i8** %1
%106 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %105)
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %98
%109 = call i32 @write(i32 %99, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 13)
%110 = getelementptr inbounds %struct.passwd, %struct.passwd* %101, i64 0, i32 1
%111 = load i8*, i8** %110
%112 = call i32 @strlen(i8* %111)
%113 = call i32 @write(i32 %99, i8* %111, i32 %112)
%114 = call i32 @write(i32 %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
%115 = load i32, i32* @STDIN_FILENO
%116 = call i32 @read(i32 %115, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @main.buf, i64 0, i64 0), i32 254)
%117 = icmp sgt i32 %116, 0
br i1 %117, label %118, label %124
118: ; preds = %108, %118
%119 = phi i32 [ %122, %118 ], [ %116, %108 ]
store i8 0, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @main.buf, i64 0, i64 254)
%120 = call i32 @write(i32 %99, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @main.buf, i64 0, i64 0), i32 %119)
%121 = load i32, i32* @STDIN_FILENO
%122 = call i32 @read(i32 %121, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @main.buf, i64 0, i64 0), i32 254)
%123 = icmp sgt i32 %122, 0
br i1 %123, label %118, label %124
124: ; preds = %118, %108
%125 = call i32 @write(i32 %99, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%126 = call i32 @exit(i32 0)
unreachable
}