#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 */
char encrypt(char const, char const);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char const *);
void encryptstr(char *cyphertext, const char *keyword, const char *plaintext) {
  int i, j = 0;
  int keylen = strlen(keyword);
  memset(cyphertext, 0, sizeof(char));
  for (i = 0; i < strlen(plaintext); i++) {
    if (plaintext[i] != ' ') {
      cyphertext[i] = encrypt(keyword[j], plaintext[i]);
      j = (j + 1) % keylen;
    } else {
      cyphertext[i] = ' ';
    }
  }
}


x86 assembly (clang, -O0):
<encryptstr>:
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   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11fc <encryptstr+0xcc>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11dd <encryptstr+0xad>
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   1040 <encrypt@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    11e9 <encryptstr+0xb9>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
jmp    11ee <encryptstr+0xbe>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <encryptstr+0x3e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encryptstr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11b2 <encryptstr+0x82>
xor    %ebx,%ebx
jmp    1187 <encryptstr+0x57>
mov    %cl,(%r15,%rbx,1)
add    $0x1,%rbx
mov    %r13,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11b2 <encryptstr+0x82>
movzbl 0x0(%r13,%rbx,1),%eax
mov    $0x20,%cl
cmp    $0x20,%al
je     1170 <encryptstr+0x40>
movslq %ebp,%rbp
movsbl (%r14,%rbp,1),%edi
movsbl %al,%esi
call   1040 <encrypt@plt>
mov    %eax,%ecx
add    $0x1,%ebp
mov    %ebp,%eax
cltd
idiv   %r12d
mov    %edx,%ebp
jmp    1170 <encryptstr+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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