#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*/ XOR(unsigned char *, unsigned char *, unsigned char *);
int /*<<< orphan*/ des(unsigned char *, unsigned char *, unsigned char *);
int /*<<< orphan*/ hex2str(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int YL_MAC(unsigned char *MACKey, unsigned char *InData, int InDataLen,
           unsigned char *MAC) {
  int i, b;
  unsigned char Tmp1[20];
  unsigned char Tmp2[20];
  unsigned char Tmp3[20];
  unsigned char Tmp4[20];
  b = (InDataLen + 7) / 8;
  memset(InData + InDataLen, 0, b * 8 - InDataLen);
  memcpy(Tmp1, InData, 8);
  for (i = 1; i < b; i++) {
    XOR(Tmp1, InData + i * 8, Tmp1);
  }
  hex2str(Tmp2, Tmp1, 8);
  hex2str(Tmp3, Tmp1 + 4, 8);
  des(Tmp2, Tmp2, MACKey);
  XOR(Tmp2, Tmp3, Tmp4);
  des(Tmp4, Tmp4, MACKey);
  hex2str(MAC, Tmp4, 8);
  return 0;
}


x86 assembly (clang, -O0):
<YL_MAC>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x7,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x28(%rbp),%edx
shl    $0x3,%edx
sub    -0x14(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1050 <memcpy@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11e5 <YL_MAC+0x95>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%eax
shl    $0x3,%eax
cltq
add    %rax,%rsi
lea    -0x40(%rbp),%rdx
call   1060 <XOR@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11af <YL_MAC+0x5f>
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x8,%edx
call   1070 <hex2str@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
add    $0x4,%rsi
mov    $0x8,%edx
call   1070 <hex2str@plt>
lea    -0x60(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1030 <des@plt>
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
call   1060 <XOR@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1030 <des@plt>
mov    -0x20(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x8,%edx
call   1070 <hex2str@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<YL_MAC>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x7(%rdx),%eax
lea    0xe(%rdx),%r12d
test   %eax,%eax
cmovns %eax,%r12d
movslq %edx,%rbp
lea    (%rsi,%rbp,1),%rdi
mov    %r12d,%edx
and    $0xfffffff8,%edx
sub    %ebp,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1050 <memcpy@plt>
cmp    $0x9,%ebp
jl     11d8 <YL_MAC+0x88>
sar    $0x3,%r12d
cmp    $0x3,%r12d
mov    $0x2,%ebp
cmovge %r12d,%ebp
add    $0x8,%rbx
add    $0xffffffffffffffff,%rbp
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1060 <XOR@plt>
add    $0x8,%rbx
add    $0xffffffffffffffff,%rbp
jne    11c0 <YL_MAC+0x70>
lea    0x60(%rsp),%r13
mov    %rsp,%rsi
mov    %r13,%rdi
mov    $0x8,%edx
call   1070 <hex2str@plt>
lea    0x4(%rsp),%rsi
lea    0x40(%rsp),%r12
mov    %r12,%rdi
mov    $0x8,%edx
call   1070 <hex2str@plt>
mov    %r13,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1030 <des@plt>
lea    0x20(%rsp),%rbx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <XOR@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <des@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1070 <hex2str@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @YL_MAC(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [20 x i8]
%12 = alloca [20 x i8]
%13 = alloca [20 x i8]
%14 = alloca [20 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 7
%17 = sdiv i32 %16, 8
store i32 %17, i32* %10
%18 = load i8*, i8** %6
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i32, i32* %10
%23 = mul nsw i32 %22, 8
%24 = load i32, i32* %7
%25 = sub nsw i32 %23, %24
%26 = call i32 @memset(i8* %21, i32 0, i32 %25)
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%28 = load i8*, i8** %6
%29 = call i32 @memcpy(i8* %27, i8* %28, i32 8)
store i32 1, i32* %9
br label %30
30: ; preds = %43, %4
%31 = load i32, i32* %9
%32 = load i32, i32* %10
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %46
34: ; preds = %30
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%36 = load i8*, i8** %6
%37 = load i32, i32* %9
%38 = mul nsw i32 %37, 8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%42 = call i32 @XOR(i8* %35, i8* %40, i8* %41)
br label %43
43: ; preds = %34
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %30
46: ; preds = %30
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%49 = call i32 @hex2str(i8* %47, i8* %48, i32 8)
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%52 = getelementptr inbounds i8, i8* %51, i64 4
%53 = call i32 @hex2str(i8* %50, i8* %52, i32 8)
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%56 = load i8*, i8** %5
%57 = call i32 @des(i8* %54, i8* %55, i8* %56)
%58 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%60 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%61 = call i32 @XOR(i8* %58, i8* %59, i8* %60)
%62 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%63 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%64 = load i8*, i8** %5
%65 = call i32 @des(i8* %62, i8* %63, i8* %64)
%66 = load i8*, i8** %8
%67 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%68 = call i32 @hex2str(i8* %66, i8* %67, i32 8)
ret i32 0
}

LLVM IR (-O2):
define i32 @YL_MAC(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
%7 = alloca [20 x i8]
%8 = alloca [20 x i8]
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%13 = add nsw i32 %2, 7
%14 = sdiv i32 %13, 8
%15 = sext i32 %2 to i64
%16 = getelementptr inbounds i8, i8* %1, i64 %15
%17 = shl nsw i32 %14, 3
%18 = sub nsw i32 %17, %2
%19 = tail call i32 @memset(i8* %16, i32 0, i32 %18)
%20 = call i32 @memcpy(i8* %9, i8* %1, i32 8)
%21 = icmp sgt i32 %2, 8
br i1 %21, label %22, label %32
22: ; preds = %4
%23 = call i32 @llvm.smax.i32(i32 %14, i32 2)
%24 = zext i32 %23 to i64
br label %25
25: ; preds = %22, %25
%26 = phi i64 [ 1, %22 ], [ %30, %25 ]
%27 = shl nsw i64 %26, 3
%28 = getelementptr inbounds i8, i8* %1, i64 %27
%29 = call i32 @XOR(i8* %9, i8* %28, i8* %9)
%30 = add nuw nsw i64 %26, 1
%31 = icmp eq i64 %30, %24
br i1 %31, label %32, label %25
32: ; preds = %25, %4
%33 = call i32 @hex2str(i8* %10, i8* %9, i32 8)
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 4
%35 = call i32 @hex2str(i8* %11, i8* %34, i32 8)
%36 = call i32 @des(i8* %10, i8* %10, i8* %0)
%37 = call i32 @XOR(i8* %10, i8* %11, i8* %12)
%38 = call i32 @des(i8* %12, i8* %12, i8* %0)
%39 = call i32 @hex2str(i8* %3, i8* %12, i32 8)
ret i32 0
}