#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 /*<<< orphan*/ scanf(char *, int *, int *, int *, int *);
int main() {
  int a, b, c, d;
  int num, dem, k;
  scanf("%d/%d + %d/%d", &a, &b, &c, &d);
  if (b == 0 || d == 0) {
    printf("entrada invalida!\n");
  } else {
    num = a * d + c * b;
    dem = b * d;
    k = gcd(num, dem);
    num = num / k;
    dem = dem / k;
    printf("%d/%d\n", num, dem);
  }
  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
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
je     116f <main+0x3f>
cmpl   $0x0,-0x14(%rbp)
jne    1182 <main+0x52>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <main+0xa5>
mov    -0x8(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1050 <gcd@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1050 <scanf@plt>
mov    0x10(%rsp),%ebx
test   %ebx,%ebx
je     11b0 <main+0x70>
mov    0x8(%rsp),%ebp
test   %ebp,%ebp
je     11b0 <main+0x70>
mov    0x14(%rsp),%eax
imul   %ebp,%eax
imul   %ebx,%ebp
imul   0xc(%rsp),%ebx
add    %eax,%ebx
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <gcd@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %eax,%esi
mov    %ebp,%eax
cltd
idiv   %ecx
lea    0xe69(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11bc <main+0x7c>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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