#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(void) {
  int numerator = 0, denominator = 1, gcd = 1, numerator_cache = 0,
      denominator_cache = 1;
  printf("enter a fraction:(xx/xx)\n");
  scanf("%d/%d", &numerator, &denominator);
  numerator_cache = numerator;
  denominator_cache = denominator;
  while (denominator != 0) {
    gcd = numerator;
    numerator = denominator;
    denominator = gcd % denominator;
  }
  gcd = numerator;
  printf("in lowest terms: %d/%d\n", numerator_cache / gcd,
         denominator_cache / gcd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%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,-0xc(%rbp)
je     11a5 <main+0x85>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0xc(%rbp)
jmp    1180 <main+0x60>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%esi
mov    -0x18(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%edx
lea    0xe5c(%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
movl   $0x0,0x4(%rsp)
movl   $0x1,(%rsp)
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%ecx
mov    %esi,%edi
test   %ecx,%ecx
je     1196 <main+0x66>
mov    %ecx,%edx
mov    %esi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edi,%eax
mov    %edx,%edi
cltd
idiv   %edi
test   %edx,%edx
jne    1180 <main+0x50>
mov    %edi,0x4(%rsp)
movl   $0x0,(%rsp)
mov    %esi,%eax
cltd
idiv   %edi
mov    %eax,%esi
mov    %ecx,%eax
cltd
idiv   %edi
lea    0xe5d(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d/%d\00"
@.str.2 = [24 x i8] c"in lowest terms: %d/%d\0A\00"
@str = [25 x i8] c"enter a fraction:(xx/xx)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 %16, 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
store i32 %11, i32* %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %0
%17 = phi i32 [ %11, %15 ], [ %7, %0 ]
%18 = sdiv i32 %7, %17
%19 = sdiv i32 %8, %17
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
ret i32 0
}