#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 a, b, x, y, t, gcd, lcm;
  printf("Enter two integers\n");
  scanf("%d%d", &x, &y);
  a = x;
  b = y;
  while (b != 0) {
    t = b;
    b = a % b;
    a = t;
  }
  gcd = a;
  lcm = (x * y) / gcd;
  printf("Greatest common divisor of %d and %d = %d\n", x, y, gcd);
  printf("Least common multiple of %d and %d = %d\n", x, y, lcm);
  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    0xed0(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1182 <main+0x62>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x3d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf1d(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%r8d
mov    %esi,%ecx
test   %r8d,%r8d
je     117b <main+0x4b>
mov    %esi,%eax
mov    %r8d,%edx
nopl   0x0(%rax)
mov    %edx,%ecx
cltd
idiv   %ecx
mov    %ecx,%eax
test   %edx,%edx
jne    1170 <main+0x40>
mov    %r8d,%eax
imul   %esi,%eax
cltd
idiv   %ecx
mov    %eax,%ebx
lea    0xe78(%rip),%rdi
mov    %r8d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xe8a(%rip),%rdi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter two integers\0A\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [43 x i8] c"Greatest common divisor of %d and %d = %d\0A\00"
@.str.3 = [41 x i8] c"Least common multiple of %d and %d = %d\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 ([20 x i8], [20 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* %2
%12 = load i32, i32* %5
store i32 %12, i32* %3
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* %3
store i32 %17, i32* %6
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = srem i32 %18, %19
store i32 %20, i32* %3
%21 = load i32, i32* %6
store i32 %21, i32* %2
br label %13
22: ; preds = %13
%23 = load i32, i32* %2
store i32 %23, i32* %7
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = mul nsw i32 %24, %25
%27 = load i32, i32* %7
%28 = sdiv i32 %26, %27
store i32 %28, i32* %8
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = load i32, i32* %7
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 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* %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 %34, i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [43 x i8] c"Greatest common divisor of %d and %d = %d\0A\00"
@.str.3 = [41 x i8] c"Least common multiple of %d and %d = %d\0A\00"
@str = [19 x i8] c"Enter two integers\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 ([19 x i8], [19 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 %15, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %12, %10 ], [ %7, %0 ]
%12 = phi i32 [ %13, %10 ], [ %8, %0 ]
%13 = srem i32 %11, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %10
15: ; preds = %10, %0
%16 = phi i32 [ %7, %0 ], [ %12, %10 ]
%17 = mul nsw i32 %8, %7
%18 = sdiv i32 %17, %16
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %8, i32 %16)
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %20, i32 %21, i32 %18)
ret i32 0
}