#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 */
struct crypt_data {
  int dummy;
};

/* Variables and functions */
char *__crypt_blowfish(char const *, char const *, char *);
char *__crypt_des(char const *, char const *, char *);
char *__crypt_r(const char *key, const char *salt, struct crypt_data *data) {
  char *output = (char *)data;
  if (salt[0] == '$' && salt[1] && salt[2]) {
    if (salt[1] == '2' && salt[3] == '$')
      return __crypt_blowfish(key, salt, output);
  }
  return __crypt_des(key, salt, output);
}


x86 assembly (clang, -O0):
<__crypt_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    11af <__crypt_r+0x8f>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11af <__crypt_r+0x8f>
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
je     11af <__crypt_r+0x8f>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x32,%eax
jne    11aa <__crypt_r+0x8a>
mov    -0x18(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x24,%eax
jne    11aa <__crypt_r+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <__crypt_blowfish@plt>
mov    %rax,-0x8(%rbp)
jmp    11c4 <__crypt_r+0xa4>
jmp    11af <__crypt_r+0x8f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <__crypt_des@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__crypt_r>:
cmpb   $0x24,(%rsi)
jne    1141 <__crypt_r+0x21>
mov    0x1(%rsi),%al
test   %al,%al
je     1141 <__crypt_r+0x21>
cmpb   $0x0,0x2(%rsi)
je     1141 <__crypt_r+0x21>
cmp    $0x32,%al
jne    1141 <__crypt_r+0x21>
cmpb   $0x24,0x3(%rsi)
jne    1141 <__crypt_r+0x21>
jmp    1040 <__crypt_blowfish@plt>
jmp    1030 <__crypt_des@plt>

LLVM IR (-O0):
%struct.crypt_data = type { i32 }
define i8* @__crypt_r(i8* %0, i8* %1, %struct.crypt_data* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.crypt_data*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store %struct.crypt_data* %2, %struct.crypt_data** %7
%9 = load %struct.crypt_data*, %struct.crypt_data** %7
%10 = bitcast %struct.crypt_data* %9 to i8*
store i8* %10, i8** %8
%11 = load i8*, i8** %6
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 36
br i1 %15, label %16, label %46
16: ; preds = %3
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %46
22: ; preds = %16
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %46
28: ; preds = %22
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 50
br i1 %33, label %34, label %45
34: ; preds = %28
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i64 3
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 36
br i1 %39, label %40, label %45
40: ; preds = %34
%41 = load i8*, i8** %5
%42 = load i8*, i8** %6
%43 = load i8*, i8** %8
%44 = call i8* @__crypt_blowfish(i8* %41, i8* %42, i8* %43)
store i8* %44, i8** %4
br label %51
45: ; preds = %34, %28
br label %46
46: ; preds = %45, %22, %16, %3
%47 = load i8*, i8** %5
%48 = load i8*, i8** %6
%49 = load i8*, i8** %8
%50 = call i8* @__crypt_des(i8* %47, i8* %48, i8* %49)
store i8* %50, i8** %4
br label %51
51: ; preds = %46, %40
%52 = load i8*, i8** %4
ret i8* %52
}

LLVM IR (-O2):
%struct.crypt_data = type { i32 }
define i8* @__crypt_r(i8* %0, i8* %1, %struct.crypt_data* %2) {
%4 = bitcast %struct.crypt_data* %2 to i8*
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 36
br i1 %6, label %7, label %23
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %1, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %23, label %11
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %1, i64 2
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
%15 = icmp eq i8 %9, 50
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = getelementptr inbounds i8, i8* %1, i64 3
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 36
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = tail call i8* @__crypt_blowfish(i8* %0, i8* %1, i8* %4)
br label %25
23: ; preds = %17, %11, %7, %3
%24 = tail call i8* @__crypt_des(i8* %0, i8* %1, i8* %4)
br label %25
25: ; preds = %23, %21
%26 = phi i8* [ %22, %21 ], [ %24, %23 ]
ret i8* %26
}