#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 TestMd5();
int TestRc4();
int TestSha1();
int TestSha256();
int TestSha512();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  bool success;
  bool allSuccess = true;
  printf("CryptLibTest\n"
         "------------\n"
         "\n");
  success = TestMd5();
  if (!success) {
    allSuccess = false;
  }
  printf("Test MD5    - %s\n", success ? "Pass" : "Fail");
  success = TestSha1();
  if (!success) {
    allSuccess = false;
  }
  printf("Test SHA1   - %s\n", success ? "Pass" : "Fail");
  success = TestSha256();
  if (!success) {
    allSuccess = false;
  }
  printf("Test SHA256 - %s\n", success ? "Pass" : "Fail");
  success = TestSha512();
  if (!success) {
    allSuccess = false;
  }
  printf("Test SHA512 - %s\n", success ? "Pass" : "Fail");
  success = TestRc4();
  if (!success) {
    allSuccess = false;
  }
  printf("Test RC4    - %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    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <TestMd5@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    119f <main+0x3f>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xe8a(%rip),%rsi
lea    0xe7e(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <TestSha1@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11e0 <main+0x80>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xe49(%rip),%rsi
lea    0xe3d(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <TestSha256@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1221 <main+0xc1>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xe08(%rip),%rsi
lea    0xdfc(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <TestSha512@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1262 <main+0x102>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xdc7(%rip),%rsi
lea    0xdbb(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <TestRc4@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    12a3 <main+0x143>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xd86(%rip),%rsi
lea    0xd7a(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     12f4 <main+0x194>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    130e <main+0x1ae>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1315 <main+0x1b5>
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    0xed2(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <TestMd5@plt>
test   %eax,%eax
sete   %r14b
lea    0xe6c(%rip),%r15
lea    0xe60(%rip),%rbp
mov    %rbp,%rsi
cmove  %r15,%rsi
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <TestSha1@plt>
test   %eax,%eax
sete   %r12b
mov    %rbp,%rsi
cmove  %r15,%rsi
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <TestSha256@plt>
test   %eax,%eax
sete   %bl
mov    %rbp,%rsi
cmove  %r15,%rsi
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <TestSha512@plt>
test   %eax,%eax
sete   %r13b
mov    %rbp,%rsi
cmove  %r15,%rsi
lea    0xe1b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <TestRc4@plt>
test   %eax,%eax
sete   %al
cmove  %r15,%rbp
or     %r13b,%al
or     %r12b,%bl
or     %al,%bl
or     %r14b,%bl
lea    0xe04(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe16(%rip),%rax
lea    0xe15(%rip),%rdi
test   %bl,%bl
cmovne %rax,%rdi
movzbl %bl,%ebx
call   1040 <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 = [28 x i8] c"CryptLibTest\0A------------\0A\0A\00"
@.str.1 = [18 x i8] c"Test MD5 - %s\0A\00"
@.str.2 = [5 x i8] c"Pass\00"
@.str.3 = [5 x i8] c"Fail\00"
@.str.4 = [18 x i8] c"Test SHA1 - %s\0A\00"
@.str.5 = [18 x i8] c"Test SHA256 - %s\0A\00"
@.str.6 = [18 x i8] c"Test SHA512 - %s\0A\00"
@.str.7 = [18 x i8] c"Test RC4 - %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 ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @TestMd5()
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 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, 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)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 (...) @TestSha1()
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %9
store i32 0, i32* %3
br label %19
19: ; preds = %18, %9
%20 = load i32, i32* %2
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, 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)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = call i32 (...) @TestSha256()
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %19
store i32 0, i32* %3
br label %29
29: ; preds = %28, %19
%30 = load i32, i32* %2
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, 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)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %33)
%35 = call i32 (...) @TestSha512()
store i32 %35, i32* %2
%36 = load i32, i32* %2
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %29
store i32 0, i32* %3
br label %39
39: ; preds = %38, %29
%40 = load i32, i32* %2
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i64
%43 = select i1 %41, 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)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %43)
%45 = call i32 (...) @TestRc4()
store i32 %45, i32* %2
%46 = load i32, i32* %2
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %39
store i32 0, i32* %3
br label %49
49: ; preds = %48, %39
%50 = load i32, i32* %2
%51 = icmp ne i32 %50, 0
%52 = zext i1 %51 to i64
%53 = select i1 %51, 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)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%56 = load i32, i32* %3
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %49
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %62
60: ; preds = %49
%61 = 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 %63
62: ; preds = %58
store i32 0, i32* %1
br label %63
63: ; preds = %62, %60
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"Test MD5 - %s\0A\00"
@.str.2 = [5 x i8] c"Pass\00"
@.str.3 = [5 x i8] c"Fail\00"
@.str.4 = [18 x i8] c"Test SHA1 - %s\0A\00"
@.str.5 = [18 x i8] c"Test SHA256 - %s\0A\00"
@.str.6 = [18 x i8] c"Test SHA512 - %s\0A\00"
@.str.7 = [18 x i8] c"Test RC4 - %s\0A\00"
@str = [27 x i8] c"CryptLibTest\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 ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @TestMd5()
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, 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)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = tail call i32 (...) @TestSha1()
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, 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)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%10 = tail call i32 (...) @TestSha256()
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, 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)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%14 = tail call i32 (...) @TestSha512()
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, 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)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%18 = tail call i32 (...) @TestRc4()
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, 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)
%21 = select i1 %19, i1 true, i1 %15
%22 = select i1 %21, i1 true, i1 %11
%23 = select i1 %22, i1 true, i1 %7
%24 = select i1 %23, i1 true, i1 %3
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %20)
%26 = tail call i32 @putchar(i32 10)
%27 = select i1 %24, 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)
%28 = zext i1 %24 to i32
%29 = tail call i32 @puts(i8* dereferenceable(1) %27)
ret i32 %28
}