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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11bb <main+0x8b>
cmpl   $0x0,-0x10(%rbp)
jne    1194 <main+0x64>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1204 <main+0xd4>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <gcd@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ff <main+0xcf>
cmpl   $0x0,-0x10(%rbp)
jne    11dd <main+0xad>
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1204 <main+0xd4>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <gcd@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <main+0x2e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1040 <scanf@plt>
xor    %ebp,%ebp
lea    0xeaf(%rip),%r14
lea    0xea6(%rip),%rbx
jmp    1182 <main+0x52>
cs nopw 0x0(%rax,%rax,1)
nop
call   1050 <gcd@plt>
mov    0x4(%rsp),%ecx
sub    %eax,%ecx
mov    %ecx,0x4(%rsp)
add    $0x1,%ebp
mov    0x4(%rsp),%esi
test   $0x1,%bpl
jne    11a0 <main+0x70>
test   %esi,%esi
je     11aa <main+0x7a>
mov    0xc(%rsp),%edi
jmp    1170 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
test   %esi,%esi
je     11ad <main+0x7d>
mov    0x8(%rsp),%edi
jmp    1170 <main+0x40>
mov    %r14,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [3 x i8] c"1\0A\00"
@.str.2 = [3 x i8] c"0\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
store i32 0, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
br label %8
8: ; preds = %0, %40
%9 = load i32, i32* %5
%10 = srem i32 %9, 2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %41
17: ; preds = %12
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = call i32 @gcd(i32 %18, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = sub nsw i32 %22, %21
store i32 %23, i32* %4
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %40
26: ; preds = %8
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %41
31: ; preds = %26
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = call i32 @gcd(i32 %32, i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, %35
store i32 %37, i32* %4
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %40
40: ; preds = %31, %17
br label %8
41: ; preds = %29, %15
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@str = [2 x i8] c"0\00"
@str.3 = [2 x i8] c"1\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
br label %8
8: ; preds = %26, %0
%9 = phi i32 [ 0, %0 ], [ %28, %26 ]
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %11, label %14, label %20
14: ; preds = %8
br i1 %13, label %29, label %15
15: ; preds = %14
%16 = load i32, i32* %1
%17 = call i32 @gcd(i32 %16, i32 %12)
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, %17
br label %26
20: ; preds = %8
br i1 %13, label %29, label %21
21: ; preds = %20
%22 = load i32, i32* %2
%23 = call i32 @gcd(i32 %22, i32 %12)
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, %23
br label %26
26: ; preds = %21, %15
%27 = phi i32 [ %19, %15 ], [ %25, %21 ]
store i32 %27, i32* %3
%28 = add nuw nsw i32 %9, 1
br label %8
29: ; preds = %20, %14
%30 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0), %14 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), %20 ]
%31 = call i32 @puts(i8* dereferenceable(1) %30)
ret i32 0
}