#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 *md5crypt(char const *, char const *, char *);
scalar_t__ memcmp(char *, char const *, int);
char *__crypt_md5(const char *key, const char *setting, char *output) {
  static const char testkey[] = "Xy01@#\x01\x02\x80\x7f\xff\r\n\x81\t !";
  static const char testsetting[] = "$1$abcd0123$";
  static const char testhash[] = "$1$abcd0123$9Qcg8DyviekV3tDGMZynJ1";
  char testbuf[64];
  char *p, *q;
  p = md5crypt(key, setting, output);
  q = md5crypt(testkey, testsetting, testbuf);
  if (!p || q != testbuf || memcmp(testbuf, testhash, sizeof testhash))
    return "*";
  return p;
}


x86 assembly (clang, -O0):
<__crypt_md5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <md5crypt@plt>
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdx
lea    0xeac(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <md5crypt@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     119f <__crypt_md5+0x7f>
mov    -0x70(%rbp),%rax
lea    -0x60(%rbp),%rcx
cmp    %rcx,%rax
jne    119f <__crypt_md5+0x7f>
lea    -0x60(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x23,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     11af <__crypt_md5+0x8f>
lea    0xe9d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b7 <__crypt_md5+0x97>
mov    -0x68(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__crypt_md5>:
push   %r14
push   %rbx
sub    $0x48,%rsp
call   1040 <md5crypt@plt>
mov    %rax,%rbx
lea    0xeca(%rip),%rdi
lea    0xed5(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdx
call   1040 <md5crypt@plt>
mov    %rax,%rcx
lea    0xef1(%rip),%rax
test   %rbx,%rbx
je     117e <__crypt_md5+0x5e>
cmp    %r14,%rcx
jne    117e <__crypt_md5+0x5e>
lea    0xebd(%rip),%rsi
mov    %rsp,%rdi
mov    $0x23,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
lea    0xec9(%rip),%rax
cmove  %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__crypt_md5.testkey = internal constant [18 x i8] c"Xy01@#\01\02\80\7F\FF\0D\0A\81\09 !\00"
@__crypt_md5.testsetting = internal constant [13 x i8] c"$1$abcd0123$\00"
@__crypt_md5.testhash = internal constant [35 x i8] c"$1$abcd0123$9Qcg8DyviekV3tDGMZynJ1\00"
@.str = [2 x i8] c"*\00"
define i8* @__crypt_md5(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [64 x i8]
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = call i8* @md5crypt(i8* %11, i8* %12, i8* %13)
store i8* %14, i8** %9
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%16 = call i8* @md5crypt(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__crypt_md5.testkey, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__crypt_md5.testsetting, i64 0, i64 0), i8* %15)
store i8* %16, i8** %10
%17 = load i8*, i8** %9
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %27
19: ; preds = %3
%20 = load i8*, i8** %10
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%22 = icmp ne i8* %20, %21
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%25 = call i64 @memcmp(i8* %24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @__crypt_md5.testhash, i64 0, i64 0), i32 35)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23, %19, %3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4
br label %30
28: ; preds = %23
%29 = load i8*, i8** %9
store i8* %29, i8** %4
br label %30
30: ; preds = %28, %27
%31 = load i8*, i8** %4
ret i8* %31
}

LLVM IR (-O2):
@__crypt_md5.testkey = internal constant [18 x i8] c"Xy01@#\01\02\80\7F\FF\0D\0A\81\09 !\00"
@__crypt_md5.testsetting = internal constant [13 x i8] c"$1$abcd0123$\00"
@__crypt_md5.testhash = internal constant [35 x i8] c"$1$abcd0123$9Qcg8DyviekV3tDGMZynJ1\00"
@.str = [2 x i8] c"*\00"
define i8* @__crypt_md5(i8* %0, i8* %1, i8* %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @md5crypt(i8* %0, i8* %1, i8* %2)
%7 = call i8* @md5crypt(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__crypt_md5.testkey, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__crypt_md5.testsetting, i64 0, i64 0), i8* %5)
%8 = icmp eq i8* %6, null
%9 = icmp ne i8* %7, %5
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = call i64 @memcmp(i8* %5, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @__crypt_md5.testhash, i64 0, i64 0), i32 35)
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
br label %15
15: ; preds = %11, %3
%16 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %3 ], [ %14, %11 ]
ret i8* %16
}