#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 uint64_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ IdeaDecrypt(int *, int *);
int /*<<< orphan*/ IdeaEncrypt(int *, int *);
int /*<<< orphan*/ MakeKey(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int CoreTest() {
  srand((unsigned int)time(NULL));
  uint64_t message[15];
  uint64_t messageCopy[15];
  int i;
  uint64_t key[2];
  MakeKey((uint16_t *)key);
  for (i = 0; i < 25; i++) {
    message[0] = rand() * rand();
    messageCopy[0] = message[0];
    IdeaEncrypt(message, key);
    IdeaDecrypt(message, key);
    if (message[0] != messageCopy[0]) {
      printf("\x1b[31m"
             "Single ERROR\n"
             "\x1b[0m");
      return 1;
    }
  }
  printf("\x1b[32m"
         "Single Encryption OK\n"
         "\x1b[0m");
  return 0;
}


x86 assembly (clang, -O0):
<CoreTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x8c(%rbp),%rdi
call   1040 <MakeKey@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x19,-0x84(%rbp)
jge    1233 <CoreTest+0xc3>
mov    $0x0,%al
call   1090 <rand@plt>
mov    %eax,-0x90(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x80(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x8c(%rbp),%rsi
call   1030 <IdeaEncrypt@plt>
lea    -0x40(%rbp),%rdi
lea    -0x8c(%rbp),%rsi
call   1080 <IdeaDecrypt@plt>
mov    -0x40(%rbp),%eax
cmp    -0x80(%rbp),%eax
je     121a <CoreTest+0xaa>
lea    0xdf7(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1246 <CoreTest+0xd6>
jmp    121f <CoreTest+0xaf>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11a1 <CoreTest+0x31>
lea    0xddd(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CoreTest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1040 <MakeKey@plt>
mov    $0x19,%r13d
lea    0x10(%rsp),%r12
lea    0xe6c(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%ebx
imul   %ebp,%ebx
mov    %ebx,0x10(%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <IdeaEncrypt@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1080 <IdeaDecrypt@plt>
cmp    %ebx,0x10(%rsp)
jne    11ef <CoreTest+0x7f>
add    $0xffffffff,%r13d
jne    11b0 <CoreTest+0x40>
xor    %ebx,%ebx
jmp    11fb <CoreTest+0x8b>
mov    $0x1,%ebx
lea    0xe05(%rip),%r14
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\1B[31mSingle ERROR\0A\1B[0m\00"
@.str.1 = [31 x i8] c"\1B[32mSingle Encryption OK\0A\1B[0m\00"
define i32 @CoreTest() {
%1 = alloca i32
%2 = alloca [15 x i32]
%3 = alloca [15 x i32]
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = call i64 @time(i32* null)
%7 = trunc i64 %6 to i32
%8 = call i32 @srand(i32 %7)
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%10 = call i32 @MakeKey(i32* %9)
store i32 0, i32* %4
br label %11
11: ; preds = %36, %0
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 25
br i1 %13, label %14, label %39
14: ; preds = %11
%15 = call i32 (...) @rand()
%16 = call i32 (...) @rand()
%17 = mul nsw i32 %15, %16
%18 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
store i32 %17, i32* %18
%19 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds [15 x i32], [15 x i32]* %3, i64 0, i64 0
store i32 %20, i32* %21
%22 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%24 = call i32 @IdeaEncrypt(i32* %22, i32* %23)
%25 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%27 = call i32 @IdeaDecrypt(i32* %25, i32* %26)
%28 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
%29 = load i32, i32* %28
%30 = getelementptr inbounds [15 x i32], [15 x i32]* %3, i64 0, i64 0
%31 = load i32, i32* %30
%32 = icmp ne i32 %29, %31
br i1 %32, label %33, label %35
33: ; preds = %14
%34 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %41
35: ; preds = %14
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %11
39: ; preds = %11
%40 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %41
41: ; preds = %39, %33
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str = [23 x i8] c"\1B[31mSingle ERROR\0A\1B[0m\00"
@.str.1 = [31 x i8] c"\1B[32mSingle Encryption OK\0A\1B[0m\00"
define i32 @CoreTest() {
%1 = alloca [15 x i32]
%2 = alloca [2 x i32]
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = bitcast [15 x i32]* %1 to i8*
%7 = bitcast [2 x i32]* %2 to i8*
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%9 = call i32 @MakeKey(i32* %8)
%10 = getelementptr inbounds [15 x i32], [15 x i32]* %1, i64 0, i64 0
br label %14
11: ; preds = %14
%12 = add nuw nsw i32 %15, 1
%13 = icmp eq i32 %12, 25
br i1 %13, label %23, label %14
14: ; preds = %0, %11
%15 = phi i32 [ 0, %0 ], [ %12, %11 ]
%16 = call i32 (...) @rand()
%17 = call i32 (...) @rand()
%18 = mul nsw i32 %17, %16
store i32 %18, i32* %10
%19 = call i32 @IdeaEncrypt(i32* %10, i32* %8)
%20 = call i32 @IdeaDecrypt(i32* %10, i32* %8)
%21 = load i32, i32* %10
%22 = icmp eq i32 %21, %18
br i1 %22, label %11, label %23
23: ; preds = %11, %14
%24 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %14 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), %11 ]
%25 = phi i32 [ 1, %14 ], [ 0, %11 ]
%26 = call i32 @printf(i8* dereferenceable(1) %24)
ret i32 %25
}