#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 */
int /*<<< orphan*/ Padded(char *, int, int);
int /*<<< orphan*/ encrytion(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
char *strncpy(char *, char *, int);
int main() {
  int c, m, k;
  char *n, *e;
  char to_encryted[50] = " a";
  char key[20] = " CATALEPSY ";
  char temp[20];
  k = strlen(to_encryted);
  c = strlen(key);
  m = c % k;
  if (m != 0) {
    Padded(to_encryted, k, c);
    printf(" padded output: %s\n", to_encryted);
  }
  n = strncpy(temp, to_encryted, 20);
  encrytion(n, key);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
movb   $0x20,-0x60(%rbp)
movb   $0x61,-0x5f(%rbp)
mov    0xe6f(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe6c(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe6a(%rip),%eax
mov    %eax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11f4 <main+0x94>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1070 <Padded@plt>
lea    -0x60(%rbp),%rsi
lea    0xe25(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1080 <encrytion@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movw   $0x0,0x50(%rsp)
movw   $0x6120,0x20(%rsp)
movaps 0xe82(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0x20(%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
cltd
idiv   %ebx
test   %edx,%edx
je     11c7 <main+0x77>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ecx,%edx
call   1060 <Padded@plt>
lea    0xe55(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
lea    0x60(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rsi
mov    %rax,%rdi
call   1070 <encrytion@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.key = [20 x i8] c" CATALEPSY \00\00\00\00\00\00\00\00\00"
@.str = [20 x i8] c" padded output: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [50 x i8]
%8 = alloca [20 x i8]
%9 = alloca [20 x i8]
store i32 0, i32* %1
%10 = bitcast [50 x i8]* %7 to i8*
%11 = bitcast i8* %10 to [50 x i8]*
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i32 0, i32 0
store i8 32, i8* %12
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i32 0, i32 1
store i8 97, i8* %13
%14 = bitcast [20 x i8]* %8 to i8*
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %4
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = load i32, i32* %4
%21 = srem i32 %19, %20
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %0
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%26 = load i32, i32* %4
%27 = load i32, i32* %2
%28 = call i32 @Padded(i8* %25, i32 %26, i32 %27)
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %24, %0
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%34 = call i8* @strncpy(i8* %32, i8* %33, i32 20)
store i8* %34, i8** %5
%35 = load i8*, i8** %5
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%37 = call i32 @encrytion(i8* %35, i8* %36)
ret i32 0
}

LLVM IR (-O2):
@__const.main.key = [20 x i8] c" CATALEPSY \00\00\00\00\00\00\00\00\00"
@.str = [20 x i8] c" padded output: %s\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
store i8 32, i8* %4
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 1
store i8 97, i8* %5
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = call i32 @strlen(i8* %4)
%9 = call i32 @strlen(i8* %6)
%10 = srem i32 %9, %8
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = call i32 @Padded(i8* %4, i32 %8, i32 %9)
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %15
15: ; preds = %12, %0
%16 = call i8* @strncpy(i8* %7, i8* %4, i32 20)
%17 = call i32 @encrytion(i8* %16, i8* %6)
ret i32 0
}