#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 m, n, p, q, gcd, lcm, rem;
  printf("Enter two numbers : ");
  scanf("%d%d", &m, &n);
  p = m;
  q = n;
  while (n != 0) {
    rem = m % n;
    m = n;
    n = rem;
  }
  gcd = m;
  lcm = (p * q) / gcd;
  printf("\n The LCM of %d and %d = %d", p, q, lcm);
  printf("\n The GCD of %d and %d = %d", p, q, gcd);
  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    0xed1(%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)
cmpl   $0x0,-0xc(%rbp)
je     1182 <main+0x62>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    115d <main+0x3d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
mov    0xc(%rsp),%r14d
mov    0x8(%rsp),%ebp
mov    %r14d,%ebx
test   %ebp,%ebp
je     1187 <main+0x67>
mov    %ebp,%edx
mov    %r14d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
mov    %edx,%ebx
cltd
idiv   %ebx
test   %edx,%edx
jne    1170 <main+0x50>
mov    %ebx,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    %ebp,%eax
imul   %r14d,%eax
cltd
idiv   %ebx
lea    0xe83(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"Enter two numbers : \00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [28 x i8] c"\0A The LCM of %d and %d = %d\00"
@.str.3 = [28 x i8] c"\0A The GCD of %d and %d = %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 ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 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 = mul nsw i32 %8, %7
%19 = sdiv i32 %18, %17
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %8, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %8, i32 %17)
ret i32 0
}