#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 int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
struct spwd {
  int /*<<< orphan*/ sp_pwdp;
};
struct passwd {
  char *pw_name;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
scalar_t__ crypt(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
struct passwd *getpwnam(char *);
struct spwd *getspnam(char *);
struct tm *localtime(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  char *ip = "127.0.0.1";
  if (3 > argc) {
    printf("Error: bad args\n", argv[0]);
    printf("Usage: %s user password [ip]\n", argv[0]);
    exit(1);
  };
  if (4 <= argc) {
    ip = (char *)malloc(strlen(argv[3]));
    strcpy(ip, argv[3]);
  }
  time_t lt = time(NULL);
  struct tm *ptr = localtime(&lt);
  char str[280];
  strftime(str, 100, "%Y-%m-%d %H:%M:%S ", ptr);
  FILE *pFile = fopen("/usr/local/vesta/log/auth.log", "a+");
  if (NULL == pFile) {
    printf("Error: can not open file /usr/local/vesta/log/auth.log \n");
    exit(12);
  }
  int len = 0;
  if (strlen(argv[1]) >= 100) {
    printf("Too long username\n");
    exit(1);
  }
  struct passwd *userinfo = getpwnam(argv[1]);
  if (NULL != userinfo) {
    struct spwd *passw = getspnam(userinfo->pw_name);
    if (NULL != passw) {
      char *cryptedPasswrd = (char *)crypt(argv[2], passw->sp_pwdp);
      if (strcmp(passw->sp_pwdp, crypt(argv[2], passw->sp_pwdp)) == 0) {
        strcat(str, userinfo->pw_name);
        strcat(str, " ");
        strcat(str, ip);
        strcat(str, " successfully logged in \n");
        fputs(str, pFile);
        fclose(pFile);
        exit(EXIT_SUCCESS);
      } else {
        printf("Error: password missmatch\n");
        strcat(str, userinfo->pw_name);
        strcat(str, " ");
        strcat(str, ip);
        strcat(str, " failed to login \n");
        fputs(str, pFile);
        fclose(pFile);
        exit(9);
      };
    }
  } else {
    printf("Error: no such user\n", argv[1]);
    strcat(str, argv[1]);
    strcat(str, " ");
    strcat(str, ip);
    strcat(str, " failed to login \n");
    fputs(str, pFile);
    fclose(pFile);
    exit(3);
  };
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xde0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x3,%eax
cmp    -0x8(%rbp),%eax
jle    1266 <main+0x66>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
jg     129d <main+0x9d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x64,%esi
lea    0xd6c(%rip),%rdx
call   10e0 <strftime@plt>
lea    0xd73(%rip),%rdi
lea    0xd8a(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x148(%rbp)
xor    %eax,%eax
cmp    -0x148(%rbp),%rax
jne    1313 <main+0x113>
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0xc,%edi
call   1120 <exit@plt>
movl   $0x0,-0x14c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <strlen@plt>
cmp    $0x64,%eax
jl     134b <main+0x14b>
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <getpwnam@plt>
mov    %rax,-0x158(%rbp)
xor    %eax,%eax
cmp    -0x158(%rbp),%rax
je     14ee <main+0x2ee>
mov    -0x158(%rbp),%rax
mov    (%rax),%rdi
call   10f0 <getspnam@plt>
mov    %rax,-0x160(%rbp)
xor    %eax,%eax
cmp    -0x160(%rbp),%rax
je     14e9 <main+0x2e9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x160(%rbp),%rax
mov    (%rax),%esi
call   1050 <crypt@plt>
mov    %rax,-0x168(%rbp)
mov    -0x160(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x16c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x160(%rbp),%rax
mov    (%rax),%esi
call   1050 <crypt@plt>
mov    -0x16c(%rbp),%edi
mov    %rax,%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1466 <main+0x266>
lea    -0x140(%rbp),%rdi
mov    -0x158(%rbp),%rax
mov    (%rax),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xc39(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xc85(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x148(%rbp),%rdi
call   1060 <fclose@plt>
mov    0x2b81(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
lea    0xc66(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x158(%rbp),%rax
mov    (%rax),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xbb2(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xc33(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x148(%rbp),%rdi
call   1060 <fclose@plt>
mov    $0x9,%edi
call   1120 <exit@plt>
jmp    1577 <main+0x377>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xc04(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xb24(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xba5(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x148(%rbp),%rdi
call   1060 <fclose@plt>
mov    $0x3,%edi
call   1120 <exit@plt>
mov    0x2a62(%rip),%rax
mov    (%rax),%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x130,%rsp
mov    %rsi,%r12
cmp    $0x2,%edi
jle    12f4 <main+0xe4>
cmp    $0x3,%edi
jne    123a <main+0x2a>
lea    0xdc8(%rip),%r14
jmp    125b <main+0x4b>
mov    0x18(%r12),%rdi
call   1080 <strlen@plt>
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,%r14
mov    0x18(%r12),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xdb1(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
lea    0xdab(%rip),%rdi
lea    0xdc2(%rip),%rsi
call   1110 <fopen@plt>
test   %rax,%rax
je     131c <main+0x10c>
mov    %rax,%r15
mov    0x8(%r12),%rdi
call   1080 <strlen@plt>
cmp    $0x64,%eax
jge    1332 <main+0x122>
mov    0x8(%r12),%rdi
call   10c0 <getpwnam@plt>
test   %rax,%rax
je     1348 <main+0x138>
mov    %rax,%r13
mov    (%rax),%rdi
call   1100 <getspnam@plt>
test   %rax,%rax
jne    13ac <main+0x19c>
mov    0x2cff(%rip),%rax
mov    (%rax),%eax
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe06(%rip),%rdi
call   1050 <puts@plt>
mov    (%r12),%rsi
lea    0xcff(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xda6(%rip),%rdi
call   1050 <puts@plt>
mov    $0xc,%edi
call   1130 <exit@plt>
lea    0xd7e(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xd3a(%rip),%rdi
call   1050 <puts@plt>
mov    0x8(%r12),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0xccc(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1120 <strcat@plt>
lea    0xcef(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <fputs@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    $0x3,%edi
call   1130 <exit@plt>
mov    %rax,%rbx
mov    0x10(%r12),%rdi
mov    (%rax),%esi
call   1060 <crypt@plt>
mov    (%rbx),%ebx
mov    0x10(%r12),%rdi
mov    %ebx,%esi
call   1060 <crypt@plt>
mov    %ebx,%edi
mov    %rax,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1433 <main+0x223>
mov    0x0(%r13),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0xc49(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1120 <strcat@plt>
lea    0xc52(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <fputs@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    0x2bb4(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    0xc63(%rip),%rdi
call   1050 <puts@plt>
mov    0x0(%r13),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0xbe2(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1120 <strcat@plt>
lea    0xc05(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <fputs@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    $0x9,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.passwd = type { i8* }
%struct.spwd = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [17 x i8] c"Error: bad args\0A\00"
@.str.2 = [30 x i8] c"Usage: %s user password [ip]\0A\00"
@.str.3 = [19 x i8] c"%Y-%m-%d %H:%M:%S \00"
@.str.4 = [30 x i8] c"/usr/local/vesta/log/auth.log\00"
@.str.5 = [3 x i8] c"a+\00"
@.str.6 = [57 x i8] c"Error: can not open file /usr/local/vesta/log/auth.log \0A\00"
@.str.7 = [19 x i8] c"Too long username\0A\00"
@.str.8 = [2 x i8] c" \00"
@.str.9 = [26 x i8] c" successfully logged in \0A\00"
@EXIT_SUCCESS = global i32 0
@.str.10 = [27 x i8] c"Error: password missmatch\0A\00"
@.str.11 = [19 x i8] c" failed to login \0A\00"
@.str.12 = [21 x i8] c"Error: no such user\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.tm*
%9 = alloca [280 x i8]
%10 = alloca i32*
%11 = alloca i32
%12 = alloca %struct.passwd*
%13 = alloca %struct.spwd*
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %6
%15 = load i32, i32* %4
%16 = icmp sgt i32 3, %15
br i1 %16, label %17, label %27
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = load i32, i32* %4
%29 = icmp sle i32 4, %28
br i1 %29, label %30, label %42
30: ; preds = %27
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i32 @strlen(i8* %33)
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** %6
%37 = load i8*, i8** %6
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 3
%40 = load i8*, i8** %39
%41 = call i32 @strcpy(i8* %37, i8* %40)
br label %42
42: ; preds = %30, %27
%43 = call i32 @time(i32* null)
store i32 %43, i32* %7
%44 = call %struct.tm* @localtime(i32* %7)
store %struct.tm* %44, %struct.tm** %8
%45 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%46 = load %struct.tm*, %struct.tm** %8
%47 = call i32 @strftime(i8* %45, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %46)
%48 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %48, i32** %10
%49 = load i32*, i32** %10
%50 = icmp eq i32* null, %49
br i1 %50, label %51, label %54
51: ; preds = %42
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
%53 = call i32 @exit(i32 12)
unreachable
54: ; preds = %42
store i32 0, i32* %11
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i32 @strlen(i8* %57)
%59 = icmp sge i32 %58, 100
br i1 %59, label %60, label %63
60: ; preds = %54
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %54
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = call %struct.passwd* @getpwnam(i8* %66)
store %struct.passwd* %67, %struct.passwd** %12
%68 = load %struct.passwd*, %struct.passwd** %12
%69 = icmp ne %struct.passwd* null, %68
br i1 %69, label %70, label %139
70: ; preds = %63
%71 = load %struct.passwd*, %struct.passwd** %12
%72 = getelementptr inbounds %struct.passwd, %struct.passwd* %71, i32 0, i32 0
%73 = load i8*, i8** %72
%74 = call %struct.spwd* @getspnam(i8* %73)
store %struct.spwd* %74, %struct.spwd** %13
%75 = load %struct.spwd*, %struct.spwd** %13
%76 = icmp ne %struct.spwd* null, %75
br i1 %76, label %77, label %138
77: ; preds = %70
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 2
%80 = load i8*, i8** %79
%81 = load %struct.spwd*, %struct.spwd** %13
%82 = getelementptr inbounds %struct.spwd, %struct.spwd* %81, i32 0, i32 0
%83 = load i32, i32* %82
%84 = call i64 @crypt(i8* %80, i32 %83)
%85 = inttoptr i64 %84 to i8*
store i8* %85, i8** %14
%86 = load %struct.spwd*, %struct.spwd** %13
%87 = getelementptr inbounds %struct.spwd, %struct.spwd* %86, i32 0, i32 0
%88 = load i32, i32* %87
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 2
%91 = load i8*, i8** %90
%92 = load %struct.spwd*, %struct.spwd** %13
%93 = getelementptr inbounds %struct.spwd, %struct.spwd* %92, i32 0, i32 0
%94 = load i32, i32* %93
%95 = call i64 @crypt(i8* %91, i32 %94)
%96 = call i64 @strcmp(i32 %88, i64 %95)
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %118
98: ; preds = %77
%99 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%100 = load %struct.passwd*, %struct.passwd** %12
%101 = getelementptr inbounds %struct.passwd, %struct.passwd* %100, i32 0, i32 0
%102 = load i8*, i8** %101
%103 = call i32 @strcat(i8* %99, i8* %102)
%104 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%105 = call i32 @strcat(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%106 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%107 = load i8*, i8** %6
%108 = call i32 @strcat(i8* %106, i8* %107)
%109 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%110 = call i32 @strcat(i8* %109, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%111 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%112 = load i32*, i32** %10
%113 = call i32 @fputs(i8* %111, i32* %112)
%114 = load i32*, i32** %10
%115 = call i32 @fclose(i32* %114)
%116 = load i32, i32* @EXIT_SUCCESS
%117 = call i32 @exit(i32 %116)
unreachable
118: ; preds = %77
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%120 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%121 = load %struct.passwd*, %struct.passwd** %12
%122 = getelementptr inbounds %struct.passwd, %struct.passwd* %121, i32 0, i32 0
%123 = load i8*, i8** %122
%124 = call i32 @strcat(i8* %120, i8* %123)
%125 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%126 = call i32 @strcat(i8* %125, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%127 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%128 = load i8*, i8** %6
%129 = call i32 @strcat(i8* %127, i8* %128)
%130 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%131 = call i32 @strcat(i8* %130, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%132 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%133 = load i32*, i32** %10
%134 = call i32 @fputs(i8* %132, i32* %133)
%135 = load i32*, i32** %10
%136 = call i32 @fclose(i32* %135)
%137 = call i32 @exit(i32 9)
unreachable
138: ; preds = %70
br label %162
139: ; preds = %63
%140 = load i8**, i8*** %5
%141 = getelementptr inbounds i8*, i8** %140, i64 1
%142 = load i8*, i8** %141
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %142)
%144 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%145 = load i8**, i8*** %5
%146 = getelementptr inbounds i8*, i8** %145, i64 1
%147 = load i8*, i8** %146
%148 = call i32 @strcat(i8* %144, i8* %147)
%149 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%150 = call i32 @strcat(i8* %149, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%151 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%152 = load i8*, i8** %6
%153 = call i32 @strcat(i8* %151, i8* %152)
%154 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%155 = call i32 @strcat(i8* %154, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%156 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%157 = load i32*, i32** %10
%158 = call i32 @fputs(i8* %156, i32* %157)
%159 = load i32*, i32** %10
%160 = call i32 @fclose(i32* %159)
%161 = call i32 @exit(i32 3)
unreachable
162: ; preds = %138
%163 = load i32, i32* @EXIT_SUCCESS
ret i32 %163
}

LLVM IR (-O2):
%struct.tm = type { i32 }
%struct.passwd = type { i8* }
%struct.spwd = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.2 = [30 x i8] c"Usage: %s user password [ip]\0A\00"
@.str.3 = [19 x i8] c"%Y-%m-%d %H:%M:%S \00"
@.str.4 = [30 x i8] c"/usr/local/vesta/log/auth.log\00"
@.str.5 = [3 x i8] c"a+\00"
@.str.8 = [2 x i8] c" \00"
@.str.9 = [26 x i8] c" successfully logged in \0A\00"
@EXIT_SUCCESS = global i32 0
@.str.11 = [19 x i8] c" failed to login \0A\00"
@str = [20 x i8] c"Error: no such user\00"
@str.13 = [26 x i8] c"Error: password missmatch\00"
@str.14 = [18 x i8] c"Too long username\00"
@str.15 = [56 x i8] c"Error: can not open file /usr/local/vesta/log/auth.log \00"
@str.16 = [16 x i8] c"Error: bad args\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [280 x i8]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.16, i64 0, i64 0))
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = icmp eq i32 %0, 3
br i1 %12, label %21, label %13
13: ; preds = %11
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i32 @strlen(i8* %15)
%17 = tail call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i8*
%19 = load i8*, i8** %14
%20 = tail call i32 @strcpy(i8* %18, i8* %19)
br label %21
21: ; preds = %13, %11
%22 = phi i8* [ %18, %13 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %11 ]
%23 = bitcast i32* %3 to i8*
%24 = tail call i32 @time(i32* null)
store i32 %24, i32* %3
%25 = call %struct.tm* @localtime(i32* %3)
%26 = getelementptr inbounds [280 x i8], [280 x i8]* %4, i64 0, i64 0
%27 = call i32 @strftime(i8* %26, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %25)
%28 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %21
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.15, i64 0, i64 0))
%32 = call i32 @exit(i32 12)
unreachable
33: ; preds = %21
%34 = getelementptr inbounds i8*, i8** %1, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strlen(i8* %35)
%37 = icmp sgt i32 %36, 99
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.14, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %33
%42 = load i8*, i8** %34
%43 = call %struct.passwd* @getpwnam(i8* %42)
%44 = icmp eq %struct.passwd* %43, null
br i1 %44, label %83, label %45
45: ; preds = %41
%46 = getelementptr inbounds %struct.passwd, %struct.passwd* %43, i64 0, i32 0
%47 = load i8*, i8** %46
%48 = call %struct.spwd* @getspnam(i8* %47)
%49 = icmp eq %struct.spwd* %48, null
br i1 %49, label %81, label %50
50: ; preds = %45
%51 = getelementptr inbounds i8*, i8** %1, i64 2
%52 = load i8*, i8** %51
%53 = getelementptr inbounds %struct.spwd, %struct.spwd* %48, i64 0, i32 0
%54 = load i32, i32* %53
%55 = call i64 @crypt(i8* %52, i32 %54)
%56 = load i32, i32* %53
%57 = load i8*, i8** %51
%58 = call i64 @crypt(i8* %57, i32 %56)
%59 = call i64 @strcmp(i32 %56, i64 %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %50
%62 = load i8*, i8** %46
%63 = call i32 @strcat(i8* %26, i8* %62)
%64 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%65 = call i32 @strcat(i8* %26, i8* %22)
%66 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%67 = call i32 @fputs(i8* %26, i32* %28)
%68 = call i32 @fclose(i32* %28)
%69 = load i32, i32* @EXIT_SUCCESS
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %50
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.13, i64 0, i64 0))
%73 = load i8*, i8** %46
%74 = call i32 @strcat(i8* %26, i8* %73)
%75 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%76 = call i32 @strcat(i8* %26, i8* %22)
%77 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%78 = call i32 @fputs(i8* %26, i32* %28)
%79 = call i32 @fclose(i32* %28)
%80 = call i32 @exit(i32 9)
unreachable
81: ; preds = %45
%82 = load i32, i32* @EXIT_SUCCESS
ret i32 %82
83: ; preds = %41
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%85 = load i8*, i8** %34
%86 = call i32 @strcat(i8* %26, i8* %85)
%87 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%88 = call i32 @strcat(i8* %26, i8* %22)
%89 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%90 = call i32 @fputs(i8* %26, i32* %28)
%91 = call i32 @fclose(i32* %28)
%92 = call i32 @exit(i32 3)
unreachable
}