#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 */

/* Variables and functions */
scalar_t__ crypt(char const *, char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
int CmpCryptWord(const char *salt, const char *genpass, const char *pass) {
  char *hash;
  hash = (char *)crypt(genpass, salt);
  if (!hash) {
    perror("Crypt");
    exit(1);
  }
  char newpass[25];
  int len = strlen(salt);
  strcpy(newpass, hash + len);
  if (strcmp(pass, newpass) == 0)
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<CmpCryptWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a6 <CmpCryptWord+0x46>
lea    0xe69(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x54(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x54(%rbp),%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e9 <CmpCryptWord+0x89>
movl   $0x1,-0x4(%rbp)
jmp    11f0 <CmpCryptWord+0x90>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CmpCryptWord>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1040 <crypt@plt>
test   %rax,%rax
je     11bc <CmpCryptWord+0x5c>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe3d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"Crypt\00"
define i32 @CmpCryptWord(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [25 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %6
%12 = load i8*, i8** %5
%13 = call i64 @crypt(i8* %11, i8* %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %8
%15 = load i8*, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %3
%18 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %3
%21 = load i8*, i8** %5
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %10
%23 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%24 = load i8*, i8** %8
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = call i32 @strcpy(i8* %23, i8* %27)
%29 = load i8*, i8** %7
%30 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%31 = call i64 @strcmp(i8* %29, i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %20
store i32 1, i32* %4
br label %35
34: ; preds = %20
store i32 0, i32* %4
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [6 x i8] c"Crypt\00"
define i32 @CmpCryptWord(i8* %0, i8* %1, i8* %2) {
%4 = alloca [25 x i8]
%5 = tail call i64 @crypt(i8* %1, i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = inttoptr i64 %5 to i8*
%12 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%13 = tail call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = call i32 @strcpy(i8* %12, i8* %15)
%17 = call i64 @strcmp(i8* %2, i8* %12)
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
ret i32 %19
}