#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, int);
main() {
  int num = 256, den = 1024, counter = 2;
  printf("Actual fraction is: %d/%d\n", num, den);
  while (counter <= num) {
    if ((num % counter) == 0) {
      if ((den % counter) == 0) {
        num /= counter;
        den /= counter;
      } else {
        counter++;
      }
    } else {
      counter++;
    }
  }
  printf("simplified fraction is: %d/%d \n", num, den);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x100,-0x8(%rbp)
movl   $0x400,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ab <main+0x9b>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    119d <main+0x8d>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    118f <main+0x7f>
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1198 <main+0x88>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a6 <main+0x96>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <main+0x36>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xee6(%rip),%rdi
mov    $0x100,%ebx
mov    $0x400,%ebp
mov    $0x100,%esi
mov    $0x400,%edx
call   1030 <printf@plt>
mov    $0x2,%esi
jmp    1147 <main+0x37>
nopw   0x0(%rax,%rax,1)
add    $0x1,%esi
cmp    %ebx,%esi
jg     1163 <main+0x53>
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1140 <main+0x30>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1140 <main+0x30>
mov    %ecx,%ebx
mov    %eax,%ebp
cmp    %ebx,%esi
jle    1147 <main+0x37>
lea    0xeb1(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Actual fraction is: %d/%d\0A\00"
@.str.1 = [32 x i8] c"simplified fraction is: %d/%d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 256, i32* %2
store i32 1024, i32* %3
store i32 2, i32* %4
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
br label %8
8: ; preds = %36, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = srem i32 %13, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %12
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = srem i32 %18, %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %17
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = sdiv i32 %24, %23
store i32 %25, i32* %2
%26 = load i32, i32* %4
%27 = load i32, i32* %3
%28 = sdiv i32 %27, %26
store i32 %28, i32* %3
br label %32
29: ; preds = %17
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %32
32: ; preds = %29, %22
br label %36
33: ; preds = %12
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %36
36: ; preds = %33, %32
br label %8
37: ; preds = %8
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %38, i32 %39)
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [27 x i8] c"Actual fraction is: %d/%d\0A\00"
@.str.1 = [32 x i8] c"simplified fraction is: %d/%d \0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 256, i32 1024)
br label %2
2: ; preds = %0, %17
%3 = phi i32 [ 2, %0 ], [ %20, %17 ]
%4 = phi i32 [ 1024, %0 ], [ %19, %17 ]
%5 = phi i32 [ 256, %0 ], [ %18, %17 ]
%6 = srem i32 %5, %3
%7 = sdiv i32 %5, %3
%8 = icmp eq i32 %6, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = srem i32 %4, %3
%11 = sdiv i32 %4, %3
%12 = icmp eq i32 %10, 0
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = add nsw i32 %3, 1
br label %17
15: ; preds = %2
%16 = add nsw i32 %3, 1
br label %17
17: ; preds = %9, %13, %15
%18 = phi i32 [ %5, %13 ], [ %5, %15 ], [ %7, %9 ]
%19 = phi i32 [ %4, %13 ], [ %4, %15 ], [ %11, %9 ]
%20 = phi i32 [ %14, %13 ], [ %16, %15 ], [ %3, %9 ]
%21 = icmp sgt i32 %20, %18
br i1 %21, label %22, label %2
22: ; preds = %17
%23 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
ret i32 0
}