#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int test_bitstring();
int test_hash();
int test_idxgen();
int test_key();
int test_ntru();
int test_poly();
int main(int argc, char **argv) {
  printf("Running tests...\n");
  uint8_t pass = test_poly();
  pass &= test_ntru();
  pass &= test_idxgen();
  pass &= test_bitstring();
  pass &= test_key();
  pass &= test_hash();
  printf("%s\n", pass ? "All tests passed" : "One or more tests failed");
  return pass ? 0 : 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <test_poly@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1070 <test_ntru@plt>
and    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <test_idxgen@plt>
and    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1080 <test_bitstring@plt>
and    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <test_key@plt>
and    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <test_hash@plt>
and    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
lea    0xe3e(%rip),%rsi
lea    0xe26(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <test_poly@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <test_ntru@plt>
mov    %eax,%ebp
and    %ebx,%ebp
xor    %eax,%eax
call   1060 <test_idxgen@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1080 <test_bitstring@plt>
mov    %eax,%ebx
and    %r14d,%ebx
and    %ebp,%ebx
xor    %eax,%eax
call   1050 <test_key@plt>
mov    %eax,%ebp
and    %ebx,%ebp
xor    %eax,%eax
call   1040 <test_hash@plt>
xor    %ebx,%ebx
test   %eax,%ebp
sete   %bl
lea    0xe45(%rip),%rax
lea    0xe2d(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Running tests...\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [17 x i8] c"All tests passed\00"
@.str.3 = [25 x i8] c"One or more tests failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @test_poly()
store i32 %8, i32* %6
%9 = call i32 (...) @test_ntru()
%10 = load i32, i32* %6
%11 = and i32 %10, %9
store i32 %11, i32* %6
%12 = call i32 (...) @test_idxgen()
%13 = load i32, i32* %6
%14 = and i32 %13, %12
store i32 %14, i32* %6
%15 = call i32 (...) @test_bitstring()
%16 = load i32, i32* %6
%17 = and i32 %16, %15
store i32 %17, i32* %6
%18 = call i32 (...) @test_key()
%19 = load i32, i32* %6
%20 = and i32 %19, %18
store i32 %20, i32* %6
%21 = call i32 (...) @test_hash()
%22 = load i32, i32* %6
%23 = and i32 %22, %21
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %6
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 0, i32 1
ret i32 %32
}

LLVM IR (-O2):
@.str.2 = [17 x i8] c"All tests passed\00"
@.str.3 = [25 x i8] c"One or more tests failed\00"
@str = [17 x i8] c"Running tests...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @test_poly()
%5 = tail call i32 (...) @test_ntru()
%6 = and i32 %5, %4
%7 = tail call i32 (...) @test_idxgen()
%8 = and i32 %6, %7
%9 = tail call i32 (...) @test_bitstring()
%10 = and i32 %8, %9
%11 = tail call i32 (...) @test_key()
%12 = and i32 %10, %11
%13 = tail call i32 (...) @test_hash()
%14 = and i32 %12, %13
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0)
%17 = tail call i32 @puts(i8* dereferenceable(1) %16)
%18 = zext i1 %15 to i32
ret i32 %18
}