#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 HCF(int, int);
int LCM(int, int);
int /*<<< orphan*/ clrscr();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[20], n, i, x, y;
  clrscr();
  printf("How many elements do you want to enter(<=20) ? ");
  scanf("%d", &n);
  printf("Enter the elements: ");
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  x = HCF(a[0], a[1]);
  for (i = 2; i < n; i++)
    x = HCF(x, a[i]);
  y = LCM(a[0], a[1]);
  for (i = 2; i < n; i++)
    y = LCM(y, a[i]);
  printf("The HCF is : %d\nThe LCM is : %d", x, y);
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clrscr@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x64(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    11de <main+0x7e>
movslq -0x68(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe97(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11a9 <main+0x49>
mov    -0x60(%rbp),%edi
mov    -0x5c(%rbp),%esi
call   1060 <HCF@plt>
mov    %eax,-0x6c(%rbp)
movl   $0x2,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1220 <main+0xc0>
mov    -0x6c(%rbp),%edi
movslq -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
call   1060 <HCF@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11f3 <main+0x93>
mov    -0x60(%rbp),%edi
mov    -0x5c(%rbp),%esi
call   1040 <LCM@plt>
mov    %eax,-0x70(%rbp)
movl   $0x2,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1262 <main+0x102>
mov    -0x70(%rbp),%edi
movslq -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
call   1040 <LCM@plt>
mov    %eax,-0x70(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1235 <main+0xd5>
mov    -0x6c(%rbp),%esi
mov    -0x70(%rbp),%edx
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getch@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <clrscr@plt>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed9(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r15
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r15
jl     11b0 <main+0x50>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1060 <HCF@plt>
mov    %eax,%ebp
cmpl   $0x3,0xc(%rsp)
jl     120b <main+0xab>
mov    $0x2,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%esi
mov    %ebp,%edi
call   1060 <HCF@plt>
mov    %eax,%ebp
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11f0 <main+0x90>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1040 <LCM@plt>
cmpl   $0x3,0xc(%rsp)
jl     1249 <main+0xe9>
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp,%rbx,4),%esi
mov    %eax,%edi
call   1040 <LCM@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rcx
cmp    %rcx,%rbx
jl     1230 <main+0xd0>
lea    0xdf5(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <getch@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"How many elements do you want to enter(<=20) ? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Enter the elements: \00"
@.str.3 = [32 x i8] c"The HCF is : %d\0AThe LCM is : %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (...) @clrscr()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %11
23: ; preds = %11
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%25 = load i32, i32* %24
%26 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 @HCF(i32 %25, i32 %27)
store i32 %28, i32* %5
store i32 2, i32* %4
br label %29
29: ; preds = %40, %23
%30 = load i32, i32* %4
%31 = load i32, i32* %3
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %43
33: ; preds = %29
%34 = load i32, i32* %5
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 @HCF(i32 %34, i32 %38)
store i32 %39, i32* %5
br label %40
40: ; preds = %33
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %29
43: ; preds = %29
%44 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%45 = load i32, i32* %44
%46 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 1
%47 = load i32, i32* %46
%48 = call i32 @LCM(i32 %45, i32 %47)
store i32 %48, i32* %6
store i32 2, i32* %4
br label %49
49: ; preds = %60, %43
%50 = load i32, i32* %4
%51 = load i32, i32* %3
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = load i32, i32* %6
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = call i32 @LCM(i32 %54, i32 %58)
store i32 %59, i32* %6
br label %60
60: ; preds = %53
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %49
63: ; preds = %49
%64 = load i32, i32* %5
%65 = load i32, i32* %6
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %64, i32 %65)
%67 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str = [48 x i8] c"How many elements do you want to enter(<=20) ? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Enter the elements: \00"
@.str.3 = [32 x i8] c"The HCF is : %d\0AThe LCM is : %d\00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = alloca i32
%3 = bitcast [20 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @clrscr()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
br label %11
11: ; preds = %0, %11
%12 = phi i64 [ %15, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = add nuw nsw i64 %12, 1
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %11, label %19
19: ; preds = %11
%20 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%21 = load i32, i32* %20
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 1
%26 = call i32 @HCF(i32 %21, i32 %23)
%27 = load i32, i32* %2
%28 = icmp sgt i32 %27, 2
br i1 %28, label %29, label %39
29: ; preds = %19, %29
%30 = phi i64 [ %35, %29 ], [ 2, %19 ]
%31 = phi i32 [ %34, %29 ], [ %26, %19 ]
%32 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %30
%33 = load i32, i32* %32
%34 = call i32 @HCF(i32 %31, i32 %33)
%35 = add nuw nsw i64 %30, 1
%36 = load i32, i32* %2
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %29, label %39
39: ; preds = %29, %19
%40 = phi i32 [ %26, %19 ], [ %34, %29 ]
%41 = load i32, i32* %24
%42 = load i32, i32* %25
%43 = call i32 @LCM(i32 %41, i32 %42)
%44 = load i32, i32* %2
%45 = icmp sgt i32 %44, 2
br i1 %45, label %46, label %56
46: ; preds = %39, %46
%47 = phi i64 [ %52, %46 ], [ 2, %39 ]
%48 = phi i32 [ %51, %46 ], [ %43, %39 ]
%49 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %47
%50 = load i32, i32* %49
%51 = call i32 @LCM(i32 %48, i32 %50)
%52 = add nuw nsw i64 %47, 1
%53 = load i32, i32* %2
%54 = sext i32 %53 to i64
%55 = icmp slt i64 %52, %54
br i1 %55, label %46, label %56
56: ; preds = %46, %39
%57 = phi i32 [ %43, %39 ], [ %51, %46 ]
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %57)
%59 = call i32 (...) @getch()
ret i32 0
}