#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 char uint8_t;

/* Variables and functions */
void ventrilo_first_enc(uint8_t *data, int size) {
  static const uint8_t first[] = "\xAA\x55\x22\xCC\x69\x7C\x38\x91\x88\xF5\xE1";
  int i;
  for (i = 0; i < size; i++) {
    data[i] += first[i % 11] + (i % 27);
  }
}


x86 assembly (clang, -O0):
<ventrilo_first_enc>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1163 <ventrilo_first_enc+0x63>
mov    -0x10(%rbp),%eax
mov    $0xb,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0xecd(%rip),%rax
movsbl (%rax,%rcx,1),%esi
mov    -0x10(%rbp),%eax
mov    $0x1b,%ecx
cltd
idiv   %ecx
add    %edx,%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
add    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <ventrilo_first_enc+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<ventrilo_first_enc>:
push   %rbx
test   %esi,%esi
jle    116e <ventrilo_first_enc+0x6e>
mov    %esi,%r8d
xor    %esi,%esi
lea    0xeef(%rip),%r9
movabs $0x2e8ba2e8ba2e8ba3,%r10
a2 8b 2e
xor    %ecx,%ecx
nopl   (%rax)
mov    %esi,%eax
imul   $0x2f684bdb,%rax,%rax
shr    $0x20,%rax
mov    %esi,%edx
sub    %eax,%edx
shr    %edx
add    %eax,%edx
shr    $0x4,%edx
lea    (%rdx,%rdx,8),%eax
lea    (%rax,%rax,2),%r11d
mov    %esi,%ebx
mov    %rcx,%rax
mul    %r10
sub    %r11b,%bl
shr    %rdx
imul   $0xfffffffffffffff5,%rdx,%rax
movzbl (%r9,%rax,1),%eax
add    (%rdi,%rcx,1),%al
add    %bl,%al
mov    %al,(%rdi,%rcx,1)
add    $0x1,%rcx
add    $0x1,%esi
add    $0x1,%r9
cmp    %rcx,%r8
jne    1120 <ventrilo_first_enc+0x20>
pop    %rbx
ret

LLVM IR (-O0):
@ventrilo_first_enc.first = internal constant [12 x i8] c"\AAU\22\CCi|8\91\88\F5\E1\00"
define void @ventrilo_first_enc(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %28, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %31
10: ; preds = %6
%11 = load i32, i32* %5
%12 = srem i32 %11, 11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [12 x i8], [12 x i8]* @ventrilo_first_enc.first, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = load i32, i32* %5
%18 = srem i32 %17, 27
%19 = add nsw i32 %16, %18
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = add nsw i32 %25, %19
%27 = trunc i32 %26 to i8
store i8 %27, i8* %23
br label %28
28: ; preds = %10
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %6
31: ; preds = %6
ret void
}

LLVM IR (-O2):
@ventrilo_first_enc.first = internal unnamed_addr constant [12 x i8] c"\AAU\22\CCi|8\91\88\F5\E1\00"
define void @ventrilo_first_enc(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %19, %6 ]
%8 = trunc i64 %7 to i32
%9 = urem i32 %8, 11
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [12 x i8], [12 x i8]* @ventrilo_first_enc.first, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = urem i32 %8, 27
%14 = getelementptr inbounds i8, i8* %0, i64 %7
%15 = load i8, i8* %14
%16 = trunc i32 %13 to i8
%17 = add i8 %12, %16
%18 = add i8 %17, %15
store i8 %18, i8* %14
%19 = add nuw nsw i64 %7, 1
%20 = icmp eq i64 %19, %5
br i1 %20, label %21, label %6
21: ; preds = %6, %2
ret void
}