#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(void) {
  int numerator1, denominator1, numerator2, denominator2;
  printf("enter the first fraction:(xx/xx)\n");
  scanf("%d/%d", &numerator1, &denominator1);
  getchar();
  printf("enter the operation:\n");
  char ch = getchar();
  printf("enter the second fraction:\n");
  scanf("%d/%d", &numerator2, &denominator2);
  switch (ch) {
  case '+':
    printf("%d/%d\n", (numerator1 * denominator2 + numerator2 * denominator1),
           denominator1 * denominator2);
    break;
  case '-':
    printf("%d/%d\n", (numerator1 * denominator2 - numerator2 * denominator1),
           denominator1 * denominator2);
    break;
  case '*':
    printf("%d/%d\n", numerator1 * numerator2, denominator1 * denominator2);
    break;
  case '/':
    printf("%d/%d\n", numerator1 * denominator2, denominator1 * numerator2);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
mov    %rdi,-0x28(%rbp)
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x29(%rbp),%al
call   1040 <getchar@plt>
mov    -0x29(%rbp),%al
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
call   1040 <getchar@plt>
mov    %al,%cl
mov    -0x29(%rbp),%al
mov    %cl,-0x15(%rbp)
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <scanf@plt>
movsbl -0x15(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     1267 <main+0x137>
mov    -0x20(%rbp),%rax
lea    0xe33(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%esi
imul   -0x14(%rbp),%esi
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
add    %eax,%esi
mov    -0xc(%rbp),%edx
imul   -0x14(%rbp),%edx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1267 <main+0x137>
mov    -0x8(%rbp),%esi
imul   -0x14(%rbp),%esi
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
sub    %eax,%esi
mov    -0xc(%rbp),%edx
imul   -0x14(%rbp),%edx
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1267 <main+0x137>
mov    -0x8(%rbp),%esi
imul   -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
imul   -0x14(%rbp),%edx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1267 <main+0x137>
mov    -0x8(%rbp),%esi
imul   -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
imul   -0x10(%rbp),%edx
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%r14
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r14,%rdi
call   1060 <scanf@plt>
movsbl %bl,%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     122a <main+0xea>
lea    0xe48(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0xc(%rsp),%esi
imul   0x14(%rsp),%esi
mov    0x8(%rsp),%edx
jmp    1217 <main+0xd7>
mov    0x8(%rsp),%eax
mov    0x14(%rsp),%ecx
imul   %eax,%ecx
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%esi
imul   %edx,%esi
add    %ecx,%esi
imul   %eax,%edx
jmp    121c <main+0xdc>
mov    0x8(%rsp),%eax
mov    0x14(%rsp),%esi
imul   %eax,%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
imul   %edx,%ecx
sub    %ecx,%esi
imul   %eax,%edx
jmp    121c <main+0xdc>
mov    0x8(%rsp),%esi
imul   0x14(%rsp),%esi
mov    0xc(%rsp),%edx
imul   0x10(%rsp),%edx
lea    0xdfb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"enter the first fraction:(xx/xx)\0A\00"
@.str.1 = [6 x i8] c"%d/%d\00"
@.str.2 = [22 x i8] c"enter the operation:\0A\00"
@.str.3 = [28 x i8] c"enter the second fraction:\0A\00"
@.str.4 = [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 i8
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%9 = call signext i8 (...) @getchar()
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%11 = call signext i8 (...) @getchar()
store i8 %11, i8* %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
switch i32 %15, label %56 [
i32 43, label %16
i32 45, label %28
i32 42, label %40
i32 47, label %48
]
16: ; preds = %0
%17 = load i32, i32* %2
%18 = load i32, i32* %5
%19 = mul nsw i32 %17, %18
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = mul nsw i32 %20, %21
%23 = add nsw i32 %19, %22
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = mul nsw i32 %24, %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %26)
br label %56
28: ; preds = %0
%29 = load i32, i32* %2
%30 = load i32, i32* %5
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %4
%33 = load i32, i32* %3
%34 = mul nsw i32 %32, %33
%35 = sub nsw i32 %31, %34
%36 = load i32, i32* %3
%37 = load i32, i32* %5
%38 = mul nsw i32 %36, %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %38)
br label %56
40: ; preds = %0
%41 = load i32, i32* %2
%42 = load i32, i32* %4
%43 = mul nsw i32 %41, %42
%44 = load i32, i32* %3
%45 = load i32, i32* %5
%46 = mul nsw i32 %44, %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %43, i32 %46)
br label %56
48: ; preds = %0
%49 = load i32, i32* %2
%50 = load i32, i32* %5
%51 = mul nsw i32 %49, %50
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = mul nsw i32 %52, %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %51, i32 %54)
br label %56
56: ; preds = %0, %48, %40, %28, %16
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d/%d\00"
@.str.4 = [7 x i8] c"%d/%d\0A\00"
@str = [33 x i8] c"enter the first fraction:(xx/xx)\00"
@str.5 = [21 x i8] c"enter the operation:\00"
@str.6 = [27 x i8] c"enter the second fraction:\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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%11 = call signext i8 (...) @getchar()
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
%13 = call signext i8 (...) @getchar()
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%16 = sext i8 %13 to i32
switch i32 %16, label %53 [
i32 43, label %17
i32 45, label %27
i32 42, label %37
i32 47, label %45
]
17: ; preds = %0
%18 = load i32, i32* %1
%19 = load i32, i32* %4
%20 = mul nsw i32 %19, %18
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = mul nsw i32 %22, %21
%24 = add nsw i32 %23, %20
%25 = mul nsw i32 %22, %19
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %24, i32 %25)
br label %53
27: ; preds = %0
%28 = load i32, i32* %1
%29 = load i32, i32* %4
%30 = mul nsw i32 %29, %28
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = mul nsw i32 %32, %31
%34 = sub nsw i32 %30, %33
%35 = mul nsw i32 %32, %29
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %34, i32 %35)
br label %53
37: ; preds = %0
%38 = load i32, i32* %1
%39 = load i32, i32* %3
%40 = mul nsw i32 %39, %38
%41 = load i32, i32* %2
%42 = load i32, i32* %4
%43 = mul nsw i32 %42, %41
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %43)
br label %53
45: ; preds = %0
%46 = load i32, i32* %1
%47 = load i32, i32* %4
%48 = mul nsw i32 %47, %46
%49 = load i32, i32* %2
%50 = load i32, i32* %3
%51 = mul nsw i32 %50, %49
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %48, i32 %51)
br label %53
53: ; preds = %0, %45, %37, %27, %17
ret i32 0
}