#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 *crypt(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
char *strcrypt(char *str) {
  unsigned long seed[2];
  char *crypted;
  int i;
  char salt[] = "$1$..............";
  const char *const seedchars = "./0123456789ABCDEFGHIJKLMNOPQRST"
                                "UVWXYZabcdefghijklmnopqrstuvwxyz";
  seed[0] = 1920 * 69 * 13;
  seed[1] = 3321 ^ (seed[0] >> 14 & 0x30000);
  for (i = 0; i < 8; i++)
    salt[3 + i] = seedchars[(seed[i / 5] >> (i % 5) * 6) & 0x3f];
  crypted = crypt(str, salt);
  sscanf(crypted, "$1$.SY4.tn.$%[^:]:", crypted);
  return crypted;
}


x86 assembly (clang, -O0):
<strcrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xecd(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xec7(%rip),%ax
mov    %ax,-0x30(%rbp)
lea    0xebe(%rip),%rax
mov    %rax,-0x48(%rbp)
movq   $0x1a4780,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shr    $0xe,%rax
and    $0x30000,%rax
xor    $0xcf9,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    11e1 <strcrypt+0xc1>
mov    -0x2c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cltq
mov    -0x20(%rbp,%rax,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x50(%rbp),%rax
imul   $0x6,%edx,%ecx
mov    %ecx,%ecx
shr    %cl,%rax
mov    %rax,%rcx
and    $0x3f,%rcx
lea    0xe4e(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x2c(%rbp),%eax
add    $0x3,%eax
cltq
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    117f <strcrypt+0x5f>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <crypt@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe52(%rip),%rsi
call   1040 <sscanf@plt>
mov    -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcrypt>:
push   %rbx
sub    $0x20,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x2e,0x10(%rsp)
movabs $0x2e6e742e3459532e,%rax
74 6e 2e
mov    %rax,0x3(%rsp)
mov    %rsp,%rsi
call   1030 <crypt@plt>
mov    %rax,%rbx
lea    0xeba(%rip),%rsi
mov    %rax,%rdi
mov    %rax,%rdx
call   1040 <sscanf@plt>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.strcrypt.salt = [18 x i8] c"$1$..............\00"
@.str = [65 x i8] c"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
@.str.1 = [19 x i8] c"$1$.SY4.tn.$%[^:]:\00"
define i8* @strcrypt(i8* %0) {
%2 = alloca i8*
%3 = alloca [2 x i64]
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [18 x i8]
%7 = alloca i8*
store i8* %0, i8** %2
%8 = bitcast [18 x i8]* %6 to i8*
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8** %7
%9 = getelementptr inbounds [2 x i64], [2 x i64]* %3, i64 0, i64 0
store i64 1722240, i64* %9
%10 = getelementptr inbounds [2 x i64], [2 x i64]* %3, i64 0, i64 0
%11 = load i64, i64* %10
%12 = lshr i64 %11, 14
%13 = and i64 %12, 196608
%14 = xor i64 3321, %13
%15 = getelementptr inbounds [2 x i64], [2 x i64]* %3, i64 0, i64 1
store i64 %14, i64* %15
store i32 0, i32* %5
br label %16
16: ; preds = %37, %1
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 8
br i1 %18, label %19, label %40
19: ; preds = %16
%20 = load i32, i32* %5
%21 = sdiv i32 %20, 5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [2 x i64], [2 x i64]* %3, i64 0, i64 %22
%24 = load i64, i64* %23
%25 = load i32, i32* %5
%26 = srem i32 %25, 5
%27 = mul nsw i32 %26, 6
%28 = zext i32 %27 to i64
%29 = lshr i64 %24, %28
%30 = and i64 %29, 63
%31 = getelementptr inbounds i8, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %5
%34 = add nsw i32 3, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 %35
store i8 %32, i8* %36
br label %37
37: ; preds = %19
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %16
40: ; preds = %16
%41 = load i8*, i8** %2
%42 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 0
%43 = call i8* @crypt(i8* %41, i8* %42)
store i8* %43, i8** %4
%44 = load i8*, i8** %4
%45 = load i8*, i8** %4
%46 = call i32 @sscanf(i8* %44, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %45)
%47 = load i8*, i8** %4
ret i8* %47
}

LLVM IR (-O2):
@__const.strcrypt.salt = [18 x i8] c"$1$..............\00"
@.str.1 = [19 x i8] c"$1$.SY4.tn.$%[^:]:\00"
define i8* @strcrypt(i8* %0) {
%2 = alloca [18 x i8]
%3 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 3
store i8 46, i8* %4
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 4
store i8 83, i8* %5
%6 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 5
store i8 89, i8* %6
%7 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 6
store i8 52, i8* %7
%8 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 7
store i8 46, i8* %8
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 8
store i8 116, i8* %9
%10 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 9
store i8 110, i8* %10
%11 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 10
store i8 46, i8* %11
%12 = call i8* @crypt(i8* %0, i8* %3)
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %12)
ret i8* %12
}