#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*/ lgc(long);
int /*<<< orphan*/ lgf(long);
int /*<<< orphan*/ printf(char *, long, int /*<<< orphan*/);
void testLg() {
  for (long i = 0; i < 10; i++) {
    printf("ceil (lg (%ld)) = %ld\n", i, lgc(i));
    printf("floor (lg (%ld)) = %ld\n", i, lgf(i));
  }
}


x86 assembly (clang, -O0):
<testLg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
cmpq   $0xa,-0x8(%rbp)
jge    11a2 <testLg+0x72>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <lgc@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <lgf@plt>
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1140 <testLg+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testLg>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <lgc@plt>
lea    0xebe(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <lgf@plt>
lea    0xebb(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <lgc@plt>
mov    $0x1,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <lgf@plt>
mov    $0x1,%esi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <lgc@plt>
mov    $0x2,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <lgf@plt>
mov    $0x2,%esi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x3,%edi
call   1050 <lgc@plt>
mov    $0x3,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x3,%edi
call   1040 <lgf@plt>
mov    $0x3,%esi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x4,%edi
call   1050 <lgc@plt>
mov    $0x4,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x4,%edi
call   1040 <lgf@plt>
mov    $0x4,%esi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x5,%edi
call   1050 <lgc@plt>
mov    $0x5,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x5,%edi
call   1040 <lgf@plt>
mov    $0x5,%esi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x6,%edi
call   1050 <lgc@plt>
mov    $0x6,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x6,%edi
call   1040 <lgf@plt>
mov    $0x6,%esi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x7,%edi
call   1050 <lgc@plt>
mov    $0x7,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x7,%edi
call   1040 <lgf@plt>
mov    $0x7,%esi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x8,%edi
call   1050 <lgc@plt>
mov    $0x8,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x8,%edi
call   1040 <lgf@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x9,%edi
call   1050 <lgc@plt>
mov    $0x9,%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x9,%edi
call   1040 <lgf@plt>
mov    $0x9,%esi
mov    %rbx,%rdi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"ceil (lg (%ld)) = %ld\0A\00"
@.str.1 = [24 x i8] c"floor (lg (%ld)) = %ld\0A\00"
define void @testLg() {
%1 = alloca i64
store i64 0, i64* %1
br label %2
2: ; preds = %14, %0
%3 = load i64, i64* %1
%4 = icmp slt i64 %3, 10
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = load i64, i64* %1
%7 = load i64, i64* %1
%8 = call i32 @lgc(i64 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %6, i32 %8)
%10 = load i64, i64* %1
%11 = load i64, i64* %1
%12 = call i32 @lgf(i64 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %10, i32 %12)
br label %14
14: ; preds = %5
%15 = load i64, i64* %1
%16 = add nsw i64 %15, 1
store i64 %16, i64* %1
br label %2
17: ; preds = %2
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"ceil (lg (%ld)) = %ld\0A\00"
@.str.1 = [24 x i8] c"floor (lg (%ld)) = %ld\0A\00"
define void @testLg() {
%1 = tail call i32 @lgc(i64 0)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 0, i32 %1)
%3 = tail call i32 @lgf(i64 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 0, i32 %3)
%5 = tail call i32 @lgc(i64 1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 1, i32 %5)
%7 = tail call i32 @lgf(i64 1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 1, i32 %7)
%9 = tail call i32 @lgc(i64 2)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 2, i32 %9)
%11 = tail call i32 @lgf(i64 2)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 2, i32 %11)
%13 = tail call i32 @lgc(i64 3)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 3, i32 %13)
%15 = tail call i32 @lgf(i64 3)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 3, i32 %15)
%17 = tail call i32 @lgc(i64 4)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 4, i32 %17)
%19 = tail call i32 @lgf(i64 4)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 4, i32 %19)
%21 = tail call i32 @lgc(i64 5)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 5, i32 %21)
%23 = tail call i32 @lgf(i64 5)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 5, i32 %23)
%25 = tail call i32 @lgc(i64 6)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 6, i32 %25)
%27 = tail call i32 @lgf(i64 6)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 6, i32 %27)
%29 = tail call i32 @lgc(i64 7)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 7, i32 %29)
%31 = tail call i32 @lgf(i64 7)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 7, i32 %31)
%33 = tail call i32 @lgc(i64 8)
%34 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 8, i32 %33)
%35 = tail call i32 @lgf(i64 8)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 8, i32 %35)
%37 = tail call i32 @lgc(i64 9)
%38 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 9, i32 %37)
%39 = tail call i32 @lgf(i64 9)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 9, i32 %39)
ret void
}