#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(char const *, char const *);
char *md5_crypt(char const *, char const *);
int strlen(char const *);
scalar_t__ strncmp(char const *, char *, int);
char *crypt(const char *pw, const char *salt) {
  if (strlen(salt) > 3 && strncmp(salt, "$1$", 3) == 0) {
    return md5_crypt(pw, salt);
  } else {
    return des_crypt(pw, 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),%rdi
call   1050 <strlen@plt>
cmp    $0x3,%eax
jle    1197 <crypt+0x57>
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1197 <crypt+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <md5_crypt@plt>
mov    %rax,-0x8(%rbp)
jmp    11a8 <crypt+0x68>
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>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jl     1170 <crypt+0x30>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1182 <crypt+0x42>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <des_crypt@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <md5_crypt@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"$1$\00"
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 = call i32 @strlen(i8* %6)
%8 = icmp sgt i32 %7, 3
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = call i8* @md5_crypt(i8* %14, i8* %15)
store i8* %16, i8** %3
br label %21
17: ; preds = %9, %2
%18 = load i8*, i8** %4
%19 = load i8*, i8** %5
%20 = call i8* @des_crypt(i8* %18, i8* %19)
store i8* %20, i8** %3
br label %21
21: ; preds = %17, %13
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [4 x i8] c"$1$\00"
define i8* @crypt(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = icmp sgt i32 %3, 3
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i8* @md5_crypt(i8* %0, i8* %1)
br label %12
10: ; preds = %5, %2
%11 = tail call i8* @des_crypt(i8* %0, i8* %1)
br label %12
12: ; preds = %10, %8
%13 = phi i8* [ %9, %8 ], [ %11, %10 ]
ret i8* %13
}