#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 */
typedef int /*<<< orphan*/ s2;
typedef int /*<<< orphan*/ res;

/* Variables and functions */
char *crypt(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *crypt16(char *key, char *salt) {
  static char res[25];
  static char s2[3];
  char *p;
  memset(res, 0, sizeof(res));
  p = crypt(key, salt);
  strncpy(res, p, 13);
  if (strlen(key) > 8) {
    strncpy(s2, &(res[2]), 2);
    p = crypt(&(key[8]), s2);
    strncpy(&(res[13]), &(p[2]), 11);
    memset(s2, 0, sizeof(s2));
  }
  return (res);
}


x86 assembly (clang, -O0):
<crypt16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x2ef9(%rip),%rdi
xor    %esi,%esi
mov    $0x19,%edx
call   1060 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0x2ed1(%rip),%rdi
mov    $0xd,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x8,%eax
jle    11ff <crypt16+0xbf>
lea    0x2ec7(%rip),%rdi
lea    0x2ea7(%rip),%rsi
add    $0x2,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
lea    0x2ea3(%rip),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
add    $0x2,%rsi
lea    0x2e72(%rip),%rdi
add    $0xd,%rdi
mov    $0xb,%edx
call   1030 <strncpy@plt>
lea    0x2e76(%rip),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
lea    0x2e4a(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt16>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x2efe(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x19,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <crypt@plt>
mov    %r15,%rdi
mov    %rax,%rsi
mov    $0xd,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x9,%eax
jl     11d7 <crypt16+0x97>
lea    0x2ed9(%rip),%r14
lea    0x2ebb(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
add    $0x8,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <crypt@plt>
lea    0x2(%rax),%rsi
lea    0x2e9f(%rip),%rdi
mov    $0xb,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
lea    0x2e72(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@crypt16.res = internal global [25 x i8] zeroinitializer
@crypt16.s2 = internal global [3 x i8] zeroinitializer
define i8* @crypt16(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = call i32 @memset(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 0), i32 0, i32 25)
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i8* @crypt(i8* %7, i8* %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = call i32 @strncpy(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 0), i8* %10, i32 13)
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp sgt i32 %13, 8
br i1 %14, label %15, label %24
15: ; preds = %2
%16 = call i32 @strncpy(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @crypt16.s2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 2), i32 2)
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 8
%19 = call i8* @crypt(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @crypt16.s2, i64 0, i64 0))
store i8* %19, i8** %5
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 2
%22 = call i32 @strncpy(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 13), i8* %21, i32 11)
%23 = call i32 @memset(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @crypt16.s2, i64 0, i64 0), i32 0, i32 3)
br label %24
24: ; preds = %15, %2
ret i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 0)
}

LLVM IR (-O2):
@crypt16.res = internal global [25 x i8] zeroinitializer
@crypt16.s2 = internal global [3 x i8] zeroinitializer
define i8* @crypt16(i8* %0, i8* %1) {
%3 = tail call i32 @memset(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 0), i32 0, i32 25)
%4 = tail call i8* @crypt(i8* %0, i8* %1)
%5 = tail call i32 @strncpy(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 0), i8* %4, i32 13)
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 8
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = tail call i32 @strncpy(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @crypt16.s2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 2), i32 2)
%10 = getelementptr inbounds i8, i8* %0, i64 8
%11 = tail call i8* @crypt(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @crypt16.s2, i64 0, i64 0))
%12 = getelementptr inbounds i8, i8* %11, i64 2
%13 = tail call i32 @strncpy(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 13), i8* %12, i32 11)
%14 = tail call i32 @memset(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @crypt16.s2, i64 0, i64 0), i32 0, i32 3)
br label %15
15: ; preds = %8, %2
ret i8* getelementptr inbounds ([25 x i8], [25 x i8]* @crypt16.res, i64 0, i64 0)
}