#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 /*<<< orphan*/);
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 /*<<< orphan*/ 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 %s \n", argv[0]);
    exit(12);
  }
  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    131a <main+0x11a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0xc,%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <getpwnam@plt>
mov    %rax,-0x150(%rbp)
xor    %eax,%eax
cmp    -0x150(%rbp),%rax
je     14bd <main+0x2bd>
mov    -0x150(%rbp),%rax
mov    (%rax),%rdi
call   10f0 <getspnam@plt>
mov    %rax,-0x158(%rbp)
xor    %eax,%eax
cmp    -0x158(%rbp),%rax
je     14b8 <main+0x2b8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x158(%rbp),%rax
mov    (%rax),%esi
call   1050 <crypt@plt>
mov    %rax,-0x160(%rbp)
mov    -0x158(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x164(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x158(%rbp),%rax
mov    (%rax),%esi
call   1050 <crypt@plt>
mov    -0x164(%rbp),%edi
mov    %rax,%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1435 <main+0x235>
lea    -0x140(%rbp),%rdi
mov    -0x150(%rbp),%rax
mov    (%rax),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xc6a(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xc88(%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    0x2bb2(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x150(%rbp),%rax
mov    (%rax),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xbe3(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xc36(%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    1546 <main+0x346>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xc07(%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    0xb55(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xba8(%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    0x2a93(%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    12e1 <main+0xd1>
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     1309 <main+0xf9>
mov    %rax,%r15
mov    0x8(%r12),%rdi
call   10c0 <getpwnam@plt>
test   %rax,%rax
je     1325 <main+0x115>
mov    %rax,%r13
mov    (%rax),%rdi
call   1100 <getspnam@plt>
test   %rax,%rax
jne    1389 <main+0x179>
mov    0x2d12(%rip),%rax
mov    (%rax),%eax
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xded(%rip),%rdi
call   1050 <puts@plt>
mov    (%r12),%rsi
lea    0xd12(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    (%r12),%rsi
lea    0xd48(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xc,%edi
call   1130 <exit@plt>
lea    0xd7b(%rip),%rdi
call   1050 <puts@plt>
mov    0x8(%r12),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0xcef(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1120 <strcat@plt>
lea    0xd30(%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    1410 <main+0x200>
mov    0x0(%r13),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0xc6c(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1120 <strcat@plt>
lea    0xc93(%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    0x2bd7(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    0xca4(%rip),%rdi
call   1050 <puts@plt>
mov    0x0(%r13),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0xc05(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1120 <strcat@plt>
lea    0xc46(%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 = [30 x i8] c"Error: can not open file %s \0A\00"
@.str.7 = [2 x i8] c" \00"
@.str.8 = [26 x i8] c" successfully logged in \0A\00"
@EXIT_SUCCESS = global i32 0
@.str.9 = [27 x i8] c"Error: password missmatch\0A\00"
@.str.10 = [19 x i8] c" failed to login \0A\00"
@.str.11 = [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 %struct.passwd*
%12 = alloca %struct.spwd*
%13 = 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
%14 = load i32, i32* %4
%15 = icmp sgt i32 3, %14
br i1 %15, label %16, label %26
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i32, i32* %4
%28 = icmp sle i32 4, %27
br i1 %28, label %29, label %41
29: ; preds = %26
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32 @strlen(i8* %32)
%34 = call i64 @malloc(i32 %33)
%35 = inttoptr i64 %34 to i8*
store i8* %35, i8** %6
%36 = load i8*, i8** %6
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
%40 = call i32 @strcpy(i8* %36, i8* %39)
br label %41
41: ; preds = %29, %26
%42 = call i32 @time(i32* null)
store i32 %42, i32* %7
%43 = call %struct.tm* @localtime(i32* %7)
store %struct.tm* %43, %struct.tm** %8
%44 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%45 = load %struct.tm*, %struct.tm** %8
%46 = call i32 @strftime(i8* %44, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %45)
%47 = 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* %47, i32** %10
%48 = load i32*, i32** %10
%49 = icmp eq i32* null, %48
br i1 %49, label %50, label %56
50: ; preds = %41
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 0
%53 = load i8*, i8** %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %53)
%55 = call i32 @exit(i32 12)
unreachable
56: ; preds = %41
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = call %struct.passwd* @getpwnam(i8* %59)
store %struct.passwd* %60, %struct.passwd** %11
%61 = load %struct.passwd*, %struct.passwd** %11
%62 = icmp ne %struct.passwd* null, %61
br i1 %62, label %63, label %132
63: ; preds = %56
%64 = load %struct.passwd*, %struct.passwd** %11
%65 = getelementptr inbounds %struct.passwd, %struct.passwd* %64, i32 0, i32 0
%66 = load i8*, i8** %65
%67 = call %struct.spwd* @getspnam(i8* %66)
store %struct.spwd* %67, %struct.spwd** %12
%68 = load %struct.spwd*, %struct.spwd** %12
%69 = icmp ne %struct.spwd* null, %68
br i1 %69, label %70, label %131
70: ; preds = %63
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = load %struct.spwd*, %struct.spwd** %12
%75 = getelementptr inbounds %struct.spwd, %struct.spwd* %74, i32 0, i32 0
%76 = load i32, i32* %75
%77 = call i64 @crypt(i8* %73, i32 %76)
%78 = inttoptr i64 %77 to i8*
store i8* %78, i8** %13
%79 = load %struct.spwd*, %struct.spwd** %12
%80 = getelementptr inbounds %struct.spwd, %struct.spwd* %79, i32 0, i32 0
%81 = load i32, i32* %80
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 2
%84 = load i8*, i8** %83
%85 = load %struct.spwd*, %struct.spwd** %12
%86 = getelementptr inbounds %struct.spwd, %struct.spwd* %85, i32 0, i32 0
%87 = load i32, i32* %86
%88 = call i64 @crypt(i8* %84, i32 %87)
%89 = call i64 @strcmp(i32 %81, i64 %88)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %111
91: ; preds = %70
%92 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%93 = load %struct.passwd*, %struct.passwd** %11
%94 = getelementptr inbounds %struct.passwd, %struct.passwd* %93, i32 0, i32 0
%95 = load i8*, i8** %94
%96 = call i32 @strcat(i8* %92, i8* %95)
%97 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%98 = call i32 @strcat(i8* %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%99 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%100 = load i8*, i8** %6
%101 = call i32 @strcat(i8* %99, i8* %100)
%102 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%103 = call i32 @strcat(i8* %102, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%104 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%105 = load i32*, i32** %10
%106 = call i32 @fputs(i8* %104, i32* %105)
%107 = load i32*, i32** %10
%108 = call i32 @fclose(i32* %107)
%109 = load i32, i32* @EXIT_SUCCESS
%110 = call i32 @exit(i32 %109)
unreachable
111: ; preds = %70
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%113 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%114 = load %struct.passwd*, %struct.passwd** %11
%115 = getelementptr inbounds %struct.passwd, %struct.passwd* %114, i32 0, i32 0
%116 = load i8*, i8** %115
%117 = call i32 @strcat(i8* %113, i8* %116)
%118 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%119 = call i32 @strcat(i8* %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%120 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%121 = load i8*, i8** %6
%122 = call i32 @strcat(i8* %120, i8* %121)
%123 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%124 = call i32 @strcat(i8* %123, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%125 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%126 = load i32*, i32** %10
%127 = call i32 @fputs(i8* %125, i32* %126)
%128 = load i32*, i32** %10
%129 = call i32 @fclose(i32* %128)
%130 = call i32 @exit(i32 9)
unreachable
131: ; preds = %63
br label %155
132: ; preds = %56
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 1
%135 = load i8*, i8** %134
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %135)
%137 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%138 = load i8**, i8*** %5
%139 = getelementptr inbounds i8*, i8** %138, i64 1
%140 = load i8*, i8** %139
%141 = call i32 @strcat(i8* %137, i8* %140)
%142 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%143 = call i32 @strcat(i8* %142, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%144 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%145 = load i8*, i8** %6
%146 = call i32 @strcat(i8* %144, i8* %145)
%147 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%148 = call i32 @strcat(i8* %147, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%149 = getelementptr inbounds [280 x i8], [280 x i8]* %9, i64 0, i64 0
%150 = load i32*, i32** %10
%151 = call i32 @fputs(i8* %149, i32* %150)
%152 = load i32*, i32** %10
%153 = call i32 @fclose(i32* %152)
%154 = call i32 @exit(i32 3)
unreachable
155: ; preds = %131
%156 = load i32, i32* @EXIT_SUCCESS
ret i32 %156
}

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.6 = [30 x i8] c"Error: can not open file %s \0A\00"
@.str.7 = [2 x i8] c" \00"
@.str.8 = [26 x i8] c" successfully logged in \0A\00"
@EXIT_SUCCESS = global i32 0
@.str.10 = [19 x i8] c" failed to login \0A\00"
@str = [20 x i8] c"Error: no such user\00"
@str.12 = [26 x i8] c"Error: password missmatch\00"
@str.13 = [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.13, 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 %34
30: ; preds = %21
%31 = load i8*, i8** %1
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 12)
unreachable
34: ; preds = %21
%35 = getelementptr inbounds i8*, i8** %1, i64 1
%36 = load i8*, i8** %35
%37 = call %struct.passwd* @getpwnam(i8* %36)
%38 = icmp eq %struct.passwd* %37, null
br i1 %38, label %77, label %39
39: ; preds = %34
%40 = getelementptr inbounds %struct.passwd, %struct.passwd* %37, i64 0, i32 0
%41 = load i8*, i8** %40
%42 = call %struct.spwd* @getspnam(i8* %41)
%43 = icmp eq %struct.spwd* %42, null
br i1 %43, label %75, label %44
44: ; preds = %39
%45 = getelementptr inbounds i8*, i8** %1, i64 2
%46 = load i8*, i8** %45
%47 = getelementptr inbounds %struct.spwd, %struct.spwd* %42, i64 0, i32 0
%48 = load i32, i32* %47
%49 = call i64 @crypt(i8* %46, i32 %48)
%50 = load i32, i32* %47
%51 = load i8*, i8** %45
%52 = call i64 @crypt(i8* %51, i32 %50)
%53 = call i64 @strcmp(i32 %50, i64 %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %65
55: ; preds = %44
%56 = load i8*, i8** %40
%57 = call i32 @strcat(i8* %26, i8* %56)
%58 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%59 = call i32 @strcat(i8* %26, i8* %22)
%60 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%61 = call i32 @fputs(i8* %26, i32* %28)
%62 = call i32 @fclose(i32* %28)
%63 = load i32, i32* @EXIT_SUCCESS
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %44
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.12, i64 0, i64 0))
%67 = load i8*, i8** %40
%68 = call i32 @strcat(i8* %26, i8* %67)
%69 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%70 = call i32 @strcat(i8* %26, i8* %22)
%71 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%72 = call i32 @fputs(i8* %26, i32* %28)
%73 = call i32 @fclose(i32* %28)
%74 = call i32 @exit(i32 9)
unreachable
75: ; preds = %39
%76 = load i32, i32* @EXIT_SUCCESS
ret i32 %76
77: ; preds = %34
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%79 = load i8*, i8** %35
%80 = call i32 @strcat(i8* %26, i8* %79)
%81 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%82 = call i32 @strcat(i8* %26, i8* %22)
%83 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%84 = call i32 @fputs(i8* %26, i32* %28)
%85 = call i32 @fclose(i32* %28)
%86 = call i32 @exit(i32 3)
unreachable
}