#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 */
char *crypt(char const *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *pw_encrypt(const char *clear, const char *salt) {
  static char cipher[128];
  char *cp;
  cp = crypt(clear, salt);
  if (!cp) {
    return (NULL);
  }
  if ((NULL != salt) && (salt[0] == '$') && (strlen(cp) <= 13)) {
    return (NULL);
  }
  if (strlen(cp) != 13) {
    return cp;
  }
  strcpy(cipher, cp);
  return cipher;
}


x86 assembly (clang, -O0):
<pw_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1169 <pw_encrypt+0x39>
movq   $0x0,-0x8(%rbp)
jmp    11de <pw_encrypt+0xae>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     11a4 <pw_encrypt+0x74>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    11a4 <pw_encrypt+0x74>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0xd,%eax
jg     11a4 <pw_encrypt+0x74>
movq   $0x0,-0x8(%rbp)
jmp    11de <pw_encrypt+0xae>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0xd,%eax
je     11c3 <pw_encrypt+0x93>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11de <pw_encrypt+0xae>
mov    -0x20(%rbp),%rsi
lea    0x2e82(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2e76(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pw_encrypt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1040 <crypt@plt>
test   %rax,%rax
je     115b <pw_encrypt+0x2b>
mov    %rax,%r14
test   %rbx,%rbx
je     1160 <pw_encrypt+0x30>
cmpb   $0x24,(%rbx)
jne    1160 <pw_encrypt+0x30>
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    $0xe,%eax
jge    1160 <pw_encrypt+0x30>
xor    %r14d,%r14d
jmp    1182 <pw_encrypt+0x52>
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    $0xd,%eax
jne    1182 <pw_encrypt+0x52>
lea    0x2edc(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@pw_encrypt.cipher = internal global [128 x i8] zeroinitializer
define i8* @pw_encrypt(i8* %0, i8* %1) {
%3 = tail call i8* @crypt(i8* %0, i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = icmp eq i8* %1, null
br i1 %6, label %13, label %7
7: ; preds = %5
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 36
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = tail call i32 @strlen(i8* %3)
%12 = icmp slt i32 %11, 14
br i1 %12, label %18, label %13
13: ; preds = %10, %7, %5
%14 = tail call i32 @strlen(i8* %3)
%15 = icmp eq i32 %14, 13
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @strcpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @pw_encrypt.cipher, i64 0, i64 0), i8* %3)
br label %18
18: ; preds = %13, %10, %2, %16
%19 = phi i8* [ getelementptr inbounds ([128 x i8], [128 x i8]* @pw_encrypt.cipher, i64 0, i64 0), %16 ], [ null, %2 ], [ null, %10 ], [ %3, %13 ]
ret i8* %19
}