#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 passwd {
  char *pw_name;
  int /*<<< orphan*/ pw_dir;
  int /*<<< orphan*/ pw_uid;
  int /*<<< orphan*/ pw_shell;
};
typedef int /*<<< orphan*/ fname;

/* Variables and functions */
scalar_t__ EEXIST;
int /*<<< orphan*/ F_OK;
int O_CREAT;
int O_EXCL;
int O_WRONLY;
scalar_t__ access(char *, int /*<<< orphan*/);
scalar_t__ chdir(int /*<<< orphan*/);
scalar_t__ close(int);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getpid();
struct passwd *getpwnam(char *);
struct passwd *getpwuid(int);
int getuid();
scalar_t__ mkdir(char *, int);
int open(char *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ setuid(int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(int /*<<< orphan*/, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ usleep(int);
int write(int, char *, scalar_t__);
int main(int argc, char **argv) {
  struct passwd *pw;
  char fname[22];
  int fidx = getpid();
  int origuid = getuid();
  if (argc != 3) {
    fprintf(stderr, "Three arguments required\n");
    return 1;
  }
  pw = getpwnam(argv[1]);
  if (!pw) {
    fprintf(stderr, "No such account exists\n");
    return 1;
  }
  if (strcmp(pw->pw_shell, "/var/lib/adom/server/user_login_leagues") &&
      strcmp(pw->pw_shell, "/var/lib/adom/server/user_login")) {
    fprintf(stderr, "This does not seem to be a player account!\n");
    return 1;
  }
  setuid(pw->pw_uid);
  if (chdir(pw->pw_dir) < 0) {
    perror("chdir");
    return 1;
  }
  if (access("silence", F_OK) == 0) {
    fprintf(stderr, "%s has denied sending messages.  Sorry.\n", pw->pw_name);
    return 1;
  }
  if (mkdir(".messages", 0777) < 0 && errno != EEXIST) {
    perror("mkdir");
    return 1;
  }
  if (!(pw = getpwuid(origuid))) {
    fprintf(stderr, "You don't exist.  Go away.\n");
    return 1;
  }
  while (1) {
    int mfile;
    snprintf(fname, sizeof(fname), ".messages/%d", fidx++);
    mfile = open(fname, O_CREAT | O_EXCL | O_WRONLY, 0666);
    if (mfile < 0) {
      if (errno == EEXIST)
        continue;
      perror("creat");
      return 1;
    }
    if (!(write(mfile, (pw->pw_name), strlen(pw->pw_name)) ==
          (int)strlen(pw->pw_name)) ||
        !(write(mfile, (" "), strlen(" ")) == (int)strlen(" ")) ||
        !(write(mfile, (argv[2]), strlen(argv[2])) == (int)strlen(argv[2])) ||
        !(write(mfile, ("\n"), strlen("\n")) == (int)strlen("\n"))) {
      perror("write");
      return 1;
    }
    if (close(mfile) < 0) {
      perror("close");
      return 1;
    }
    break;
  }
  system("screen -S adom -X eval 'msgminwait 0' 'msgwait 0' 'exec "
         "/var/lib/adom/server/message_display' 'msgminwait 1' 'msgwait 5'");
  usleep(200000);
  system("screen -S adom -X eval 'msgminwait 0' 'msgwait 0' 'exec "
         "/var/lib/adom/server/message_display' 'msgminwait 1' 'msgwait 5'");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1090 <getuid@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1277 <main+0x57>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12b6 <main+0x96>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xd77(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%edi
lea    0xd6e(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     1313 <main+0xf3>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%edi
lea    0xd79(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     1313 <main+0xf3>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%edi
call   1130 <setuid@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
call   1080 <chdir@plt>
cmp    $0x0,%rax
jge    134d <main+0x12d>
lea    0xd6a(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
mov    0x2c54(%rip),%rax
mov    (%rax),%esi
lea    0xd4f(%rip),%rdi
call   1110 <access@plt>
cmp    $0x0,%rax
jne    1396 <main+0x176>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xd31(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
lea    0xd40(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
jge    13e3 <main+0x1c3>
mov    0x2c08(%rip),%rax
mov    (%rax),%rax
mov    0x2c16(%rip),%rcx
cmp    (%rcx),%rax
je     13e3 <main+0x1c3>
lea    0xd15(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
mov    -0x38(%rbp),%edi
call   1060 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    141c <main+0x1fc>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
lea    0xce4(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
jmp    1421 <main+0x201>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    $0x16,%esi
lea    0xccd(%rip),%rdx
call   10b0 <snprintf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2bac(%rip),%rax
mov    (%rax),%esi
mov    0x2b73(%rip),%rax
or     (%rax),%esi
mov    0x2b52(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1100 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    14ae <main+0x28e>
mov    0x2b42(%rip),%rax
mov    (%rax),%rax
mov    0x2b50(%rip),%rcx
cmp    (%rcx),%rax
jne    1496 <main+0x276>
jmp    1421 <main+0x201>
lea    0xc79(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
jne    15c5 <main+0x3a5>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    0xc18(%rip),%rdi
call   1070 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%rdx
lea    0xc06(%rip),%rsi
call   1040 <write@plt>
mov    %eax,-0x50(%rbp)
lea    0xbf7(%rip),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%eax
cmp    %ecx,%eax
jne    15c5 <main+0x3a5>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%eax
cmp    %ecx,%eax
jne    15c5 <main+0x3a5>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
lea    0xb13(%rip),%rdi
call   1070 <strlen@plt>
mov    -0x6c(%rbp),%edi
mov    %rax,%rdx
lea    0xb01(%rip),%rsi
call   1040 <write@plt>
mov    %eax,-0x68(%rbp)
lea    0xaf2(%rip),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%eax
cmp    %ecx,%eax
je     15dd <main+0x3bd>
lea    0xb52(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
mov    -0x3c(%rbp),%edi
call   10c0 <close@plt>
cmp    $0x0,%rax
jge    1607 <main+0x3e7>
lea    0xb2e(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1635 <main+0x415>
jmp    160c <main+0x3ec>
lea    0xb17(%rip),%rdi
call   10a0 <system@plt>
mov    $0x30d40,%edi
call   1140 <usleep@plt>
lea    0xb01(%rip),%rdi
call   10a0 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <getuid@plt>
cmp    $0x3,%ebx
jne    129d <main+0x7d>
mov    %eax,%r15d
mov    0x8(%r14),%rdi
call   10e0 <getpwnam@plt>
test   %rax,%rax
je     13a4 <main+0x184>
mov    %rax,%rbx
mov    0x10(%rax),%edi
lea    0xdc8(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     12b2 <main+0x92>
mov    0x10(%rbx),%edi
lea    0xddc(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     12b2 <main+0x92>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
jmp    13b4 <main+0x194>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
lea    0xd53(%rip),%rsi
jmp    13b4 <main+0x194>
mov    0xc(%rbx),%edi
call   1130 <setuid@plt>
mov    0x8(%rbx),%edi
call   1080 <chdir@plt>
test   %rax,%rax
js     14ce <main+0x2ae>
mov    0x2cd6(%rip),%rax
mov    (%rax),%esi
lea    0xdd1(%rip),%rdi
call   1110 <access@plt>
test   %rax,%rax
je     13cf <main+0x1af>
lea    0xded(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
jns    1319 <main+0xf9>
mov    0x2cba(%rip),%rax
mov    (%rax),%rax
mov    0x2cc8(%rip),%rcx
cmp    (%rcx),%rax
jne    14e0 <main+0x2c0>
mov    %r15d,%edi
call   1060 <getpwuid@plt>
test   %rax,%rax
je     14b0 <main+0x290>
mov    %rax,0x8(%rsp)
mov    %r14,(%rsp)
lea    0x10(%rsp),%r13
mov    0x2c71(%rip),%r12
mov    0x2c7a(%rip),%r15
mov    0x2c8b(%rip),%r14
nopl   (%rax)
mov    %r13,%rdi
mov    $0x16,%esi
lea    0xdaa(%rip),%rdx
mov    %ebp,%ecx
call   10b0 <snprintf@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
mov    0x2c82(%rip),%rax
or     (%rax),%esi
or     (%r12),%esi
mov    %r13,%rdi
mov    $0x1b6,%edx
call   1100 <open@plt>
test   %eax,%eax
jns    13eb <main+0x1cb>
add    $0x1,%ebp
mov    (%r15),%rax
cmp    (%r14),%rax
je     1350 <main+0x130>
lea    0xd77(%rip),%rdi
jmp    14e7 <main+0x2c7>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
lea    0xc66(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xcd2(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
jmp    13bb <main+0x19b>
mov    %eax,%ebx
mov    0x8(%rsp),%r14
mov    (%r14),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %eax,%ebp
mov    (%r14),%rdi
call   1070 <strlen@plt>
cmp    %eax,%ebp
jne    14c5 <main+0x2a5>
lea    0xcf9(%rip),%rsi
mov    $0x1,%edx
mov    %ebx,%edi
call   1040 <write@plt>
cmp    $0x1,%eax
jne    14c5 <main+0x2a5>
mov    (%rsp),%r14
mov    0x10(%r14),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %eax,%ebp
mov    0x10(%r14),%rdi
call   1070 <strlen@plt>
cmp    %eax,%ebp
jne    14c5 <main+0x2a5>
lea    0xc39(%rip),%rsi
mov    $0x1,%edx
mov    %ebx,%edi
call   1040 <write@plt>
cmp    $0x1,%eax
jne    14c5 <main+0x2a5>
mov    %ebx,%edi
call   10c0 <close@plt>
test   %rax,%rax
js     14d7 <main+0x2b7>
lea    0xc9b(%rip),%rbx
mov    %rbx,%rdi
call   10a0 <system@plt>
mov    $0x30d40,%edi
call   1140 <usleep@plt>
mov    %rbx,%rdi
call   10a0 <system@plt>
xor    %eax,%eax
jmp    13c0 <main+0x1a0>
mov    0x2b19(%rip),%rax
mov    (%rax),%edi
lea    0xc2d(%rip),%rsi
jmp    13b4 <main+0x194>
lea    0xc52(%rip),%rdi
jmp    14e7 <main+0x2c7>
lea    0xbd1(%rip),%rdi
jmp    14e7 <main+0x2c7>
lea    0xc46(%rip),%rdi
jmp    14e7 <main+0x2c7>
lea    0xc00(%rip),%rdi
call   1120 <perror@plt>
jmp    13bb <main+0x19b>

LLVM IR (-O0):
%struct.passwd = type { i8*, i32, i32, i32 }
@stderr = global i32 0
@.str = [26 x i8] c"Three arguments required\0A\00"
@.str.1 = [24 x i8] c"No such account exists\0A\00"
@.str.2 = [40 x i8] c"/var/lib/adom/server/user_login_leagues\00"
@.str.3 = [32 x i8] c"/var/lib/adom/server/user_login\00"
@.str.4 = [44 x i8] c"This does not seem to be a player account!\0A\00"
@.str.5 = [6 x i8] c"chdir\00"
@.str.6 = [8 x i8] c"silence\00"
@F_OK = global i32 0
@.str.7 = [41 x i8] c"%s has denied sending messages. Sorry.\0A\00"
@.str.8 = [10 x i8] c".messages\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.9 = [6 x i8] c"mkdir\00"
@.str.10 = [28 x i8] c"You don't exist. Go away.\0A\00"
@.str.11 = [13 x i8] c".messages/%d\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@O_WRONLY = global i32 0
@.str.12 = [6 x i8] c"creat\00"
@.str.13 = [2 x i8] c" \00"
@.str.14 = [2 x i8] c"\0A\00"
@.str.15 = [6 x i8] c"write\00"
@.str.16 = [6 x i8] c"close\00"
@.str.17 = [121 x i8] c"screen -S adom -X eval 'msgminwait 0' 'msgwait 0' 'exec /var/lib/adom/server/message_display' 'msgminwait 1' 'msgwait 5'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca [22 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (...) @getpid()
store i32 %11, i32* %8
%12 = call i32 (...) @getuid()
store i32 %12, i32* %9
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %162
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call %struct.passwd* @getpwnam(i8* %21)
store %struct.passwd* %22, %struct.passwd** %6
%23 = load %struct.passwd*, %struct.passwd** %6
%24 = icmp ne %struct.passwd* %23, null
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %162
28: ; preds = %18
%29 = load %struct.passwd*, %struct.passwd** %6
%30 = getelementptr inbounds %struct.passwd, %struct.passwd* %29, i32 0, i32 3
%31 = load i32, i32* %30
%32 = call i64 @strcmp(i32 %31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %43
34: ; preds = %28
%35 = load %struct.passwd*, %struct.passwd** %6
%36 = getelementptr inbounds %struct.passwd, %struct.passwd* %35, i32 0, i32 3
%37 = load i32, i32* %36
%38 = call i64 @strcmp(i32 %37, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %162
43: ; preds = %34, %28
%44 = load %struct.passwd*, %struct.passwd** %6
%45 = getelementptr inbounds %struct.passwd, %struct.passwd* %44, i32 0, i32 2
%46 = load i32, i32* %45
%47 = call i32 @setuid(i32 %46)
%48 = load %struct.passwd*, %struct.passwd** %6
%49 = getelementptr inbounds %struct.passwd, %struct.passwd* %48, i32 0, i32 1
%50 = load i32, i32* %49
%51 = call i64 @chdir(i32 %50)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %43
%54 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %162
55: ; preds = %43
%56 = load i32, i32* @F_OK
%57 = call i64 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %65
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = load %struct.passwd*, %struct.passwd** %6
%62 = getelementptr inbounds %struct.passwd, %struct.passwd* %61, i32 0, i32 0
%63 = load i8*, i8** %62
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %63)
store i32 1, i32* %3
br label %162
65: ; preds = %55
%66 = call i64 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 511)
%67 = icmp slt i64 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %65
%69 = load i64, i64* @errno
%70 = load i64, i64* @EEXIST
%71 = icmp ne i64 %69, %70
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %162
74: ; preds = %68, %65
%75 = load i32, i32* %9
%76 = call %struct.passwd* @getpwuid(i32 %75)
store %struct.passwd* %76, %struct.passwd** %6
%77 = icmp ne %struct.passwd* %76, null
br i1 %77, label %81, label %78
78: ; preds = %74
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %162
81: ; preds = %74
br label %82
82: ; preds = %81, %100
%83 = getelementptr inbounds [22 x i8], [22 x i8]* %7, i64 0, i64 0
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
%86 = call i32 @snprintf(i8* %83, i32 22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %84)
%87 = getelementptr inbounds [22 x i8], [22 x i8]* %7, i64 0, i64 0
%88 = load i32, i32* @O_CREAT
%89 = load i32, i32* @O_EXCL
%90 = or i32 %88, %89
%91 = load i32, i32* @O_WRONLY
%92 = or i32 %90, %91
%93 = call i32 @open(i8* %87, i32 %92, i32 438)
store i32 %93, i32* %10
%94 = load i32, i32* %10
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %103
96: ; preds = %82
%97 = load i64, i64* @errno
%98 = load i64, i64* @EEXIST
%99 = icmp eq i64 %97, %98
br i1 %99, label %100, label %101
100: ; preds = %96
br label %82
101: ; preds = %96
%102 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %3
br label %162
103: ; preds = %82
%104 = load i32, i32* %10
%105 = load %struct.passwd*, %struct.passwd** %6
%106 = getelementptr inbounds %struct.passwd, %struct.passwd* %105, i32 0, i32 0
%107 = load i8*, i8** %106
%108 = load %struct.passwd*, %struct.passwd** %6
%109 = getelementptr inbounds %struct.passwd, %struct.passwd* %108, i32 0, i32 0
%110 = load i8*, i8** %109
%111 = call i64 @strlen(i8* %110)
%112 = call i32 @write(i32 %104, i8* %107, i64 %111)
%113 = load %struct.passwd*, %struct.passwd** %6
%114 = getelementptr inbounds %struct.passwd, %struct.passwd* %113, i32 0, i32 0
%115 = load i8*, i8** %114
%116 = call i64 @strlen(i8* %115)
%117 = trunc i64 %116 to i32
%118 = icmp eq i32 %112, %117
br i1 %118, label %119, label %149
119: ; preds = %103
%120 = load i32, i32* %10
%121 = call i64 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%122 = call i32 @write(i32 %120, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i64 %121)
%123 = call i64 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%124 = trunc i64 %123 to i32
%125 = icmp eq i32 %122, %124
br i1 %125, label %126, label %149
126: ; preds = %119
%127 = load i32, i32* %10
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 2
%130 = load i8*, i8** %129
%131 = load i8**, i8*** %5
%132 = getelementptr inbounds i8*, i8** %131, i64 2
%133 = load i8*, i8** %132
%134 = call i64 @strlen(i8* %133)
%135 = call i32 @write(i32 %127, i8* %130, i64 %134)
%136 = load i8**, i8*** %5
%137 = getelementptr inbounds i8*, i8** %136, i64 2
%138 = load i8*, i8** %137
%139 = call i64 @strlen(i8* %138)
%140 = trunc i64 %139 to i32
%141 = icmp eq i32 %135, %140
br i1 %141, label %142, label %149
142: ; preds = %126
%143 = load i32, i32* %10
%144 = call i64 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%145 = call i32 @write(i32 %143, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i64 %144)
%146 = call i64 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%147 = trunc i64 %146 to i32
%148 = icmp eq i32 %145, %147
br i1 %148, label %151, label %149
149: ; preds = %142, %126, %119, %103
%150 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %3
br label %162
151: ; preds = %142
%152 = load i32, i32* %10
%153 = call i64 @close(i32 %152)
%154 = icmp slt i64 %153, 0
br i1 %154, label %155, label %157
155: ; preds = %151
%156 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0))
store i32 1, i32* %3
br label %162
157: ; preds = %151
br label %158
158: ; preds = %157
%159 = call i32 @system(i8* getelementptr inbounds ([121 x i8], [121 x i8]* @.str.17, i64 0, i64 0))
%160 = call i32 @usleep(i32 200000)
%161 = call i32 @system(i8* getelementptr inbounds ([121 x i8], [121 x i8]* @.str.17, i64 0, i64 0))
store i32 0, i32* %3
br label %162
162: ; preds = %158, %155, %149, %101, %78, %72, %59, %53, %40, %25, %15
%163 = load i32, i32* %3
ret i32 %163
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i32, i32, i32 }
@stderr = global i32 0
@.str = [26 x i8] c"Three arguments required\0A\00"
@.str.1 = [24 x i8] c"No such account exists\0A\00"
@.str.2 = [40 x i8] c"/var/lib/adom/server/user_login_leagues\00"
@.str.3 = [32 x i8] c"/var/lib/adom/server/user_login\00"
@.str.4 = [44 x i8] c"This does not seem to be a player account!\0A\00"
@.str.5 = [6 x i8] c"chdir\00"
@.str.6 = [8 x i8] c"silence\00"
@F_OK = global i32 0
@.str.7 = [41 x i8] c"%s has denied sending messages. Sorry.\0A\00"
@.str.8 = [10 x i8] c".messages\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.9 = [6 x i8] c"mkdir\00"
@.str.10 = [28 x i8] c"You don't exist. Go away.\0A\00"
@.str.11 = [13 x i8] c".messages/%d\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@O_WRONLY = global i32 0
@.str.12 = [6 x i8] c"creat\00"
@.str.13 = [2 x i8] c" \00"
@.str.14 = [2 x i8] c"\0A\00"
@.str.15 = [6 x i8] c"write\00"
@.str.16 = [6 x i8] c"close\00"
@.str.17 = [121 x i8] c"screen -S adom -X eval 'msgminwait 0' 'msgwait 0' 'exec /var/lib/adom/server/message_display' 'msgminwait 1' 'msgwait 5'\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [22 x i8]
%4 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @getpid()
%6 = tail call i32 (...) @getuid()
%7 = icmp eq i32 %0, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %117
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call %struct.passwd* @getpwnam(i8* %13)
%15 = icmp eq %struct.passwd* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %117
19: ; preds = %11
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i64 0, i32 3
%21 = load i32, i32* %20
%22 = tail call i64 @strcmp(i32 %21, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %19
%25 = load i32, i32* %20
%26 = tail call i64 @strcmp(i32 %25, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
br label %117
31: ; preds = %24, %19
%32 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i64 0, i32 2
%33 = load i32, i32* %32
%34 = tail call i32 @setuid(i32 %33)
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i64 0, i32 1
%36 = load i32, i32* %35
%37 = tail call i64 @chdir(i32 %36)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %31
%40 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %117
41: ; preds = %31
%42 = load i32, i32* @F_OK
%43 = tail call i64 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %41
%46 = load i32, i32* @stderr
%47 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i64 0, i32 0
%48 = load i8*, i8** %47
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %48)
br label %117
50: ; preds = %41
%51 = tail call i64 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 511)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %50
%54 = load i64, i64* @errno
%55 = load i64, i64* @EEXIST
%56 = icmp eq i64 %54, %55
br i1 %56, label %59, label %57
57: ; preds = %53
%58 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %117
59: ; preds = %53, %50
%60 = tail call %struct.passwd* @getpwuid(i32 %6)
%61 = icmp eq %struct.passwd* %60, null
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i32, i32* @stderr
%64 = tail call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
br label %117
65: ; preds = %59, %75
%66 = phi i32 [ %76, %75 ], [ %5, %59 ]
%67 = call i32 @snprintf(i8* %4, i32 22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %66)
%68 = load i32, i32* @O_CREAT
%69 = load i32, i32* @O_EXCL
%70 = or i32 %69, %68
%71 = load i32, i32* @O_WRONLY
%72 = or i32 %70, %71
%73 = call i32 @open(i8* %4, i32 %72, i32 438)
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %82
75: ; preds = %65
%76 = add nsw i32 %66, 1
%77 = load i64, i64* @errno
%78 = load i64, i64* @EEXIST
%79 = icmp eq i64 %77, %78
br i1 %79, label %65, label %80
80: ; preds = %75
%81 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
br label %117
82: ; preds = %65
%83 = getelementptr inbounds %struct.passwd, %struct.passwd* %60, i64 0, i32 0
%84 = load i8*, i8** %83
%85 = call i64 @strlen(i8* dereferenceable(1) %84)
%86 = call i32 @write(i32 %73, i8* %84, i64 %85)
%87 = load i8*, i8** %83
%88 = call i64 @strlen(i8* dereferenceable(1) %87)
%89 = trunc i64 %88 to i32
%90 = icmp eq i32 %86, %89
br i1 %90, label %91, label %106
91: ; preds = %82
%92 = call i32 @write(i32 %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i64 1)
%93 = icmp eq i32 %92, 1
br i1 %93, label %94, label %106
94: ; preds = %91
%95 = getelementptr inbounds i8*, i8** %1, i64 2
%96 = load i8*, i8** %95
%97 = call i64 @strlen(i8* dereferenceable(1) %96)
%98 = call i32 @write(i32 %73, i8* %96, i64 %97)
%99 = load i8*, i8** %95
%100 = call i64 @strlen(i8* dereferenceable(1) %99)
%101 = trunc i64 %100 to i32
%102 = icmp eq i32 %98, %101
br i1 %102, label %103, label %106
103: ; preds = %94
%104 = call i32 @write(i32 %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i64 1)
%105 = icmp eq i32 %104, 1
br i1 %105, label %108, label %106
106: ; preds = %103, %94, %91, %82
%107 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
br label %117
108: ; preds = %103
%109 = call i64 @close(i32 %73)
%110 = icmp slt i64 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %108
%112 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0))
br label %117
113: ; preds = %108
%114 = call i32 @system(i8* getelementptr inbounds ([121 x i8], [121 x i8]* @.str.17, i64 0, i64 0))
%115 = call i32 @usleep(i32 200000)
%116 = call i32 @system(i8* getelementptr inbounds ([121 x i8], [121 x i8]* @.str.17, i64 0, i64 0))
br label %117
117: ; preds = %106, %111, %80, %113, %62, %57, %45, %39, %28, %16, %8
%118 = phi i32 [ 1, %8 ], [ 1, %28 ], [ 1, %39 ], [ 1, %45 ], [ 1, %57 ], [ 0, %113 ], [ 1, %62 ], [ 1, %16 ], [ 1, %80 ], [ 1, %111 ], [ 1, %106 ]
ret i32 %118
}