#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 */
scalar_t__ EOF;
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ scanf(char *, int *, int *);
int /*<<< orphan*/ stdin;
int main() {
  int num1, num2, i;
  int yue = 0;
  freopen("sample1.in", "r", stdin);
  while (scanf("%d %d", &num1, &num2) != EOF) {
    for (i = num1; i >= 2; i--) {
      if ((num1 % i == 0) && (num2 % i == 0)) {
        num1 /= i;
        num2 /= i;
      } else if (num2 % num1 == 0) {
        num2 /= num1;
        num1 = 1;
      }
    }
    printf("%d %d\n", num1, num2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
lea    0xeaa(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1040 <freopen@plt>
lea    0xea4(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
je     1225 <main+0xf5>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jl     120e <main+0xde>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11d3 <main+0xa3>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11d3 <main+0xa3>
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    11fb <main+0xcb>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    11f6 <main+0xc6>
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
jmp    11fb <main+0xcb>
jmp    1200 <main+0xd0>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    118c <main+0x5c>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
jmp    1162 <main+0x32>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
lea    0xeb5(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <freopen@plt>
lea    0xeaf(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x2e6e(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    1189 <main+0x59>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe83(%rip),%r14
lea    0xe76(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%r13
jmp    11d0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%esi
mov    %r14,%rdi
mov    %ecx,%edx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <scanf@plt>
cmp    0x0(%rbp),%rax
je     1178 <main+0x48>
mov    0x4(%rsp),%ebx
mov    (%rsp),%ecx
cmp    $0x2,%ebx
jl     11b0 <main+0x80>
mov    %ebx,%esi
jmp    11fa <main+0xca>
mov    %edi,0x4(%rsp)
mov    %eax,(%rsp)
mov    %eax,%ecx
mov    %edi,%esi
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%eax
cmp    $0x2,%ebx
mov    %eax,%ebx
jle    11b2 <main+0x82>
mov    %esi,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    120e <main+0xde>
mov    %eax,%edi
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     11e0 <main+0xb0>
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    11f0 <main+0xc0>
mov    %eax,(%rsp)
movl   $0x1,0x4(%rsp)
mov    $0x1,%esi
mov    %eax,%ecx
jmp    11f0 <main+0xc0>

LLVM IR (-O0):
@.str = [11 x i8] c"sample1.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [6 x i8] c"%d %d\00"
@EOF = global i64 0
@.str.3 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%6 = load i32, i32* @stdin
%7 = call i32 @freopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %8
8: ; preds = %48, %0
%9 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %52
12: ; preds = %8
%13 = load i32, i32* %2
store i32 %13, i32* %4
br label %14
14: ; preds = %45, %12
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 2
br i1 %16, label %17, label %48
17: ; preds = %14
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = srem i32 %18, %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %34
22: ; preds = %17
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = srem i32 %23, %24
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %22
%28 = load i32, i32* %4
%29 = load i32, i32* %2
%30 = sdiv i32 %29, %28
store i32 %30, i32* %2
%31 = load i32, i32* %4
%32 = load i32, i32* %3
%33 = sdiv i32 %32, %31
store i32 %33, i32* %3
br label %44
34: ; preds = %22, %17
%35 = load i32, i32* %3
%36 = load i32, i32* %2
%37 = srem i32 %35, %36
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %34
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = sdiv i32 %41, %40
store i32 %42, i32* %3
store i32 1, i32* %2
br label %43
43: ; preds = %39, %34
br label %44
44: ; preds = %43, %27
br label %45
45: ; preds = %44
%46 = load i32, i32* %4
%47 = add nsw i32 %46, -1
store i32 %47, i32* %4
br label %14
48: ; preds = %14
%49 = load i32, i32* %2
%50 = load i32, i32* %3
%51 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %50)
br label %8
52: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"sample1.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [6 x i8] c"%d %d\00"
@EOF = global i64 0
@.str.3 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = load i32, i32* @stdin
%6 = tail call i32 @freopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %43, label %10
10: ; preds = %0, %36
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = icmp sgt i32 %11, 1
br i1 %13, label %14, label %36
14: ; preds = %10, %31
%15 = phi i32 [ %34, %31 ], [ %11, %10 ]
%16 = phi i32 [ %33, %31 ], [ %11, %10 ]
%17 = phi i32 [ %32, %31 ], [ %12, %10 ]
%18 = srem i32 %16, %15
%19 = sdiv i32 %16, %15
%20 = icmp eq i32 %18, 0
br i1 %20, label %21, label %26
21: ; preds = %14
%22 = srem i32 %17, %15
%23 = sdiv i32 %17, %15
%24 = icmp eq i32 %22, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 %19, i32* %1
store i32 %23, i32* %2
br label %31
26: ; preds = %21, %14
%27 = srem i32 %17, %16
%28 = sdiv i32 %17, %16
%29 = icmp eq i32 %27, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 %28, i32* %2
store i32 1, i32* %1
br label %31
31: ; preds = %25, %30, %26
%32 = phi i32 [ %23, %25 ], [ %28, %30 ], [ %17, %26 ]
%33 = phi i32 [ %19, %25 ], [ 1, %30 ], [ %16, %26 ]
%34 = add nsw i32 %15, -1
%35 = icmp sgt i32 %15, 2
br i1 %35, label %14, label %36
36: ; preds = %31, %10
%37 = phi i32 [ %12, %10 ], [ %32, %31 ]
%38 = phi i32 [ %11, %10 ], [ %33, %31 ]
%39 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %37)
%40 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%41 = load i64, i64* @EOF
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %10
43: ; preds = %36, %0
ret i32 0
}