#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*/ logTest(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ timeLog(long);
int main(int argc, char *argv[]) {
  unsigned short i;
  unsigned short x;
  printf("\n-----------------\n");
  printf("Unit Tests\n");
  printf("-----------------\n");
  for (i = 0; i < 16; i++) {
    x = 1 << i;
    logTest(x - 1);
    logTest(x);
    logTest(x + 1);
  }
  logTest(0xfffe);
  logTest(0xffff);
  printf("\n-----------------\n");
  printf("Performance Tests\n");
  printf("-----------------\n");
  timeLog(1000000000l);
  return 0;
}


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    0xeb3(%rip),%rdi
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
movw   $0x0,-0x12(%rbp)
movzwl -0x12(%rbp),%eax
cmp    $0x10,%eax
jge    11be <main+0x8e>
movzwl -0x12(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %ax,-0x14(%rbp)
movzwl -0x14(%rbp),%edi
sub    $0x1,%edi
call   1050 <logTest@plt>
movzwl -0x14(%rbp),%edi
call   1050 <logTest@plt>
movzwl -0x14(%rbp),%edi
add    $0x1,%edi
call   1050 <logTest@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    1170 <main+0x40>
mov    $0xfffe,%edi
call   1050 <logTest@plt>
mov    $0xffff,%edi
call   1050 <logTest@plt>
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe10(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3b9aca00,%edi
call   1030 <timeLog@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    $0x1,%ebx
mov    %ebp,%ecx
shl    %cl,%ebx
lea    -0x1(%rbx),%edi
call   1050 <logTest@plt>
mov    %ebx,%edi
call   1050 <logTest@plt>
add    $0x1,%ebx
mov    %ebx,%edi
call   1050 <logTest@plt>
add    $0x1,%ebp
cmp    $0x10,%ebp
jne    1160 <main+0x30>
mov    $0xfffe,%edi
call   1050 <logTest@plt>
mov    $0xffff,%edi
call   1050 <logTest@plt>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3b9aca00,%edi
call   1040 <timeLog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0A-----------------\0A\00"
@.str.1 = [12 x i8] c"Unit Tests\0A\00"
@.str.2 = [19 x i8] c"-----------------\0A\00"
@.str.3 = [19 x i8] c"Performance Tests\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
%7 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i16 0, i16* %6
br label %11
11: ; preds = %31, %2
%12 = load i16, i16* %6
%13 = zext i16 %12 to i32
%14 = icmp slt i32 %13, 16
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = load i16, i16* %6
%17 = zext i16 %16 to i32
%18 = shl i32 1, %17
%19 = trunc i32 %18 to i16
store i16 %19, i16* %7
%20 = load i16, i16* %7
%21 = zext i16 %20 to i32
%22 = sub nsw i32 %21, 1
%23 = call i32 @logTest(i32 %22)
%24 = load i16, i16* %7
%25 = zext i16 %24 to i32
%26 = call i32 @logTest(i32 %25)
%27 = load i16, i16* %7
%28 = zext i16 %27 to i32
%29 = add nsw i32 %28, 1
%30 = call i32 @logTest(i32 %29)
br label %31
31: ; preds = %15
%32 = load i16, i16* %6
%33 = add i16 %32, 1
store i16 %33, i16* %6
br label %11
34: ; preds = %11
%35 = call i32 @logTest(i32 65534)
%36 = call i32 @logTest(i32 65535)
%37 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @timeLog(i64 1000000000)
ret i32 0
}

LLVM IR (-O2):
@str.4 = [11 x i8] c"Unit Tests\00"
@str.6 = [19 x i8] c"\0A-----------------\00"
@str.7 = [18 x i8] c"Performance Tests\00"
@str.8 = [18 x i8] c"-----------------\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.4, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
br label %6
6: ; preds = %2, %6
%7 = phi i32 [ 0, %2 ], [ %14, %6 ]
%8 = shl nuw nsw i32 1, %7
%9 = add nsw i32 %8, -1
%10 = tail call i32 @logTest(i32 %9)
%11 = tail call i32 @logTest(i32 %8)
%12 = add nuw nsw i32 %8, 1
%13 = tail call i32 @logTest(i32 %12)
%14 = add nuw nsw i32 %7, 1
%15 = icmp eq i32 %14, 16
br i1 %15, label %16, label %6
16: ; preds = %6
%17 = tail call i32 @logTest(i32 65534)
%18 = tail call i32 @logTest(i32 65535)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%22 = tail call i32 @timeLog(i64 1000000000)
ret i32 0
}