#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 main() {
  int numerator, denominator, remainder;
  int m, n;
  printf("Enter a fraction:");
  scanf("%d/%d", &numerator, &denominator);
  m = numerator;
  n = denominator;
  while (n != 0) {
    remainder = m % n;
    m = n;
    n = remainder;
  }
  printf("In lowest terms:%d/%d\n", numerator / m, denominator / m);
  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    0xece(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1182 <main+0x62>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    115d <main+0x3d>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%esi
mov    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%edx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%ecx
mov    %esi,%edi
test   %ecx,%ecx
je     116b <main+0x4b>
mov    %ecx,%edx
mov    %esi,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %edx,%edi
cltd
idiv   %edi
mov    %edi,%eax
test   %edx,%edx
jne    1160 <main+0x40>
mov    %esi,%eax
cltd
idiv   %edi
mov    %eax,%esi
mov    %ecx,%eax
cltd
idiv   %edi
lea    0xe9a(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter a fraction:\00"
@.str.1 = [6 x i8] c"%d/%d\00"
@.str.2 = [23 x i8] c"In lowest terms:%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
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 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 = load i32, i32* %2
store i32 %9, i32* %5
%10 = load i32, i32* %3
store i32 %10, i32* %6
br label %11
11: ; preds = %14, %0
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = srem i32 %15, %16
store i32 %17, i32* %4
%18 = load i32, i32* %6
store i32 %18, i32* %5
%19 = load i32, i32* %4
store i32 %19, i32* %6
br label %11
20: ; preds = %11
%21 = load i32, i32* %2
%22 = load i32, i32* %5
%23 = sdiv i32 %21, %22
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = sdiv i32 %24, %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter a fraction:\00"
@.str.1 = [6 x i8] c"%d/%d\00"
@.str.2 = [23 x i8] c"In lowest terms:%d/%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %13, %10 ], [ %8, %0 ]
%12 = phi i32 [ %11, %10 ], [ %7, %0 ]
%13 = srem i32 %12, %11
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %10
15: ; preds = %10, %0
%16 = phi i32 [ %7, %0 ], [ %11, %10 ]
%17 = sdiv i32 %7, %16
%18 = sdiv i32 %8, %16
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18)
ret i32 0
}