#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 /*<<< orphan*/ abs(int);
int getDivisor(int /*<<< orphan*/, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int, ...);
int scanf(char *, int *, int *, int *, int *);
int main(int argc, char const *argv[]) {
  int a, b, c, d, fenzi, fenmu, tmp;
  while (scanf("%d/%d%d/%d", &a, &b, &c, &d) != -1) {
    getchar();
    a *= d;
    c *= b;
    fenmu = b * d;
    fenzi = a + c;
    if (fenzi) {
      tmp = getDivisor(abs(fenzi), fenmu);
      if (tmp == fenmu)
        printf("%d\n", fenzi / fenmu);
      else
        printf("%d/%d\n", fenzi / tmp, fenmu / tmp);
    } else
      printf("%d\n", 0);
  }
  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    0xe93(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1070 <scanf@plt>
cmp    $0xffffffff,%eax
je     123a <main+0xea>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    -0x20(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1225 <main+0xd5>
mov    -0x24(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,%edi
mov    -0x28(%rbp),%esi
call   1030 <getDivisor@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    1200 <main+0xb0>
mov    -0x24(%rbp),%eax
cltd
idivl  -0x28(%rbp)
mov    %eax,%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1220 <main+0xd0>
mov    -0x24(%rbp),%eax
cltd
idivl  -0x2c(%rbp)
mov    %eax,%esi
mov    -0x28(%rbp),%eax
cltd
idivl  -0x2c(%rbp)
mov    %eax,%edx
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1235 <main+0xe5>
lea    0xde2(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1166 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1060 <scanf@plt>
cmp    $0xffffffff,%eax
je     1245 <main+0x105>
lea    0xc(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%rbp
jmp    11c1 <main+0x81>
nopl   (%rax)
lea    0xe77(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1060 <scanf@plt>
cmp    $0xffffffff,%eax
je     1245 <main+0x105>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x10(%rsp),%eax
mov    0xc(%rsp),%ecx
imul   %eax,%ecx
mov    %ecx,0xc(%rsp)
mov    0x14(%rsp),%r14d
mov    0x8(%rsp),%r15d
imul   %r14d,%r15d
mov    %r15d,0x8(%rsp)
add    %ecx,%r15d
je     1190 <main+0x50>
imul   %eax,%r14d
mov    %r15d,%edi
neg    %edi
cmovs  %r15d,%edi
mov    %r14d,%esi
call   1030 <getDivisor@plt>
cmp    %r14d,%eax
jne    1220 <main+0xe0>
mov    %r15d,%eax
cltd
idiv   %r14d
lea    0xdf7(%rip),%rdi
mov    %eax,%esi
jmp    1199 <main+0x59>
xchg   %ax,%ax
mov    %eax,%ecx
mov    %r15d,%eax
cltd
idiv   %ecx
mov    %eax,%esi
mov    %r14d,%eax
cltd
idiv   %ecx
lea    0xdd4(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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