#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 a, b, c, i, d;
  printf("Enter numerator and denominator ");
  scanf("%d %d", &a, &b);
  for (i = 1; i <= a, i <= b; i++) {
    if ((a % i == 0) && (b % i == 0)) {
      c = a / i;
      d = b / i;
      a = c;
      b = d;
    }
  }
  printf("The numerator is %d  and denominator is %d", c, d);
  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    0xedd(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11b7 <main+0x97>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    11a4 <main+0x84>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    11a4 <main+0x84>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11a9 <main+0x89>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1158 <main+0x38>
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
mov    0xc(%rsp),%r9d
mov    0x8(%rsp),%edi
jmp    1164 <main+0x44>
cs nopw 0x0(%rax,%rax,1)
cmp    %edi,%ebx
jge    1190 <main+0x70>
add    $0x1,%ebx
mov    %r9d,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1160 <main+0x40>
mov    %eax,%ecx
mov    %edi,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1160 <main+0x40>
mov    %ecx,0xc(%rsp)
mov    %eax,0x8(%rsp)
mov    %eax,%edi
mov    %ecx,%r9d
mov    %ecx,%esi
mov    %eax,%r8d
jmp    1160 <main+0x40>
lea    0xe90(%rip),%rdi
mov    %r8d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter numerator and denominator \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [43 x i8] c"The numerator is %d and denominator is %d\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 ([33 x i8], [33 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)
store i32 1, i32* %5
br label %9
9: ; preds = %37, %0
%10 = load i32, i32* %5
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
%13 = zext i1 %12 to i32
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %40
17: ; preds = %9
%18 = load i32, i32* %2
%19 = load i32, i32* %5
%20 = srem i32 %18, %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %36
22: ; preds = %17
%23 = load i32, i32* %3
%24 = load i32, i32* %5
%25 = srem i32 %23, %24
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %22
%28 = load i32, i32* %2
%29 = load i32, i32* %5
%30 = sdiv i32 %28, %29
store i32 %30, i32* %4
%31 = load i32, i32* %3
%32 = load i32, i32* %5
%33 = sdiv i32 %31, %32
store i32 %33, i32* %6
%34 = load i32, i32* %4
store i32 %34, i32* %2
%35 = load i32, i32* %6
store i32 %35, i32* %3
br label %36
36: ; preds = %27, %22, %17
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %9
40: ; preds = %9
%41 = load i32, i32* %4
%42 = load i32, i32* %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter numerator and denominator \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [43 x i8] c"The numerator is %d and denominator is %d\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 ([33 x i8], [33 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 sgt i32 %8, 0
br label %10
10: ; preds = %0, %24
%11 = phi i32 [ %28, %24 ], [ undef, %0 ]
%12 = phi i32 [ %29, %24 ], [ 1, %0 ]
%13 = phi i32 [ %27, %24 ], [ undef, %0 ]
%14 = phi i32 [ %26, %24 ], [ %7, %0 ]
%15 = phi i32 [ %25, %24 ], [ %8, %0 ]
%16 = srem i32 %14, %12
%17 = sdiv i32 %14, %12
%18 = icmp eq i32 %16, 0
br i1 %18, label %19, label %24
19: ; preds = %10
%20 = srem i32 %15, %12
%21 = sdiv i32 %15, %12
%22 = icmp eq i32 %20, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 %17, i32* %1
store i32 %21, i32* %2
br label %24
24: ; preds = %10, %19, %23
%25 = phi i32 [ %21, %23 ], [ %15, %19 ], [ %15, %10 ]
%26 = phi i32 [ %17, %23 ], [ %14, %19 ], [ %14, %10 ]
%27 = phi i32 [ %17, %23 ], [ %13, %19 ], [ %13, %10 ]
%28 = phi i32 [ %21, %23 ], [ %11, %19 ], [ %11, %10 ]
%29 = add nuw nsw i32 %12, 1
%30 = icmp slt i32 %12, %25
br i1 %30, label %10, label %31
31: ; preds = %24
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28)
ret i32 0
}