#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 *);
main() {
  int gcd, lcm, n1, n2, num1, num2, r;
  printf("Enter n1 and n2 \n");
  scanf("%d%d", &n1, &n2);
  num1 = n1;
  num2 = n2;
  while (n1 % n2 != 0) {
    r = n1 % n2;
    n1 = n2;
    n2 = r;
  }
  gcd = n2;
  lcm = (num1 * num2) / gcd;
  printf("GCD and LCM of %d and %d are %d and %d respectively\n", num1, num2,
         gcd, lcm);
}


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    0xece(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
je     1188 <main+0x68>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x3d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%r8d
mov    %esi,%eax
cltd
idiv   %r8d
mov    %r8d,%ecx
test   %edx,%edx
je     1184 <main+0x54>
mov    %r8d,%ecx
nopl   0x0(%rax)
mov    %ecx,%edi
mov    %edx,%ecx
mov    %edi,%eax
cltd
idiv   %ecx
test   %edx,%edx
jne    1170 <main+0x40>
mov    %edi,0x4(%rsp)
mov    %ecx,(%rsp)
mov    %r8d,%eax
imul   %esi,%eax
cltd
idiv   %ecx
lea    0xe71(%rip),%rdi
mov    %r8d,%edx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [53 x i8] c"GCD and LCM of %d and %d are %d and %d respectively\0A\00"
@str = [17 x i8] c"Enter n1 and n2 \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 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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 = srem i32 %7, %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %0, %11
%12 = phi i32 [ %14, %11 ], [ %9, %0 ]
%13 = phi i32 [ %12, %11 ], [ %8, %0 ]
%14 = srem i32 %13, %12
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %11
16: ; preds = %11
store i32 %13, i32* %1
store i32 %12, i32* %2
br label %17
17: ; preds = %16, %0
%18 = phi i32 [ %12, %16 ], [ %8, %0 ]
%19 = mul nsw i32 %8, %7
%20 = sdiv i32 %19, %18
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %8, i32 %18, i32 %20)
ret i32 0
}