#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 TestSha1();
int TestSha256();
int TestSha512();
int /*<<< orphan*/ printf(char *, char *);
bool TestHashes(void) {
  bool success;
  bool allSuccess = true;
  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");
  return allSuccess;
}


x86 assembly (clang, -O0):
<TestHashes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1060 <TestMd5@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    117a <TestHashes+0x2a>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
lea    0xe94(%rip),%rsi
lea    0xe88(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <TestSha1@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11b9 <TestHashes+0x69>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
lea    0xe55(%rip),%rsi
lea    0xe49(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <TestSha256@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11f8 <TestHashes+0xa8>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
lea    0xe16(%rip),%rsi
lea    0xe0a(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <TestSha512@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1237 <TestHashes+0xe7>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
lea    0xdd7(%rip),%rsi
lea    0xdcb(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestHashes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1060 <TestMd5@plt>
test   %eax,%eax
sete   %r14b
lea    0xeac(%rip),%r15
lea    0xea0(%rip),%rbp
mov    %rbp,%rsi
cmove  %r15,%rsi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <TestSha1@plt>
test   %eax,%eax
sete   %bl
mov    %rbp,%rsi
cmove  %r15,%rsi
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <TestSha256@plt>
test   %eax,%eax
sete   %r12b
mov    %rbp,%rsi
cmove  %r15,%rsi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <TestSha512@plt>
test   %eax,%eax
sete   %al
cmove  %r15,%rbp
or     %r12b,%al
or     %r14b,%bl
or     %al,%bl
xor    $0x1,%bl
movzbl %bl,%ebx
lea    0xe59(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Test MD5 - %s\0A\00"
@.str.1 = [5 x i8] c"Pass\00"
@.str.2 = [5 x i8] c"Fail\00"
@.str.3 = [19 x i8] c"Test SHA1 - %s\0A\00"
@.str.4 = [19 x i8] c"Test SHA256 - %s\0A\00"
@.str.5 = [19 x i8] c"Test SHA512 - %s\0A\00"
define i32 @TestHashes() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %2
%3 = call i32 (...) @TestMd5()
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 0, i32* %2
br label %7
7: ; preds = %6, %0
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 (...) @TestSha1()
store i32 %13, i32* %1
%14 = load i32, i32* %1
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %7
store i32 0, i32* %2
br label %17
17: ; preds = %16, %7
%18 = load i32, i32* %1
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = call i32 (...) @TestSha256()
store i32 %23, i32* %1
%24 = load i32, i32* %1
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %17
store i32 0, i32* %2
br label %27
27: ; preds = %26, %17
%28 = load i32, i32* %1
%29 = icmp ne i32 %28, 0
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%32 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = call i32 (...) @TestSha512()
store i32 %33, i32* %1
%34 = load i32, i32* %1
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %27
store i32 0, i32* %2
br label %37
37: ; preds = %36, %27
%38 = load i32, i32* %1
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%42 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%43 = load i32, i32* %2
ret i32 %43
}

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