#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*/ test_frequency(int, int);
int /*<<< orphan*/ test_shift(int);
int main() {
  for (int shift = 0; shift < 512; shift++) {
    test_shift(shift);
  }
  for (int n = 16; n <= 256; n *= 2) {
    for (int frequency = 1; frequency < n / 2; frequency++) {
      test_frequency(frequency, n);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x200,-0x8(%rbp)
jge    1159 <main+0x39>
mov    -0x8(%rbp),%edi
call   1030 <test_shift@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
movl   $0x10,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jg     11be <main+0x9e>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11ab <main+0x8b>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <test_frequency@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1174 <main+0x54>
jmp    11b0 <main+0x90>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1030 <test_shift@plt>
add    $0x1,%ebx
cmp    $0x200,%ebx
jne    1130 <main+0x10>
mov    $0x1,%ebx
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <test_frequency@plt>
mov    $0x2,%edi
mov    $0x10,%esi
call   1040 <test_frequency@plt>
mov    $0x3,%edi
mov    $0x10,%esi
call   1040 <test_frequency@plt>
mov    $0x4,%edi
mov    $0x10,%esi
call   1040 <test_frequency@plt>
mov    $0x5,%edi
mov    $0x10,%esi
call   1040 <test_frequency@plt>
mov    $0x6,%edi
mov    $0x10,%esi
call   1040 <test_frequency@plt>
mov    $0x7,%edi
mov    $0x10,%esi
call   1040 <test_frequency@plt>
mov    $0x1,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x2,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x3,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x4,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x5,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x6,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x7,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x8,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x9,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0xa,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0xb,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0xc,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0xd,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0xe,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0xf,%edi
mov    $0x20,%esi
call   1040 <test_frequency@plt>
mov    $0x1,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x2,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x3,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x4,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x5,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x6,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x7,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x8,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x9,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0xa,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0xb,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0xc,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0xd,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0xe,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0xf,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x10,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x11,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x12,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x13,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x14,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x15,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x16,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x17,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x18,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x19,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x1a,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x1b,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x1c,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x1d,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x1e,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
mov    $0x1f,%edi
mov    $0x40,%esi
call   1040 <test_frequency@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    $0x80,%esi
call   1040 <test_frequency@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    1470 <main+0x350>
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
mov    $0x100,%esi
call   1040 <test_frequency@plt>
add    $0x1,%ebx
cmp    $0x80,%ebx
jne    1490 <main+0x370>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %11, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 512
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i32, i32* %2
%10 = call i32 @test_shift(i32 %9)
br label %11
11: ; preds = %8
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
br label %5
14: ; preds = %5
store i32 16, i32* %3
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 256
br i1 %17, label %18, label %35
18: ; preds = %15
store i32 1, i32* %4
br label %19
19: ; preds = %28, %18
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 2
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = call i32 @test_frequency(i32 %25, i32 %26)
br label %28
28: ; preds = %24
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %19
31: ; preds = %19
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = mul nsw i32 %33, 2
store i32 %34, i32* %3
br label %15
35: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %4, %1 ]
%3 = tail call i32 @test_shift(i32 %2)
%4 = add nuw nsw i32 %2, 1
%5 = icmp eq i32 %4, 512
br i1 %5, label %6, label %1
6: ; preds = %1
%7 = tail call i32 @test_frequency(i32 1, i32 16)
%8 = tail call i32 @test_frequency(i32 2, i32 16)
%9 = tail call i32 @test_frequency(i32 3, i32 16)
%10 = tail call i32 @test_frequency(i32 4, i32 16)
%11 = tail call i32 @test_frequency(i32 5, i32 16)
%12 = tail call i32 @test_frequency(i32 6, i32 16)
%13 = tail call i32 @test_frequency(i32 7, i32 16)
%14 = tail call i32 @test_frequency(i32 1, i32 32)
%15 = tail call i32 @test_frequency(i32 2, i32 32)
%16 = tail call i32 @test_frequency(i32 3, i32 32)
%17 = tail call i32 @test_frequency(i32 4, i32 32)
%18 = tail call i32 @test_frequency(i32 5, i32 32)
%19 = tail call i32 @test_frequency(i32 6, i32 32)
%20 = tail call i32 @test_frequency(i32 7, i32 32)
%21 = tail call i32 @test_frequency(i32 8, i32 32)
%22 = tail call i32 @test_frequency(i32 9, i32 32)
%23 = tail call i32 @test_frequency(i32 10, i32 32)
%24 = tail call i32 @test_frequency(i32 11, i32 32)
%25 = tail call i32 @test_frequency(i32 12, i32 32)
%26 = tail call i32 @test_frequency(i32 13, i32 32)
%27 = tail call i32 @test_frequency(i32 14, i32 32)
%28 = tail call i32 @test_frequency(i32 15, i32 32)
%29 = tail call i32 @test_frequency(i32 1, i32 64)
%30 = tail call i32 @test_frequency(i32 2, i32 64)
%31 = tail call i32 @test_frequency(i32 3, i32 64)
%32 = tail call i32 @test_frequency(i32 4, i32 64)
%33 = tail call i32 @test_frequency(i32 5, i32 64)
%34 = tail call i32 @test_frequency(i32 6, i32 64)
%35 = tail call i32 @test_frequency(i32 7, i32 64)
%36 = tail call i32 @test_frequency(i32 8, i32 64)
%37 = tail call i32 @test_frequency(i32 9, i32 64)
%38 = tail call i32 @test_frequency(i32 10, i32 64)
%39 = tail call i32 @test_frequency(i32 11, i32 64)
%40 = tail call i32 @test_frequency(i32 12, i32 64)
%41 = tail call i32 @test_frequency(i32 13, i32 64)
%42 = tail call i32 @test_frequency(i32 14, i32 64)
%43 = tail call i32 @test_frequency(i32 15, i32 64)
%44 = tail call i32 @test_frequency(i32 16, i32 64)
%45 = tail call i32 @test_frequency(i32 17, i32 64)
%46 = tail call i32 @test_frequency(i32 18, i32 64)
%47 = tail call i32 @test_frequency(i32 19, i32 64)
%48 = tail call i32 @test_frequency(i32 20, i32 64)
%49 = tail call i32 @test_frequency(i32 21, i32 64)
%50 = tail call i32 @test_frequency(i32 22, i32 64)
%51 = tail call i32 @test_frequency(i32 23, i32 64)
%52 = tail call i32 @test_frequency(i32 24, i32 64)
%53 = tail call i32 @test_frequency(i32 25, i32 64)
%54 = tail call i32 @test_frequency(i32 26, i32 64)
%55 = tail call i32 @test_frequency(i32 27, i32 64)
%56 = tail call i32 @test_frequency(i32 28, i32 64)
%57 = tail call i32 @test_frequency(i32 29, i32 64)
%58 = tail call i32 @test_frequency(i32 30, i32 64)
%59 = tail call i32 @test_frequency(i32 31, i32 64)
br label %60
60: ; preds = %60, %6
%61 = phi i32 [ %63, %60 ], [ 1, %6 ]
%62 = tail call i32 @test_frequency(i32 %61, i32 128)
%63 = add nuw nsw i32 %61, 1
%64 = icmp eq i32 %63, 64
br i1 %64, label %65, label %60
65: ; preds = %60, %65
%66 = phi i32 [ %68, %65 ], [ 1, %60 ]
%67 = tail call i32 @test_frequency(i32 %66, i32 256)
%68 = add nuw nsw i32 %66, 1
%69 = icmp eq i32 %68, 128
br i1 %69, label %70, label %65
70: ; preds = %65
ret i32 0
}