#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*/ encrypt_piece(unsigned char *, unsigned char *);
void encrypt(unsigned char *buffer, unsigned char *buf2, unsigned int length) {
  int numSets = (length & 0xFFFFFFF8 + 7) / 8;
  if (length > 0) {
    unsigned int i;
    for (i = numSets; i != 0; i--) {
      encrypt_piece(&buffer[i * 8], &buf2[i * 8]);
    }
  }
}


x86 assembly (clang, -O0):
<encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0xffffffff,%eax
shr    $0x3,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jbe    117f <encrypt+0x6f>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117a <encrypt+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
shl    $0x3,%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%eax
shl    $0x3,%eax
mov    %eax,%eax
add    %rax,%rsi
call   1030 <encrypt_piece@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <encrypt+0x2f>
jmp    117f <encrypt+0x6f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encrypt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x8,%edx
jb     1146 <encrypt+0x36>
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
shr    $0x3,%ebx
lea    0x0(,%rbx,8),%ebp
xchg   %ax,%ax
mov    %ebp,%esi
lea    (%r15,%rsi,1),%rdi
add    %r14,%rsi
call   1030 <encrypt_piece@plt>
add    $0xfffffff8,%ebp
add    $0xffffffff,%ebx
jne    1130 <encrypt+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @encrypt(i8* %0, i8* %1, i32 %2) {
%4 = icmp ult i32 %2, 8
br i1 %4, label %16, label %5
5: ; preds = %3
%6 = lshr i32 %2, 3
br label %7
7: ; preds = %5, %7
%8 = phi i32 [ %14, %7 ], [ %6, %5 ]
%9 = shl i32 %8, 3
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = getelementptr inbounds i8, i8* %1, i64 %10
%13 = tail call i32 @encrypt_piece(i8* %11, i8* %12)
%14 = add nsw i32 %8, -1
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %7, %3
ret void
}