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


x86 assembly (clang, -O0):
<crypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    1198 <crypt+0x78>
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x24,%eax
jne    1198 <crypt+0x78>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x31,%eax
jne    1193 <crypt+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <__md5_crypt@plt>
mov    %rax,-0x8(%rbp)
jmp    11a9 <crypt+0x89>
jmp    1198 <crypt+0x78>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <__des_crypt@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt>:
cmpb   $0x24,(%rsi)
jne    1136 <crypt+0x16>
cmpb   $0x24,0x2(%rsi)
jne    1136 <crypt+0x16>
cmpb   $0x31,0x1(%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*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
store i8* %8, i8** %6
%9 = load i8*, i8** %5
store i8* %9, i8** %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 36
br i1 %14, label %15, label %32
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 36
br i1 %20, label %21, label %32
21: ; preds = %15
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 49
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = load i8*, i8** %6
%29 = load i8*, i8** %7
%30 = call i8* @__md5_crypt(i8* %28, i8* %29)
store i8* %30, i8** %3
br label %36
31: ; preds = %21
br label %32
32: ; preds = %31, %15, %2
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = call i8* @__des_crypt(i8* %33, i8* %34)
store i8* %35, i8** %3
br label %36
36: ; preds = %32, %27
%37 = load i8*, i8** %3
ret i8* %37
}

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 2
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 36
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %1, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 49
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
}