#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, int);
scalar_t__ scanf(char *, int *, int *);
int main(void) {
  int x, y, count, temp;
  while (scanf("%d%d", &x, &y) != EOF && (x != 0 || y != 0)) {
    if (x < y) {
      temp = x;
      x = y;
      y = temp;
    }
    count = 0;
    while (y != 0) {
      x %= y;
      temp = x;
      x = y;
      y = temp;
      count++;
    }
    printf("%d %d\n", x, count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e99(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x15(%rbp)
je     117a <main+0x5a>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x16(%rbp)
jne    1174 <main+0x54>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    118a <main+0x6a>
jmp    11fc <main+0xdc>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <main+0x88>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11e5 <main+0xc5>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11af <main+0x8f>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%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),%rbx
cmp    (%rbx),%rax
jne    115f <main+0x3f>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe9f(%rip),%r14
lea    0xe93(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
jmp    119d <main+0x7d>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ecx,%edx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <scanf@plt>
cmp    (%rbx),%rax
je     114f <main+0x2f>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%eax
mov    %edx,%ecx
or     %eax,%ecx
je     114f <main+0x2f>
cmp    %eax,%edx
jge    11c0 <main+0xa0>
mov    %eax,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    %eax,%esi
jmp    11c4 <main+0xa4>
nopl   0x0(%rax,%rax,1)
mov    %edx,%esi
mov    %eax,%edx
xor    %ecx,%ecx
test   %edx,%edx
je     1180 <main+0x60>
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
mov    %edx,%esi
cltd
idiv   %esi
add    $0x1,%ecx
test   %edx,%edx
jne    11d0 <main+0xb0>
mov    %esi,0xc(%rsp)
movl   $0x0,0x8(%rsp)
jmp    1180 <main+0x60>

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

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