#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 int /*<<< orphan*/ indata;

/* Variables and functions */
int /*<<< orphan*/ TriDesEncrypt(unsigned char *, int, char *, unsigned char,
                                 unsigned char *);
int /*<<< orphan*/ memcpy(char *, char *, unsigned char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int EnTarck2(unsigned char *MagData, unsigned char MagDataLen,
             unsigned char *Out, unsigned char *TheKey) {
  char indata[100];
  unsigned char inlen;
  memset(indata, 0, sizeof(indata));
  memcpy(indata, (char *)MagData, MagDataLen);
  inlen = (MagDataLen + 7) / 8 * 8;
  Out[0] = ((inlen / 10) << 4) + (inlen % 10);
  TriDesEncrypt(TheKey, 16, indata, inlen, Out + 1);
  return 0;
}


x86 assembly (clang, -O0):
<EnTarck2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x9(%rbp),%al
movzbl %al,%edx
call   1050 <memcpy@plt>
movzbl -0x9(%rbp),%eax
add    $0x7,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
shl    $0x3,%eax
mov    %al,-0x91(%rbp)
movzbl -0x91(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
shl    $0x4,%eax
mov    %eax,-0x98(%rbp)
movzbl -0x91(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x98(%rbp),%eax
add    %edx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    -0x91(%rbp),%al
mov    -0x18(%rbp),%r8
add    $0x1,%r8
mov    $0x10,%esi
movzbl %al,%ecx
call   1030 <TriDesEncrypt@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EnTarck2>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %esi,%ebx
mov    %rdi,%r13
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
lea    0x7(%rbx),%eax
and    $0xf8,%al
movzbl %al,%ecx
imul   $0xcd,%ecx,%eax
shr    $0xb,%eax
mov    %eax,%edx
shl    $0x4,%dl
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %ecx,%ebx
sub    %al,%bl
or     %dl,%bl
mov    %bl,(%r12)
add    $0x1,%r12
mov    %r14,%rdi
mov    $0x10,%esi
mov    %r15,%rdx
mov    %r12,%r8
call   1030 <TriDesEncrypt@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @EnTarck2(i8* %0, i8 zeroext %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [100 x i8]
%10 = alloca i8
store i8* %0, i8** %5
store i8 %1, i8* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 100)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = load i8, i8* %6
%16 = call i32 @memcpy(i8* %13, i8* %14, i8 zeroext %15)
%17 = load i8, i8* %6
%18 = zext i8 %17 to i32
%19 = add nsw i32 %18, 7
%20 = sdiv i32 %19, 8
%21 = mul nsw i32 %20, 8
%22 = trunc i32 %21 to i8
store i8 %22, i8* %10
%23 = load i8, i8* %10
%24 = zext i8 %23 to i32
%25 = sdiv i32 %24, 10
%26 = shl i32 %25, 4
%27 = load i8, i8* %10
%28 = zext i8 %27 to i32
%29 = srem i32 %28, 10
%30 = add nsw i32 %26, %29
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 0
store i8 %31, i8* %33
%34 = load i8*, i8** %8
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%36 = load i8, i8* %10
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = call i32 @TriDesEncrypt(i8* %34, i32 16, i8* %35, i8 zeroext %36, i8* %38)
ret i32 0
}

LLVM IR (-O2):
define i32 @EnTarck2(i8* %0, i8 zeroext %1, i8* %2, i8* %3) {
%5 = alloca [100 x i8]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 100)
%8 = call i32 @memcpy(i8* %6, i8* %0, i8 zeroext %1)
%9 = add i8 %1, 7
%10 = and i8 %9, -8
%11 = udiv i8 %10, 10
%12 = shl i8 %11, 4
%13 = urem i8 %10, 10
%14 = or i8 %12, %13
store i8 %14, i8* %2
%15 = getelementptr inbounds i8, i8* %2, i64 1
%16 = call i32 @TriDesEncrypt(i8* %3, i32 16, i8* %6, i8 zeroext %10, i8* %15)
ret i32 0
}