#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;
  int den1, den2;
  int result_num;
  int result_den;
  printf("Enter 2 fractions (x/x + x/x): ");
  scanf("%d/%d + %d/%d", &num1, &den1, &num2, &den2);
  result_num = num1 * den2 + num2 * den1;
  result_den = den1 * den2;
  printf("The sum is: %d/%d\n", result_num, result_den);
  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    0xedc(%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),%eax
imul   -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xeab(%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    0xee7(%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    0xeba(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Enter 2 fractions (x/x + x/x): \00"
@.str.1 = [14 x i8] c"%d/%d + %d/%d\00"
@.str.2 = [19 x i8] c"The sum is: %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
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %4, i32* %3, i32* %5)
%10 = load i32, i32* %2
%11 = load i32, i32* %5
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = mul nsw i32 %13, %14
%16 = add nsw i32 %12, %15
store i32 %16, i32* %6
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = mul nsw i32 %17, %18
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter 2 fractions (x/x + x/x): \00"
@.str.1 = [14 x i8] c"%d/%d + %d/%d\00"
@.str.2 = [19 x i8] c"The sum is: %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 ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([14 x i8], [14 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 ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18)
ret i32 0
}