#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 TestEndianCorrectness();
int TestLargeVector();
int TestStreamConsistency();
int TestVectors();
bool TestAesCtr(void) {
  bool totalSuccess = true;
  bool success;
  success = TestVectors();
  if (!success) {
    totalSuccess = false;
  }
  success = TestLargeVector();
  if (!success) {
    totalSuccess = false;
  }
  success = TestStreamConsistency();
  if (!success) {
    totalSuccess = false;
  }
  success = TestEndianCorrectness();
  if (!success) {
    totalSuccess = false;
  }
  return totalSuccess;
}


x86 assembly (clang, -O0):
<TestAesCtr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
mov    $0x0,%al
call   1030 <TestVectors@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    116a <TestAesCtr+0x2a>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <TestLargeVector@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1185 <TestAesCtr+0x45>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <TestStreamConsistency@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11a0 <TestAesCtr+0x60>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <TestEndianCorrectness@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11bb <TestAesCtr+0x7b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestAesCtr>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <TestVectors@plt>
test   %eax,%eax
setne  %bpl
xor    %eax,%eax
call   1060 <TestLargeVector@plt>
test   %eax,%eax
setne  %bl
xor    %eax,%eax
call   1040 <TestStreamConsistency@plt>
test   %eax,%eax
setne  %r14b
xor    %eax,%eax
call   1050 <TestEndianCorrectness@plt>
test   %eax,%eax
setne  %al
and    %r14b,%al
and    %bpl,%bl
and    %al,%bl
movzbl %bl,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @TestAesCtr() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %1
%3 = call i32 (...) @TestVectors()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 0, i32* %1
br label %7
7: ; preds = %6, %0
%8 = call i32 (...) @TestLargeVector()
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7
store i32 0, i32* %1
br label %12
12: ; preds = %11, %7
%13 = call i32 (...) @TestStreamConsistency()
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12
store i32 0, i32* %1
br label %17
17: ; preds = %16, %12
%18 = call i32 (...) @TestEndianCorrectness()
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %17
store i32 0, i32* %1
br label %22
22: ; preds = %21, %17
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @TestAesCtr() {
%1 = tail call i32 (...) @TestVectors()
%2 = icmp ne i32 %1, 0
%3 = tail call i32 (...) @TestLargeVector()
%4 = icmp ne i32 %3, 0
%5 = tail call i32 (...) @TestStreamConsistency()
%6 = icmp ne i32 %5, 0
%7 = tail call i32 (...) @TestEndianCorrectness()
%8 = icmp ne i32 %7, 0
%9 = select i1 %8, i1 %6, i1 false
%10 = select i1 %9, i1 %4, i1 false
%11 = select i1 %10, i1 %2, i1 false
%12 = zext i1 %11 to i32
ret i32 %12
}