#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 /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int a, b, x, y;
  scanf("%d%d", &a, &b);
  x = a;
  y = b;
  while (a != b) {
    if (a > b) {
      a = a - b;
    } else {
      b = b - a;
    }
  }
  printf("GCD is %d\n", a);
  printf("LCM is %d", (x * y) / a);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1183 <main+0x63>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1175 <main+0x55>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    117e <main+0x5e>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    114f <main+0x2f>
mov    -0x8(%rbp),%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%esi
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1040 <scanf@plt>
mov    (%rsp),%ebp
mov    0x4(%rsp),%ebx
mov    %ebp,%esi
cmp    %ebx,%ebp
je     116b <main+0x4b>
mov    %ebp,%eax
mov    %ebx,%esi
jmp    115c <main+0x3c>
nopw   0x0(%rax,%rax,1)
sub    %eax,%esi
mov    %esi,0x4(%rsp)
mov    %eax,%ecx
cmp    %esi,%ecx
je     116b <main+0x4b>
mov    %eax,%ecx
sub    %esi,%ecx
jle    1150 <main+0x30>
mov    %ecx,(%rsp)
mov    %ecx,%eax
cmp    %esi,%ecx
jne    115c <main+0x3c>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
imul   %ebp,%ebx
mov    %ebx,%eax
cltd
idivl  (%rsp)
lea    0xe89(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [11 x i8] c"GCD is %d\0A\00"
@.str.2 = [10 x i8] c"LCM is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%7 = load i32, i32* %2
store i32 %7, i32* %4
%8 = load i32, i32* %3
store i32 %8, i32* %5
br label %9
9: ; preds = %25, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = sub nsw i32 %18, %19
store i32 %20, i32* %2
br label %25
21: ; preds = %13
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = sub nsw i32 %22, %23
store i32 %24, i32* %3
br label %25
25: ; preds = %21, %17
br label %9
26: ; preds = %9
%27 = load i32, i32* %2
%28 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %2
%33 = sdiv i32 %31, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [11 x i8] c"GCD is %d\0A\00"
@.str.2 = [10 x i8] c"LCM 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 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = icmp eq i32 %6, %7
br i1 %8, label %21, label %9
9: ; preds = %0, %17
%10 = phi i32 [ %19, %17 ], [ %6, %0 ]
%11 = phi i32 [ %18, %17 ], [ %7, %0 ]
%12 = icmp sgt i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = sub nsw i32 %10, %11
store i32 %14, i32* %1
br label %17
15: ; preds = %9
%16 = sub nsw i32 %11, %10
store i32 %16, i32* %2
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %16, %15 ], [ %11, %13 ]
%19 = phi i32 [ %10, %15 ], [ %14, %13 ]
%20 = icmp eq i32 %19, %18
br i1 %20, label %21, label %9
21: ; preds = %17, %0
%22 = phi i32 [ %6, %0 ], [ %18, %17 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = mul nsw i32 %7, %6
%25 = load i32, i32* %1
%26 = sdiv i32 %24, %25
%27 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %26)
ret i32 0
}