#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 p, r, n, m, temp;
  printf("Please input two integers n,m:");
  scanf("%d,%d,", &n, &m);
  if (n < m) {
    temp = n;
    n = m;
    m = temp;
  }
  p = n * m;
  while (m != 0) {
    r = n % m;
    n = m;
    m = r;
  }
  printf("Their greatest common divisor is:%d\n", n);
  printf("Their least common divisor is:%d\n", p / n);
  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    0xedb(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116f <main+0x4f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     119e <main+0x7e>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <main+0x59>
mov    -0x10(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%esi
lea    0xe8c(%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    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
cmp    %ecx,%eax
jge    1161 <main+0x41>
mov    %ecx,0x8(%rsp)
mov    %eax,0xc(%rsp)
mov    %eax,%ebx
jmp    1165 <main+0x45>
mov    %ecx,%ebx
mov    %eax,%ecx
mov    %ecx,%esi
test   %ebx,%ebx
je     1187 <main+0x67>
mov    %ebx,%edx
mov    %ecx,%esi
nop
mov    %esi,%eax
mov    %edx,%esi
cltd
idiv   %esi
test   %edx,%edx
jne    1170 <main+0x50>
mov    %esi,0x8(%rsp)
movl   $0x0,0xc(%rsp)
imul   %ecx,%ebx
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
cltd
idivl  0x8(%rsp)
lea    0xea5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Please input two integers n,m:\00"
@.str.1 = [7 x i8] c"%d,%d,\00"
@.str.2 = [37 x i8] c"Their greatest common divisor is:%d\0A\00"
@.str.3 = [34 x i8] c"Their least common divisor is:%d\0A\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 ([31 x i8], [31 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* %4, i32* %5)
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = load i32, i32* %4
store i32 %13, i32* %6
%14 = load i32, i32* %5
store i32 %14, i32* %4
%15 = load i32, i32* %6
store i32 %15, i32* %5
br label %16
16: ; preds = %12, %0
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = mul nsw i32 %17, %18
store i32 %19, i32* %2
br label %20
20: ; preds = %23, %16
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = srem i32 %24, %25
store i32 %26, i32* %3
%27 = load i32, i32* %5
store i32 %27, i32* %4
%28 = load i32, i32* %3
store i32 %28, i32* %5
br label %20
29: ; preds = %20
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %2
%33 = load i32, i32* %4
%34 = sdiv i32 %32, %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Please input two integers n,m:\00"
@.str.1 = [7 x i8] c"%d,%d,\00"
@.str.2 = [37 x i8] c"Their greatest common divisor is:%d\0A\00"
@.str.3 = [34 x i8] c"Their least common divisor is:%d\0A\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 %8, i32* %1
store i32 %7, i32* %2
br label %11
11: ; preds = %10, %0
%12 = phi i32 [ %7, %10 ], [ %8, %0 ]
%13 = phi i32 [ %8, %10 ], [ %7, %0 ]
%14 = icmp eq i32 %12, 0
br i1 %14, label %21, label %15
15: ; preds = %11, %15
%16 = phi i32 [ %18, %15 ], [ %12, %11 ]
%17 = phi i32 [ %16, %15 ], [ %13, %11 ]
%18 = srem i32 %17, %16
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %15
20: ; preds = %15
store i32 %16, i32* %1
store i32 0, i32* %2
br label %21
21: ; preds = %20, %11
%22 = phi i32 [ %16, %20 ], [ %13, %11 ]
%23 = mul nsw i32 %12, %13
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%25 = load i32, i32* %1
%26 = sdiv i32 %23, %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %26)
ret i32 0
}