#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 log_2(int);
unsigned long pow_2(int);
int /*<<< orphan*/ printf(char *);
void util_test() {
  printf("Testing log_2\n");
  assert(log_2(1UL) == 0);
  assert(log_2(2UL) == 1);
  assert(log_2(4UL) == 2);
  assert(log_2(1073741824UL) == 30);
  assert(log_2(2147483648UL) == 31);
  assert(log_2(3) == -1);
  assert(log_2(12) == -1);
  printf("Testing pow_2\n");
  assert(pow_2(0) == 1UL);
  assert(pow_2(1) == 2UL);
  assert(pow_2(2) == 4UL);
  assert(pow_2(3) == 8UL);
  assert(pow_2(30) == 1073741824UL);
  assert(pow_2(31) == 2147483648UL);
}


x86 assembly (clang, -O0):
<util_test>:
push   %rbp
mov    %rsp,%rbp
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1030 <log_2@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x2,%edi
call   1030 <log_2@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x4,%edi
call   1030 <log_2@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x40000000,%edi
call   1030 <log_2@plt>
cmp    $0x1e,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x80000000,%edi
call   1030 <log_2@plt>
cmp    $0x1f,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x3,%edi
call   1030 <log_2@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0xc,%edi
call   1030 <log_2@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <pow_2@plt>
cmp    $0x1,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x1,%edi
call   1050 <pow_2@plt>
cmp    $0x2,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x2,%edi
call   1050 <pow_2@plt>
cmp    $0x4,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x3,%edi
call   1050 <pow_2@plt>
cmp    $0x8,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x1e,%edi
call   1050 <pow_2@plt>
cmp    $0x40000000,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x1f,%edi
call   1050 <pow_2@plt>
mov    $0x80000000,%ecx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_test>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1030 <log_2@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    $0x2,%edi
call   1030 <log_2@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    $0x4,%edi
call   1030 <log_2@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1060 <assert@plt>
mov    $0x40000000,%edi
call   1030 <log_2@plt>
xor    %edi,%edi
cmp    $0x1e,%eax
sete   %dil
call   1060 <assert@plt>
mov    $0x80000000,%edi
call   1030 <log_2@plt>
xor    %edi,%edi
cmp    $0x1f,%eax
sete   %dil
call   1060 <assert@plt>
mov    $0x3,%edi
call   1030 <log_2@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1060 <assert@plt>
mov    $0xc,%edi
call   1030 <log_2@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xe13(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1050 <pow_2@plt>
xor    %edi,%edi
cmp    $0x1,%rax
sete   %dil
call   1060 <assert@plt>
mov    $0x1,%edi
call   1050 <pow_2@plt>
xor    %edi,%edi
cmp    $0x2,%rax
sete   %dil
call   1060 <assert@plt>
mov    $0x2,%edi
call   1050 <pow_2@plt>
xor    %edi,%edi
cmp    $0x4,%rax
sete   %dil
call   1060 <assert@plt>
mov    $0x3,%edi
call   1050 <pow_2@plt>
xor    %edi,%edi
cmp    $0x8,%rax
sete   %dil
call   1060 <assert@plt>
mov    $0x1e,%edi
call   1050 <pow_2@plt>
xor    %edi,%edi
cmp    $0x40000000,%rax
sete   %dil
call   1060 <assert@plt>
mov    $0x1f,%edi
call   1050 <pow_2@plt>
mov    $0x80000000,%ecx
xor    %edi,%edi
cmp    %rcx,%rax
sete   %dil
pop    %rax
jmp    1060 <assert@plt>

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

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