#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 GetTMK(char *TK, char *TmkTkKey, char *TmkKey) {
  char Tmk[16];
  char HexTK[17];
  char HexTmkTkKey[17];
  memset(Tmk, 0, 16);
  GetRand(Tmk);
  str2hex(HexTK, 16, TK);
  TriDesEncrypt(HexTK, 16, Tmk, 16, HexTmkTkKey);
  hex2str(TmkTkKey, HexTmkTkKey, 32);
  hex2str(TmkKey, Tmk, 32);
}


x86 assembly (clang, -O0):
<GetTMK>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
call   1060 <GetRand@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x10,%esi
call   1050 <str2hex@plt>
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x70(%rbp),%r8
mov    $0x10,%ecx
mov    %ecx,%esi
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>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetTMK>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
call   1060 <GetRand@plt>
lea    0x30(%rsp),%r13
mov    %r13,%rdi
mov    $0x10,%esi
mov    %rbx,%rdx
call   1050 <str2hex@plt>
lea    0x10(%rsp),%rbx
mov    %r13,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
mov    $0x10,%ecx
mov    %rbx,%r8
call   1030 <TriDesEncrypt@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1070 <hex2str@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x20,%edx
call   1070 <hex2str@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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