#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 fnGCD(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main(void) {
  int iVal1, iVal2, iVal3, iGcd, iLcm;
  printf("\nEnter three values\n");
  scanf("%d%d%d", &iVal1, &iVal2, &iVal3);
  iGcd = fnGCD(fnGCD(iVal1, iVal2), iVal3);
  iLcm = (iVal1 > iVal2) ? (iVal1 > iVal3 ? iVal1 : iVal3)
                         : (iVal2 > iVal3 ? iVal2 : iVal3);
  while ((iLcm % iVal1) || (iLcm % iVal2) || (iLcm % iVal3))
    iLcm++;
  printf("\nGCD of %d %d and %d : %d", iVal1, iVal2, iVal3, iGcd);
  printf("\nLCM of %d %d and %d : %d", iVal1, iVal2, iVal3, iLcm);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <fnGCD@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%esi
call   1040 <fnGCD@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11b1 <main+0x81>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11a0 <main+0x70>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11a6 <main+0x76>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11d4 <main+0xa4>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11c8 <main+0x98>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11ce <main+0x9e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x25(%rbp)
jne    1214 <main+0xe4>
mov    -0x18(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x25(%rbp)
jne    1214 <main+0xe4>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1224 <main+0xf4>
jmp    1232 <main+0x102>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11da <main+0xaa>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1050 <fnGCD@plt>
mov    0x4(%rsp),%esi
mov    %eax,%edi
call   1050 <fnGCD@plt>
mov    %eax,%r8d
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%r9d
cmp    %r9d,%esi
mov    %r9d,%ebx
cmovg  %esi,%ebx
mov    0x4(%rsp),%ecx
cmp    %ecx,%ebx
cmovle %ecx,%ebx
jmp    11b3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    11b0 <main+0x70>
mov    %ebx,%eax
cltd
idiv   %r9d
test   %edx,%edx
jne    11b0 <main+0x70>
mov    %ebx,%eax
cltd
idiv   %ecx
test   %edx,%edx
jne    11b0 <main+0x70>
lea    0xe31(%rip),%rdi
mov    %r9d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
lea    0xe2e(%rip),%rdi
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter three values\0A\00"
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [26 x i8] c"\0AGCD of %d %d and %d : %d\00"
@.str.3 = [26 x i8] c"\0ALCM of %d %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
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 @fnGCD(i32 %9, i32 %10)
%12 = load i32, i32* %4
%13 = call i32 @fnGCD(i32 %11, i32 %12)
store i32 %13, i32* %5
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %0
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* %2
br label %25
23: ; preds = %17
%24 = load i32, i32* %4
br label %25
25: ; preds = %23, %21
%26 = phi i32 [ %22, %21 ], [ %24, %23 ]
br label %37
27: ; preds = %0
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load i32, i32* %3
br label %35
33: ; preds = %27
%34 = load i32, i32* %4
br label %35
35: ; preds = %33, %31
%36 = phi i32 [ %32, %31 ], [ %34, %33 ]
br label %37
37: ; preds = %35, %25
%38 = phi i32 [ %26, %25 ], [ %36, %35 ]
store i32 %38, i32* %6
br label %39
39: ; preds = %56, %37
%40 = load i32, i32* %6
%41 = load i32, i32* %2
%42 = srem i32 %40, %41
%43 = icmp ne i32 %42, 0
br i1 %43, label %54, label %44
44: ; preds = %39
%45 = load i32, i32* %6
%46 = load i32, i32* %3
%47 = srem i32 %45, %46
%48 = icmp ne i32 %47, 0
br i1 %48, label %54, label %49
49: ; preds = %44
%50 = load i32, i32* %6
%51 = load i32, i32* %4
%52 = srem i32 %50, %51
%53 = icmp ne i32 %52, 0
br label %54
54: ; preds = %49, %44, %39
%55 = phi i1 [ true, %44 ], [ true, %39 ], [ %53, %49 ]
br i1 %55, label %56, label %59
56: ; preds = %54
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %39
59: ; preds = %54
%60 = load i32, i32* %2
%61 = load i32, i32* %3
%62 = load i32, i32* %4
%63 = load i32, i32* %5
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %60, i32 %61, i32 %62, i32 %63)
%65 = load i32, i32* %2
%66 = load i32, i32* %3
%67 = load i32, i32* %4
%68 = load i32, i32* %6
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %65, i32 %66, i32 %67, i32 %68)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [26 x i8] c"\0AGCD of %d %d and %d : %d\00"
@.str.3 = [26 x i8] c"\0ALCM of %d %d and %d : %d\00"
@str = [20 x i8] c"\0AEnter three values\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = call i32 @fnGCD(i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = call i32 @fnGCD(i32 %11, i32 %12)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = icmp sgt i32 %14, %15
%17 = load i32, i32* %3
%18 = select i1 %16, i32 %14, i32 %15
%19 = icmp sgt i32 %18, %17
%20 = select i1 %19, i32 %18, i32 %17
br label %21
21: ; preds = %31, %0
%22 = phi i32 [ %20, %0 ], [ %32, %31 ]
%23 = srem i32 %22, %14
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = srem i32 %22, %15
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = srem i32 %22, %17
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %21, %25, %28
%32 = add nsw i32 %22, 1
br label %21
33: ; preds = %28
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %15, i32 %17, i32 %13)
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %36, i32 %37, i32 %22)
ret i32 0
}