#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 find_gcd(int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int numerator;
  int denominator;
  int gcd;
  while (1) {
    scanf("%d ", &numerator);
    if (numerator == 0) {
      break;
    } else {
      scanf("%d\n", &denominator);
      if (numerator % denominator == 0) {
        printf("%d\n", numerator / denominator);
      } else {
        gcd = find_gcd(numerator, denominator);
        if (gcd == 1) {
          printf("%d/%d\n", numerator, denominator);
        } else {
          int simple_num = numerator / gcd;
          int simple_den = denominator / gcd;
          printf("%d/%d\n", simple_num, simple_den);
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    115e <main+0x2e>
jmp    1202 <main+0xd2>
lea    0xea2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    119a <main+0x6a>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f8 <main+0xc8>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <find_gcd@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    11cb <main+0x9b>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f3 <main+0xc3>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f8 <main+0xc8>
jmp    11fd <main+0xcd>
jmp    113f <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    0xebc(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
je     11fa <main+0xca>
lea    0xea7(%rip),%rbx
lea    0xc(%rsp),%r14
lea    0xe94(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xe8c(%rip),%r13
jmp    119e <main+0x6e>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
je     11fa <main+0xca>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
mov    %edi,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1180 <main+0x50>
call   1030 <find_gcd@plt>
mov    %eax,%ecx
mov    0x8(%rsp),%eax
cmp    $0x1,%ecx
jne    11e0 <main+0xb0>
mov    0xc(%rsp),%edx
mov    %r13,%rdi
mov    %eax,%esi
jmp    11f1 <main+0xc1>
cs nopw 0x0(%rax,%rax,1)
nop
cltd
idiv   %ecx
mov    %eax,%esi
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
mov    %r13,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118c <main+0x5c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [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
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %0, %45
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %46
12: ; preds = %7
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = srem i32 %14, %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = sdiv i32 %19, %20
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %44
23: ; preds = %12
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @find_gcd(i32 %24, i32 %25)
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %31)
br label %43
33: ; preds = %23
%34 = load i32, i32* %2
%35 = load i32, i32* %4
%36 = sdiv i32 %34, %35
store i32 %36, i32* %5
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = sdiv i32 %37, %38
store i32 %39, i32* %6
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41)
br label %43
43: ; preds = %33, %29
br label %44
44: ; preds = %43, %18
br label %45
45: ; preds = %44
br label %7
46: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [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 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %33, label %8
8: ; preds = %0, %29
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = srem i32 %10, %11
%13 = sdiv i32 %10, %11
%14 = icmp eq i32 %12, 0
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %29
17: ; preds = %8
%18 = call i32 @find_gcd(i32 %10, i32 %11)
%19 = icmp eq i32 %18, 1
%20 = load i32, i32* %1
br i1 %19, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %2
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %22)
br label %29
24: ; preds = %17
%25 = sdiv i32 %20, %18
%26 = load i32, i32* %2
%27 = sdiv i32 %26, %18
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %27)
br label %29
29: ; preds = %15, %24, %21
%30 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%31 = load i32, i32* %1
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %8
33: ; preds = %29, %0
ret i32 0
}