#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 *);
char *cryptStr(char *oStr, char *sStr) {
  char key[5 + 1] = "\001\002\003\004\005";
  int p = (int)5;
  int k;
  for (k = 0; k < strlen(sStr); ++k) {
    oStr[k] = sStr[k] ^ key[k % p--];
    if (!p)
      p = (int)5;
  }
  oStr[strlen(sStr)] = '\0';
  return oStr;
}


x86 assembly (clang, -O0):
<cryptStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeda(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xed4(%rip),%ax
mov    %ax,-0x12(%rbp)
movl   $0x5,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    11c1 <cryptStr+0xb1>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x1c(%rbp)
cltd
idiv   %ecx
mov    -0x2c(%rbp),%eax
movslq %edx,%rcx
movsbl -0x16(%rbp,%rcx,1),%ecx
xor    %ecx,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x0,-0x1c(%rbp)
jne    11ae <cryptStr+0x9e>
movl   $0x5,-0x1c(%rbp)
jmp    11b3 <cryptStr+0xa3>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1142 <cryptStr+0x32>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cryptStr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
cmpb   $0x0,(%rsi)
je     1170 <cryptStr+0x60>
mov    %rsi,%r15
mov    $0x5,%r12d
xor    %ebx,%ebx
lea    0xecb(%rip),%r13
mov    $0x5,%ecx
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rcx),%ebp
mov    %ebx,%eax
cltd
idiv   %ecx
movzbl (%rdx,%r13,1),%eax
xor    (%r15,%rbx,1),%al
mov    %al,(%r14,%rbx,1)
test   %ebp,%ebp
cmove  %r12d,%ebp
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %ebp,%ecx
cmp    %rbx,%rax
ja     1140 <cryptStr+0x30>
jmp    1172 <cryptStr+0x62>
xor    %eax,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.cryptStr.key = [6 x i8] c"\01\02\03\04\05\00"
define i8* @cryptStr(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [6 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = bitcast [6 x i8]* %5 to i8*
store i32 5, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %40, %2
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = icmp ult i64 %11, %13
br i1 %14, label %15, label %43
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i32, i32* %7
%23 = load i32, i32* %6
%24 = add nsw i32 %23, -1
store i32 %24, i32* %6
%25 = srem i32 %22, %23
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = xor i32 %21, %29
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %3
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %15
store i32 5, i32* %6
br label %39
39: ; preds = %38, %15
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %9
43: ; preds = %9
%44 = load i8*, i8** %3
%45 = load i8*, i8** %4
%46 = call i64 @strlen(i8* %45)
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8 0, i8* %47
%48 = load i8*, i8** %3
ret i8* %48
}

LLVM IR (-O2):
@__const.cryptStr.key = [6 x i8] c"\01\02\03\04\05\00"
define i8* @cryptStr(i8* returned writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %23, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %20, %5 ], [ 0, %2 ]
%7 = phi i32 [ %19, %5 ], [ 5, %2 ]
%8 = getelementptr inbounds i8, i8* %1, i64 %6
%9 = load i8, i8* %8
%10 = add nsw i32 %7, -1
%11 = trunc i64 %6 to i32
%12 = srem i32 %11, %7
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [6 x i8], [6 x i8]* @__const.cryptStr.key, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = xor i8 %15, %9
%17 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %16, i8* %17
%18 = icmp eq i32 %10, 0
%19 = select i1 %18, i32 5, i32 %10
%20 = add nuw nsw i64 %6, 1
%21 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%22 = icmp ugt i64 %21, %20
br i1 %22, label %5, label %23
23: ; preds = %5, %2
%24 = phi i64 [ 0, %2 ], [ %21, %5 ]
%25 = getelementptr inbounds i8, i8* %0, i64 %24
store i8 0, i8* %25
ret i8* %0
}