#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*/ assert(int);
int /*<<< orphan*/ end_test();
int /*<<< orphan*/ start_test(char *);
int valid_beat_duration(int);
void test_valid_beat_duration() {
  int right[] = {1, 2, 4, 8, 16, 32, 64, 128, 256};
  int wrong[] = {0, 3, -3, 5, 7, 14, 15, 18, 212};
  int i;
  start_test("valid_beat_duration");
  for (i = 0; i < 9; i++) {
    assert(valid_beat_duration(right[i]));
    assert(!valid_beat_duration(wrong[i]));
  }
  end_test();
}


x86 assembly (clang, -O0):
<test_valid_beat_duration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x30(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x24,%edx
call   1060 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xeb8(%rip),%rsi
mov    $0x24,%edx
call   1060 <memcpy@plt>
lea    0xecb(%rip),%rdi
call   1040 <start_test@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x9,-0x64(%rbp)
jge    11e0 <test_valid_beat_duration+0x90>
movslq -0x64(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
call   1070 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%edi
call   1070 <valid_beat_duration@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1195 <test_valid_beat_duration+0x45>
mov    $0x0,%al
call   1030 <end_test@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_valid_beat_duration>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <start_test@plt>
mov    $0x1,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
xor    %edi,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x2,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0x3,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x4,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0xfffffffd,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x8,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0x5,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x10,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0x7,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x20,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0xe,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x40,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0xf,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x80,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0x12,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x100,%edi
call   1060 <valid_beat_duration@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0xd4,%edi
call   1060 <valid_beat_duration@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <end_test@plt>

LLVM IR (-O0):
@__const.test_valid_beat_duration.right = [9 x i32] [i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128, i32 256]
@__const.test_valid_beat_duration.wrong = [9 x i32] [i32 0, i32 3, i32 -3, i32 5, i32 7, i32 14, i32 15, i32 18, i32 212]
@.str = [20 x i8] c"valid_beat_duration\00"
define void @test_valid_beat_duration() {
%1 = alloca [9 x i32]
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = bitcast [9 x i32]* %1 to i8*
%5 = bitcast [9 x i32]* %2 to i8*
%6 = call i32 @start_test(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %26, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 9
br i1 %9, label %10, label %29
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @valid_beat_duration(i32 %14)
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i32 @valid_beat_duration(i32 %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
br label %26
26: ; preds = %10
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %7
29: ; preds = %7
%30 = call i32 (...) @end_test()
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"valid_beat_duration\00"
define void @test_valid_beat_duration() {
%1 = tail call i32 @start_test(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @valid_beat_duration(i32 1)
%3 = tail call i32 @assert(i32 %2)
%4 = tail call i32 @valid_beat_duration(i32 0)
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @valid_beat_duration(i32 2)
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @valid_beat_duration(i32 3)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @valid_beat_duration(i32 4)
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 @valid_beat_duration(i32 -3)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = tail call i32 @valid_beat_duration(i32 8)
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @valid_beat_duration(i32 5)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i32 @valid_beat_duration(i32 16)
%27 = tail call i32 @assert(i32 %26)
%28 = tail call i32 @valid_beat_duration(i32 7)
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = tail call i32 @assert(i32 %30)
%32 = tail call i32 @valid_beat_duration(i32 32)
%33 = tail call i32 @assert(i32 %32)
%34 = tail call i32 @valid_beat_duration(i32 14)
%35 = icmp eq i32 %34, 0
%36 = zext i1 %35 to i32
%37 = tail call i32 @assert(i32 %36)
%38 = tail call i32 @valid_beat_duration(i32 64)
%39 = tail call i32 @assert(i32 %38)
%40 = tail call i32 @valid_beat_duration(i32 15)
%41 = icmp eq i32 %40, 0
%42 = zext i1 %41 to i32
%43 = tail call i32 @assert(i32 %42)
%44 = tail call i32 @valid_beat_duration(i32 128)
%45 = tail call i32 @assert(i32 %44)
%46 = tail call i32 @valid_beat_duration(i32 18)
%47 = icmp eq i32 %46, 0
%48 = zext i1 %47 to i32
%49 = tail call i32 @assert(i32 %48)
%50 = tail call i32 @valid_beat_duration(i32 256)
%51 = tail call i32 @assert(i32 %50)
%52 = tail call i32 @valid_beat_duration(i32 212)
%53 = icmp eq i32 %52, 0
%54 = zext i1 %53 to i32
%55 = tail call i32 @assert(i32 %54)
%56 = tail call i32 (...) @end_test()
ret void
}