#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*/ g_memcpy(char *, char *, int);
int /*<<< orphan*/ g_memset(char *, int, int);
int /*<<< orphan*/ ssl_md5_clear(void *);
int /*<<< orphan*/ ssl_md5_complete(void *, char *);
void *ssl_md5_info_create();
int /*<<< orphan*/ ssl_md5_info_delete(void *);
int /*<<< orphan*/ ssl_md5_transform(void *, char *, int);
int /*<<< orphan*/ ssl_sha1_clear(void *);
int /*<<< orphan*/ ssl_sha1_complete(void *, char *);
void *ssl_sha1_info_create();
int /*<<< orphan*/ ssl_sha1_info_delete(void *);
int /*<<< orphan*/ ssl_sha1_transform(void *, char *, int);
void xrdp_sec_hash_48(char *out, char *in, char *salt1, char *salt2, int salt) {
  int i;
  void *sha1_info;
  void *md5_info;
  char pad[4];
  char sha1_sig[20];
  char md5_sig[16];
  sha1_info = ssl_sha1_info_create();
  md5_info = ssl_md5_info_create();
  for (i = 0; i < 3; i++) {
    g_memset(pad, salt + i, 4);
    ssl_sha1_clear(sha1_info);
    ssl_sha1_transform(sha1_info, pad, i + 1);
    ssl_sha1_transform(sha1_info, in, 48);
    ssl_sha1_transform(sha1_info, salt1, 32);
    ssl_sha1_transform(sha1_info, salt2, 32);
    ssl_sha1_complete(sha1_info, sha1_sig);
    ssl_md5_clear(md5_info);
    ssl_md5_transform(md5_info, in, 48);
    ssl_md5_transform(md5_info, sha1_sig, 20);
    ssl_md5_complete(md5_info, md5_sig);
    g_memcpy(out + i * 16, md5_sig, 16);
  }
  ssl_sha1_info_delete(sha1_info);
  ssl_md5_info_delete(md5_info);
}


