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

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ smbhash(unsigned char *, unsigned char const *,
                           unsigned char *);
void grad_mschap(const unsigned char *win_password,
                 const unsigned char *challenge, unsigned char *response) {
  unsigned char p21[21];
  memset(p21, 0, sizeof(p21));
  memcpy(p21, win_password, 16);
  smbhash(response, challenge, p21);
  smbhash(response + 8, challenge, p21 + 7);
  smbhash(response + 16, challenge, p21 + 14);
}


x86 assembly (clang, -O0):
<grad_mschap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <smbhash@plt>
mov    -0x18(%rbp),%rdi
add    $0x8,%rdi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
add    $0x7,%rdx
call   1030 <smbhash@plt>
mov    -0x18(%rbp),%rdi
add    $0x10,%rdi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
add    $0xe,%rdx
call   1030 <smbhash@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grad_mschap>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsp,%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <smbhash@plt>
lea    0x8(%rbx),%rdi
lea    0x7(%rsp),%rdx
mov    %r14,%rsi
call   1030 <smbhash@plt>
add    $0x10,%rbx
lea    0xe(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <smbhash@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @grad_mschap(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [21 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 21)
%10 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @memcpy(i8* %10, i8* %11, i32 16)
%13 = load i8*, i8** %6
%14 = load i8*, i8** %5
%15 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%16 = call i32 @smbhash(i8* %13, i8* %14, i8* %15)
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 8
%19 = load i8*, i8** %5
%20 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%21 = getelementptr inbounds i8, i8* %20, i64 7
%22 = call i32 @smbhash(i8* %18, i8* %19, i8* %21)
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i64 16
%25 = load i8*, i8** %5
%26 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%27 = getelementptr inbounds i8, i8* %26, i64 14
%28 = call i32 @smbhash(i8* %24, i8* %25, i8* %27)
ret void
}

LLVM IR (-O2):
define void @grad_mschap(i8* %0, i8* %1, i8* %2) {
%4 = alloca [21 x i8]
%5 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 21)
%7 = call i32 @memcpy(i8* %5, i8* %0, i32 16)
%8 = call i32 @smbhash(i8* %2, i8* %1, i8* %5)
%9 = getelementptr inbounds i8, i8* %2, i64 8
%10 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 7
%11 = call i32 @smbhash(i8* %9, i8* %1, i8* %10)
%12 = getelementptr inbounds i8, i8* %2, i64 16
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 14
%14 = call i32 @smbhash(i8* %12, i8* %1, i8* %13)
ret void
}