#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*/ dep;
typedef int /*<<< orphan*/ c;

/* Variables and functions */
int /*<<< orphan*/ decrypt(char *, char const *, char *);
int /*<<< orphan*/ encrypt(char const *, char const *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char const *);
int strlen(char const *);
int main() {
  const char *key = "deceptive";
  const char *p = "We are discovered save yourself";
  char c[strlen(p) + (strlen(key) - strlen(p) % strlen(key)) + 1];
  char dep[sizeof(c)];
  memset(c, 0, sizeof(c));
  memset(dep, 0, sizeof(dep));
  printf("p: %s\n", p);
  encrypt(p, key, c);
  printf("Encrypted: %s\n", c);
  decrypt(c, key, dep);
  printf("Dncrypted: %s\n", dep);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x54(%rbp),%ecx
mov    %eax,%esi
mov    -0x50(%rbp),%eax
cltd
idiv   %esi
mov    %edx,%eax
mov    -0x4c(%rbp),%edx
sub    %eax,%edx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x1(%rax,%rcx,1),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rdi
sub    %rdx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x18(%rbp),%rsi
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdx
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <encrypt@plt>
mov    -0x40(%rbp),%rsi
lea    0xdf7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rsi
call   1030 <decrypt@plt>
mov    -0x38(%rbp),%rsi
lea    0xde5(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xea5(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
lea    0xe89(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
add    %r12d,%ebx
sub    %edx,%ebx
add    $0x1,%ebx
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
mov    %r13,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1070 <memset@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1070 <memset@plt>
lea    0xe4d(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1060 <encrypt@plt>
lea    0xe37(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <decrypt@plt>
lea    0xe29(%rip),%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"deceptive\00"
@.str.1 = [32 x i8] c"We are discovered save yourself\00"
@.str.2 = [7 x i8] c"p: %s\0A\00"
@.str.3 = [15 x i8] c"Encrypted: %s\0A\00"
@.str.4 = [15 x i8] c"Dncrypted: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = srem i32 %12, %14
%16 = sub nsw i32 %10, %15
%17 = add nsw i32 %8, %16
%18 = add nsw i32 %17, 1
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %4
%21 = alloca i8, i64 %19
store i64 %19, i64* %5
%22 = alloca i8, i64 %19
store i64 %19, i64* %6
%23 = trunc i64 %19 to i32
%24 = call i32 @memset(i8* %21, i32 0, i32 %23)
%25 = trunc i64 %19 to i32
%26 = call i32 @memset(i8* %22, i32 0, i32 %25)
%27 = load i8*, i8** %3
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %3
%30 = load i8*, i8** %2
%31 = call i32 @encrypt(i8* %29, i8* %30, i8* %21)
%32 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%33 = load i8*, i8** %2
%34 = call i32 @decrypt(i8* %21, i8* %33, i8* %22)
%35 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %22)
store i32 0, i32* %1
%36 = load i8*, i8** %4
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [10 x i8] c"deceptive\00"
@.str.1 = [32 x i8] c"We are discovered save yourself\00"
@.str.2 = [7 x i8] c"p: %s\0A\00"
@.str.3 = [15 x i8] c"Encrypted: %s\0A\00"
@.str.4 = [15 x i8] c"Dncrypted: %s\0A\00"
define i32 @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = srem i32 %3, %4
%6 = add i32 %1, 1
%7 = add i32 %6, %2
%8 = sub i32 %7, %5
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = alloca i8, i64 %9
%12 = call i32 @memset(i8* %10, i32 0, i32 %8)
%13 = call i32 @memset(i8* %11, i32 0, i32 %8)
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @encrypt(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %10)
%16 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%17 = call i32 @decrypt(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %11)
%18 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %11)
ret i32 0
}