#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(int argc, char **argv) {
  int iX1, iX2, iY1, iY2, iRem, iGcd, iLcm;
  printf("\n*********************************************************");
  printf("\n*\tPROGRAM TO FIND GCD & LCM OF TWO NUMBERS\t*\n");
  printf("*********************************************************");
  printf("\nEnter two numbers\n");
  scanf("%d%d", &iX1, &iX2);
  if (0 == iX1 && 0 == iX2) {
    printf("\nGCD doesn't  exist\n");
    exit(0);
  } else {
    iY1 = iX1;
    iY2 = iX2;
    while (iY2 != 0) {
      iRem = iY1 % iY2;
      iY1 = iY2;
      iY2 = iRem;
    }
    iGcd = iY1;
    iLcm = (iX1 * iX2) / iGcd;
    printf("\nGCD of %d and %d is %d\n", iX1, iX2, iGcd);
    printf("\nLCM of %d and %d is %d\n", iX1, iX2, iLcm);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    11bd <main+0x8d>
xor    %eax,%eax
cmp    -0x18(%rbp),%eax
jne    11bd <main+0x8d>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11ee <main+0xbe>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11c9 <main+0x99>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltd
idivl  -0x28(%rbp)
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xe88(%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    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%r8d
mov    %esi,%eax
or     %r8d,%eax
je     11f7 <main+0xb7>
mov    %esi,%ecx
test   %r8d,%r8d
je     11bb <main+0x7b>
mov    %esi,%eax
mov    %r8d,%edx
nopl   0x0(%rax,%rax,1)
mov    %edx,%ecx
cltd
idiv   %ecx
mov    %ecx,%eax
test   %edx,%edx
jne    11b0 <main+0x70>
mov    %r8d,%eax
imul   %esi,%eax
cltd
idiv   %ecx
mov    %eax,%ebx
lea    0xe73(%rip),%rdi
mov    %r8d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xe73(%rip),%rdi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"\0A*********************************************************\00"
@.str.1 = [47 x i8] c"\0A*\09PROGRAM TO FIND GCD & LCM OF TWO NUMBERS\09*\0A\00"
@.str.2 = [58 x i8] c"*********************************************************\00"
@.str.3 = [20 x i8] c"\0AEnter two numbers\0A\00"
@.str.4 = [5 x i8] c"%d%d\00"
@.str.5 = [21 x i8] c"\0AGCD doesn't exist\0A\00"
@.str.6 = [25 x i8] c"\0AGCD of %d and %d is %d\0A\00"
@.str.7 = [25 x i8] c"\0ALCM of %d and %d is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %6, i32* %7)
%18 = load i32, i32* %6
%19 = icmp eq i32 0, %18
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i32, i32* %7
%22 = icmp eq i32 0, %21
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %20, %2
%27 = load i32, i32* %6
store i32 %27, i32* %8
%28 = load i32, i32* %7
store i32 %28, i32* %9
br label %29
29: ; preds = %32, %26
%30 = load i32, i32* %9
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = srem i32 %33, %34
store i32 %35, i32* %10
%36 = load i32, i32* %9
store i32 %36, i32* %8
%37 = load i32, i32* %10
store i32 %37, i32* %9
br label %29
38: ; preds = %29
%39 = load i32, i32* %8
store i32 %39, i32* %11
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = mul nsw i32 %40, %41
%43 = load i32, i32* %11
%44 = sdiv i32 %42, %43
store i32 %44, i32* %12
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = load i32, i32* %11
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %45, i32 %46, i32 %47)
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = load i32, i32* %12
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %49, i32 %50, i32 %51)
br label %53
53: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"\0A*********************************************************\00"
@.str.2 = [58 x i8] c"*********************************************************\00"
@.str.4 = [5 x i8] c"%d%d\00"
@.str.6 = [25 x i8] c"\0AGCD of %d and %d is %d\0A\00"
@.str.7 = [25 x i8] c"\0ALCM of %d and %d is %d\0A\00"
@str = [46 x i8] c"\0A*\09PROGRAM TO FIND GCD & LCM OF TWO NUMBERS\09*\00"
@str.8 = [19 x i8] c"\0AEnter two numbers\00"
@str.9 = [20 x i8] c"\0AGCD doesn't exist\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %18, label %17
17: ; preds = %2
br i1 %15, label %26, label %21
18: ; preds = %2
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %17, %21
%22 = phi i32 [ %23, %21 ], [ %12, %17 ]
%23 = phi i32 [ %24, %21 ], [ %14, %17 ]
%24 = srem i32 %22, %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %21
26: ; preds = %21, %17
%27 = phi i32 [ %12, %17 ], [ %23, %21 ]
%28 = mul nsw i32 %14, %12
%29 = sdiv i32 %28, %27
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %12, i32 %14, i32 %27)
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %31, i32 %32, i32 %29)
ret i32 0
}