#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*/ cr_close();
int /*<<< orphan*/ cr_decrypt(char *);
int /*<<< orphan*/ cr_encrypt(char *);
int /*<<< orphan*/ cr_init(char *, char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int main() {
  char string[256] = {0};
  fgets(string, 256, stdin);
  cr_init("derpderpderpderp", "AAAAAAAAAAAAAAAA");
  printf("Plaintext before: %s\n", string);
  cr_encrypt(string);
  cr_decrypt(string);
  printf("Plaintext after : %s\n", string);
  cr_close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1070 <fgets@plt>
lea    0xe4a(%rip),%rdi
lea    0xe54(%rip),%rsi
call   1080 <cr_init@plt>
lea    -0x110(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <cr_encrypt@plt>
lea    -0x110(%rbp),%rdi
call   1090 <cr_decrypt@plt>
lea    -0x110(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <cr_close@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
lea    0xe0e(%rip),%rdi
lea    0xe18(%rip),%rsi
call   1070 <cr_init@plt>
lea    0xe1d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <cr_encrypt@plt>
mov    %rbx,%rdi
call   1080 <cr_decrypt@plt>
lea    0xe14(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <cr_close@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [17 x i8] c"derpderpderpderp\00"
@.str.1 = [17 x i8] c"AAAAAAAAAAAAAAAA\00"
@.str.2 = [22 x i8] c"Plaintext before: %s\0A\00"
@.str.3 = [22 x i8] c"Plaintext after : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
store i32 0, i32* %1
%3 = bitcast [256 x i8]* %2 to i8*
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 256, i32 %5)
%7 = call i32 @cr_init(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i32 @cr_encrypt(i8* %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%13 = call i32 @cr_decrypt(i8* %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = call i32 (...) @cr_close()
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [17 x i8] c"derpderpderpderp\00"
@.str.1 = [17 x i8] c"AAAAAAAAAAAAAAAA\00"
@.str.2 = [22 x i8] c"Plaintext before: %s\0A\00"
@.str.3 = [22 x i8] c"Plaintext after : %s\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 256, i32 %3)
%5 = call i32 @cr_init(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%7 = call i32 @cr_encrypt(i8* %2)
%8 = call i32 @cr_decrypt(i8* %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%10 = call i32 (...) @cr_close()
ret i32 0
}