#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;
long long gcd(long long, long long);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ recursive(long long, long long);
scalar_t__ scanf(char *, long long *, long long *);
int main(void) {
  long long a, b, c;
  while (scanf("%lld %lld", &a, &b) != EOF) {
    c = gcd(a, b);
    a /= c;
    b /= c;
    printf("%lld\n", recursive(a, b));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%rax
je     11c6 <main+0x86>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <gcd@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <recursive@plt>
mov    %eax,%esi
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%rdi
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x2e80(%rip),%rbx
cmp    (%rbx),%rax
jne    117d <main+0x3d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe86(%rip),%r14
lea    0xe75(%rip),%r15
lea    0x8(%rsp),%r12
mov    %rsp,%r13
jmp    11ce <main+0x8e>
cs nopw 0x0(%rax,%rax,1)
nop
cqto
idiv   %rcx
mov    %rax,%rsi
mov    %rsi,(%rsp)
call   1050 <recursive@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <scanf@plt>
cmp    (%rbx),%rax
je     116d <main+0x2d>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
call   1060 <gcd@plt>
mov    %rax,%rcx
mov    0x8(%rsp),%rax
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     1200 <main+0xc0>
cqto
idiv   %rcx
mov    %rax,%rdi
jmp    1206 <main+0xc6>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
mov    %rdi,0x8(%rsp)
mov    (%rsp),%rax
mov    %rcx,%rdx
or     %rax,%rdx
shr    $0x20,%rdx
jne    11a0 <main+0x60>
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
jmp    11a8 <main+0x68>

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

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