#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 log(double);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char *argv[]) {
  int n;
  double i, j;
  scanf("%i", &n);
  while (n--) {
    scanf("%lf %lf", &i, &j);
    printf("%.3lf\n", (log(i) / log(j)));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11b4 <main+0x84>
lea    0xe90(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
call   1050 <log@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <log@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
jmp    1158 <main+0x28>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xebd(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     11b0 <main+0x80>
lea    0xea6(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe9d(%rip),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x18(%rsp),%xmm0
call   1050 <log@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
call   1050 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jae    1170 <main+0x40>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [8 x i8] c"%lf %lf\00"
@.str.2 = [7 x i8] c"%.3lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %10
10: ; preds = %14, %2
%11 = load i32, i32* %6
%12 = add nsw i32 %11, -1
store i32 %12, i32* %6
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %7, double* %8)
%16 = load double, double* %7
%17 = call i32 @log(double %16)
%18 = load double, double* %8
%19 = call i32 @log(double %18)
%20 = sdiv i32 %17, %19
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %10
22: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [8 x i8] c"%lf %lf\00"
@.str.2 = [7 x i8] c"%.3lf\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = bitcast i32* %3 to i8*
%7 = bitcast double* %4 to i8*
%8 = bitcast double* %5 to i8*
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = add nsw i32 %10, -1
store i32 %11, i32* %3
%12 = icmp eq i32 %10, 0
br i1 %12, label %24, label %13
13: ; preds = %2, %13
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %4, double* %5)
%15 = load double, double* %4
%16 = call i32 @log(double %15)
%17 = load double, double* %5
%18 = call i32 @log(double %17)
%19 = sdiv i32 %16, %18
%20 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %3
%22 = add nsw i32 %21, -1
store i32 %22, i32* %3
%23 = icmp eq i32 %21, 0
br i1 %23, label %24, label %13
24: ; preds = %13, %2
ret i32 0
}