#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 *, char *, int);
void handle(int a, int b, int c) {
  char *text;
  if ((b - a) == (c - b)) {
    text = "AP";
    int next = c + (c - b);
    printf("%s %d\n", text, next);
  } else if ((b / a) == (c / b)) {
    text = "GP";
    int next = c * (c / b);
    printf("%s %d\n", text, next);
  }
}


x86 assembly (clang, -O0):
<handle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jne    1166 <handle+0x56>
lea    0xec4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    11bf <handle+0xaf>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jne    11ba <handle+0xaa>
lea    0xe7f(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
jmp    11bf <handle+0xaf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle>:
mov    %edx,%ecx
mov    %esi,%edx
sub    %edi,%edx
mov    %ecx,%eax
sub    %esi,%eax
cmp    %eax,%edx
jne    1133 <handle+0x23>
add    %ecx,%edx
lea    0xedc(%rip),%rdi
lea    0xed2(%rip),%rsi
jmp    1030 <printf@plt>
mov    %esi,%eax
cltd
idiv   %edi
mov    %eax,%r8d
mov    %ecx,%eax
cltd
idiv   %esi
cmp    %eax,%r8d
jne    115f <handle+0x4f>
imul   %ecx,%r8d
lea    0xeb3(%rip),%rdi
lea    0xeb3(%rip),%rsi
mov    %r8d,%edx
jmp    1030 <printf@plt>
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"AP\00"
@.str.1 = [7 x i8] c"%s %d\0A\00"
@.str.2 = [3 x i8] c"GP\00"
define void @handle(i32 %0, i32 %1, i32 %2) {
%4 = sub nsw i32 %1, %0
%5 = sub nsw i32 %2, %1
%6 = icmp eq i32 %4, %5
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = add nsw i32 %4, %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %17
10: ; preds = %3
%11 = sdiv i32 %1, %0
%12 = sdiv i32 %2, %1
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = mul nsw i32 %11, %2
%16 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %10, %14, %7
ret void
}