#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*/ plaintext;
typedef int /*<<< orphan*/ cyphertext;

/* Variables and functions */
char decrypt(char const, char const);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, int);
int strlen(char const *);
void decryptstr(char *plaintext, const char *keyword, const char *cyphertext) {
  int i, j = 0;
  int keylen = strlen(keyword);
  int textlen = strlen(cyphertext);
  memset(plaintext, 0, sizeof(char));
  if (sizeof(plaintext) != sizeof(cyphertext)) {
    printf("plaintext: %ld, cyphertext: %ld\n", sizeof(plaintext),
           sizeof(cyphertext));
    return;
  }
  for (i = 0; i < textlen; i++) {
    if (cyphertext[i] != ' ') {
      plaintext[i] = decrypt(keyword[j], cyphertext[i]);
      j = (j + 1) % keylen;
    } else {
      plaintext[i] = ' ';
    }
  }
  plaintext[textlen] = '\0';
}


x86 assembly (clang, -O0):
<decryptstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11f8 <decryptstr+0xc8>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11d9 <decryptstr+0xa9>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl %dl,%edi
movsbl (%rax,%rcx,1),%esi
call   1030 <decrypt@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x24(%rbp)
mov    %edx,-0x20(%rbp)
jmp    11e5 <decryptstr+0xb5>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
jmp    11ea <decryptstr+0xba>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117a <decryptstr+0x4a>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decryptstr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r12d,(%rsp)
test   %r12d,%r12d
jle    11b8 <decryptstr+0x88>
mov    (%rsp),%r12d
xor    %r13d,%r13d
jmp    118d <decryptstr+0x5d>
xchg   %ax,%ax
mov    %cl,(%rbx,%r13,1)
add    $0x1,%r13
cmp    %r13,%r12
je     11b8 <decryptstr+0x88>
movzbl (%r14,%r13,1),%eax
mov    $0x20,%cl
cmp    $0x20,%al
je     1180 <decryptstr+0x50>
movslq %ebp,%rbp
movsbl (%r15,%rbp,1),%edi
movsbl %al,%esi
call   1030 <decrypt@plt>
mov    %eax,%ecx
add    $0x1,%ebp
mov    %ebp,%eax
cltd
idivl  0x4(%rsp)
mov    %edx,%ebp
jmp    1180 <decryptstr+0x50>
movslq (%rsp),%rax
movb   $0x0,(%rbx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @decryptstr(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %8
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %9
%13 = load i8*, i8** %6
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %10
%15 = load i8*, i8** %4
%16 = call i32 @memset(i8* %15, i32 0, i32 1)
store i32 0, i32* %7
br label %17
17: ; preds = %55, %3
%18 = load i32, i32* %7
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %58
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 32
br i1 %28, label %29, label %49
29: ; preds = %21
%30 = load i8*, i8** %5
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = load i8*, i8** %6
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = call signext i8 @decrypt(i8 signext %34, i8 signext %39)
%41 = load i8*, i8** %4
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %40, i8* %44
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
%47 = load i32, i32* %9
%48 = srem i32 %46, %47
store i32 %48, i32* %8
br label %54
49: ; preds = %21
%50 = load i8*, i8** %4
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 32, i8* %53
br label %54
54: ; preds = %49, %29
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %17
58: ; preds = %17
%59 = load i8*, i8** %4
%60 = load i32, i32* %10
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8 0, i8* %62
ret void
}

LLVM IR (-O2):
define void @decryptstr(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @strlen(i8* %2)
%6 = tail call i32 @memset(i8* %0, i32 0, i32 1)
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %29
8: ; preds = %3
%9 = zext i32 %5 to i64
br label %10
10: ; preds = %8, %23
%11 = phi i64 [ 0, %8 ], [ %27, %23 ]
%12 = phi i32 [ 0, %8 ], [ %25, %23 ]
%13 = getelementptr inbounds i8, i8* %2, i64 %11
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
br i1 %15, label %23, label %16
16: ; preds = %10
%17 = sext i32 %12 to i64
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = load i8, i8* %18
%20 = tail call signext i8 @decrypt(i8 signext %19, i8 signext %14)
%21 = add nsw i32 %12, 1
%22 = srem i32 %21, %4
br label %23
23: ; preds = %10, %16
%24 = phi i8 [ %20, %16 ], [ 32, %10 ]
%25 = phi i32 [ %22, %16 ], [ %12, %10 ]
%26 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 %24, i8* %26
%27 = add nuw nsw i64 %11, 1
%28 = icmp eq i64 %27, %9
br i1 %28, label %29, label %10
29: ; preds = %23, %3
%30 = sext i32 %5 to i64
%31 = getelementptr inbounds i8, i8* %0, i64 %30
store i8 0, i8* %31
ret void
}