#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 gcd(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int A, B, g, itr, i;
  scanf("%d", &itr);
  for (i = 0; i < itr; i++) {
    scanf("%d %d", &A, &B);
    g = gcd(A, B);
    printf("%d\n", g * (A / g) * (B / g));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebd(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b9 <main+0x89>
lea    0xe95(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <gcd@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
imul   %eax,%esi
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
imul   %eax,%esi
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1158 <main+0x28>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11b5 <main+0x85>
lea    0xea3(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xe98(%rip),%rbx
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1050 <gcd@plt>
mov    %eax,%ecx
mov    0xc(%rsp),%esi
mov    %esi,%eax
cltd
idiv   %ecx
sub    %edx,%esi
mov    0x8(%rsp),%eax
cltd
idiv   %ecx
imul   %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %0, %10
%11 = phi i32 [ %23, %10 ], [ 0, %0 ]
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @gcd(i32 %13, i32 %14)
%16 = load i32, i32* %1
%17 = srem i32 %16, %15
%18 = sub i32 %16, %17
%19 = load i32, i32* %2
%20 = sdiv i32 %19, %15
%21 = mul nsw i32 %20, %18
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i32 %11, 1
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %10, label %26
26: ; preds = %10, %0
ret i32 0
}