#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 scanf(char *, int *, int *, int *);
int main() {
  int a, b, c;
  while (scanf("%d%d%d", &a, &b, &c) == 3 && (a | b | c)) {
    if (b - a == c - b)
      printf("AP %d\n", c + c - b);
    else
      printf("GP %d\n", c * c / b);
  }
  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
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
mov    %al,-0x11(%rbp)
jne    1169 <main+0x49>
mov    -0x8(%rbp),%eax
or     -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1179 <main+0x59>
jmp    11c5 <main+0xa5>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jne    11a7 <main+0x87>
mov    -0x10(%rbp),%esi
add    -0x10(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    11c0 <main+0xa0>
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xe53(%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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1040 <scanf@plt>
cmp    $0x3,%eax
jne    11cf <main+0xaf>
lea    0xeae(%rip),%r14
lea    0xea0(%rip),%r15
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbx
lea    0xe98(%rip),%rbp
jmp    11a6 <main+0x86>
nopl   0x0(%rax,%rax,1)
imul   %eax,%eax
cltd
idiv   %ecx
mov    %rbp,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1040 <scanf@plt>
cmp    $0x3,%eax
jne    11cf <main+0xaf>
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    %ecx,%esi
or     %edx,%esi
mov    0xc(%rsp),%eax
or     %eax,%esi
je     11cf <main+0xaf>
mov    %ecx,%esi
sub    %edx,%esi
mov    %eax,%edx
sub    %ecx,%edx
cmp    %edx,%esi
jne    1180 <main+0x60>
add    %eax,%eax
sub    %ecx,%eax
mov    %r14,%rdi
jmp    1189 <main+0x69>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d%d%d\00"
@.str.1 = [7 x i8] c"AP %d\0A\00"
@.str.2 = [7 x i8] c"GP %d\0A\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 ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%8 = icmp eq i32 %7, 3
br i1 %8, label %9, label %31
9: ; preds = %0, %28
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = or i32 %11, %10
%13 = load i32, i32* %3
%14 = or i32 %12, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %9
%17 = sub nsw i32 %11, %10
%18 = sub nsw i32 %13, %11
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = shl nsw i32 %13, 1
%22 = sub nsw i32 %21, %11
%23 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %28
24: ; preds = %16
%25 = mul nsw i32 %13, %13
%26 = sdiv i32 %25, %11
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %20
%29 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%30 = icmp eq i32 %29, 3
br i1 %30, label %9, label %31
31: ; preds = %9, %28, %0
ret i32 0
}