int GenerateCrypt(char *szUser, char *szPassword, char *szChallenge64,
                  long clientinfo, long embkey, char *szResult) {
  unsigned char szDecoded[256];
  unsigned char szKey[256];
  unsigned char szAscii[256];
  unsigned int nDecodedLen;
  long challengetime = 0;
  int nMoveBits;
  long challengetime_new = 0;
  long a, b, c, d;
  unsigned int nKey;
  int nUser;
  unsigned int nEncoded;
  nDecodedLen = lutil_b64_pton(szChallenge64, szDecoded, 256);
  memcpy(&challengetime, szDecoded + 6, 4);
  Change_Endianness(&challengetime);
  challengetime |= ~embkey;
  nMoveBits = challengetime % 30;
  a = challengetime << ((32 - nMoveBits) % 32);
  b = challengetime >> (((unsigned int)nMoveBits) % 32);
  c = ~(0xffffffff << ((32 - nMoveBits) % 32));
  d = b & c;
  challengetime_new = a | d;
  nKey = KeyMD5Encode(szKey, (unsigned char *)szPassword,
                      strlen((char *)szPassword), (unsigned char *)szDecoded,
                      nDecodedLen);
  szKey[nKey] = 0;
  Change_Endianness(&clientinfo);
  Change_Endianness(&challengetime_new);
  nUser = strlen((char *)szUser);
  memcpy(szAscii, szUser, nUser);
  szAscii[nUser] = ' ';
  memcpy(szAscii + nUser + 1, &challengetime_new, 4);
  memcpy(szAscii + nUser + 1 + 4, &clientinfo, 4);
  memcpy(szAscii + nUser + 1 + 4 + 4, szKey, nKey);
  nEncoded = lutil_b64_ntop((unsigned char *)szAscii, nUser + 1 + 4 + 4 + nKey,
                            szResult, 256);
  return nEncoded;
}


