#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*/ decrypted;
typedef int /*<<< orphan*/ ciphertext;

/* Variables and functions */
int /*<<< orphan*/ dummy(char *, char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ stypr(char *, char *, unsigned int);
int main(int argc, char **argv) {
  char plaintext[] = "Throwing out sample is really difficult.\x00";
  unsigned int ptsize = strlen(plaintext) * 6 + 5;
  char *ciphertext = malloc(ptsize + 1);
  char *decrypted = malloc(strlen(plaintext) + 1);
  memset(ciphertext, 0x00, sizeof(ciphertext));
  memset(decrypted, 0x00, sizeof(decrypted));
  stypr(plaintext, ciphertext, ptsize);
  printf("%s\n", ciphertext);
  dummy(ciphertext, decrypted);
  printf("%s\n", decrypted);
  free(decrypted);
  free(ciphertext);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x2a,%edx
call   1080 <memcpy@plt>
lea    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
imul   $0x6,%eax,%eax
add    $0x5,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   10a0 <stypr@plt>
mov    -0x50(%rbp),%rsi
lea    0xe0c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1040 <dummy@plt>
mov    -0x58(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1060 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movups 0xe99(%rip),%xmm0
movups %xmm0,0x1a(%rsp)
movaps 0xe83(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe67(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
add    %eax,%eax
lea    (%rax,%rax,2),%ebp
add    $0x5,%ebp
lea    (%rax,%rax,2),%edi
add    $0x6,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1090 <stypr@plt>
lea    0xe27(%rip),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <dummy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.plaintext = [42 x i8] c"Throwing out sample is really difficult.\00\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [42 x i8]
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [42 x i8]* %6 to i8*
%11 = getelementptr inbounds [42 x i8], [42 x i8]* %6, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = mul nsw i32 %12, 6
%14 = add nsw i32 %13, 5
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = add i32 %15, 1
%17 = call i8* @malloc(i32 %16)
store i8* %17, i8** %8
%18 = getelementptr inbounds [42 x i8], [42 x i8]* %6, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = call i8* @malloc(i32 %20)
store i8* %21, i8** %9
%22 = load i8*, i8** %8
%23 = call i32 @memset(i8* %22, i32 0, i32 8)
%24 = load i8*, i8** %9
%25 = call i32 @memset(i8* %24, i32 0, i32 8)
%26 = getelementptr inbounds [42 x i8], [42 x i8]* %6, i64 0, i64 0
%27 = load i8*, i8** %8
%28 = load i32, i32* %7
%29 = call i32 @stypr(i8* %26, i8* %27, i32 %28)
%30 = load i8*, i8** %8
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %8
%33 = load i8*, i8** %9
%34 = call i32 @dummy(i8* %32, i8* %33)
%35 = load i8*, i8** %9
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %9
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %8
%40 = call i32 @free(i8* %39)
ret i32 0
}

LLVM IR (-O2):
@__const.main.plaintext = [42 x i8] c"Throwing out sample is really difficult.\00\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [42 x i8]
%4 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 0
%5 = call i32 @strlen(i8* %4)
%6 = mul nsw i32 %5, 6
%7 = add nsw i32 %6, 5
%8 = add i32 %6, 6
%9 = call i8* @malloc(i32 %8)
%10 = call i32 @strlen(i8* %4)
%11 = add nsw i32 %10, 1
%12 = call i8* @malloc(i32 %11)
%13 = call i32 @memset(i8* %9, i32 0, i32 8)
%14 = call i32 @memset(i8* %12, i32 0, i32 8)
%15 = call i32 @stypr(i8* %4, i8* %9, i32 %7)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%17 = call i32 @dummy(i8* %9, i8* %12)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%19 = call i32 @free(i8* %12)
%20 = call i32 @free(i8* %9)
ret i32 0
}