#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 /*<<< orphan*/ swap(int *, int *);
int main() {
  int m, n, temp;
  printf("Enter two numbers: ");
  scanf("%d %d", &m, &n);
  if (m < n)
    swap(&m, &n);
  while (n > 0) {
    temp = m % n;
    m = n;
    n = temp;
  }
  printf("GCD is %d", m);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117a <main+0x4a>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <swap@plt>
jmp    117f <main+0x4f>
cmpl   $0x0,-0xc(%rbp)
jle    11a4 <main+0x74>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    117f <main+0x4f>
mov    -0x8(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
cmp    %edx,%esi
jge    1172 <main+0x42>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <swap@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
test   %edx,%edx
jle    1192 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
mov    %esi,%eax
mov    %edx,%esi
cltd
idiv   %esi
test   %edx,%edx
jg     1180 <main+0x50>
mov    %esi,0x4(%rsp)
mov    %edx,(%rsp)
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter two numbers: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [10 x i8] c"GCD is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @swap(i32* %2, i32* %3)
br label %12
12: ; preds = %10, %0
br label %13
13: ; preds = %16, %12
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = srem i32 %17, %18
store i32 %19, i32* %4
%20 = load i32, i32* %3
store i32 %20, i32* %2
%21 = load i32, i32* %4
store i32 %21, i32* %3
br label %13
22: ; preds = %13
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter two numbers: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [10 x i8] c"GCD is %d\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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 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 %14
10: ; preds = %0
%11 = call i32 @swap(i32* %1, i32* %2)
%12 = load i32, i32* %2
%13 = load i32, i32* %1
br label %14
14: ; preds = %10, %0
%15 = phi i32 [ %13, %10 ], [ %7, %0 ]
%16 = phi i32 [ %12, %10 ], [ %8, %0 ]
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14, %18
%19 = phi i32 [ %21, %18 ], [ %16, %14 ]
%20 = phi i32 [ %19, %18 ], [ %15, %14 ]
%21 = srem i32 %20, %19
%22 = icmp sgt i32 %21, 0
br i1 %22, label %18, label %23
23: ; preds = %18
store i32 %19, i32* %1
store i32 %21, i32* %2
br label %24
24: ; preds = %23, %14
%25 = phi i32 [ %19, %23 ], [ %15, %14 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %25)
ret i32 0
}