#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*/ Common_D2_13_15(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ ExchangeCWs(unsigned char *, unsigned char *);
void hdSurEncPhase2_D2_13_15(unsigned char *cws) {
  int i;
  for (i = 7; i >= 0; i--) {
    if ((i & 1) == 0) {
      Common_D2_13_15((unsigned char *)&cws[8], (unsigned char *)&cws[0], i);
    } else {
      Common_D2_13_15((unsigned char *)&cws[0], (unsigned char *)&cws[8], i);
    }
  }
  ExchangeCWs((unsigned char *)&cws[8], (unsigned char *)&cws[0]);
}


x86 assembly (clang, -O0):
<hdSurEncPhase2_D2_13_15>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     118c <hdSurEncPhase2_D2_13_15+0x6c>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1165 <hdSurEncPhase2_D2_13_15+0x45>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <Common_D2_13_15@plt>
jmp    1179 <hdSurEncPhase2_D2_13_15+0x59>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
mov    -0xc(%rbp),%edx
call   1030 <Common_D2_13_15@plt>
jmp    117e <hdSurEncPhase2_D2_13_15+0x5e>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <hdSurEncPhase2_D2_13_15+0x13>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0x8(%rbp),%rsi
call   1040 <ExchangeCWs@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hdSurEncPhase2_D2_13_15>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x8(%rdi),%r14
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <Common_D2_13_15@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <Common_D2_13_15@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <Common_D2_13_15@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <Common_D2_13_15@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <Common_D2_13_15@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <Common_D2_13_15@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <Common_D2_13_15@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <Common_D2_13_15@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <ExchangeCWs@plt>

LLVM IR (-O0):
define void @hdSurEncPhase2_D2_13_15(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 7, i32* %3
br label %4
4: ; preds = %26, %1
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %29
7: ; preds = %4
%8 = load i32, i32* %3
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 8
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i32, i32* %3
%17 = call i32 @Common_D2_13_15(i8* %13, i8* %15, i32 %16)
br label %25
18: ; preds = %7
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 8
%23 = load i32, i32* %3
%24 = call i32 @Common_D2_13_15(i8* %20, i8* %22, i32 %23)
br label %25
25: ; preds = %18, %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, -1
store i32 %28, i32* %3
br label %4
29: ; preds = %4
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 8
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = call i32 @ExchangeCWs(i8* %31, i8* %33)
ret void
}

LLVM IR (-O2):
define void @hdSurEncPhase2_D2_13_15(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 8
%3 = tail call i32 @Common_D2_13_15(i8* %0, i8* %2, i32 7)
%4 = tail call i32 @Common_D2_13_15(i8* %2, i8* %0, i32 6)
%5 = tail call i32 @Common_D2_13_15(i8* %0, i8* %2, i32 5)
%6 = tail call i32 @Common_D2_13_15(i8* %2, i8* %0, i32 4)
%7 = tail call i32 @Common_D2_13_15(i8* %0, i8* %2, i32 3)
%8 = tail call i32 @Common_D2_13_15(i8* %2, i8* %0, i32 2)
%9 = tail call i32 @Common_D2_13_15(i8* %0, i8* %2, i32 1)
%10 = tail call i32 @Common_D2_13_15(i8* %2, i8* %0, i32 0)
%11 = tail call i32 @ExchangeCWs(i8* %2, i8* %0)
ret void
}