#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 EXIT_SUCCESS;
int /*<<< orphan*/ RAND_bytes(unsigned char *, int);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(long);
scalar_t__ memcmp(unsigned char *, unsigned char *, long);
int /*<<< orphan*/ print_diff(unsigned char *, unsigned char *, long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ t_mixdecrypt(int, unsigned char *, unsigned char *, long,
                                unsigned char *, unsigned char *);
int /*<<< orphan*/ t_mixencrypt(int, unsigned char *, unsigned char *, long,
                                unsigned char *, unsigned char *);
int main(int argc, char *argv[]) {
  (void)argc;
  (void)argv;
  unsigned char key[16];
  unsigned char iv[16];
  unsigned char *in;
  unsigned char *dec;
  unsigned char *out;
  in = malloc((4L * (4 * 1024)));
  dec = malloc((4L * (4 * 1024)));
  out = malloc((4L * (4 * 1024)));
  RAND_bytes(in, (4L * (4 * 1024)));
  RAND_bytes(key, 16);
  RAND_bytes(iv, 16);
  printf("ENCRYPTION with %d threads (SIZE %lu)\n", 3, (4L * (4 * 1024)));
  t_mixencrypt(3, in, out, (4L * (4 * 1024)), key, iv);
  printf("DECRYPTION with %d threads (SIZE %lu)\n", 2, (4L * (4 * 1024)));
  t_mixdecrypt(2, out, dec, (4L * (4 * 1024)), key, iv);
  if (0)
    print_diff(in, dec, (4L * (4 * 1024)));
  assert(0 == memcmp(in, dec, (4L * (4 * 1024))));
  printf("TEST OK\n");
  free(in);
  free(out);
  free(dec);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x4000,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x4000,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x4000,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x4000,%esi
call   1040 <RAND_bytes@plt>
lea    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   1040 <RAND_bytes@plt>
lea    -0x30(%rbp),%rdi
mov    $0x10,%esi
call   1040 <RAND_bytes@plt>
lea    0xe0f(%rip),%rdi
mov    $0x3,%esi
mov    $0x4000,%edx
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    -0x48(%rbp),%rdx
lea    -0x20(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    $0x3,%edi
mov    $0x4000,%ecx
call   10a0 <t_mixencrypt@plt>
lea    0xdff(%rip),%rdi
mov    $0x2,%esi
mov    $0x4000,%edx
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    -0x20(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    $0x2,%edi
mov    $0x4000,%ecx
call   1060 <t_mixdecrypt@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    $0x4000,%edx
call   1070 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    $0x4000,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    $0x4000,%edi
call   10a0 <malloc@plt>
mov    %rax,%r14
mov    $0x4000,%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x4000,%esi
call   1050 <RAND_bytes@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x10,%esi
call   1050 <RAND_bytes@plt>
mov    %rsp,%r13
mov    %r13,%rdi
mov    $0x10,%esi
call   1050 <RAND_bytes@plt>
lea    0xe06(%rip),%rdi
mov    $0x4000,%edx
mov    $0x3,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x4000,%ecx
mov    $0x3,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%r8
mov    %r13,%r9
call   10b0 <t_mixencrypt@plt>
lea    0xdfa(%rip),%rdi
mov    $0x4000,%edx
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x4000,%ecx
mov    $0x2,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%r8
mov    %r13,%r9
call   1070 <t_mixdecrypt@plt>
mov    $0x4000,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
lea    0xdd0(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [39 x i8] c"ENCRYPTION with %d threads (SIZE %lu)\0A\00"
@.str.1 = [39 x i8] c"DECRYPTION with %d threads (SIZE %lu)\0A\00"
@.str.2 = [9 x i8] c"TEST OK\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [16 x i8]
%7 = alloca [16 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i8* @malloc(i64 16384)
store i8* %13, i8** %8
%14 = call i8* @malloc(i64 16384)
store i8* %14, i8** %9
%15 = call i8* @malloc(i64 16384)
store i8* %15, i8** %10
%16 = load i8*, i8** %8
%17 = call i32 @RAND_bytes(i8* %16, i32 16384)
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%19 = call i32 @RAND_bytes(i8* %18, i32 16)
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%21 = call i32 @RAND_bytes(i8* %20, i32 16)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 3, i64 16384)
%23 = load i8*, i8** %8
%24 = load i8*, i8** %10
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%27 = call i32 @t_mixencrypt(i32 3, i8* %23, i8* %24, i64 16384, i8* %25, i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 2, i64 16384)
%29 = load i8*, i8** %10
%30 = load i8*, i8** %9
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%33 = call i32 @t_mixdecrypt(i32 2, i8* %29, i8* %30, i64 16384, i8* %31, i8* %32)
%34 = load i8*, i8** %8
%35 = load i8*, i8** %9
%36 = call i64 @memcmp(i8* %34, i8* %35, i64 16384)
%37 = icmp eq i64 0, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%41 = load i8*, i8** %8
%42 = call i32 @free(i8* %41)
%43 = load i8*, i8** %10
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %9
%46 = call i32 @free(i8* %45)
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
@.str = [39 x i8] c"ENCRYPTION with %d threads (SIZE %lu)\0A\00"
@.str.1 = [39 x i8] c"DECRYPTION with %d threads (SIZE %lu)\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [8 x i8] c"TEST OK\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%7 = tail call dereferenceable_or_null(16384) i8* @malloc(i64 16384)
%8 = tail call dereferenceable_or_null(16384) i8* @malloc(i64 16384)
%9 = tail call dereferenceable_or_null(16384) i8* @malloc(i64 16384)
%10 = tail call i32 @RAND_bytes(i8* %7, i32 16384)
%11 = call i32 @RAND_bytes(i8* %5, i32 16)
%12 = call i32 @RAND_bytes(i8* %6, i32 16)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 3, i64 16384)
%14 = call i32 @t_mixencrypt(i32 3, i8* %7, i8* %9, i64 16384, i8* %5, i8* %6)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 2, i64 16384)
%16 = call i32 @t_mixdecrypt(i32 2, i8* %9, i8* %8, i64 16384, i8* %5, i8* %6)
%17 = call i64 @memcmp(i8* %7, i8* %8, i64 16384)
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%22 = call i32 @free(i8* %7)
%23 = call i32 @free(i8* %9)
%24 = call i32 @free(i8* %8)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}