x86 assembly (clang, -O0):
<xrdp_sec_hash_48>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    $0x0,%al
call   1090 <ssl_sha1_info_create@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   10c0 <ssl_md5_info_create@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    12db <xrdp_sec_hash_48+0x11b>
lea    -0x3c(%rbp),%rdi
mov    -0x24(%rbp),%esi
add    -0x28(%rbp),%esi
mov    $0x4,%edx
call   1030 <g_memset@plt>
mov    -0x30(%rbp),%rdi
call   1080 <ssl_sha1_clear@plt>
mov    -0x30(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
mov    -0x28(%rbp),%edx
add    $0x1,%edx
call   1060 <ssl_sha1_transform@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x30,%edx
call   1060 <ssl_sha1_transform@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x20,%edx
call   1060 <ssl_sha1_transform@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x20,%edx
call   1060 <ssl_sha1_transform@plt>
mov    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <ssl_sha1_complete@plt>
mov    -0x38(%rbp),%rdi
call   1040 <ssl_md5_clear@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x30,%edx
call   10d0 <ssl_md5_transform@plt>
mov    -0x38(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x14,%edx
call   10d0 <ssl_md5_transform@plt>
mov    -0x38(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   10e0 <ssl_md5_complete@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%eax
shl    $0x4,%eax
cltq
add    %rax,%rdi
lea    -0x60(%rbp),%rsi
mov    $0x10,%edx
call   10a0 <g_memcpy@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f9 <xrdp_sec_hash_48+0x39>
mov    -0x30(%rbp),%rdi
call   10b0 <ssl_sha1_info_delete@plt>
mov    -0x38(%rbp),%rdi
call   1050 <ssl_md5_info_delete@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrdp_sec_hash_48>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8d,%ebp
mov    %rbp,0x10(%rsp)
mov    %rcx,(%rsp)
mov    %rdx,%r14
mov    %rdx,0x18(%rsp)
mov    %rsi,%r12
mov    %rdi,0x28(%rsp)
xor    %eax,%eax
call   1090 <ssl_sha1_info_create@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   10c0 <ssl_md5_info_create@plt>
mov    %rax,%r15
lea    0xc(%rsp),%r13
mov    %r13,%rdi
mov    %ebp,%esi
mov    $0x4,%edx
call   1030 <g_memset@plt>
mov    %rbx,%rdi
call   1080 <ssl_sha1_clear@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r12,0x20(%rsp)
mov    $0x30,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x20,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    (%rsp),%rsi
mov    $0x20,%edx
call   1060 <ssl_sha1_transform@plt>
lea    0x40(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <ssl_sha1_complete@plt>
mov    %r15,%rdi
call   1040 <ssl_md5_clear@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x30,%edx
call   10d0 <ssl_md5_transform@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x14,%edx
call   10d0 <ssl_md5_transform@plt>
lea    0x30(%rsp),%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
call   10e0 <ssl_md5_complete@plt>
mov    0x28(%rsp),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x10,%edx
call   10a0 <g_memcpy@plt>
mov    0x10(%rsp),%rax
lea    0x1(%rax),%esi
mov    %r13,%rdi
mov    $0x4,%edx
call   1030 <g_memset@plt>
mov    %rbx,%rdi
call   1080 <ssl_sha1_clear@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x2,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    0x20(%rsp),%r13
mov    %r13,%rsi
mov    $0x30,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
mov    $0x20,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    (%rsp),%rsi
mov    $0x20,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <ssl_sha1_complete@plt>
mov    %r15,%rdi
call   1040 <ssl_md5_clear@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x30,%edx
call   10d0 <ssl_md5_transform@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x14,%edx
call   10d0 <ssl_md5_transform@plt>
mov    %r15,%rdi
lea    0x30(%rsp),%r14
mov    %r14,%rsi
call   10e0 <ssl_md5_complete@plt>
lea    0x10(%r12),%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   10a0 <g_memcpy@plt>
mov    0x10(%rsp),%rsi
add    $0x2,%esi
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x4,%edx
call   1030 <g_memset@plt>
mov    %rbx,%rdi
call   1080 <ssl_sha1_clear@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x30,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
mov    $0x20,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
mov    (%rsp),%rsi
mov    $0x20,%edx
call   1060 <ssl_sha1_transform@plt>
mov    %rbx,%rdi
lea    0x40(%rsp),%rbp
mov    %rbp,%rsi
call   1070 <ssl_sha1_complete@plt>
mov    %r15,%rdi
call   1040 <ssl_md5_clear@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x30,%edx
call   10d0 <ssl_md5_transform@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x14,%edx
call   10d0 <ssl_md5_transform@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10e0 <ssl_md5_complete@plt>
add    $0x20,%r12
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   10a0 <g_memcpy@plt>
mov    %rbx,%rdi
call   10b0 <ssl_sha1_info_delete@plt>
mov    %r15,%rdi
call   1050 <ssl_md5_info_delete@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @xrdp_sec_hash_48(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca [4 x i8]
%15 = alloca [20 x i8]
%16 = alloca [16 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%17 = call i8* (...) @ssl_sha1_info_create()
store i8* %17, i8** %12
%18 = call i8* (...) @ssl_md5_info_create()
store i8* %18, i8** %13
store i32 0, i32* %11
br label %19
19: ; preds = %65, %5
%20 = load i32, i32* %11
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %68
22: ; preds = %19
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %14, i64 0, i64 0
%24 = load i32, i32* %10
%25 = load i32, i32* %11
%26 = add nsw i32 %24, %25
%27 = call i32 @g_memset(i8* %23, i32 %26, i32 4)
%28 = load i8*, i8** %12
%29 = call i32 @ssl_sha1_clear(i8* %28)
%30 = load i8*, i8** %12
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %14, i64 0, i64 0
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
%34 = call i32 @ssl_sha1_transform(i8* %30, i8* %31, i32 %33)
%35 = load i8*, i8** %12
%36 = load i8*, i8** %7
%37 = call i32 @ssl_sha1_transform(i8* %35, i8* %36, i32 48)
%38 = load i8*, i8** %12
%39 = load i8*, i8** %8
%40 = call i32 @ssl_sha1_transform(i8* %38, i8* %39, i32 32)
%41 = load i8*, i8** %12
%42 = load i8*, i8** %9
%43 = call i32 @ssl_sha1_transform(i8* %41, i8* %42, i32 32)
%44 = load i8*, i8** %12
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %15, i64 0, i64 0
%46 = call i32 @ssl_sha1_complete(i8* %44, i8* %45)
%47 = load i8*, i8** %13
%48 = call i32 @ssl_md5_clear(i8* %47)
%49 = load i8*, i8** %13
%50 = load i8*, i8** %7
%51 = call i32 @ssl_md5_transform(i8* %49, i8* %50, i32 48)
%52 = load i8*, i8** %13
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %15, i64 0, i64 0
%54 = call i32 @ssl_md5_transform(i8* %52, i8* %53, i32 20)
%55 = load i8*, i8** %13
%56 = getelementptr inbounds [16 x i8], [16 x i8]* %16, i64 0, i64 0
%57 = call i32 @ssl_md5_complete(i8* %55, i8* %56)
%58 = load i8*, i8** %6
%59 = load i32, i32* %11
%60 = mul nsw i32 %59, 16
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %16, i64 0, i64 0
%64 = call i32 @g_memcpy(i8* %62, i8* %63, i32 16)
br label %65
65: ; preds = %22
%66 = load i32, i32* %11
%67 = add nsw i32 %66, 1
store i32 %67, i32* %11
br label %19
68: ; preds = %19
%69 = load i8*, i8** %12
%70 = call i32 @ssl_sha1_info_delete(i8* %69)
%71 = load i8*, i8** %13
%72 = call i32 @ssl_md5_info_delete(i8* %71)
ret void
}

LLVM IR (-O2):
define void @xrdp_sec_hash_48(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca [4 x i8]
%7 = alloca [20 x i8]
%8 = alloca [16 x i8]
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%12 = tail call i8* (...) @ssl_sha1_info_create()
%13 = tail call i8* (...) @ssl_md5_info_create()
%14 = call i32 @g_memset(i8* %9, i32 %4, i32 4)
%15 = call i32 @ssl_sha1_clear(i8* %12)
%16 = call i32 @ssl_sha1_transform(i8* %12, i8* %9, i32 1)
%17 = call i32 @ssl_sha1_transform(i8* %12, i8* %1, i32 48)
%18 = call i32 @ssl_sha1_transform(i8* %12, i8* %2, i32 32)
%19 = call i32 @ssl_sha1_transform(i8* %12, i8* %3, i32 32)
%20 = call i32 @ssl_sha1_complete(i8* %12, i8* %10)
%21 = call i32 @ssl_md5_clear(i8* %13)
%22 = call i32 @ssl_md5_transform(i8* %13, i8* %1, i32 48)
%23 = call i32 @ssl_md5_transform(i8* %13, i8* %10, i32 20)
%24 = call i32 @ssl_md5_complete(i8* %13, i8* %11)
%25 = call i32 @g_memcpy(i8* %0, i8* %11, i32 16)
%26 = add i32 %4, 1
%27 = call i32 @g_memset(i8* %9, i32 %26, i32 4)
%28 = call i32 @ssl_sha1_clear(i8* %12)
%29 = call i32 @ssl_sha1_transform(i8* %12, i8* %9, i32 2)
%30 = call i32 @ssl_sha1_transform(i8* %12, i8* %1, i32 48)
%31 = call i32 @ssl_sha1_transform(i8* %12, i8* %2, i32 32)
%32 = call i32 @ssl_sha1_transform(i8* %12, i8* %3, i32 32)
%33 = call i32 @ssl_sha1_complete(i8* %12, i8* %10)
%34 = call i32 @ssl_md5_clear(i8* %13)
%35 = call i32 @ssl_md5_transform(i8* %13, i8* %1, i32 48)
%36 = call i32 @ssl_md5_transform(i8* %13, i8* %10, i32 20)
%37 = call i32 @ssl_md5_complete(i8* %13, i8* %11)
%38 = getelementptr inbounds i8, i8* %0, i64 16
%39 = call i32 @g_memcpy(i8* %38, i8* %11, i32 16)
%40 = add i32 %4, 2
%41 = call i32 @g_memset(i8* %9, i32 %40, i32 4)
%42 = call i32 @ssl_sha1_clear(i8* %12)
%43 = call i32 @ssl_sha1_transform(i8* %12, i8* %9, i32 3)
%44 = call i32 @ssl_sha1_transform(i8* %12, i8* %1, i32 48)
%45 = call i32 @ssl_sha1_transform(i8* %12, i8* %2, i32 32)
%46 = call i32 @ssl_sha1_transform(i8* %12, i8* %3, i32 32)
%47 = call i32 @ssl_sha1_complete(i8* %12, i8* %10)
%48 = call i32 @ssl_md5_clear(i8* %13)
%49 = call i32 @ssl_md5_transform(i8* %13, i8* %1, i32 48)
%50 = call i32 @ssl_md5_transform(i8* %13, i8* %10, i32 20)
%51 = call i32 @ssl_md5_complete(i8* %13, i8* %11)
%52 = getelementptr inbounds i8, i8* %0, i64 32
%53 = call i32 @g_memcpy(i8* %52, i8* %11, i32 16)
%54 = call i32 @ssl_sha1_info_delete(i8* %12)
%55 = call i32 @ssl_md5_info_delete(i8* %13)
ret void
}