#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 pow(int, int);
scalar_t__ sqrt(int);
int is_square(int a, int b, int c, int d) {
  int lp_contains = ((a + c) * (b + d) / 2) -
                    (gcd(a, b) + gcd(b, c) + gcd(c, d) + gcd(d, a)) / 2 + 1;
  return pow((int)sqrt(lp_contains), 2) == lp_contains;
}


x86 assembly (clang, -O0):
<is_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    -0x10(%rbp),%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <gcd@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <gcd@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <gcd@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <gcd@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_square>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%r13d
mov    %edi,%r15d
lea    (%r12,%r15,1),%eax
lea    (%r14,%r13,1),%ecx
imul   %eax,%ecx
mov    %ecx,%ebx
shr    $0x1f,%ebx
add    %ecx,%ebx
sar    %ebx
call   1040 <gcd@plt>
mov    %eax,0x4(%rsp)
mov    %r13d,%edi
mov    %r12d,%esi
call   1040 <gcd@plt>
mov    %eax,%ebp
add    0x4(%rsp),%ebp
mov    %r12d,%edi
mov    %r14d,%esi
call   1040 <gcd@plt>
mov    %eax,%r12d
add    %ebp,%r12d
mov    %r14d,%edi
mov    %r15d,%esi
call   1040 <gcd@plt>
add    %r12d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
sub    %ecx,%ebx
add    $0x1,%ebx
mov    %ebx,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
xor    %ecx,%ecx
cmp    %ebx,%eax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_square(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = load i32, i32* %7
%12 = add nsw i32 %10, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = add nsw i32 %13, %14
%16 = mul nsw i32 %12, %15
%17 = sdiv i32 %16, 2
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 @gcd(i32 %18, i32 %19)
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @gcd(i32 %21, i32 %22)
%24 = add nsw i32 %20, %23
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = call i32 @gcd(i32 %25, i32 %26)
%28 = add nsw i32 %24, %27
%29 = load i32, i32* %8
%30 = load i32, i32* %5
%31 = call i32 @gcd(i32 %29, i32 %30)
%32 = add nsw i32 %28, %31
%33 = sdiv i32 %32, 2
%34 = sub nsw i32 %17, %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
%36 = load i32, i32* %9
%37 = call i64 @sqrt(i32 %36)
%38 = trunc i64 %37 to i32
%39 = call i32 @pow(i32 %38, i32 2)
%40 = load i32, i32* %9
%41 = icmp eq i32 %39, %40
%42 = zext i1 %41 to i32
ret i32 %42
}

LLVM IR (-O2):
define i32 @is_square(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = add nsw i32 %2, %0
%6 = add nsw i32 %3, %1
%7 = mul nsw i32 %6, %5
%8 = sdiv i32 %7, 2
%9 = tail call i32 @gcd(i32 %0, i32 %1)
%10 = tail call i32 @gcd(i32 %1, i32 %2)
%11 = add nsw i32 %10, %9
%12 = tail call i32 @gcd(i32 %2, i32 %3)
%13 = add nsw i32 %11, %12
%14 = tail call i32 @gcd(i32 %3, i32 %0)
%15 = add nsw i32 %13, %14
%16 = sdiv i32 %15, -2
%17 = add nsw i32 %8, 1
%18 = add i32 %17, %16
%19 = tail call i64 @sqrt(i32 %18)
%20 = trunc i64 %19 to i32
%21 = tail call i32 @pow(i32 %20, i32 2)
%22 = icmp eq i32 %21, %18
%23 = zext i1 %22 to i32
ret i32 %23
}