#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*/ str2hex(char *, int, char *);
void GetPIK(char *Tmk, char *PikTmkKey, char *PikKey, char *CheckValue) {
  char Pik[16];
  char HexTmk[17];
  char HexPikTmkKey[17];
  char HexCheckValue[8];
  GetRand(Pik);
  str2hex(HexTmk, 16, Tmk);
  TriDesEncrypt(HexTmk, 16, Pik, 16, HexPikTmkKey);
  hex2str(PikTmkKey, HexPikTmkKey, 32);
  hex2str(PikKey, Pik, 32);
  TriDesEncrypt(Pik, 16, "\x00\x00\x00\x00\x00\x00\x00\x00", 8, HexCheckValue);
  hex2str(CheckValue, HexCheckValue, 8);
}


x86 assembly (clang, -O0):
<GetPIK>:
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   1050 <GetRand@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x10,%esi
call   1040 <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   1060 <hex2str@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    0xe3a(%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):
<GetPIK>:
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
lea    0x10(%rsp),%r13
mov    %r13,%rdi
call   1050 <GetRand@plt>
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x10,%esi
mov    %rbx,%rdx
call   1040 <str2hex@plt>
lea    0x20(%rsp),%rbx
mov    %rbp,%rdi
mov    $0x10,%esi
mov    %r13,%rdx
mov    $0x10,%ecx
mov    %rbx,%r8
call   1030 <TriDesEncrypt@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1060 <hex2str@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x20,%edx
call   1060 <hex2str@plt>
lea    0xe40(%rip),%rdx
lea    0x8(%rsp),%rbx
mov    %r13,%rdi
mov    $0x10,%esi
mov    $0x8,%ecx
mov    %rbx,%r8
call   1030 <TriDesEncrypt@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1060 <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 @GetPIK(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 [17 x i8], [17 x i8]* %10, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = call i32 @str2hex(i8* %15, i32 16, i8* %16)
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 0
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %11, i64 0, i64 0
%21 = call i32 @TriDesEncrypt(i8* %18, i32 16, i8* %19, i32 16, i8* %20)
%22 = load i8*, i8** %6
%23 = getelementptr inbounds [17 x i8], [17 x i8]* %11, i64 0, i64 0
%24 = call i32 @hex2str(i8* %22, i8* %23, i32 32)
%25 = load i8*, i8** %7
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%27 = call i32 @hex2str(i8* %25, i8* %26, i32 32)
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%30 = call i32 @TriDesEncrypt(i8* %28, i32 16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8, i8* %29)
%31 = load i8*, i8** %8
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%33 = call i32 @hex2str(i8* %31, i8* %32, i32 8)
ret void
}

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