#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);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(void) {
  int a, b, temp;
  scanf("%d %d", &a, &b);
  if (b > a) {
    temp = b;
    b = a;
    a = temp;
  }
  while (1) {
    temp = a % b;
    if (temp == 0) {
      printf("%d\n", b);
      break;
    } else {
      a = b, b = temp;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1161 <main+0x41>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1166 <main+0x46>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    118e <main+0x6e>
mov    -0xc(%rbp),%esi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    119f <main+0x7f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x46>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
jle    114b <main+0x2b>
mov    %ecx,(%rsp)
mov    %eax,0x4(%rsp)
mov    %ecx,%esi
jmp    114f <main+0x2f>
mov    %eax,%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1174 <main+0x54>
cs nopw 0x0(%rax,%rax,1)
mov    %esi,%ecx
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1160 <main+0x40>
mov    %ecx,0x4(%rsp)
mov    %esi,(%rsp)
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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