#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, int *);
int main(void) {
  int num1, num2, denom1, denom2;
  printf("enter two fractions seperated by a plus sign: ");
  scanf("%d/%d+%d/%d", &num1, &denom1, &num2, &denom2);
  printf("%d/%d\n", ((num1 * denom2) + (num2 * denom1)), (denom1 * denom2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
imul   -0x14(%rbp),%esi
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
add    %eax,%esi
mov    -0x10(%rbp),%edx
imul   -0x14(%rbp),%edx
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
mov    0x14(%rsp),%ecx
imul   %eax,%ecx
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%esi
imul   %edx,%esi
add    %ecx,%esi
imul   %eax,%edx
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"enter two fractions seperated by a plus sign: \00"
@.str.1 = [12 x i8] c"%d/%d+%d/%d\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
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %4, i32* %3, i32* %5)
%8 = load i32, i32* %2
%9 = load i32, i32* %5
%10 = mul nsw i32 %8, %9
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = mul nsw i32 %11, %12
%14 = add nsw i32 %10, %13
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = mul nsw i32 %15, %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"enter two fractions seperated by a plus sign: \00"
@.str.1 = [12 x i8] c"%d/%d+%d/%d\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 = 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %3, i32* %2, i32* %4)
%11 = load i32, i32* %1
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, %11
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = mul nsw i32 %15, %14
%17 = add nsw i32 %16, %13
%18 = mul nsw i32 %15, %12
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18)
ret i32 0
}