#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*/ key;

/* Variables and functions */
int strlen(char *);
void encryptDecrypt(char *input, char *output) {
  char key[] = {'K', 'C', 'Q'};
  int i;
  for (i = 0; i < strlen(input); i++) {
    output[i] = input[i] ^ key[i % (sizeof(key) / sizeof(char))];
  }
}


x86 assembly (clang, -O0):
<encryptDecrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xed9(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xed1(%rip),%al
mov    %al,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1199 <encryptDecrypt+0x89>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
movslq -0x18(%rbp),%rax
mov    $0x3,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x20(%rbp),%eax
movsbl -0x13(%rbp,%rdx,1),%ecx
xor    %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113b <encryptDecrypt+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encryptDecrypt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    1172 <encryptDecrypt+0x62>
xor    %ebx,%ebx
movabs $0xaaaaaaaaaaaaaaab,%r12
aa aa aa
lea    0xec5(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
mul    %r12
shr    %rdx
lea    (%rdx,%rdx,2),%rax
mov    %r13,%rcx
sub    %rax,%rcx
movzbl (%rcx,%rbx,1),%eax
xor    (%r15,%rbx,1),%al
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1140 <encryptDecrypt+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.encryptDecrypt.key = [3 x i8] c"KCQ"
define void @encryptDecrypt(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [3 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = bitcast [3 x i8]* %5 to i8*
store i32 0, i32* %6
br label %8
8: ; preds = %32, %2
%9 = load i32, i32* %6
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %35
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = urem i64 %21, 3
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = xor i32 %19, %25
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %4
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
br label %32
32: ; preds = %13
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %8
35: ; preds = %8
ret void
}

LLVM IR (-O2):
@__const.encryptDecrypt.key = [3 x i8] c"KCQ"
define void @encryptDecrypt(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %2, %5
%6 = phi i64 [ %16, %5 ], [ 0, %2 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = trunc i64 %6 to i32
%10 = urem i32 %9, 3
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [3 x i8], [3 x i8]* @__const.encryptDecrypt.key, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = xor i8 %13, %8
%15 = getelementptr inbounds i8, i8* %1, i64 %6
store i8 %14, i8* %15
%16 = add nuw nsw i64 %6, 1
%17 = tail call i32 @strlen(i8* %0)
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %5, label %20
20: ; preds = %5, %2
ret void
}