#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 char uint8_t;

/* Variables and functions */
int /*<<< orphan*/ des(char *, char *, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
size_t strlen(char const *);
char toupper(char const);
void lm_create_hash(const char *password, uint8_t result[16]) {
  size_t i;
  uint8_t password1[7];
  uint8_t password2[7];
  uint8_t kgs[] = "KGS!@#$%";
  uint8_t hash1[8];
  uint8_t hash2[8];
  memset(password1, 0, 7);
  memset(password2, 0, 7);
  for (i = 0; i < 7; i++) {
    if (i < strlen(password))
      password1[i] = toupper(password[i]);
    if (i + 7 < strlen(password))
      password2[i] = toupper(password[i + 7]);
  }
  des(password1, kgs, hash1);
  des(password2, kgs, hash2);
  memcpy(result + 0, hash1, 8);
  memcpy(result + 8, hash2, 8);
}


x86 assembly (clang, -O0):
<lm_create_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x2f(%rbp)
mov    0xe97(%rip),%al
mov    %al,-0x27(%rbp)
lea    -0x1f(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1060 <memset@plt>
lea    -0x26(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1060 <memset@plt>
movq   $0x0,-0x18(%rbp)
cmpq   $0x7,-0x18(%rbp)
jae    123a <lm_create_hash+0xea>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jae    11e3 <lm_create_hash+0x93>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,-0x1f(%rbp,%rax,1)
mov    -0x18(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
jae    1224 <lm_create_hash+0xd4>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl 0x7(%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,-0x26(%rbp,%rax,1)
jmp    1229 <lm_create_hash+0xd9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119c <lm_create_hash+0x4c>
lea    -0x1f(%rbp),%rdi
lea    -0x2f(%rbp),%rsi
lea    -0x37(%rbp),%rdx
call   1050 <des@plt>
lea    -0x26(%rbp),%rdi
lea    -0x2f(%rbp),%rsi
lea    -0x3f(%rbp),%rdx
call   1050 <des@plt>
mov    -0x10(%rbp),%rdi
lea    -0x37(%rbp),%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
lea    -0x3f(%rbp),%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lm_create_hash>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movabs $0x252423402153474b,%rax
23 24 25
mov    %rax,0x18(%rsp)
movb   $0x0,0x20(%rsp)
lea    0x11(%rsp),%rdi
xor    %r12d,%r12d
xor    %esi,%esi
mov    $0x7,%edx
call   1060 <memset@plt>
lea    0xa(%rsp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1060 <memset@plt>
jmp    11ad <lm_create_hash+0x5d>
nopl   0x0(%rax)
add    $0xfffffffffffffffa,%rbx
mov    %rbx,%r12
cmp    $0x7,%rbx
je     11ed <lm_create_hash+0x9d>
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    %rax,%r12
jae    11c9 <lm_create_hash+0x79>
movsbl (%r15,%r12,1),%edi
call   1030 <toupper@plt>
mov    %al,0x11(%rsp,%r12,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0x7(%r12),%rbx
cmp    %rax,%rbx
jae    11a0 <lm_create_hash+0x50>
movsbl 0x7(%r15,%r12,1),%edi
call   1030 <toupper@plt>
mov    %al,0xa(%rsp,%r12,1)
jmp    11a0 <lm_create_hash+0x50>
lea    0x11(%rsp),%rdi
lea    0x18(%rsp),%rbx
lea    0x30(%rsp),%r15
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <des@plt>
lea    0xa(%rsp),%rdi
lea    0x28(%rsp),%r12
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <des@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
add    $0x8,%r14
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.lm_create_hash.kgs = [9 x i8] c"KGS!@#$%\00"
define void @lm_create_hash(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [7 x i8]
%7 = alloca [7 x i8]
%8 = alloca [9 x i8]
%9 = alloca [8 x i8]
%10 = alloca [8 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%11 = bitcast [9 x i8]* %8 to i8*
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 7)
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 7)
store i64 0, i64* %5
br label %16
16: ; preds = %48, %2
%17 = load i64, i64* %5
%18 = icmp ult i64 %17, 7
br i1 %18, label %19, label %51
19: ; preds = %16
%20 = load i64, i64* %5
%21 = load i8*, i8** %3
%22 = call i64 @strlen(i8* %21)
%23 = icmp ult i64 %20, %22
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i64, i64* %5
%27 = getelementptr inbounds i8, i8* %25, i64 %26
%28 = load i8, i8* %27
%29 = call signext i8 @toupper(i8 signext %28)
%30 = load i64, i64* %5
%31 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 %30
store i8 %29, i8* %31
br label %32
32: ; preds = %24, %19
%33 = load i64, i64* %5
%34 = add i64 %33, 7
%35 = load i8*, i8** %3
%36 = call i64 @strlen(i8* %35)
%37 = icmp ult i64 %34, %36
br i1 %37, label %38, label %47
38: ; preds = %32
%39 = load i8*, i8** %3
%40 = load i64, i64* %5
%41 = add i64 %40, 7
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = call signext i8 @toupper(i8 signext %43)
%45 = load i64, i64* %5
%46 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %45
store i8 %44, i8* %46
br label %47
47: ; preds = %38, %32
br label %48
48: ; preds = %47
%49 = load i64, i64* %5
%50 = add i64 %49, 1
store i64 %50, i64* %5
br label %16
51: ; preds = %16
%52 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%53 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%54 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%55 = call i32 @des(i8* %52, i8* %53, i8* %54)
%56 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 0
%57 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%58 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%59 = call i32 @des(i8* %56, i8* %57, i8* %58)
%60 = load i8*, i8** %4
%61 = getelementptr inbounds i8, i8* %60, i64 0
%62 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%63 = call i32 @memcpy(i8* %61, i8* %62, i32 8)
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i64 8
%66 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%67 = call i32 @memcpy(i8* %65, i8* %66, i32 8)
ret void
}

LLVM IR (-O2):
@__const.lm_create_hash.kgs = [9 x i8] c"KGS!@#$%\00"
define void @lm_create_hash(i8* nocapture %0, i8* %1) {
%3 = alloca [7 x i8]
%4 = alloca [7 x i8]
%5 = alloca [9 x i8]
%6 = alloca [8 x i8]
%7 = alloca [8 x i8]
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%13 = call i32 @memset(i8* %8, i32 0, i32 7)
%14 = call i32 @memset(i8* %9, i32 0, i32 7)
br label %15
15: ; preds = %2, %33
%16 = phi i64 [ 0, %2 ], [ %34, %33 ]
%17 = call i64 @strlen(i8* dereferenceable(1) %0)
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = getelementptr inbounds i8, i8* %0, i64 %16
%21 = load i8, i8* %20
%22 = call signext i8 @toupper(i8 signext %21)
%23 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 %16
store i8 %22, i8* %23
br label %24
24: ; preds = %19, %15
%25 = add nuw nsw i64 %16, 7
%26 = call i64 @strlen(i8* dereferenceable(1) %0)
%27 = icmp ult i64 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = getelementptr inbounds i8, i8* %0, i64 %25
%30 = load i8, i8* %29
%31 = call signext i8 @toupper(i8 signext %30)
%32 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 %16
store i8 %31, i8* %32
br label %33
33: ; preds = %24, %28
%34 = add nuw nsw i64 %16, 1
%35 = icmp eq i64 %34, 7
br i1 %35, label %36, label %15
36: ; preds = %33
%37 = call i32 @des(i8* %8, i8* %10, i8* %11)
%38 = call i32 @des(i8* %9, i8* %10, i8* %12)
%39 = call i32 @memcpy(i8* %1, i8* %11, i32 8)
%40 = getelementptr inbounds i8, i8* %1, i64 8
%41 = call i32 @memcpy(i8* %40, i8* %12, i32 8)
ret void
}