#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*/ TriDesDecrypt(char *, int, char *, int, char *);
int /*<<< orphan*/ TriDesEncrypt(char *, int, char *, int, char *);
int /*<<< orphan*/ hex2str(char *, char *, int);
int /*<<< orphan*/ str2hex(char *, int, char *);
void UnTRK(char *Zmk, char *TrkZmkKey, char *TrkKey, char *CheckValue) {
  char Trk[16];
  char HexZmk[17];
  char HexTrkZmkKey[17];
  char HexCheckValue[8];
  str2hex(HexZmk, 16, Zmk);
  str2hex(HexTrkZmkKey, 16, TrkZmkKey);
  TriDesDecrypt(HexZmk, 16, HexTrkZmkKey, 16, Trk);
  hex2str(TrkKey, Trk, 32);
  TriDesEncrypt(Trk, 16, "\x00\x00\x00\x00\x00\x00\x00\x00", 8, HexCheckValue);
  hex2str(CheckValue, HexCheckValue, 8);
}


x86 assembly (clang, -O0):
<UnTRK>:
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    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x10,%esi
call   1050 <str2hex@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x10,%esi
call   1050 <str2hex@plt>
lea    -0x50(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    -0x30(%rbp),%r8
mov    $0x10,%ecx
mov    %ecx,%esi
call   1040 <TriDesDecrypt@plt>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x20,%edx
call   1060 <hex2str@plt>
lea    -0x30(%rbp),%rdi
lea    -0x78(%rbp),%r8
mov    $0x10,%esi
lea    0xe43(%rip),%rdx
mov    $0x8,%ecx
call   1030 <TriDesEncrypt@plt>
mov    -0x20(%rbp),%rdi
lea    -0x78(%rbp),%rsi
mov    $0x8,%edx
call   1060 <hex2str@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UnTRK>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rdx
lea    0x40(%rsp),%r12
mov    %r12,%rdi
mov    $0x10,%esi
call   1050 <str2hex@plt>
lea    0x20(%rsp),%r13
mov    %r13,%rdi
mov    $0x10,%esi
mov    %rbx,%rdx
call   1050 <str2hex@plt>
lea    0x10(%rsp),%rbx
mov    %r12,%rdi
mov    $0x10,%esi
mov    %r13,%rdx
mov    $0x10,%ecx
mov    %rbx,%r8
call   1040 <TriDesDecrypt@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1060 <hex2str@plt>
lea    0xe4c(%rip),%rdx
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    $0x10,%esi
mov    $0x8,%ecx
mov    %r15,%r8
call   1030 <TriDesEncrypt@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1060 <hex2str@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] zeroinitializer
define void @UnTRK(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 [17 x i8], [17 x i8]* %10, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = call i32 @str2hex(i8* %13, i32 16, i8* %14)
%16 = getelementptr inbounds [17 x i8], [17 x i8]* %11, i64 0, i64 0
%17 = load i8*, i8** %6
%18 = call i32 @str2hex(i8* %16, i32 16, i8* %17)
%19 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 0
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %11, i64 0, i64 0
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%22 = call i32 @TriDesDecrypt(i8* %19, i32 16, i8* %20, i32 16, i8* %21)
%23 = load i8*, i8** %7
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%25 = call i32 @hex2str(i8* %23, i8* %24, i32 32)
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%28 = call i32 @TriDesEncrypt(i8* %26, i32 16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8, i8* %27)
%29 = load i8*, i8** %8
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%31 = call i32 @hex2str(i8* %29, i8* %30, i32 8)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] zeroinitializer
define void @UnTRK(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 @str2hex(i8* %10, i32 16, i8* %0)
%14 = call i32 @str2hex(i8* %11, i32 16, i8* %1)
%15 = call i32 @TriDesDecrypt(i8* %10, i32 16, i8* %11, i32 16, i8* %9)
%16 = call i32 @hex2str(i8* %2, i8* %9, i32 32)
%17 = call i32 @TriDesEncrypt(i8* %9, i32 16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8, i8* %12)
%18 = call i32 @hex2str(i8* %3, i8* %12, i32 8)
ret void
}