x86 assembly (clang, -O0):
<GenerateCrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3a0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x340(%rbp)
movq   $0x0,-0x350(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x100,%edx
mov    $0x0,%al
call   1040 <lutil_b64_pton@plt>
mov    %eax,-0x334(%rbp)
mov    -0x12a(%rbp),%eax
mov    %eax,-0x340(%rbp)
lea    -0x340(%rbp),%rdi
mov    $0x0,%al
call   1070 <Change_Endianness@plt>
mov    -0x28(%rbp),%rax
xor    $0xffffffffffffffff,%rax
or     -0x340(%rbp),%rax
mov    %rax,-0x340(%rbp)
mov    -0x340(%rbp),%rax
mov    $0x1e,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x344(%rbp)
mov    -0x340(%rbp),%rax
mov    %rax,-0x398(%rbp)
mov    $0x20,%eax
sub    -0x344(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    -0x398(%rbp),%rax
mov    %edx,%ecx
shl    %cl,%rax
mov    %rax,-0x358(%rbp)
mov    -0x340(%rbp),%rax
mov    -0x344(%rbp),%ecx
and    $0x1f,%ecx
mov    %ecx,%ecx
sar    %cl,%rax
mov    %rax,-0x360(%rbp)
mov    $0x20,%eax
sub    -0x344(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
mov    %eax,%eax
mov    %rax,-0x368(%rbp)
mov    -0x360(%rbp),%rax
and    -0x368(%rbp),%rax
mov    %rax,-0x370(%rbp)
mov    -0x358(%rbp),%rax
or     -0x370(%rbp),%rax
mov    %rax,-0x350(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x390(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x388(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x390(%rbp),%rdi
mov    -0x388(%rbp),%rsi
mov    %rax,%rdx
lea    -0x130(%rbp),%rcx
mov    -0x334(%rbp),%r8d
mov    $0x0,%al
call   1060 <KeyMD5Encode@plt>
mov    %eax,-0x374(%rbp)
mov    -0x374(%rbp),%eax
movb   $0x0,-0x230(%rbp,%rax,1)
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1070 <Change_Endianness@plt>
lea    -0x350(%rbp),%rdi
mov    $0x0,%al
call   1070 <Change_Endianness@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x378(%rbp)
lea    -0x330(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x378(%rbp),%rdx
call   1050 <memcpy@plt>
movslq -0x378(%rbp),%rax
movb   $0x20,-0x330(%rbp,%rax,1)
20
movslq -0x378(%rbp),%rax
mov    -0x350(%rbp),%ecx
mov    %ecx,-0x32f(%rbp,%rax,1)
movslq -0x378(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,-0x32b(%rbp,%rax,1)
lea    -0x330(%rbp),%rdi
movslq -0x378(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
add    $0x4,%rdi
add    $0x4,%rdi
lea    -0x230(%rbp),%rsi
mov    -0x374(%rbp),%eax
mov    %eax,%edx
call   1050 <memcpy@plt>
lea    -0x330(%rbp),%rdi
mov    -0x378(%rbp),%esi
add    $0x1,%esi
add    $0x4,%esi
add    $0x4,%esi
add    -0x374(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    $0x100,%ecx
mov    $0x0,%al
call   1080 <lutil_b64_ntop@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x37c(%rbp),%eax
add    $0x3a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenerateCrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x328,%rsp
mov    %r9,0x18(%rsp)
mov    %r8,%rbx
mov    %rsi,%r13
mov    %rdi,%r15
mov    %rcx,0x10(%rsp)
movq   $0x0,(%rsp)
lea    0x220(%rsp),%r12
mov    %rdx,%rdi
mov    %r12,%rsi
mov    $0x100,%edx
xor    %eax,%eax
call   1040 <lutil_b64_pton@plt>
mov    %eax,%ebp
mov    0x226(%rsp),%eax
mov    %eax,(%rsp)
mov    %rsp,%rdi
xor    %eax,%eax
call   1070 <Change_Endianness@plt>
not    %rbx
or     (%rsp),%rbx
mov    %rbx,(%rsp)
movabs $0x8888888888888889,%rcx
88 88 88
mov    %rbx,%rax
imul   %rcx
lea    (%rdx,%rbx,1),%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
shr    $0x4,%ecx
add    %eax,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%eax
sub    %edx,%eax
add    %ecx,%eax
add    %ebx,%eax
mov    %eax,%edx
neg    %dl
mov    %edx,%ecx
and    $0x1f,%cl
mov    %rbx,%rsi
shl    %cl,%rsi
and    $0x1f,%al
mov    %eax,%ecx
sar    %cl,%rbx
mov    $0xffffffff,%eax
mov    %edx,%ecx
shl    %cl,%eax
not    %eax
and    %eax,%ebx
or     %rsi,%rbx
mov    %rbx,0x8(%rsp)
mov    %r13,%rdi
call   1030 <strlen@plt>
lea    0x120(%rsp),%r14
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
mov    %r12,%rcx
mov    %ebp,%r8d
xor    %eax,%eax
call   1060 <KeyMD5Encode@plt>
mov    %eax,%r12d
mov    %eax,%ebx
movb   $0x0,0x120(%rsp,%rbx,1)
lea    0x10(%rsp),%rdi
xor    %eax,%eax
call   1070 <Change_Endianness@plt>
lea    0x8(%rsp),%rdi
xor    %eax,%eax
call   1070 <Change_Endianness@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbp
lea    0x20(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1050 <memcpy@plt>
movb   $0x20,0x20(%rsp,%rbp,1)
mov    0x8(%rsp),%eax
mov    %eax,0x21(%rsp,%rbp,1)
mov    0x10(%rsp),%eax
mov    %eax,0x25(%rsp,%rbp,1)
lea    (%rsp,%rbp,1),%rdi
add    $0x29,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <memcpy@plt>
lea    (%r12,%rbp,1),%esi
add    $0x9,%esi
mov    %r13,%rdi
mov    0x18(%rsp),%rdx
mov    $0x100,%ecx
xor    %eax,%eax
call   1080 <lutil_b64_ntop@plt>
add    $0x328,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @GenerateCrypt(i8* %0, i8* %1, i8* %2, i64 %3, i64 %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8*
%13 = alloca [256 x i8]
%14 = alloca [256 x i8]
%15 = alloca [256 x i8]
%16 = alloca i32
%17 = alloca i64
%18 = alloca i32
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
%22 = alloca i64
%23 = alloca i64
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i64 %4, i64* %11
store i8* %5, i8** %12
store i64 0, i64* %17
store i64 0, i64* %19
%27 = load i8*, i8** %9
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%29 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @lutil_b64_pton to i32 (i8*, i8*, i32, ...)*)(i8* %27, i8* %28, i32 256)
store i32 %29, i32* %16
%30 = bitcast i64* %17 to i8*
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%32 = getelementptr inbounds i8, i8* %31, i64 6
%33 = call i32 (i64*, ...) bitcast (i32 (...)* @Change_Endianness to i32 (i64*, ...)*)(i64* %17)
%34 = load i64, i64* %11
%35 = xor i64 %34, -1
%36 = load i64, i64* %17
%37 = or i64 %36, %35
store i64 %37, i64* %17
%38 = load i64, i64* %17
%39 = srem i64 %38, 30
%40 = trunc i64 %39 to i32
store i32 %40, i32* %18
%41 = load i64, i64* %17
%42 = load i32, i32* %18
%43 = sub nsw i32 32, %42
%44 = srem i32 %43, 32
%45 = zext i32 %44 to i64
%46 = shl i64 %41, %45
store i64 %46, i64* %20
%47 = load i64, i64* %17
%48 = load i32, i32* %18
%49 = urem i32 %48, 32
%50 = zext i32 %49 to i64
%51 = ashr i64 %47, %50
store i64 %51, i64* %21
%52 = load i32, i32* %18
%53 = sub nsw i32 32, %52
%54 = srem i32 %53, 32
%55 = shl i32 -1, %54
%56 = xor i32 %55, -1
%57 = zext i32 %56 to i64
store i64 %57, i64* %22
%58 = load i64, i64* %21
%59 = load i64, i64* %22
%60 = and i64 %58, %59
store i64 %60, i64* %23
%61 = load i64, i64* %20
%62 = load i64, i64* %23
%63 = or i64 %61, %62
store i64 %63, i64* %19
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%65 = load i8*, i8** %8
%66 = load i8*, i8** %8
%67 = call i64 @strlen(i8* %66)
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%69 = load i32, i32* %16
%70 = call i32 (i8*, i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @KeyMD5Encode to i32 (i8*, i8*, i64, i8*, i32, ...)*)(i8* %64, i8* %65, i64 %67, i8* %68, i32 %69)
store i32 %70, i32* %24
%71 = load i32, i32* %24
%72 = zext i32 %71 to i64
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 %72
store i8 0, i8* %73
%74 = call i32 (i64*, ...) bitcast (i32 (...)* @Change_Endianness to i32 (i64*, ...)*)(i64* %10)
%75 = call i32 (i64*, ...) bitcast (i32 (...)* @Change_Endianness to i32 (i64*, ...)*)(i64* %19)
%76 = load i8*, i8** %7
%77 = call i64 @strlen(i8* %76)
%78 = trunc i64 %77 to i32
store i32 %78, i32* %25
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%80 = load i8*, i8** %7
%81 = load i32, i32* %25
%82 = sext i32 %81 to i64
%83 = load i32, i32* %25
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 %84
store i8 32, i8* %85
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%87 = load i32, i32* %25
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
%90 = getelementptr inbounds i8, i8* %89, i64 1
%91 = bitcast i64* %19 to i8*
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%93 = load i32, i32* %25
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %92, i64 %94
%96 = getelementptr inbounds i8, i8* %95, i64 1
%97 = getelementptr inbounds i8, i8* %96, i64 4
%98 = bitcast i64* %10 to i8*
%99 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%100 = load i32, i32* %25
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %99, i64 %101
%103 = getelementptr inbounds i8, i8* %102, i64 1
%104 = getelementptr inbounds i8, i8* %103, i64 4
%105 = getelementptr inbounds i8, i8* %104, i64 4
%106 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%107 = load i32, i32* %24
%108 = zext i32 %107 to i64
%109 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%110 = load i32, i32* %25
%111 = add nsw i32 %110, 1
%112 = add nsw i32 %111, 4
%113 = add nsw i32 %112, 4
%114 = load i32, i32* %24
%115 = add i32 %113, %114
%116 = load i8*, i8** %12
%117 = call i32 (i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @lutil_b64_ntop to i32 (i8*, i32, i8*, i32, ...)*)(i8* %109, i32 %115, i8* %116, i32 256)
store i32 %117, i32* %26
%118 = load i32, i32* %26
ret i32 %118
}

LLVM IR (-O2):
define i32 @GenerateCrypt(i8* nocapture %0, i8* %1, i8* %2, i64 %3, i64 %4, i8* %5) {
%7 = alloca i64
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca i64
%12 = alloca i64
store i64 %3, i64* %7
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%16 = bitcast i64* %11 to i8*
store i64 0, i64* %11
%17 = bitcast i64* %12 to i8*
%18 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @lutil_b64_pton to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* %13, i32 256)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 6
%20 = bitcast i8* %19 to i32*
%21 = bitcast i64* %11 to i32*
%22 = load i32, i32* %20
store i32 %22, i32* %21
%23 = call i32 (i64*, ...) bitcast (i32 (...)* @Change_Endianness to i32 (i64*, ...)*)(i64* %11)
%24 = xor i64 %4, -1
%25 = load i64, i64* %11
%26 = or i64 %25, %24
store i64 %26, i64* %11
%27 = srem i64 %26, 30
%28 = trunc i64 %27 to i32
%29 = sub nsw i32 0, %28
%30 = and i32 %29, 31
%31 = zext i32 %30 to i64
%32 = shl i64 %26, %31
%33 = and i64 %27, 31
%34 = ashr i64 %26, %33
%35 = shl nsw i32 -1, %30
%36 = xor i32 %35, -1
%37 = zext i32 %36 to i64
%38 = and i64 %34, %37
%39 = or i64 %38, %32
store i64 %39, i64* %12
%40 = call i64 @strlen(i8* dereferenceable(1) %1)
%41 = call i32 (i8*, i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @KeyMD5Encode to i32 (i8*, i8*, i64, i8*, i32, ...)*)(i8* %14, i8* %1, i64 %40, i8* %13, i32 %18)
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 %42
store i8 0, i8* %43
%44 = call i32 (i64*, ...) bitcast (i32 (...)* @Change_Endianness to i32 (i64*, ...)*)(i64* %7)
%45 = call i32 (i64*, ...) bitcast (i32 (...)* @Change_Endianness to i32 (i64*, ...)*)(i64* %12)
%46 = call i64 @strlen(i8* dereferenceable(1) %0)
%47 = trunc i64 %46 to i32
%48 = shl i64 %46, 32
%49 = ashr exact i64 %48, 32
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 %49
store i8 32, i8* %50
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = bitcast i64* %12 to i32*
%53 = bitcast i8* %51 to i32*
%54 = load i32, i32* %52
store i32 %54, i32* %53
%55 = getelementptr inbounds i8, i8* %50, i64 5
%56 = bitcast i64* %7 to i32*
%57 = bitcast i8* %55 to i32*
%58 = load i32, i32* %56
store i32 %58, i32* %57
%59 = getelementptr inbounds i8, i8* %50, i64 9
%60 = add i32 %41, 9
%61 = add i32 %60, %47
%62 = call i32 (i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @lutil_b64_ntop to i32 (i8*, i32, i8*, i32, ...)*)(i8* %15, i32 %61, i8* %5, i32 256)
ret i32 %62
}