#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*/ printf(char *, unsigned char const);
void decrypt_repeated_key(const unsigned char *data, size_t data_len,
                          unsigned char *key, size_t key_size) {
  size_t i = 0;
  size_t k = 0;
  for (i = 0; i < data_len; ++i) {
    printf("%c", data[i] ^ key[k]);
    ++k;
    k %= key_size;
  }
}


x86 assembly (clang, -O0):
<decrypt_repeated_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11a5 <decrypt_repeated_key+0x95>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
xor    %ecx,%eax
lea    0xe91(%rip),%rdi
movzbl %al,%esi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1140 <decrypt_repeated_key+0x30>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt_repeated_key>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1186 <decrypt_repeated_key+0x76>
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    1154 <decrypt_repeated_key+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rax
xor    %edx,%edx
div    %rbx
mov    %rdx,%rbp
add    $0x1,%r13
cmp    %r13,%r15
je     1186 <decrypt_repeated_key+0x76>
movzbl (%r14,%rbp,1),%eax
xor    (%r12,%r13,1),%al
movzbl %al,%esi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
mov    %rbp,%rax
or     %rbx,%rax
shr    $0x20,%rax
jne    1140 <decrypt_repeated_key+0x30>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    %edx,%ebp
jmp    114b <decrypt_repeated_key+0x3b>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @decrypt_repeated_key(i8* nocapture %0, i64 %1, i8* nocapture %2, i64 %3) {
%5 = icmp eq i64 %1, 0
br i1 %5, label %19, label %6
6: ; preds = %4, %6
%7 = phi i64 [ %16, %6 ], [ 0, %4 ]
%8 = phi i64 [ %17, %6 ], [ 0, %4 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %2, i64 %7
%12 = load i8, i8* %11
%13 = xor i8 %12, %10
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %13)
%15 = add i64 %7, 1
%16 = urem i64 %15, %3
%17 = add nuw i64 %8, 1
%18 = icmp eq i64 %17, %1
br i1 %18, label %19, label %6
19: ; preds = %6, %4
ret void
}