#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 */
size_t strlen(char *);
void decode(char *cypheredText, char *password, char *clearText) {
  int i;
  for (i = 0; i < strlen(cypheredText); ++i) {
    clearText[i] = cypheredText[i] ^ password[i % strlen(password)];
  }
  clearText[strlen(cypheredText)] = 0;
}


x86 assembly (clang, -O0):
<decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    11a8 <decode+0x98>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
movslq -0x1c(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rcx
mov    %rax,%rsi
mov    -0x38(%rbp),%rax
xor    %edx,%edx
div    %rsi
mov    -0x2c(%rbp),%eax
movsbl (%rcx,%rdx,1),%ecx
xor    %ecx,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <decode+0x1b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
xor    %ebx,%ebx
cmpb   $0x0,(%rdi)
je     1175 <decode+0x65>
mov    %rsi,%r15
mov    %rdi,%r12
jmp    1151 <decode+0x41>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rax
xor    %edx,%edx
div    %rcx
xor    (%r15,%rdx,1),%bpl
mov    %bpl,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    %rbx,%rax
jbe    1172 <decode+0x62>
movzbl (%r12,%rbx,1),%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
or     %rbx,%rax
shr    $0x20,%rax
jne    1130 <decode+0x20>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
jmp    1138 <decode+0x28>
mov    %rax,%rbx
movb   $0x0,(%r14,%rbx,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @decode(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %36, %3
%9 = load i32, i32* %7
%10 = sext i32 %9 to i64
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
%13 = icmp ult i64 %10, %12
br i1 %13, label %14, label %39
14: ; preds = %8
%15 = load i8*, i8** %4
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i8*, i8** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = load i8*, i8** %5
%25 = call i64 @strlen(i8* %24)
%26 = urem i64 %23, %25
%27 = getelementptr inbounds i8, i8* %21, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = xor i32 %20, %29
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %14
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %8
39: ; preds = %8
%40 = load i8*, i8** %6
%41 = load i8*, i8** %4
%42 = call i64 @strlen(i8* %41)
%43 = getelementptr inbounds i8, i8* %40, i64 %42
store i8 0, i8* %43
ret void
}

LLVM IR (-O2):
define void @decode(i8* nocapture %0, i8* nocapture %1, i8* nocapture writeonly %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3, %6
%7 = phi i64 [ %16, %6 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%11 = urem i64 %7, %10
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = load i8, i8* %12
%14 = xor i8 %13, %9
%15 = getelementptr inbounds i8, i8* %2, i64 %7
store i8 %14, i8* %15
%16 = add nuw nsw i64 %7, 1
%17 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%18 = icmp ugt i64 %17, %16
br i1 %18, label %6, label %19
19: ; preds = %6, %3
%20 = phi i64 [ 0, %3 ], [ %17, %6 ]
%21 = getelementptr inbounds i8, i8* %2, i64 %20
store i8 0, i8* %21
ret void
}