#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 TestAes();
int TestAesCbc();
int TestAesCtr();
int TestAesOfb();
int TestHashes();
int TestRc4();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  bool success;
  bool allSuccess = true;
  printf("WjCryptLibTest\n"
         "------------\n"
         "\n");
  success = TestHashes();
  if (!success) {
    allSuccess = false;
  }
  success = TestRc4();
  if (!success) {
    allSuccess = false;
  }
  printf("Test RC4     - %s\n", success ? "Pass" : "Fail");
  success = TestAes();
  if (!success) {
    allSuccess = false;
  }
  printf("Test AES     - %s\n", success ? "Pass" : "Fail");
  success = TestAesCbc();
  if (!success) {
    allSuccess = false;
  }
  printf("Test AES CBC - %s\n", success ? "Pass" : "Fail");
  success = TestAesCtr();
  if (!success) {
    allSuccess = false;
  }
  printf("Test AES CTR - %s\n", success ? "Pass" : "Fail");
  success = TestAesOfb();
  if (!success) {
    allSuccess = false;
  }
  printf("Test AES OFB - %s\n", success ? "Pass" : "Fail");
  printf("\n");
  if (allSuccess) {
    printf("All tests passed.\n");
  } else {
    printf("Fail.\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <TestHashes@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11af <main+0x3f>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1080 <TestRc4@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11ca <main+0x5a>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xe62(%rip),%rsi
lea    0xe56(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <TestAes@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    120b <main+0x9b>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xe21(%rip),%rsi
lea    0xe15(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <TestAesCbc@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    124c <main+0xdc>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xde0(%rip),%rsi
lea    0xdd4(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1090 <TestAesCtr@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    128d <main+0x11d>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xd9f(%rip),%rsi
lea    0xd93(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <TestAesOfb@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    12ce <main+0x15e>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xd5e(%rip),%rsi
lea    0xd52(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     131f <main+0x1af>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1339 <main+0x1c9>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1340 <main+0x1d0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xec7(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1040 <TestHashes@plt>
test   %eax,%eax
sete   0x7(%rsp)
xor    %eax,%eax
call   10a0 <TestRc4@plt>
test   %eax,%eax
sete   %r14b
lea    0xe4f(%rip),%rbp
lea    0xe43(%rip),%rbx
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe22(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <TestAes@plt>
test   %eax,%eax
sete   %r13b
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe1d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1080 <TestAesCbc@plt>
test   %eax,%eax
sete   %r12b
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10b0 <TestAesCtr@plt>
test   %eax,%eax
sete   %r15b
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xdff(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <TestAesOfb@plt>
test   %eax,%eax
cmove  %rbp,%rbx
sete   %al
or     %r15b,%al
or     %r13b,%r12b
or     %al,%r12b
lea    0xdeb(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
or     0x7(%rsp),%r14b
or     %r12b,%r14b
lea    0xdf8(%rip),%rax
lea    0xdf7(%rip),%rdi
cmovne %rax,%rdi
movzbl %r14b,%ebx
call   1050 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"WjCryptLibTest\0A------------\0A\0A\00"
@.str.1 = [19 x i8] c"Test RC4 - %s\0A\00"
@.str.2 = [5 x i8] c"Pass\00"
@.str.3 = [5 x i8] c"Fail\00"
@.str.4 = [19 x i8] c"Test AES - %s\0A\00"
@.str.5 = [19 x i8] c"Test AES CBC - %s\0A\00"
@.str.6 = [19 x i8] c"Test AES CTR - %s\0A\00"
@.str.7 = [19 x i8] c"Test AES OFB - %s\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [19 x i8] c"All tests passed.\0A\00"
@.str.10 = [7 x i8] c"Fail.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @TestHashes()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %0
store i32 0, i32* %3
br label %9
9: ; preds = %8, %0
%10 = call i32 (...) @TestRc4()
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9
store i32 0, i32* %3
br label %14
14: ; preds = %13, %9
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 (...) @TestAes()
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %14
store i32 0, i32* %3
br label %24
24: ; preds = %23, %14
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%30 = call i32 (...) @TestAesCbc()
store i32 %30, i32* %2
%31 = load i32, i32* %2
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %24
store i32 0, i32* %3
br label %34
34: ; preds = %33, %24
%35 = load i32, i32* %2
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%40 = call i32 (...) @TestAesCtr()
store i32 %40, i32* %2
%41 = load i32, i32* %2
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %34
store i32 0, i32* %3
br label %44
44: ; preds = %43, %34
%45 = load i32, i32* %2
%46 = icmp ne i32 %45, 0
%47 = zext i1 %46 to i64
%48 = select i1 %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %48)
%50 = call i32 (...) @TestAesOfb()
store i32 %50, i32* %2
%51 = load i32, i32* %2
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %44
store i32 0, i32* %3
br label %54
54: ; preds = %53, %44
%55 = load i32, i32* %2
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%61 = load i32, i32* %3
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %54
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %67
65: ; preds = %54
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %1
br label %68
67: ; preds = %63
store i32 0, i32* %1
br label %68
68: ; preds = %67, %65
%69 = load i32, i32* %1
ret i32 %69
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"Test RC4 - %s\0A\00"
@.str.2 = [5 x i8] c"Pass\00"
@.str.3 = [5 x i8] c"Fail\00"
@.str.4 = [19 x i8] c"Test AES - %s\0A\00"
@.str.5 = [19 x i8] c"Test AES CBC - %s\0A\00"
@.str.6 = [19 x i8] c"Test AES CTR - %s\0A\00"
@.str.7 = [19 x i8] c"Test AES OFB - %s\0A\00"
@str = [29 x i8] c"WjCryptLibTest\0A------------\0A\00"
@str.11 = [6 x i8] c"Fail.\00"
@str.12 = [18 x i8] c"All tests passed.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @TestHashes()
%3 = icmp eq i32 %2, 0
%4 = tail call i32 (...) @TestRc4()
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = tail call i32 (...) @TestAes()
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%12 = tail call i32 (...) @TestAesCbc()
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %14)
%16 = tail call i32 (...) @TestAesCtr()
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %18)
%20 = tail call i32 (...) @TestAesOfb()
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%23 = select i1 %21, i1 true, i1 %17
%24 = select i1 %23, i1 true, i1 %13
%25 = select i1 %24, i1 true, i1 %9
%26 = select i1 %25, i1 true, i1 %5
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %22)
%28 = tail call i32 @putchar(i32 10)
%29 = select i1 %26, i1 true, i1 %3
%30 = select i1 %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0)
%31 = zext i1 %29 to i32
%32 = tail call i32 @puts(i8* dereferenceable(1) %30)
ret i32 %31
}