#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*/ unicodePassword;

/* Variables and functions */
int /*<<< orphan*/ md4(unsigned char *, int, unsigned char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
void NtPasswordHash(char *secret, int secret_len, unsigned char *hash) {
  int i;
  unsigned char unicodePassword[256 * 2];
  memset(unicodePassword, 0, sizeof(unicodePassword));
  for (i = 0; i < secret_len; i++)
    unicodePassword[i * 2] = (unsigned char)secret[i];
  md4(unicodePassword, secret_len * 2, hash);
}


x86 assembly (clang, -O0):
<NtPasswordHash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1030 <memset@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1184 <NtPasswordHash+0x64>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
cltq
mov    %cl,-0x220(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1150 <NtPasswordHash+0x30>
lea    -0x220(%rbp),%rdi
mov    -0xc(%rbp),%esi
shl    $0x1,%esi
mov    -0x18(%rbp),%rdx
call   1040 <md4@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NtPasswordHash>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1030 <memset@plt>
test   %ebp,%ebp
jle    11b0 <NtPasswordHash+0x90>
mov    %ebp,%ecx
lea    -0x1(%rcx),%rdx
mov    %ecx,%esi
and    $0x3,%esi
cmp    $0x3,%rdx
jae    115b <NtPasswordHash+0x3b>
xor    %edx,%edx
jmp    118b <NtPasswordHash+0x6b>
and    $0xfffffffc,%ecx
xor    %edx,%edx
movzbl (%rbx,%rdx,1),%eax
mov    %al,(%rsp,%rdx,2)
movzbl 0x1(%rbx,%rdx,1),%eax
mov    %al,0x2(%rsp,%rdx,2)
movzbl 0x2(%rbx,%rdx,1),%eax
mov    %al,0x4(%rsp,%rdx,2)
movzbl 0x3(%rbx,%rdx,1),%eax
mov    %al,0x6(%rsp,%rdx,2)
add    $0x4,%rdx
cmp    %rdx,%rcx
jne    1160 <NtPasswordHash+0x40>
test   %rsi,%rsi
je     11b0 <NtPasswordHash+0x90>
lea    (%rsp,%rdx,2),%rcx
add    %rdx,%rbx
xor    %edx,%edx
nopl   0x0(%rax)
movzbl (%rbx,%rdx,1),%eax
mov    %al,(%rcx,%rdx,2)
add    $0x1,%rdx
cmp    %rdx,%rsi
jne    11a0 <NtPasswordHash+0x80>
add    %ebp,%ebp
mov    %rsp,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1040 <md4@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @NtPasswordHash(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [512 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 512)
store i32 0, i32* %7
br label %11
11: ; preds = %25, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %28
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = load i32, i32* %7
%22 = mul nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 %23
store i8 %20, i8* %24
br label %25
25: ; preds = %15
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %11
28: ; preds = %11
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%30 = load i32, i32* %5
%31 = mul nsw i32 %30, 2
%32 = load i8*, i8** %6
%33 = call i32 @md4(i8* %29, i32 %31, i8* %32)
ret void
}

LLVM IR (-O2):
define void @NtPasswordHash(i8* nocapture %0, i32 %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 512)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %53
8: ; preds = %3
%9 = zext i32 %1 to i64
%10 = add nsw i64 %9, -1
%11 = and i64 %9, 3
%12 = icmp ult i64 %10, 3
br i1 %12, label %40, label %13
13: ; preds = %8
%14 = and i64 %9, 4294967292
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 0, %13 ], [ %37, %15 ]
%17 = phi i64 [ 0, %13 ], [ %38, %15 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %16
%19 = load i8, i8* %18
%20 = shl nuw nsw i64 %16, 1
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %20
store i8 %19, i8* %21
%22 = or i64 %16, 1
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = shl nuw nsw i64 %22, 1
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %25
store i8 %24, i8* %26
%27 = or i64 %16, 2
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = shl nuw nsw i64 %27, 1
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %30
store i8 %29, i8* %31
%32 = or i64 %16, 3
%33 = getelementptr inbounds i8, i8* %0, i64 %32
%34 = load i8, i8* %33
%35 = shl nuw nsw i64 %32, 1
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %35
store i8 %34, i8* %36
%37 = add nuw nsw i64 %16, 4
%38 = add i64 %17, 4
%39 = icmp eq i64 %38, %14
br i1 %39, label %40, label %15
40: ; preds = %15, %8
%41 = phi i64 [ 0, %8 ], [ %37, %15 ]
%42 = icmp eq i64 %11, 0
br i1 %42, label %53, label %43
43: ; preds = %40, %43
%44 = phi i64 [ %50, %43 ], [ %41, %40 ]
%45 = phi i64 [ %51, %43 ], [ 0, %40 ]
%46 = getelementptr inbounds i8, i8* %0, i64 %44
%47 = load i8, i8* %46
%48 = shl nuw nsw i64 %44, 1
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %48
store i8 %47, i8* %49
%50 = add nuw nsw i64 %44, 1
%51 = add i64 %45, 1
%52 = icmp eq i64 %51, %11
br i1 %52, label %53, label %43
53: ; preds = %40, %43, %3
%54 = shl nsw i32 %1, 1
%55 = call i32 @md4(i8* %5, i32 %54, i8* %2)
ret void
}