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

/* Variables and functions */
int /*<<< orphan*/ lm_deshash(unsigned char *, int /*<<< orphan*/ *,
                              unsigned char *);
int /*<<< orphan*/ lm_hash_password(unsigned char *, char const *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, unsigned char const *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ nt_hash_password(unsigned char *, char const *);
void ntlm_responses(unsigned char *lm_resp, unsigned char *nt_resp,
                    const unsigned char *challenge, const char *secret) {
  unsigned char hash[21];
  DES_cblock nonce;
  memcpy(&nonce, challenge, sizeof nonce);
  lm_hash_password(hash, secret);
  memset(hash + 16, 0, 5);
  lm_deshash(lm_resp, &nonce, hash);
  lm_deshash(lm_resp + 8, &nonce, hash + 7);
  lm_deshash(lm_resp + 16, &nonce, hash + 14);
  nt_hash_password(hash, secret);
  memset(hash + 16, 0, 5);
  lm_deshash(nt_resp, &nonce, hash);
  lm_deshash(nt_resp + 8, &nonce, hash + 7);
  lm_deshash(nt_resp + 16, &nonce, hash + 14);
  memset(hash, 0, sizeof hash);
}


x86 assembly (clang, -O0):
<ntlm_responses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x44(%rbp),%rdi
mov    $0x4,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <lm_hash_password@plt>
lea    -0x40(%rbp),%rdi
add    $0x10,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x44(%rbp),%rsi
call   1060 <lm_deshash@plt>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
lea    -0x40(%rbp),%rdx
add    $0x7,%rdx
lea    -0x44(%rbp),%rsi
call   1060 <lm_deshash@plt>
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
lea    -0x40(%rbp),%rdx
add    $0xe,%rdx
lea    -0x44(%rbp),%rsi
call   1060 <lm_deshash@plt>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <nt_hash_password@plt>
lea    -0x40(%rbp),%rdi
add    $0x10,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x44(%rbp),%rsi
call   1060 <lm_deshash@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
lea    -0x40(%rbp),%rdx
add    $0x7,%rdx
lea    -0x44(%rbp),%rsi
call   1060 <lm_deshash@plt>
mov    -0x10(%rbp),%rdi
add    $0x10,%rdi
lea    -0x40(%rbp),%rdx
add    $0xe,%rdx
lea    -0x44(%rbp),%rsi
call   1060 <lm_deshash@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ntlm_responses>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0x24(%rsp),%r14
mov    %r14,%rdi
mov    %rdx,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <lm_hash_password@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <lm_deshash@plt>
lea    0x8(%rbx),%rdi
lea    0x7(%rsp),%rdx
mov    %r14,%rsi
call   1060 <lm_deshash@plt>
add    $0x10,%rbx
lea    0xe(%rsp),%rbp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1060 <lm_deshash@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <nt_hash_password@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <lm_deshash@plt>
lea    0x8(%r13),%rdi
mov    %r14,%rsi
lea    0x7(%rsp),%rdx
call   1060 <lm_deshash@plt>
add    $0x10,%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1060 <lm_deshash@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ntlm_responses(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [21 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %7
%12 = call i32 @memcpy(i32* %10, i8* %11, i32 4)
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%14 = load i8*, i8** %8
%15 = call i32 @lm_hash_password(i8* %13, i8* %14)
%16 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%17 = getelementptr inbounds i8, i8* %16, i64 16
%18 = call i32 @memset(i8* %17, i32 0, i32 5)
%19 = load i8*, i8** %5
%20 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%21 = call i32 @lm_deshash(i8* %19, i32* %10, i8* %20)
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 8
%24 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%25 = getelementptr inbounds i8, i8* %24, i64 7
%26 = call i32 @lm_deshash(i8* %23, i32* %10, i8* %25)
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 16
%29 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%30 = getelementptr inbounds i8, i8* %29, i64 14
%31 = call i32 @lm_deshash(i8* %28, i32* %10, i8* %30)
%32 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%33 = load i8*, i8** %8
%34 = call i32 @nt_hash_password(i8* %32, i8* %33)
%35 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 16
%37 = call i32 @memset(i8* %36, i32 0, i32 5)
%38 = load i8*, i8** %6
%39 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%40 = call i32 @lm_deshash(i8* %38, i32* %10, i8* %39)
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 8
%43 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%44 = getelementptr inbounds i8, i8* %43, i64 7
%45 = call i32 @lm_deshash(i8* %42, i32* %10, i8* %44)
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i64 16
%48 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%49 = getelementptr inbounds i8, i8* %48, i64 14
%50 = call i32 @lm_deshash(i8* %47, i32* %10, i8* %49)
%51 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%52 = call i32 @memset(i8* %51, i32 0, i32 21)
ret void
}

LLVM IR (-O2):
define void @ntlm_responses(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [21 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%8 = bitcast i32* %6 to i8*
%9 = call i32 @memcpy(i32* %6, i8* %2, i32 4)
%10 = call i32 @lm_hash_password(i8* %7, i8* %3)
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 16
%12 = call i32 @memset(i8* %11, i32 0, i32 5)
%13 = call i32 @lm_deshash(i8* %0, i32* %6, i8* %7)
%14 = getelementptr inbounds i8, i8* %0, i64 8
%15 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 7
%16 = call i32 @lm_deshash(i8* %14, i32* %6, i8* %15)
%17 = getelementptr inbounds i8, i8* %0, i64 16
%18 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 14
%19 = call i32 @lm_deshash(i8* %17, i32* %6, i8* %18)
%20 = call i32 @nt_hash_password(i8* %7, i8* %3)
%21 = call i32 @memset(i8* %11, i32 0, i32 5)
%22 = call i32 @lm_deshash(i8* %1, i32* %6, i8* %7)
%23 = getelementptr inbounds i8, i8* %1, i64 8
%24 = call i32 @lm_deshash(i8* %23, i32* %6, i8* %15)
%25 = getelementptr inbounds i8, i8* %1, i64 16
%26 = call i32 @lm_deshash(i8* %25, i32* %6, i8* %18)
%27 = call i32 @memset(i8* %7, i32 0, i32 21)
ret void
}