#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;
  char *pw_passwd;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int SHA_DIGEST_LENGTH;
char *crypt(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
struct passwd *get_passwd(int /*<<< orphan*/ *, int);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ pw_encrypt(unsigned char *, char *);
int /*<<< orphan*/ pw_encrypt_new(unsigned char *, unsigned char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  FILE *fp;
  struct passwd *buf;
  int ftpd, filelen, z = 0;
  char *crypted;
  char salt[2];
  char *filename;
  if (argc > 1 && strcmp(argv[1], "-c") == 0) {
    z = 1;
    ftpd = 0x02;
  } else {
    ftpd = 0x01;
  }
  if (argc == 4 && ftpd == 0x01) {
    if ((fp = fopen(argv[3], "r")) == NULL) {
      printf("Ooops, couldn\'t open your passwd file.\n");
      printf("Looks like you didnt specify a correct path.\n");
      return 1;
    }
  } else if (argc == 5 && ftpd == 0x02) {
    filelen = strlen(argv[2]) + strlen(argv[4]) + 2;
    filename = malloc(filelen);
    sprintf(filename, "%s/%s", argv[4], argv[2]);
    filename[filelen - 1] = '\0';
    if ((fp = fopen(filename, "r")) == NULL) {
      printf("Ooops, couldn\'t open the user file.\n");
      printf("Looks like you didnt specify a correct user or path.\n");
      return 1;
    }
  } else {
    printf("Usage: %s <user> <pass> <passwdfile>\n", argv[0]);
    printf("       %s -c <user> <pass> <userfilepath>\n", argv[0]);
    return 1;
  }
  while ((buf = get_passwd(fp, ftpd)) != NULL) {
    if (strcmp(buf->pw_name, argv[z + 1]))
      continue;
    if ((int)strlen(buf->pw_passwd) == 13) {
      strncpy(salt, buf->pw_passwd, 2);
      crypted = crypt(argv[z + 2], salt);
    } else if ((int)strlen(buf->pw_passwd) == SHA_DIGEST_LENGTH * 2) {
      crypted = malloc(SHA_DIGEST_LENGTH * 2 + 1);
      if (!crypted) {
        printf("Ooops, couldn't allocate %d bytes of memory for hash.\n",
               (SHA_DIGEST_LENGTH * 2 + 1));
        return 1;
      }
      pw_encrypt((unsigned char *)argv[z + 2], crypted);
    } else if ((int)strlen(buf->pw_passwd) == 50) {
      crypted = malloc(51);
      if (!crypted) {
        printf("Ooops, couldn't allocate %d bytes of memory for hash.\n",
               (SHA_DIGEST_LENGTH * 2 + 1));
        return 1;
      }
      pw_encrypt_new((unsigned char *)argv[z + 2],
                     (unsigned char *)buf->pw_passwd, crypted);
    } else {
      printf("Ooops, password is of invalid length! (not gl1 nor gl2).\n");
      return 1;
    }
    if (strcmp(buf->pw_passwd, crypted) == 0) {
      printf("MATCH\n");
      return 0;
    } else {
      printf("NOMATCH\n");
      return 0;
    }
  }
  printf("No such user in passwd file!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1208 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1a(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1208 <main+0x58>
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x24(%rbp)
jmp    120f <main+0x5f>
movl   $0x1,-0x24(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    1272 <main+0xc2>
cmpl   $0x1,-0x24(%rbp)
jne    1272 <main+0xc2>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdd1(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    126d <main+0xbd>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15a0 <main+0x3f0>
jmp    1373 <main+0x1c3>
cmpl   $0x5,-0x8(%rbp)
jne    1338 <main+0x188>
cmpl   $0x2,-0x24(%rbp)
jne    1338 <main+0x188>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   10b0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xd84(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x48(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x48(%rbp),%rdi
lea    0xd0b(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1333 <main+0x183>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15a0 <main+0x3f0>
jmp    136e <main+0x1be>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15a0 <main+0x3f0>
jmp    1373 <main+0x1c3>
jmp    1378 <main+0x1c8>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1060 <get_passwd@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     158b <main+0x3db>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     13be <main+0x20e>
jmp    1378 <main+0x1c8>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <strlen@plt>
cmp    $0xd,%eax
jne    140d <main+0x25d>
lea    -0x3a(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x2,%edx
call   1040 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x3a(%rbp),%rsi
call   1070 <crypt@plt>
mov    %rax,-0x38(%rbp)
jmp    153c <main+0x38c>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <strlen@plt>
mov    0x2bc7(%rip),%rcx
mov    (%rcx),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jne    1499 <main+0x2e9>
mov    0x2bb3(%rip),%rax
mov    (%rax),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    147a <main+0x2ca>
mov    0x2b90(%rip),%rax
mov    (%rax),%esi
shl    $0x1,%esi
add    $0x1,%esi
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15a0 <main+0x3f0>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <pw_encrypt@plt>
jmp    1537 <main+0x387>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <strlen@plt>
cmp    $0x32,%eax
jne    1518 <main+0x368>
mov    $0x33,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    14f1 <main+0x341>
mov    0x2b19(%rip),%rax
mov    (%rax),%esi
shl    $0x1,%esi
add    $0x1,%esi
lea    0xc2f(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15a0 <main+0x3f0>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <pw_encrypt_new@plt>
jmp    1532 <main+0x382>
lea    0xc25(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15a0 <main+0x3f0>
jmp    1537 <main+0x387>
jmp    153c <main+0x38c>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x38(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1571 <main+0x3c1>
lea    0xc22(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15a0 <main+0x3f0>
lea    0xc06(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15a0 <main+0x3f0>
lea    0xbf5(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
jl     1308 <main+0x148>
mov    %edi,%ebx
mov    0x8(%r14),%rdi
lea    0xe1c(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     121e <main+0x5e>
cmp    $0x4,%ebx
jne    1308 <main+0x148>
mov    0x18(%r14),%rdi
lea    0xe01(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     134a <main+0x18a>
mov    %rax,%r15
mov    $0x1,%r13d
xor    %r12d,%r12d
jmp    1292 <main+0xd2>
cmp    $0x5,%ebx
jne    1308 <main+0x148>
mov    0x10(%r14),%rdi
call   1090 <strlen@plt>
mov    %eax,%ebx
mov    0x20(%r14),%rdi
call   1090 <strlen@plt>
lea    (%rax,%rbx,1),%ebp
lea    (%rax,%rbx,1),%edi
add    $0x2,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%r14),%rcx
mov    0x20(%r14),%rdx
lea    0xdaa(%rip),%rsi
mov    %rax,%rdi
call   10e0 <sprintf@plt>
movslq %ebp,%rax
movb   $0x0,0x1(%rax,%rbx,1)
lea    0xd91(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13a5 <main+0x1e5>
mov    %rax,%r15
mov    $0x2,%r13d
mov    $0x1,%r12d
lea    0x1(%r12),%ebp
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13d,%esi
call   1060 <get_passwd@plt>
test   %rax,%rax
je     133e <main+0x17e>
mov    %rax,%rbx
mov    (%rax),%rdi
mov    (%r14,%rbp,8),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    12a0 <main+0xe0>
mov    0x8(%rbx),%rdi
call   1090 <strlen@plt>
mov    0x8(%rbx),%rsi
cmp    $0xd,%eax
jne    1362 <main+0x1a2>
lea    0x6(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x2,%edx
call   1040 <strncpy@plt>
or     $0x2,%r12d
mov    (%r14,%r12,8),%rdi
mov    %rbp,%rsi
call   1080 <crypt@plt>
mov    %rax,%r15
jmp    13ee <main+0x22e>
mov    (%r14),%rsi
lea    0xcf9(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    (%r14),%rsi
lea    0xd0e(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd4e(%rip),%rdi
jmp    140f <main+0x24f>
lea    0xdf9(%rip),%rdi
call   1070 <puts@plt>
lea    0xe14(%rip),%rdi
jmp    1422 <main+0x262>
mov    %rsi,%rdi
call   1090 <strlen@plt>
mov    %eax,%ebp
mov    0x2c75(%rip),%r13
mov    0x0(%r13),%eax
add    %eax,%eax
cmp    %eax,%ebp
jne    13ba <main+0x1fa>
or     $0x1,%ebp
mov    %ebp,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     142c <main+0x26c>
mov    %rax,%r15
or     $0x2,%r12d
mov    (%r14,%r12,8),%rdi
mov    %rax,%rsi
call   1050 <pw_encrypt@plt>
jmp    13ee <main+0x22e>
lea    0xd45(%rip),%rdi
call   1070 <puts@plt>
lea    0xd5d(%rip),%rdi
jmp    1422 <main+0x262>
mov    0x8(%rbx),%rdi
call   1090 <strlen@plt>
cmp    $0x32,%eax
jne    141b <main+0x25b>
mov    $0x33,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     1437 <main+0x277>
mov    %rax,%r15
or     $0x2,%r12d
mov    (%r14,%r12,8),%rdi
mov    0x8(%rbx),%rsi
mov    %rax,%rdx
call   1030 <pw_encrypt_new@plt>
mov    0x8(%rbx),%rdi
mov    %r15,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1408 <main+0x248>
lea    0xce3(%rip),%rdi
jmp    140f <main+0x24f>
lea    0xcdc(%rip),%rdi
call   1070 <puts@plt>
xor    %eax,%eax
jmp    132f <main+0x16f>
lea    0xc8e(%rip),%rdi
call   1070 <puts@plt>
jmp    132a <main+0x16a>
lea    0xc29(%rip),%rdi
mov    %ebp,%esi
jmp    1448 <main+0x288>
mov    0x0(%r13),%eax
lea    (%rax,%rax,1),%esi
add    $0x1,%esi
lea    0xc14(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    132a <main+0x16a>

LLVM IR (-O0):
%struct.passwd = type { i8*, i8* }
@.str = [3 x i8] c"-c\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [40 x i8] c"Ooops, couldn't open your passwd file.\0A\00"
@.str.3 = [46 x i8] c"Looks like you didnt specify a correct path.\0A\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [37 x i8] c"Ooops, couldn't open the user file.\0A\00"
@.str.6 = [54 x i8] c"Looks like you didnt specify a correct user or path.\0A\00"
@.str.7 = [38 x i8] c"Usage: %s <user> <pass> <passwdfile>\0A\00"
@.str.8 = [43 x i8] c" %s -c <user> <pass> <userfilepath>\0A\00"
@SHA_DIGEST_LENGTH = global i32 0
@.str.9 = [55 x i8] c"Ooops, couldn't allocate %d bytes of memory for hash.\0A\00"
@.str.10 = [58 x i8] c"Ooops, password is of invalid length! (not gl1 nor gl2).\0A\00"
@.str.11 = [7 x i8] c"MATCH\0A\00"
@.str.12 = [9 x i8] c"NOMATCH\0A\00"
@.str.13 = [30 x i8] c"No such user in passwd file!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.passwd*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca [2 x i8]
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 1, i32* %10
store i32 2, i32* %8
br label %24
23: ; preds = %16, %2
store i32 1, i32* %8
br label %24
24: ; preds = %23, %22
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 4
br i1 %26, label %27, label %40
27: ; preds = %24
%28 = load i32, i32* %8
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %40
30: ; preds = %27
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %34, i32** %6
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %201
39: ; preds = %30
br label %89
40: ; preds = %27, %24
%41 = load i32, i32* %4
%42 = icmp eq i32 %41, 5
br i1 %42, label %43, label %79
43: ; preds = %40
%44 = load i32, i32* %8
%45 = icmp eq i32 %44, 2
br i1 %45, label %46, label %79
46: ; preds = %43
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = call i32 @strlen(i8* %49)
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 4
%53 = load i8*, i8** %52
%54 = call i32 @strlen(i8* %53)
%55 = add nsw i32 %50, %54
%56 = add nsw i32 %55, 2
store i32 %56, i32* %9
%57 = load i32, i32* %9
%58 = call i8* @malloc(i32 %57)
store i8* %58, i8** %13
%59 = load i8*, i8** %13
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 4
%62 = load i8*, i8** %61
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = call i32 @sprintf(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %62, i8* %65)
%67 = load i8*, i8** %13
%68 = load i32, i32* %9
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
store i8 0, i8* %71
%72 = load i8*, i8** %13
%73 = call i32* @fopen(i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %73, i32** %6
%74 = icmp eq i32* %73, null
br i1 %74, label %75, label %78
75: ; preds = %46
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %201
78: ; preds = %46
br label %88
79: ; preds = %43, %40
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 0
%82 = load i8*, i8** %81
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i8* %82)
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 0
%86 = load i8*, i8** %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i8* %86)
store i32 1, i32* %3
br label %201
88: ; preds = %78
br label %89
89: ; preds = %88, %39
br label %90
90: ; preds = %107, %89
%91 = load i32*, i32** %6
%92 = load i32, i32* %8
%93 = call %struct.passwd* @get_passwd(i32* %91, i32 %92)
store %struct.passwd* %93, %struct.passwd** %7
%94 = icmp ne %struct.passwd* %93, null
br i1 %94, label %95, label %199
95: ; preds = %90
%96 = load %struct.passwd*, %struct.passwd** %7
%97 = getelementptr inbounds %struct.passwd, %struct.passwd* %96, i32 0, i32 0
%98 = load i8*, i8** %97
%99 = load i8**, i8*** %5
%100 = load i32, i32* %10
%101 = add nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8*, i8** %99, i64 %102
%104 = load i8*, i8** %103
%105 = call i64 @strcmp(i8* %98, i8* %104)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %108
107: ; preds = %95
br label %90
108: ; preds = %95
%109 = load %struct.passwd*, %struct.passwd** %7
%110 = getelementptr inbounds %struct.passwd, %struct.passwd* %109, i32 0, i32 1
%111 = load i8*, i8** %110
%112 = call i32 @strlen(i8* %111)
%113 = icmp eq i32 %112, 13
br i1 %113, label %114, label %128
114: ; preds = %108
%115 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%116 = load %struct.passwd*, %struct.passwd** %7
%117 = getelementptr inbounds %struct.passwd, %struct.passwd* %116, i32 0, i32 1
%118 = load i8*, i8** %117
%119 = call i32 @strncpy(i8* %115, i8* %118, i32 2)
%120 = load i8**, i8*** %5
%121 = load i32, i32* %10
%122 = add nsw i32 %121, 2
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8*, i8** %120, i64 %123
%125 = load i8*, i8** %124
%126 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%127 = call i8* @crypt(i8* %125, i8* %126)
store i8* %127, i8** %11
br label %188
128: ; preds = %108
%129 = load %struct.passwd*, %struct.passwd** %7
%130 = getelementptr inbounds %struct.passwd, %struct.passwd* %129, i32 0, i32 1
%131 = load i8*, i8** %130
%132 = call i32 @strlen(i8* %131)
%133 = load i32, i32* @SHA_DIGEST_LENGTH
%134 = mul nsw i32 %133, 2
%135 = icmp eq i32 %132, %134
br i1 %135, label %136, label %157
136: ; preds = %128
%137 = load i32, i32* @SHA_DIGEST_LENGTH
%138 = mul nsw i32 %137, 2
%139 = add nsw i32 %138, 1
%140 = call i8* @malloc(i32 %139)
store i8* %140, i8** %11
%141 = load i8*, i8** %11
%142 = icmp ne i8* %141, null
br i1 %142, label %148, label %143
143: ; preds = %136
%144 = load i32, i32* @SHA_DIGEST_LENGTH
%145 = mul nsw i32 %144, 2
%146 = add nsw i32 %145, 1
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0), i32 %146)
store i32 1, i32* %3
br label %201
148: ; preds = %136
%149 = load i8**, i8*** %5
%150 = load i32, i32* %10
%151 = add nsw i32 %150, 2
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i8*, i8** %149, i64 %152
%154 = load i8*, i8** %153
%155 = load i8*, i8** %11
%156 = call i32 @pw_encrypt(i8* %154, i8* %155)
br label %187
157: ; preds = %128
%158 = load %struct.passwd*, %struct.passwd** %7
%159 = getelementptr inbounds %struct.passwd, %struct.passwd* %158, i32 0, i32 1
%160 = load i8*, i8** %159
%161 = call i32 @strlen(i8* %160)
%162 = icmp eq i32 %161, 50
br i1 %162, label %163, label %184
163: ; preds = %157
%164 = call i8* @malloc(i32 51)
store i8* %164, i8** %11
%165 = load i8*, i8** %11
%166 = icmp ne i8* %165, null
br i1 %166, label %172, label %167
167: ; preds = %163
%168 = load i32, i32* @SHA_DIGEST_LENGTH
%169 = mul nsw i32 %168, 2
%170 = add nsw i32 %169, 1
%171 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0), i32 %170)
store i32 1, i32* %3
br label %201
172: ; preds = %163
%173 = load i8**, i8*** %5
%174 = load i32, i32* %10
%175 = add nsw i32 %174, 2
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds i8*, i8** %173, i64 %176
%178 = load i8*, i8** %177
%179 = load %struct.passwd*, %struct.passwd** %7
%180 = getelementptr inbounds %struct.passwd, %struct.passwd* %179, i32 0, i32 1
%181 = load i8*, i8** %180
%182 = load i8*, i8** %11
%183 = call i32 @pw_encrypt_new(i8* %178, i8* %181, i8* %182)
br label %186
184: ; preds = %157
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %201
186: ; preds = %172
br label %187
187: ; preds = %186, %148
br label %188
188: ; preds = %187, %114
%189 = load %struct.passwd*, %struct.passwd** %7
%190 = getelementptr inbounds %struct.passwd, %struct.passwd* %189, i32 0, i32 1
%191 = load i8*, i8** %190
%192 = load i8*, i8** %11
%193 = call i64 @strcmp(i8* %191, i8* %192)
%194 = icmp eq i64 %193, 0
br i1 %194, label %195, label %197
195: ; preds = %188
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %3
br label %201
197: ; preds = %188
%198 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %3
br label %201
199: ; preds = %90
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %3
br label %201
201: ; preds = %199, %197, %195, %184, %167, %143, %79, %75, %36
%202 = load i32, i32* %3
ret i32 %202
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8* }
@.str = [3 x i8] c"-c\00"
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.7 = [38 x i8] c"Usage: %s <user> <pass> <passwdfile>\0A\00"
@.str.8 = [43 x i8] c" %s -c <user> <pass> <userfilepath>\0A\00"
@SHA_DIGEST_LENGTH = global i32 0
@.str.9 = [55 x i8] c"Ooops, couldn't allocate %d bytes of memory for hash.\0A\00"
@str = [29 x i8] c"No such user in passwd file!\00"
@str.14 = [57 x i8] c"Ooops, password is of invalid length! (not gl1 nor gl2).\00"
@str.15 = [8 x i8] c"NOMATCH\00"
@str.16 = [6 x i8] c"MATCH\00"
@str.17 = [36 x i8] c"Ooops, couldn't open the user file.\00"
@str.18 = [53 x i8] c"Looks like you didnt specify a correct user or path.\00"
@str.19 = [39 x i8] c"Ooops, couldn't open your passwd file.\00"
@str.20 = [45 x i8] c"Looks like you didnt specify a correct path.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i8]
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %44
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %6
%12 = icmp eq i32 %0, 4
br i1 %12, label %13, label %44
13: ; preds = %11
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %49
18: ; preds = %13
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.19, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.20, i64 0, i64 0))
br label %127
21: ; preds = %6
%22 = icmp eq i32 %0, 5
br i1 %22, label %23, label %44
23: ; preds = %21
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @strlen(i8* %25)
%27 = getelementptr inbounds i8*, i8** %1, i64 4
%28 = load i8*, i8** %27
%29 = tail call i32 @strlen(i8* %28)
%30 = add nsw i32 %29, %26
%31 = add nsw i32 %30, 2
%32 = tail call i8* @malloc(i32 %31)
%33 = load i8*, i8** %27
%34 = load i8*, i8** %24
%35 = tail call i32 @sprintf(i8* dereferenceable(1) %32, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %33, i8* %34)
%36 = add nsw i32 %30, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %32, i64 %37
store i8 0, i8* %38
%39 = tail call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %49
41: ; preds = %23
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.17, i64 0, i64 0))
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.18, i64 0, i64 0))
br label %127
44: ; preds = %2, %11, %21
%45 = load i8*, i8** %1
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i8* %45)
%47 = load i8*, i8** %1
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i8* %47)
br label %127
49: ; preds = %23, %13
%50 = phi i32 [ 0, %13 ], [ 1, %23 ]
%51 = phi i32 [ 1, %13 ], [ 2, %23 ]
%52 = phi i32* [ %16, %13 ], [ %39, %23 ]
%53 = add nuw nsw i32 %50, 1
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %1, i64 %54
br label %56
56: ; preds = %59, %49
%57 = tail call %struct.passwd* @get_passwd(i32* %52, i32 %51)
%58 = icmp eq %struct.passwd* %57, null
br i1 %58, label %125, label %59
59: ; preds = %56
%60 = getelementptr inbounds %struct.passwd, %struct.passwd* %57, i64 0, i32 0
%61 = load i8*, i8** %60
%62 = load i8*, i8** %55
%63 = tail call i64 @strcmp(i8* %61, i8* %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %56
65: ; preds = %59
%66 = getelementptr inbounds %struct.passwd, %struct.passwd* %57, i64 0, i32 1
%67 = load i8*, i8** %66
%68 = tail call i32 @strlen(i8* %67)
%69 = icmp eq i32 %68, 13
%70 = load i8*, i8** %66
br i1 %69, label %71, label %78
71: ; preds = %65
%72 = call i32 @strncpy(i8* %4, i8* %70, i32 2)
%73 = or i32 %50, 2
%74 = zext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %1, i64 %74
%76 = load i8*, i8** %75
%77 = call i8* @crypt(i8* %76, i8* %4)
br label %116
78: ; preds = %65
%79 = tail call i32 @strlen(i8* %70)
%80 = load i32, i32* @SHA_DIGEST_LENGTH
%81 = shl nsw i32 %80, 1
%82 = icmp eq i32 %79, %81
br i1 %82, label %83, label %95
83: ; preds = %78
%84 = or i32 %79, 1
%85 = tail call i8* @malloc(i32 %84)
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0), i32 %84)
br label %127
89: ; preds = %83
%90 = or i32 %50, 2
%91 = zext i32 %90 to i64
%92 = getelementptr inbounds i8*, i8** %1, i64 %91
%93 = load i8*, i8** %92
%94 = tail call i32 @pw_encrypt(i8* %93, i8* %85)
br label %116
95: ; preds = %78
%96 = load i8*, i8** %66
%97 = tail call i32 @strlen(i8* %96)
%98 = icmp eq i32 %97, 50
br i1 %98, label %99, label %114
99: ; preds = %95
%100 = tail call dereferenceable_or_null(51) i8* @malloc(i32 51)
%101 = icmp eq i8* %100, null
br i1 %101, label %102, label %107
102: ; preds = %99
%103 = load i32, i32* @SHA_DIGEST_LENGTH
%104 = shl nsw i32 %103, 1
%105 = or i32 %104, 1
%106 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0), i32 %105)
br label %127
107: ; preds = %99
%108 = or i32 %50, 2
%109 = zext i32 %108 to i64
%110 = getelementptr inbounds i8*, i8** %1, i64 %109
%111 = load i8*, i8** %110
%112 = load i8*, i8** %66
%113 = tail call i32 @pw_encrypt_new(i8* %111, i8* %112, i8* %100)
br label %116
114: ; preds = %95
%115 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.14, i64 0, i64 0))
br label %127
116: ; preds = %89, %107, %71
%117 = phi i8* [ %77, %71 ], [ %85, %89 ], [ %100, %107 ]
%118 = load i8*, i8** %66
%119 = call i64 @strcmp(i8* %118, i8* %117)
%120 = icmp eq i64 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %116
%122 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.16, i64 0, i64 0))
br label %127
123: ; preds = %116
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.15, i64 0, i64 0))
br label %127
125: ; preds = %56
%126 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %127
127: ; preds = %125, %123, %121, %114, %102, %87, %44, %41, %18
%128 = phi i32 [ 1, %18 ], [ 0, %121 ], [ 0, %123 ], [ 1, %87 ], [ 1, %102 ], [ 1, %114 ], [ 0, %125 ], [ 1, %41 ], [ 1, %44 ]
ret i32 %128
}