#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 *__des_crypt(unsigned char *, unsigned char *);
char *__md5_crypt(unsigned char *, unsigned char *);
char *crypt(const char *key, const char *salt) {
  if (salt[0] == '$' && salt[1] == '1' && salt[2] == '$')
    return __md5_crypt((unsigned char *)key, (unsigned char *)salt);
  else
    return __des_crypt((unsigned char *)key, (unsigned char *)salt);
}


x86 assembly (clang, -O0):
<crypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    1178 <crypt+0x58>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x31,%eax
jne    1178 <crypt+0x58>
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x24,%eax
jne    1178 <crypt+0x58>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <__md5_crypt@plt>
mov    %rax,-0x8(%rbp)
jmp    1189 <crypt+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <__des_crypt@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt>:
cmpb   $0x24,(%rsi)
jne    1136 <crypt+0x16>
cmpb   $0x31,0x1(%rsi)
jne    1136 <crypt+0x16>
cmpb   $0x24,0x2(%rsi)
jne    1136 <crypt+0x16>
jmp    1030 <__md5_crypt@plt>
jmp    1040 <__des_crypt@plt>

LLVM IR (-O0):
define i8* @crypt(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 36
br i1 %10, label %11, label %27
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 49
br i1 %16, label %17, label %27
17: ; preds = %11
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 36
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = load i8*, i8** %5
%26 = call i8* @__md5_crypt(i8* %24, i8* %25)
store i8* %26, i8** %3
br label %31
27: ; preds = %17, %11, %2
%28 = load i8*, i8** %4
%29 = load i8*, i8** %5
%30 = call i8* @__des_crypt(i8* %28, i8* %29)
store i8* %30, i8** %3
br label %31
31: ; preds = %27, %23
%32 = load i8*, i8** %3
ret i8* %32
}

LLVM IR (-O2):
define i8* @crypt(i8* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 36
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 49
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %1, i64 2
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 36
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i8* @__md5_crypt(i8* %0, i8* %1)
br label %17
15: ; preds = %9, %5, %2
%16 = tail call i8* @__des_crypt(i8* %0, i8* %1)
br label %17
17: ; preds = %15, %13
%18 = phi i8* [ %14, %13 ], [ %16, %15 ]
ret i8* %18
}