#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*/ c;

/* Variables and functions */
int /*<<< orphan*/ encrypt(char const *, int const **, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char const *);
int strlen(char const *);
int main() {
  const int key[][3] = {{17, 17, 5}, {21, 18, 21}, {2, 2, 19}};
  const char *p = "pay more money";
  char c[strlen(p) + (3 - strlen(p) % 3) + 1];
  memset(c, 0, sizeof(c));
  printf("p: %s\n", p);
  encrypt(p, key, c);
  printf("Encrypted: %s\n", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x10(%rbp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0xe96(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
lea    0xeaf(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x54(%rbp),%ecx
movslq %eax,%rdx
imul   $0x55555556,%rdx,%rsi
mov    %rsi,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rsi
add    %edx,%esi
mov    %esi,%edx
lea    (%rdx,%rdx,2),%edx
sub    %eax,%edx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x4(%rax,%rcx,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x50(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x48(%rbp)
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x38(%rbp),%rsi
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
mov    -0x50(%rbp),%rdx
mov    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <encrypt@plt>
mov    -0x50(%rbp),%rsi
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x40(%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   %rbx
sub    $0x28,%rsp
mov    0xecd(%rip),%eax
mov    %eax,-0x20(%rbp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
lea    0xeb1(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rsp,%r15
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %eax,%ecx
lea    (%rbx,%rcx,1),%edx
add    $0x4,%edx
lea    0xf(%rdx),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe68(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <encrypt@plt>
lea    0xe51(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.key = [3 x [3 x i32]] [[3 x i32] [i32 17, i32 17, i32 5], [3 x i32] [i32 21, i32 18, i32 21], [3 x i32] [i32 2, i32 2, i32 19]]
@.str = [15 x i8] c"pay more money\00"
@.str.1 = [7 x i8] c"p: %s\0A\00"
@.str.2 = [15 x i8] c"Encrypted: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x [3 x i32]]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i32 0, i32* %1
%6 = bitcast [3 x [3 x i32]]* %2 to i8*
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = srem i32 %10, 3
%12 = sub nsw i32 3, %11
%13 = add nsw i32 %8, %12
%14 = add nsw i32 %13, 1
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %4
%17 = alloca i8, i64 %15
store i64 %15, i64* %5
%18 = trunc i64 %15 to i32
%19 = call i32 @memset(i8* %17, i32 0, i32 %18)
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %3
%23 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 0
%24 = bitcast [3 x i32]* %23 to i32**
%25 = call i32 @encrypt(i8* %22, i32** %24, i8* %17)
%26 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %17)
store i32 0, i32* %1
%27 = load i8*, i8** %4
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@__const.main.key = [3 x [3 x i32]] [[3 x i32] [i32 17, i32 17, i32 5], [3 x i32] [i32 21, i32 18, i32 21], [3 x i32] [i32 2, i32 2, i32 19]]
@.str = [15 x i8] c"pay more money\00"
@.str.1 = [7 x i8] c"p: %s\0A\00"
@.str.2 = [15 x i8] c"Encrypted: %s\0A\00"
define i32 @main() {
%1 = alloca [3 x [3 x i32]]
%2 = bitcast [3 x [3 x i32]]* %1 to i8*
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = srem i32 %4, 3
%6 = add i32 %3, 4
%7 = sub i32 %6, %5
%8 = zext i32 %7 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %8
%11 = call i32 @memset(i8* %10, i32 0, i32 %7)
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = bitcast [3 x [3 x i32]]* %1 to i32**
%14 = call i32 @encrypt(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32** %13, i8* %10)
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %10)
ret i32 0
}