#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 sqrt(int);
bool is_perfect_slice_dimension(int square, int slice[2]) {
  int area = slice[0] * slice[1];
  int num = sqrt(square);
  return !((area % square) || (slice[0] % num) || (slice[1] % num));
}


x86 assembly (clang, -O0):
<is_perfect_slice_dimension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
imul   0x4(%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <sqrt@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x19(%rbp)
jne    117c <is_perfect_slice_dimension+0x6c>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cltd
idivl  -0x18(%rbp)
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x19(%rbp)
jne    117c <is_perfect_slice_dimension+0x6c>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x0,%edx
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_perfect_slice_dimension>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x4(%rsi),%ebx
imul   (%rsi),%ebx
call   1030 <sqrt@plt>
mov    %eax,%esi
mov    %ebx,%eax
cltd
idiv   %ebp
xor    %ecx,%ecx
test   %edx,%edx
jne    1149 <is_perfect_slice_dimension+0x39>
mov    (%r14),%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1149 <is_perfect_slice_dimension+0x39>
mov    0x4(%r14),%eax
cltd
idiv   %esi
xor    %ecx,%ecx
test   %edx,%edx
sete   %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_perfect_slice_dimension(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%7 = load i32*, i32** %4
%8 = getelementptr inbounds i32, i32* %7, i64 0
%9 = load i32, i32* %8
%10 = load i32*, i32** %4
%11 = getelementptr inbounds i32, i32* %10, i64 1
%12 = load i32, i32* %11
%13 = mul nsw i32 %9, %12
store i32 %13, i32* %5
%14 = load i32, i32* %3
%15 = call i32 @sqrt(i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = srem i32 %16, %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %34, label %20
20: ; preds = %2
%21 = load i32*, i32** %4
%22 = getelementptr inbounds i32, i32* %21, i64 0
%23 = load i32, i32* %22
%24 = load i32, i32* %6
%25 = srem i32 %23, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %20
%28 = load i32*, i32** %4
%29 = getelementptr inbounds i32, i32* %28, i64 1
%30 = load i32, i32* %29
%31 = load i32, i32* %6
%32 = srem i32 %30, %31
%33 = icmp ne i32 %32, 0
br label %34
34: ; preds = %27, %20, %2
%35 = phi i1 [ true, %20 ], [ true, %2 ], [ %33, %27 ]
%36 = xor i1 %35, true
%37 = zext i1 %36 to i32
ret i32 %37
}

LLVM IR (-O2):
define i32 @is_perfect_slice_dimension(i32 %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = getelementptr inbounds i32, i32* %1, i64 1
%5 = load i32, i32* %4
%6 = mul nsw i32 %5, %3
%7 = tail call i32 @sqrt(i32 %0)
%8 = srem i32 %6, %0
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i32, i32* %1
%12 = srem i32 %11, %7
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %4
%16 = srem i32 %15, %7
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %14, %10, %2
%20 = phi i32 [ 0, %10 ], [ 0, %2 ], [ %18, %14 ]
ret i32 %20
}