#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*/ GetRand(char *);
int /*<<< orphan*/ TriDesEncrypt(char *, int, char *, int, char *);
int /*<<< orphan*/ hex2str(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ str2hex(char *, int, char *);
void GetMAK(char *Tmk, char *MakTmkKey, char *MakKey, char *CheckValue) {
  char Mak[16];
  char HexTmk[17];
  char HexMakTmkKey[17];
  char HexCheckValue[8];
  GetRand(Mak);
  memset(Mak + 8, 0, 8);
  str2hex(HexTmk, 16, Tmk);
  memset(HexMakTmkKey, 0, 17);
  TriDesEncrypt(HexTmk, 16, Mak, 8, HexMakTmkKey);
  hex2str(MakTmkKey, HexMakTmkKey, 32);
  hex2str(MakKey, Mak, 32);
  TriDesEncrypt(Mak, 8, "\x00\x00\x00\x00\x00\x00\x00\x00", 8, HexCheckValue);
  hex2str(CheckValue, HexCheckValue, 8);
}


x86 assembly (clang, -O0):
<GetMAK>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <GetRand@plt>
lea    -0x30(%rbp),%rdi
add    $0x8,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x10,%esi
call   1050 <str2hex@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x70(%rbp),%r8
mov    $0x10,%esi
mov    $0x8,%ecx
call   1030 <TriDesEncrypt@plt>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x20,%edx
call   1070 <hex2str@plt>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x20,%edx
call   1070 <hex2str@plt>
lea    -0x30(%rbp),%rdi
lea    -0x78(%rbp),%r8
mov    $0x8,%ecx
lea    0xe03(%rip),%rdx
mov    %ecx,%esi
call   1030 <TriDesEncrypt@plt>
mov    -0x20(%rbp),%rdi
lea    -0x78(%rbp),%rsi
mov    $0x8,%edx
call   1070 <hex2str@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetMAK>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsp,%r13
mov    %r13,%rdi
call   1060 <GetRand@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x10,%esi
mov    %rbx,%rdx
call   1050 <str2hex@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
mov    %rbp,%rdi
mov    $0x10,%esi
mov    %r13,%rdx
mov    $0x8,%ecx
mov    %rbx,%r8
call   1030 <TriDesEncrypt@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1070 <hex2str@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x20,%edx
call   1070 <hex2str@plt>
lea    0xe12(%rip),%rdx
lea    0x18(%rsp),%rbx
mov    %r13,%rdi
mov    $0x8,%esi
mov    $0x8,%ecx
mov    %rbx,%r8
call   1030 <TriDesEncrypt@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1070 <hex2str@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] zeroinitializer
define void @GetMAK(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [16 x i8]
%10 = alloca [17 x i8]
%11 = alloca [17 x i8]
%12 = alloca [8 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%14 = call i32 @GetRand(i8* %13)
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%16 = getelementptr inbounds i8, i8* %15, i64 8
%17 = call i32 @memset(i8* %16, i32 0, i32 8)
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 0
%19 = load i8*, i8** %5
%20 = call i32 @str2hex(i8* %18, i32 16, i8* %19)
%21 = getelementptr inbounds [17 x i8], [17 x i8]* %11, i64 0, i64 0
%22 = call i32 @memset(i8* %21, i32 0, i32 17)
%23 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 0
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%25 = getelementptr inbounds [17 x i8], [17 x i8]* %11, i64 0, i64 0
%26 = call i32 @TriDesEncrypt(i8* %23, i32 16, i8* %24, i32 8, i8* %25)
%27 = load i8*, i8** %6
%28 = getelementptr inbounds [17 x i8], [17 x i8]* %11, i64 0, i64 0
%29 = call i32 @hex2str(i8* %27, i8* %28, i32 32)
%30 = load i8*, i8** %7
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%32 = call i32 @hex2str(i8* %30, i8* %31, i32 32)
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%35 = call i32 @TriDesEncrypt(i8* %33, i32 8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8, i8* %34)
%36 = load i8*, i8** %8
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%38 = call i32 @hex2str(i8* %36, i8* %37, i32 8)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] zeroinitializer
define void @GetMAK(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [16 x i8]
%6 = alloca [17 x i8]
%7 = alloca [17 x i8]
%8 = alloca [8 x i8]
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%13 = call i32 @GetRand(i8* %9)
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 8
%15 = call i32 @memset(i8* %14, i32 0, i32 8)
%16 = call i32 @str2hex(i8* %10, i32 16, i8* %0)
%17 = call i32 @memset(i8* %11, i32 0, i32 17)
%18 = call i32 @TriDesEncrypt(i8* %10, i32 16, i8* %9, i32 8, i8* %11)
%19 = call i32 @hex2str(i8* %1, i8* %11, i32 32)
%20 = call i32 @hex2str(i8* %2, i8* %9, i32 32)
%21 = call i32 @TriDesEncrypt(i8* %9, i32 8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8, i8* %12)
%22 = call i32 @hex2str(i8* %3, i8* %12, i32 8)
ret void
}