#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 */
void *_crypt_extended_r_uut(char const *, char const *, char *);
int /*<<< orphan*/ strcmp(char const *, char const *);
char *__crypt_des(const char *key, const char *setting, char *output) {
  const char *test_key = "\x80\xff\x80\x01 "
                         "\x7f\x81\x80\x80\x0d\x0a\xff\x7f \x81 test";
  const char *test_setting = "_0.../9Zz";
  const char *test_hash = "_0.../9ZzX7iSJNd21sU";
  char test_buf[21];
  char *retval;
  const char *p;
  if (*setting != '_') {
    test_setting = "\x80x";
    test_hash = "\x80x22/wK52ZKGA";
  }
  retval = _crypt_extended_r_uut(key, setting, output);
  p = _crypt_extended_r_uut(test_key, test_setting, test_buf);
  if (p && !strcmp(p, test_hash) && retval)
    return retval;
  return (setting[0] == '*') ? "x" : "*";
}


x86 assembly (clang, -O0):
<__crypt_des>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xec5(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xecf(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xece(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     117b <__crypt_des+0x5b>
lea    0xec8(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xec0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <_crypt_extended_r_uut@plt>
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1040 <_crypt_extended_r_uut@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     11de <__crypt_des+0xbe>
mov    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11de <__crypt_des+0xbe>
cmpq   $0x0,-0x58(%rbp)
je     11de <__crypt_des+0xbe>
mov    -0x58(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fe <__crypt_des+0xde>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
lea    0xe59(%rip),%rax
lea    0xe42(%rip),%rcx
cmp    $0x2a,%edx
cmove  %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__crypt_des>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    (%rsi),%bpl
cmp    $0x5f,%bpl
lea    0xeda(%rip),%rax
lea    0xef2(%rip),%rbx
cmove  %rax,%rbx
call   1040 <_crypt_extended_r_uut@plt>
mov    %rax,%r15
lea    0xeab(%rip),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
call   1040 <_crypt_extended_r_uut@plt>
test   %rax,%rax
je     118c <__crypt_des+0x6c>
cmp    $0x5f,%bpl
lea    0xeaf(%rip),%rcx
lea    0xec0(%rip),%rsi
cmove  %rcx,%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    118c <__crypt_des+0x6c>
test   %r15,%r15
jne    11a2 <__crypt_des+0x82>
cmpb   $0x2a,(%r14)
lea    0xe9e(%rip),%rax
lea    0xea7(%rip),%r15
cmove  %rax,%r15
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\80\FF\80\01 \7F\81\80\80\0D\0A\FF\7F \81 test\00"
@.str.1 = [10 x i8] c"_0.../9Zz\00"
@.str.2 = [21 x i8] c"_0.../9ZzX7iSJNd21sU\00"
@.str.3 = [3 x i8] c"\80x\00"
@.str.4 = [14 x i8] c"\80x22/wK52ZKGA\00"
@.str.5 = [2 x i8] c"x\00"
@.str.6 = [2 x i8] c"*\00"
define i8* @__crypt_des(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [21 x i8]
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8** %10
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 95
br i1 %17, label %18, label %19
18: ; preds = %3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %10
br label %19
19: ; preds = %18, %3
%20 = load i8*, i8** %5
%21 = load i8*, i8** %6
%22 = load i8*, i8** %7
%23 = call i8* @_crypt_extended_r_uut(i8* %20, i8* %21, i8* %22)
store i8* %23, i8** %12
%24 = load i8*, i8** %8
%25 = load i8*, i8** %9
%26 = getelementptr inbounds [21 x i8], [21 x i8]* %11, i64 0, i64 0
%27 = call i8* @_crypt_extended_r_uut(i8* %24, i8* %25, i8* %26)
store i8* %27, i8** %13
%28 = load i8*, i8** %13
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %40
30: ; preds = %19
%31 = load i8*, i8** %13
%32 = load i8*, i8** %10
%33 = call i32 @strcmp(i8* %31, i8* %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %40, label %35
35: ; preds = %30
%36 = load i8*, i8** %12
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i8*, i8** %12
store i8* %39, i8** %4
br label %48
40: ; preds = %35, %30, %19
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 42
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
store i8* %47, i8** %4
br label %48
48: ; preds = %40, %38
%49 = load i8*, i8** %4
ret i8* %49
}

LLVM IR (-O2):
@.str = [21 x i8] c"\80\FF\80\01 \7F\81\80\80\0D\0A\FF\7F \81 test\00"
@.str.1 = [10 x i8] c"_0.../9Zz\00"
@.str.2 = [21 x i8] c"_0.../9ZzX7iSJNd21sU\00"
@.str.3 = [3 x i8] c"\80x\00"
@.str.4 = [14 x i8] c"\80x22/wK52ZKGA\00"
@.str.5 = [2 x i8] c"x\00"
@.str.6 = [2 x i8] c"*\00"
define i8* @__crypt_des(i8* %0, i8* %1, i8* %2) {
%4 = alloca [21 x i8]
%5 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 95
%8 = select i1 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%9 = tail call i8* @_crypt_extended_r_uut(i8* %0, i8* %1, i8* %2)
%10 = call i8* @_crypt_extended_r_uut(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %5)
%11 = icmp eq i8* %10, null
br i1 %11, label %18, label %12
12: ; preds = %3
%13 = select i1 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%14 = call i32 @strcmp(i8* %10, i8* dereferenceable(1) %13)
%15 = icmp eq i32 %14, 0
%16 = icmp ne i8* %9, null
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %22, label %18
18: ; preds = %12, %3
%19 = load i8, i8* %1
%20 = icmp eq i8 %19, 42
%21 = select i1 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
br label %22
22: ; preds = %12, %18
%23 = phi i8* [ %21, %18 ], [ %9, %12 ]
ret i8* %23
}