#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *, int *);
int main(void) {
  int a, b;
  while (scanf("%d %d", &a, &b) != EOF) {
    while (1) {
      if (a > b) {
        a %= b;
        if (a == 0) {
          printf("%d\n", b);
          break;
        }
      } else {
        b %= a;
        if (b == 0) {
          printf("%d\n", a);
          break;
        }
      }
    }
  }
  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    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
je     11cc <main+0xac>
jmp    1158 <main+0x38>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1193 <main+0x73>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    118e <main+0x6e>
mov    -0xc(%rbp),%esi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <main+0xa7>
jmp    11c2 <main+0xa2>
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11bd <main+0x9d>
mov    -0x8(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <main+0xa7>
jmp    11c2 <main+0xa2>
jmp    1158 <main+0x38>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
mov    0x2e9e(%rip),%r13
cmp    0x0(%r13),%rax
je     11ce <main+0xae>
lea    0xeaf(%rip),%r14
lea    0xea2(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
nopl   0x0(%rax,%rax,1)
cmp    %ecx,%esi
jle    1195 <main+0x75>
mov    %esi,%eax
cltd
idiv   %ecx
mov    %edx,%esi
mov    %edx,0xc(%rsp)
test   %edx,%edx
jne    1180 <main+0x60>
jmp    11b0 <main+0x90>
mov    %ecx,%eax
cltd
idiv   %esi
mov    %edx,%ecx
mov    %edx,0x8(%rsp)
test   %edx,%edx
jne    1180 <main+0x60>
jmp    11b2 <main+0x92>
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <scanf@plt>
cmp    0x0(%r13),%rax
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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