#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 */
int /*<<< orphan*/ MDString(unsigned char *, int, unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memset(unsigned char *, int, int);
unsigned int KeyMD5Encode(unsigned char *szEncoded, const unsigned char *szData,
                          unsigned int nSize, unsigned char *szKey,
                          unsigned int nKeyLen) {
  unsigned char ipad[64] = {0}, opad[64] = {0};
  unsigned char K[64] = {0};
  unsigned char firstPad[64 + 1024 + 1] = {0};
  unsigned char midResult[64 + 16] = {0};
  int i;
  memset(ipad, 0x36, 64);
  memset(opad, 0x5c, 64);
  memcpy(K, szKey, nKeyLen);
  for (i = 0; i < 64; i++) {
    ipad[i] ^= K[i];
    opad[i] ^= K[i];
  }
  memcpy(firstPad, ipad, 64);
  memcpy(firstPad + 64, szData, nSize);
  firstPad[64 + nSize] = '\x0';
  MDString(firstPad, 64 + nSize, midResult + 64);
  memcpy(midResult, opad, 64);
  MDString(midResult, 64 + 16, szEncoded);
  return 16;
}


x86 assembly (clang, -O0):
<KeyMD5Encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5a0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x540(%rbp),%rdi
xor    %esi,%esi
mov    $0x441,%edx
call   1040 <memset@plt>
lea    -0x590(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1040 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    $0x36,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0xb0(%rbp),%rdi
mov    $0x5c,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x594(%rbp)
cmpl   $0x40,-0x594(%rbp)
jge    1259 <KeyMD5Encode+0x129>
movslq -0x594(%rbp),%rax
movzbl -0xf0(%rbp,%rax,1),%edx
ff
movslq -0x594(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%ecx
xor    %edx,%ecx
mov    %cl,-0x70(%rbp,%rax,1)
movslq -0x594(%rbp),%rax
movzbl -0xf0(%rbp,%rax,1),%edx
ff
movslq -0x594(%rbp),%rax
movzbl -0xb0(%rbp,%rax,1),%ecx
ff
xor    %edx,%ecx
mov    %cl,-0xb0(%rbp,%rax,1)
mov    -0x594(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x594(%rbp)
jmp    11f0 <KeyMD5Encode+0xc0>
lea    -0x540(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
lea    -0x540(%rbp),%rdi
add    $0x40,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x40,%eax
mov    %eax,%eax
movb   $0x0,-0x540(%rbp,%rax,1)
lea    -0x540(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x40,%esi
lea    -0x590(%rbp),%rdx
add    $0x40,%rdx
call   1030 <MDString@plt>
lea    -0x590(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
lea    -0x590(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   1030 <MDString@plt>
mov    $0x10,%eax
add    $0x5a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KeyMD5Encode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x568,%rsp
mov    %r8d,%r14d
mov    %rcx,%rbp
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
lea    0x120(%rsp),%r12
mov    $0x441,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
lea    0x50(%rsp),%r13
mov    %r13,%rdi
mov    $0x36,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    0x10(%rsp),%rdi
mov    $0x5c,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    0x90(%rsp),%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1050 <memcpy@plt>
movaps 0x90(%rsp),%xmm0
movaps 0xa0(%rsp),%xmm1
movaps 0xb0(%rsp),%xmm2
movaps 0xc0(%rsp),%xmm3
movaps 0x50(%rsp),%xmm4
xorps  %xmm0,%xmm4
xorps  0x10(%rsp),%xmm0
movaps %xmm4,0x50(%rsp)
movaps %xmm0,0x10(%rsp)
movaps 0x60(%rsp),%xmm0
xorps  %xmm1,%xmm0
movaps %xmm0,0x60(%rsp)
xorps  0x20(%rsp),%xmm1
movaps %xmm1,0x20(%rsp)
movaps 0x70(%rsp),%xmm0
xorps  %xmm2,%xmm0
xorps  0x30(%rsp),%xmm2
movaps %xmm0,0x70(%rsp)
movaps %xmm2,0x30(%rsp)
movaps 0x80(%rsp),%xmm0
xorps  %xmm3,%xmm0
movaps %xmm0,0x80(%rsp)
xorps  0x40(%rsp),%xmm3
movaps %xmm3,0x40(%rsp)
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
lea    0x160(%rsp),%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
add    $0x40,%ebx
movb   $0x0,0x120(%rsp,%rbx,1)
mov    %r12,%rdi
mov    %ebx,%esi
lea    0x110(%rsp),%rdx
call   1030 <MDString@plt>
lea    0xd0(%rsp),%rbx
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
mov    0x8(%rsp),%rdx
call   1030 <MDString@plt>
mov    $0x10,%eax
add    $0x568,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @KeyMD5Encode(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [64 x i8]
%12 = alloca [64 x i8]
%13 = alloca [64 x i8]
%14 = alloca [1089 x i8]
%15 = alloca [80 x i8]
%16 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%17 = bitcast [64 x i8]* %11 to i8*
%18 = bitcast [64 x i8]* %12 to i8*
%19 = bitcast [64 x i8]* %13 to i8*
%20 = bitcast [1089 x i8]* %14 to i8*
%21 = bitcast [80 x i8]* %15 to i8*
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%23 = call i32 @memset(i8* %22, i32 54, i32 64)
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 92, i32 64)
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %13, i64 0, i64 0
%27 = load i8*, i8** %9
%28 = load i32, i32* %10
%29 = call i32 @memcpy(i8* %26, i8* %27, i32 %28)
store i32 0, i32* %16
br label %30
30: ; preds = %58, %5
%31 = load i32, i32* %16
%32 = icmp slt i32 %31, 64
br i1 %32, label %33, label %61
33: ; preds = %30
%34 = load i32, i32* %16
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %13, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = load i32, i32* %16
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = xor i32 %43, %38
%45 = trunc i32 %44 to i8
store i8 %45, i8* %41
%46 = load i32, i32* %16
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [64 x i8], [64 x i8]* %13, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = load i32, i32* %16
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = xor i32 %55, %50
%57 = trunc i32 %56 to i8
store i8 %57, i8* %53
br label %58
58: ; preds = %33
%59 = load i32, i32* %16
%60 = add nsw i32 %59, 1
store i32 %60, i32* %16
br label %30
61: ; preds = %30
%62 = getelementptr inbounds [1089 x i8], [1089 x i8]* %14, i64 0, i64 0
%63 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%64 = call i32 @memcpy(i8* %62, i8* %63, i32 64)
%65 = getelementptr inbounds [1089 x i8], [1089 x i8]* %14, i64 0, i64 0
%66 = getelementptr inbounds i8, i8* %65, i64 64
%67 = load i8*, i8** %7
%68 = load i32, i32* %8
%69 = call i32 @memcpy(i8* %66, i8* %67, i32 %68)
%70 = load i32, i32* %8
%71 = add i32 64, %70
%72 = zext i32 %71 to i64
%73 = getelementptr inbounds [1089 x i8], [1089 x i8]* %14, i64 0, i64 %72
store i8 0, i8* %73
%74 = getelementptr inbounds [1089 x i8], [1089 x i8]* %14, i64 0, i64 0
%75 = load i32, i32* %8
%76 = add i32 64, %75
%77 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%78 = getelementptr inbounds i8, i8* %77, i64 64
%79 = call i32 @MDString(i8* %74, i32 %76, i8* %78)
%80 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%81 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%82 = call i32 @memcpy(i8* %80, i8* %81, i32 64)
%83 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%84 = load i8*, i8** %6
%85 = call i32 @MDString(i8* %83, i32 80, i8* %84)
ret i32 16
}

LLVM IR (-O2):
define i32 @KeyMD5Encode(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca [64 x i8]
%7 = alloca [64 x i8]
%8 = alloca [64 x i8]
%9 = alloca [1089 x i8]
%10 = alloca [80 x i8]
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%14 = getelementptr inbounds [1089 x i8], [1089 x i8]* %9, i64 0, i64 0
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%16 = call i32 @memset(i8* %11, i32 54, i32 64)
%17 = call i32 @memset(i8* %12, i32 92, i32 64)
%18 = call i32 @memcpy(i8* %13, i8* %3, i32 %4)
%19 = bitcast [64 x i8]* %8 to <16 x i8>*
%20 = load <16 x i8>, <16 x i8>* %19
%21 = bitcast [64 x i8]* %6 to <16 x i8>*
%22 = load <16 x i8>, <16 x i8>* %21
%23 = xor <16 x i8> %22, %20
%24 = bitcast [64 x i8]* %6 to <16 x i8>*
store <16 x i8> %23, <16 x i8>* %24
%25 = bitcast [64 x i8]* %7 to <16 x i8>*
%26 = load <16 x i8>, <16 x i8>* %25
%27 = xor <16 x i8> %26, %20
%28 = bitcast [64 x i8]* %7 to <16 x i8>*
store <16 x i8> %27, <16 x i8>* %28
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 16
%30 = bitcast i8* %29 to <16 x i8>*
%31 = load <16 x i8>, <16 x i8>* %30
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 16
%33 = bitcast i8* %32 to <16 x i8>*
%34 = load <16 x i8>, <16 x i8>* %33
%35 = xor <16 x i8> %34, %31
%36 = bitcast i8* %32 to <16 x i8>*
store <16 x i8> %35, <16 x i8>* %36
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 16
%38 = bitcast i8* %37 to <16 x i8>*
%39 = load <16 x i8>, <16 x i8>* %38
%40 = xor <16 x i8> %39, %31
%41 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> %40, <16 x i8>* %41
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 32
%43 = bitcast i8* %42 to <16 x i8>*
%44 = load <16 x i8>, <16 x i8>* %43
%45 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 32
%46 = bitcast i8* %45 to <16 x i8>*
%47 = load <16 x i8>, <16 x i8>* %46
%48 = xor <16 x i8> %47, %44
%49 = bitcast i8* %45 to <16 x i8>*
store <16 x i8> %48, <16 x i8>* %49
%50 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 32
%51 = bitcast i8* %50 to <16 x i8>*
%52 = load <16 x i8>, <16 x i8>* %51
%53 = xor <16 x i8> %52, %44
%54 = bitcast i8* %50 to <16 x i8>*
store <16 x i8> %53, <16 x i8>* %54
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 48
%56 = bitcast i8* %55 to <16 x i8>*
%57 = load <16 x i8>, <16 x i8>* %56
%58 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 48
%59 = bitcast i8* %58 to <16 x i8>*
%60 = load <16 x i8>, <16 x i8>* %59
%61 = xor <16 x i8> %60, %57
%62 = bitcast i8* %58 to <16 x i8>*
store <16 x i8> %61, <16 x i8>* %62
%63 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 48
%64 = bitcast i8* %63 to <16 x i8>*
%65 = load <16 x i8>, <16 x i8>* %64
%66 = xor <16 x i8> %65, %57
%67 = bitcast i8* %63 to <16 x i8>*
store <16 x i8> %66, <16 x i8>* %67
%68 = call i32 @memcpy(i8* %14, i8* %11, i32 64)
%69 = getelementptr inbounds [1089 x i8], [1089 x i8]* %9, i64 0, i64 64
%70 = call i32 @memcpy(i8* %69, i8* %1, i32 %2)
%71 = add i32 %2, 64
%72 = zext i32 %71 to i64
%73 = getelementptr inbounds [1089 x i8], [1089 x i8]* %9, i64 0, i64 %72
store i8 0, i8* %73
%74 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 64
%75 = call i32 @MDString(i8* %14, i32 %71, i8* %74)
%76 = call i32 @memcpy(i8* %15, i8* %12, i32 64)
%77 = call i32 @MDString(i8* %15, i32 80, i8* %0)
ret i32 16
}