#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 floor_log2(unsigned long);
unsigned long pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
void run_test() {
  printf("경계를 테스트합니다. 각각 테스트값의 -1,+0,+1\n\n");
  for (int i = 0; i < 64; i++) {
    unsigned long test = pow(2, i);
    printf("test number : %lu\n", test);
    printf("result\n");
    printf("%d, %d, %d\n", floor_log2(test - 1), floor_log2(test),
           floor_log2(test + 1));
    printf("must have to be\n");
    if (i == 0) {
      printf("%d, %d, %d\n", i - 1, i, i + 1);
      if (floor_log2(test - 1) == i - 1 && floor_log2(test) == i &&
          floor_log2(test + 1) == i + 1)
        printf("Test result : pass!\n\n");
      else
        printf("Test result : fail!\n\n");
    } else {
      printf("%d, %d, %d\n", i - 1, i, i);
      if (floor_log2(test - 1) == i - 1 && floor_log2(test) == i &&
          floor_log2(test + 1) == i)
        printf("Test result : pass!\n\n");
      else
        printf("Test result : fail!\n\n");
    }
  }
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x40,-0x4(%rbp)
jge    1300 <run_test+0x1d0>
mov    -0x4(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
call   1040 <floor_log2@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <floor_log2@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <floor_log2@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    %eax,%ecx
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    126a <run_test+0x13a>
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
call   1040 <floor_log2@plt>
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1257 <run_test+0x127>
mov    -0x10(%rbp),%rdi
call   1040 <floor_log2@plt>
cmp    -0x4(%rbp),%eax
jne    1257 <run_test+0x127>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <floor_log2@plt>
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    1257 <run_test+0x127>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1265 <run_test+0x135>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ed <run_test+0x1bd>
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
call   1040 <floor_log2@plt>
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12da <run_test+0x1aa>
mov    -0x10(%rbp),%rdi
call   1040 <floor_log2@plt>
cmp    -0x4(%rbp),%eax
jne    12da <run_test+0x1aa>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <floor_log2@plt>
cmp    -0x4(%rbp),%eax
jne    12da <run_test+0x1aa>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e8 <run_test+0x1b8>
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ed <run_test+0x1bd>
jmp    12f2 <run_test+0x1c2>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114d <run_test+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1060 <pow@plt>
mov    %rax,%r14
lea    0xe93(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    -0x1(%r14),%r12
mov    %r12,%rdi
call   1050 <floor_log2@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <floor_log2@plt>
mov    %eax,%ebp
lea    0x1(%r14),%r15
mov    %r15,%rdi
call   1050 <floor_log2@plt>
lea    0xe65(%rip),%r13
mov    %r13,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %r13,%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
mov    $0x1,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1050 <floor_log2@plt>
lea    0xe81(%rip),%rdi
cmp    $0xffffffff,%eax
jne    1229 <run_test+0xe9>
mov    %r14,%rdi
call   1050 <floor_log2@plt>
lea    0xe6d(%rip),%rdi
test   %eax,%eax
jne    1229 <run_test+0xe9>
mov    %r15,%rdi
call   1050 <floor_log2@plt>
cmp    $0x1,%eax
lea    0xe6c(%rip),%rax
lea    0xe50(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
jmp    1248 <run_test+0x108>
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
je     1311 <run_test+0x1d1>
mov    $0x2,%edi
mov    %ebx,%esi
call   1060 <pow@plt>
mov    %rax,%r14
lea    0xda2(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdef(%rip),%rdi
call   1030 <puts@plt>
lea    -0x1(%r14),%r15
mov    %r15,%rdi
call   1050 <floor_log2@plt>
mov    %eax,%r13d
mov    %r14,%rdi
call   1050 <floor_log2@plt>
mov    %eax,%r12d
lea    0x1(%r14),%rdi
mov    %rdi,(%rsp)
call   1050 <floor_log2@plt>
lea    0xd71(%rip),%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdad(%rip),%rdi
call   1030 <puts@plt>
lea    -0x1(%rbx),%ebp
lea    0xd4c(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1050 <floor_log2@plt>
cmp    %eax,%ebp
jne    1230 <run_test+0xf0>
mov    %r14,%rdi
call   1050 <floor_log2@plt>
cmp    %eax,%ebx
jne    1230 <run_test+0xf0>
mov    (%rsp),%rdi
call   1050 <floor_log2@plt>
lea    0xd86(%rip),%rdi
cmp    %eax,%ebx
jne    1230 <run_test+0xf0>
jmp    1237 <run_test+0xf7>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"\EA\B2\BD\EA\B3\84\EB\A5\BC \ED\85\8C\EC\8A\A4\ED\8A\B8\ED\95\A9\EB\8B\88\EB\8B\A4. \EA\B0\81\EA\B0\81 \ED\85\8C\EC\8A\A4\ED\8A\B8\EA\B0\92\EC\9D\98 -1,+0,+1\0A\0A\00"
@.str.1 = [19 x i8] c"test number : %lu\0A\00"
@.str.2 = [8 x i8] c"result\0A\00"
@.str.3 = [12 x i8] c"%d, %d, %d\0A\00"
@.str.4 = [17 x i8] c"must have to be\0A\00"
@.str.5 = [22 x i8] c"Test result : pass!\0A\0A\00"
@.str.6 = [22 x i8] c"Test result : fail!\0A\0A\00"
define void @run_test() {
%1 = alloca i32
%2 = alloca i64
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %4
4: ; preds = %84, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 64
br i1 %6, label %7, label %87
7: ; preds = %4
%8 = load i32, i32* %1
%9 = call i64 @pow(i32 2, i32 %8)
store i64 %9, i64* %2
%10 = load i64, i64* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%13 = load i64, i64* %2
%14 = sub i64 %13, 1
%15 = call i32 @floor_log2(i64 %14)
%16 = load i64, i64* %2
%17 = call i32 @floor_log2(i64 %16)
%18 = load i64, i64* %2
%19 = add i64 %18, 1
%20 = call i32 @floor_log2(i64 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %17, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %55
25: ; preds = %7
%26 = load i32, i32* %1
%27 = sub nsw i32 %26, 1
%28 = load i32, i32* %1
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28, i32 %30)
%32 = load i64, i64* %2
%33 = sub i64 %32, 1
%34 = call i32 @floor_log2(i64 %33)
%35 = load i32, i32* %1
%36 = sub nsw i32 %35, 1
%37 = icmp eq i32 %34, %36
br i1 %37, label %38, label %52
38: ; preds = %25
%39 = load i64, i64* %2
%40 = call i32 @floor_log2(i64 %39)
%41 = load i32, i32* %1
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %52
43: ; preds = %38
%44 = load i64, i64* %2
%45 = add i64 %44, 1
%46 = call i32 @floor_log2(i64 %45)
%47 = load i32, i32* %1
%48 = add nsw i32 %47, 1
%49 = icmp eq i32 %46, %48
br i1 %49, label %50, label %52
50: ; preds = %43
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %54
52: ; preds = %43, %38, %25
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
br label %83
55: ; preds = %7
%56 = load i32, i32* %1
%57 = sub nsw i32 %56, 1
%58 = load i32, i32* %1
%59 = load i32, i32* %1
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %57, i32 %58, i32 %59)
%61 = load i64, i64* %2
%62 = sub i64 %61, 1
%63 = call i32 @floor_log2(i64 %62)
%64 = load i32, i32* %1
%65 = sub nsw i32 %64, 1
%66 = icmp eq i32 %63, %65
br i1 %66, label %67, label %80
67: ; preds = %55
%68 = load i64, i64* %2
%69 = call i32 @floor_log2(i64 %68)
%70 = load i32, i32* %1
%71 = icmp eq i32 %69, %70
br i1 %71, label %72, label %80
72: ; preds = %67
%73 = load i64, i64* %2
%74 = add i64 %73, 1
%75 = call i32 @floor_log2(i64 %74)
%76 = load i32, i32* %1
%77 = icmp eq i32 %75, %76
br i1 %77, label %78, label %80
78: ; preds = %72
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %82
80: ; preds = %72, %67, %55
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %82
82: ; preds = %80, %78
br label %83
83: ; preds = %82, %54
br label %84
84: ; preds = %83
%85 = load i32, i32* %1
%86 = add nsw i32 %85, 1
store i32 %86, i32* %1
br label %4
87: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"test number : %lu\0A\00"
@.str.3 = [12 x i8] c"%d, %d, %d\0A\00"
@str = [63 x i8] c"\EA\B2\BD\EA\B3\84\EB\A5\BC \ED\85\8C\EC\8A\A4\ED\8A\B8\ED\95\A9\EB\8B\88\EB\8B\A4. \EA\B0\81\EA\B0\81 \ED\85\8C\EC\8A\A4\ED\8A\B8\EA\B0\92\EC\9D\98 -1,+0,+1\0A\00"
@str.7 = [7 x i8] c"result\00"
@str.8 = [16 x i8] c"must have to be\00"
@str.11 = [21 x i8] c"Test result : fail!\0A\00"
@str.12 = [21 x i8] c"Test result : pass!\0A\00"
define void @run_test() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%2 = tail call i64 @pow(i32 2, i32 0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %2)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.7, i64 0, i64 0))
%5 = add i64 %2, -1
%6 = tail call i32 @floor_log2(i64 %5)
%7 = tail call i32 @floor_log2(i64 %2)
%8 = add i64 %2, 1
%9 = tail call i32 @floor_log2(i64 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 %7, i32 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 -1, i32 0, i32 1)
%13 = tail call i32 @floor_log2(i64 %5)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %22
15: ; preds = %0
%16 = tail call i32 @floor_log2(i64 %2)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call i32 @floor_log2(i64 %8)
%20 = icmp eq i32 %19, 1
%21 = select i1 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0)
br label %22
22: ; preds = %18, %0, %15
%23 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0), %15 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0), %0 ], [ %21, %18 ]
%24 = tail call i32 @puts(i8* dereferenceable(1) %23)
br label %26
25: ; preds = %49
ret void
26: ; preds = %49, %22
%27 = phi i32 [ 1, %22 ], [ %52, %49 ]
%28 = tail call i64 @pow(i32 2, i32 %27)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %28)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.7, i64 0, i64 0))
%31 = add i64 %28, -1
%32 = tail call i32 @floor_log2(i64 %31)
%33 = tail call i32 @floor_log2(i64 %28)
%34 = add i64 %28, 1
%35 = tail call i32 @floor_log2(i64 %34)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 %33, i32 %35)
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
%38 = add nsw i32 %27, -1
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %27, i32 %27)
%40 = tail call i32 @floor_log2(i64 %31)
%41 = icmp eq i32 %40, %38
br i1 %41, label %42, label %48
42: ; preds = %26
%43 = tail call i32 @floor_log2(i64 %28)
%44 = icmp eq i32 %43, %27
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = tail call i32 @floor_log2(i64 %34)
%47 = icmp eq i32 %46, %27
br i1 %47, label %49, label %48
48: ; preds = %45, %42, %26
br label %49
49: ; preds = %45, %48
%50 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0), %48 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0), %45 ]
%51 = tail call i32 @puts(i8* dereferenceable(1) %50)
%52 = add nuw nsw i32 %27, 1
%53 = icmp eq i32 %52, 64
br i1 %53, label %25, label %26
}