#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*/ _my_mbstowcs(short *, unsigned char *, int);
int _my_wcslen(short *);
int /*<<< orphan*/ mdfour(unsigned char *, unsigned char *, int);
int strlen(char *);
void E_md4hash(unsigned char *passwd, unsigned char *p16) {
  int len;
  signed short wpwd[129];
  len = strlen((char *)passwd);
  if (len > 128)
    len = 128;
  _my_mbstowcs(wpwd, passwd, len);
  wpwd[len] = 0;
  len = _my_wcslen(wpwd) * sizeof(signed short);
  mdfour(p16, (unsigned char *)wpwd, len);
}


x86 assembly (clang, -O0):
<E_md4hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jle    1173 <E_md4hash+0x33>
movl   $0x80,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <_my_mbstowcs@plt>
movslq -0x14(%rbp),%rax
movw   $0x0,-0x120(%rbp,%rax,2)
lea    -0x120(%rbp),%rdi
call   1040 <_my_wcslen@plt>
cltq
shl    $0x1,%rax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <mdfour@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<E_md4hash>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <strlen@plt>
cmp    $0x80,%eax
mov    $0x80,%ebp
cmovl  %eax,%ebp
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <_my_mbstowcs@plt>
movslq %ebp,%rax
movw   $0x0,(%rsp,%rax,2)
mov    %r15,%rdi
call   1040 <_my_wcslen@plt>
lea    (%rax,%rax,1),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <mdfour@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @E_md4hash(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [129 x i16]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 128
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 128, i32* %5
br label %12
12: ; preds = %11, %2
%13 = getelementptr inbounds [129 x i16], [129 x i16]* %6, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = call i32 @_my_mbstowcs(i16* %13, i8* %14, i32 %15)
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [129 x i16], [129 x i16]* %6, i64 0, i64 %18
store i16 0, i16* %19
%20 = getelementptr inbounds [129 x i16], [129 x i16]* %6, i64 0, i64 0
%21 = call i32 @_my_wcslen(i16* %20)
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 2
%24 = trunc i64 %23 to i32
store i32 %24, i32* %5
%25 = load i8*, i8** %4
%26 = getelementptr inbounds [129 x i16], [129 x i16]* %6, i64 0, i64 0
%27 = bitcast i16* %26 to i8*
%28 = load i32, i32* %5
%29 = call i32 @mdfour(i8* %25, i8* %27, i32 %28)
ret void
}

LLVM IR (-O2):
define void @E_md4hash(i8* %0, i8* %1) {
%3 = alloca [129 x i16]
%4 = bitcast [129 x i16]* %3 to i8*
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp slt i32 %5, 128
%7 = select i1 %6, i32 %5, i32 128
%8 = getelementptr inbounds [129 x i16], [129 x i16]* %3, i64 0, i64 0
%9 = call i32 @_my_mbstowcs(i16* %8, i8* %0, i32 %7)
%10 = sext i32 %7 to i64
%11 = getelementptr inbounds [129 x i16], [129 x i16]* %3, i64 0, i64 %10
store i16 0, i16* %11
%12 = call i32 @_my_wcslen(i16* %8)
%13 = shl i32 %12, 1
%14 = call i32 @mdfour(i8* %1, i8* %4, i32 %13)
ret void
}