#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 /*<<< orphan*/ keygen(unsigned short, unsigned short *, unsigned short *);
int /*<<< orphan*/ printBin(unsigned short, int);
int /*<<< orphan*/ printf(char *, ...);
void test(unsigned short seed, unsigned short eKOne, unsigned short eKTwo) {
  unsigned short kOne, kTwo;
  static int testNo = 0;
  static int testPassNo = 0;
  testNo++;
  printf("\nTEST %d", testNo);
  printf("\n----------\nGrade:\t\t");
  keygen(seed, &kOne, &kTwo);
  if ((kOne == eKOne) && (kTwo == eKTwo)) {
    printf("\033[22;1;32mPASS\033[0m\n");
    testPassNo++;
  } else
    printf("\033[22;1;31mFAIL\033[0m\n");
  printf("Seed:\t\t");
  printBin(seed, 10);
  printf("\nExpected Key 1:\t");
  printBin(eKOne, 8);
  printf("\nKey 1:\t\t");
  printBin(kOne, 8);
  printf("\nExpected Key 2:\t");
  printBin(eKTwo, 8);
  printf("\nKey 2:\t\t");
  printBin(kTwo, 8);
  printf("\n---------\n\033[22;1;32m%d/%d passed\033[0m\n", testPassNo, testNo);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dx,%ax
mov    %si,%cx
mov    %di,%dx
mov    %dx,-0x2(%rbp)
mov    %cx,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
mov    0x2ee9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ee0(%rip)
mov    0x2eda(%rip),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x8(%rbp),%rsi
lea    -0xa(%rbp),%rdx
movzwl -0x2(%rbp),%edi
call   1030 <keygen@plt>
movzwl -0x8(%rbp),%eax
movzwl -0x4(%rbp),%ecx
cmp    %ecx,%eax
jne    11d1 <test+0xa1>
movzwl -0xa(%rbp),%eax
movzwl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jne    11d1 <test+0xa1>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e7d(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e74(%rip)
jmp    11df <test+0xaf>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xa,%esi
movzwl -0x2(%rbp),%edi
call   1040 <printBin@plt>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x8,%esi
movzwl -0x4(%rbp),%edi
call   1040 <printBin@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x8,%esi
movzwl -0x8(%rbp),%edi
call   1040 <printBin@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x8,%esi
movzwl -0x6(%rbp),%edi
call   1040 <printBin@plt>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x8,%esi
movzwl -0xa(%rbp),%edi
call   1040 <printBin@plt>
mov    0x2dcf(%rip),%esi
mov    0x2dc5(%rip),%edx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
mov    0x2eef(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2ee6(%rip)
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   1040 <keygen@plt>
cmp    %bp,0xe(%rsp)
jne    11af <test+0x6f>
cmp    %r14w,0xc(%rsp)
jne    11af <test+0x6f>
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
addl   $0x1,0x2e9b(%rip)
jmp    11bb <test+0x7b>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzwl %bx,%edi
mov    $0xa,%esi
call   1050 <printBin@plt>
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzwl %bp,%edi
mov    $0x8,%esi
call   1050 <printBin@plt>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzwl 0xe(%rsp),%edi
mov    $0x8,%esi
call   1050 <printBin@plt>
lea    0xe2d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzwl %r14w,%edi
mov    $0x8,%esi
call   1050 <printBin@plt>
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzwl 0xc(%rsp),%edi
mov    $0x8,%esi
call   1050 <printBin@plt>
mov    0x2dfb(%rip),%esi
mov    0x2df1(%rip),%edx
lea    0xe04(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@test.testNo = internal global i32 0
@test.testPassNo = internal global i32 0
@.str = [9 x i8] c"\0ATEST %d\00"
@.str.1 = [21 x i8] c"\0A----------\0AGrade:\09\09\00"
@.str.2 = [20 x i8] c"\1B[22;1;32mPASS\1B[0m\0A\00"
@.str.3 = [20 x i8] c"\1B[22;1;31mFAIL\1B[0m\0A\00"
@.str.4 = [8 x i8] c"Seed:\09\09\00"
@.str.5 = [18 x i8] c"\0AExpected Key 1:\09\00"
@.str.6 = [10 x i8] c"\0AKey 1:\09\09\00"
@.str.7 = [18 x i8] c"\0AExpected Key 2:\09\00"
@.str.8 = [10 x i8] c"\0AKey 2:\09\09\00"
@.str.9 = [39 x i8] c"\0A---------\0A\1B[22;1;32m%d/%d passed\1B[0m\0A\00"
define void @test(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
store i16 %0, i16* %4
store i16 %1, i16* %5
store i16 %2, i16* %6
%9 = load i32, i32* @test.testNo
%10 = add nsw i32 %9, 1
store i32 %10, i32* @test.testNo
%11 = load i32, i32* @test.testNo
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%14 = load i16, i16* %4
%15 = call i32 @keygen(i16 zeroext %14, i16* %7, i16* %8)
%16 = load i16, i16* %7
%17 = zext i16 %16 to i32
%18 = load i16, i16* %5
%19 = zext i16 %18 to i32
%20 = icmp eq i32 %17, %19
br i1 %20, label %21, label %31
21: ; preds = %3
%22 = load i16, i16* %8
%23 = zext i16 %22 to i32
%24 = load i16, i16* %6
%25 = zext i16 %24 to i32
%26 = icmp eq i32 %23, %25
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* @test.testPassNo
%30 = add nsw i32 %29, 1
store i32 %30, i32* @test.testPassNo
br label %33
31: ; preds = %21, %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%35 = load i16, i16* %4
%36 = call i32 @printBin(i16 zeroext %35, i32 10)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%38 = load i16, i16* %5
%39 = call i32 @printBin(i16 zeroext %38, i32 8)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%41 = load i16, i16* %7
%42 = call i32 @printBin(i16 zeroext %41, i32 8)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%44 = load i16, i16* %6
%45 = call i32 @printBin(i16 zeroext %44, i32 8)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%47 = load i16, i16* %8
%48 = call i32 @printBin(i16 zeroext %47, i32 8)
%49 = load i32, i32* @test.testPassNo
%50 = load i32, i32* @test.testNo
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i32 %49, i32 %50)
ret void
}

LLVM IR (-O2):
@test.testNo = internal unnamed_addr global i32 0
@test.testPassNo = internal unnamed_addr global i32 0
@.str = [9 x i8] c"\0ATEST %d\00"
@.str.1 = [21 x i8] c"\0A----------\0AGrade:\09\09\00"
@.str.4 = [8 x i8] c"Seed:\09\09\00"
@.str.5 = [18 x i8] c"\0AExpected Key 1:\09\00"
@.str.6 = [10 x i8] c"\0AKey 1:\09\09\00"
@.str.7 = [18 x i8] c"\0AExpected Key 2:\09\00"
@.str.8 = [10 x i8] c"\0AKey 2:\09\09\00"
@.str.9 = [39 x i8] c"\0A---------\0A\1B[22;1;32m%d/%d passed\1B[0m\0A\00"
@str = [19 x i8] c"\1B[22;1;31mFAIL\1B[0m\00"
@str.10 = [19 x i8] c"\1B[22;1;32mPASS\1B[0m\00"
define void @test(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca i16
%5 = alloca i16
%6 = bitcast i16* %4 to i8*
%7 = bitcast i16* %5 to i8*
%8 = load i32, i32* @test.testNo
%9 = add nsw i32 %8, 1
store i32 %9, i32* @test.testNo
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @keygen(i16 zeroext %0, i16* %4, i16* %5)
%13 = load i16, i16* %4
%14 = icmp eq i16 %13, %1
%15 = load i16, i16* %5
%16 = icmp eq i16 %15, %2
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %18, label %22
18: ; preds = %3
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
%20 = load i32, i32* @test.testPassNo
%21 = add nsw i32 %20, 1
store i32 %21, i32* @test.testPassNo
br label %24
22: ; preds = %3
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @printBin(i16 zeroext %0, i32 10)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%28 = call i32 @printBin(i16 zeroext %1, i32 8)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%30 = load i16, i16* %4
%31 = call i32 @printBin(i16 zeroext %30, i32 8)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 @printBin(i16 zeroext %2, i32 8)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%35 = load i16, i16* %5
%36 = call i32 @printBin(i16 zeroext %35, i32 8)
%37 = load i32, i32* @test.testPassNo
%38 = load i32, i32* @test.testNo
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i32 %37, i32 %38)
ret void
}