#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 *);
int main() {
  int a, b, c;
  while (1) {
    scanf("%d %d %d", &a, &b, &c);
    if (a == 0 && b == 0 && c == 0) {
      break;
    }
    if ((c - b) == (b - a)) {
      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    $0x10,%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>
cmpl   $0x0,-0x8(%rbp)
jne    116a <main+0x4a>
cmpl   $0x0,-0xc(%rbp)
jne    116a <main+0x4a>
cmpl   $0x0,-0x10(%rbp)
jne    116a <main+0x4a>
jmp    11b8 <main+0x98>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jne    119a <main+0x7a>
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    %eax,%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
jmp    11b3 <main+0x93>
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
imul   %eax,%esi
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%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>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%ecx
test   %eax,%eax
jne    1165 <main+0x45>
test   %edi,%edi
jne    1165 <main+0x45>
test   %ecx,%ecx
je     11eb <main+0xcb>
lea    0xe9d(%rip),%r14
lea    0xe8d(%rip),%r15
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbx
lea    0xe87(%rip),%rbp
nopl   0x0(%rax)
mov    %ecx,%esi
sub    %edi,%esi
mov    %edi,%edx
sub    %eax,%edx
cmp    %edx,%esi
jne    11b0 <main+0x90>
add    %ecx,%esi
mov    %r14,%rdi
jmp    11bd <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ecx,%eax
cltd
idiv   %edi
imul   %eax,%ecx
mov    %rbp,%rdi
mov    %ecx,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%ecx
test   %eax,%eax
jne    1190 <main+0x70>
test   %edi,%edi
jne    1190 <main+0x70>
test   %ecx,%ecx
jne    1190 <main+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 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 ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
%12 = select i1 %9, i1 %11, i1 false
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %40, label %16
16: ; preds = %0, %30
%17 = phi i32 [ %37, %30 ], [ %13, %0 ]
%18 = phi i32 [ %34, %30 ], [ %10, %0 ]
%19 = phi i32 [ %32, %30 ], [ %8, %0 ]
%20 = sub nsw i32 %17, %18
%21 = sub nsw i32 %18, %19
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = add nsw i32 %20, %17
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %30
26: ; preds = %16
%27 = sdiv i32 %17, %18
%28 = mul nsw i32 %27, %17
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %26, %23
%31 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%32 = load i32, i32* %1
%33 = icmp eq i32 %32, 0
%34 = load i32, i32* %2
%35 = icmp eq i32 %34, 0
%36 = select i1 %33, i1 %35, i1 false
%37 = load i32, i32* %3
%38 = icmp eq i32 %37, 0
%39 = select i1 %36, i1 %38, i1 false
br i1 %39, label %40, label %16
40: ; preds = %30, %0
ret i32 0
}