#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 */
scalar_t__ is_perfect_slice_dimension(int, int *);
int next_square(int, int);
int find_largest_square(int slice_dimension[2]) {
  int num_squares = slice_dimension[0] < slice_dimension[1]
                        ? slice_dimension[0]
                        : slice_dimension[1];
  int i;
  for (i = 0; i < num_squares; i++) {
    int square = next_square(i, num_squares);
    if (is_perfect_slice_dimension(square, slice_dimension)) {
      return square;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_largest_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
cmp    0x4(%rcx),%eax
jge    114d <find_largest_square+0x2d>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
jmp    1157 <find_largest_square+0x37>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b2 <find_largest_square+0x92>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <next_square@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <is_perfect_slice_dimension@plt>
cmp    $0x0,%rax
je     119f <find_largest_square+0x7f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b9 <find_largest_square+0x99>
jmp    11a4 <find_largest_square+0x84>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <find_largest_square+0x44>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_largest_square>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdi),%eax
mov    0x4(%rdi),%r12d
cmp    %r12d,%eax
cmovl  %eax,%r12d
mov    $0xffffffff,%r14d
test   %r12d,%r12d
jle    1178 <find_largest_square+0x58>
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
mov    %r12d,%esi
call   1040 <next_square@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <is_perfect_slice_dimension@plt>
test   %rax,%rax
jne    1175 <find_largest_square+0x55>
add    $0x1,%ebx
cmp    %ebx,%r12d
jne    1150 <find_largest_square+0x30>
jmp    1178 <find_largest_square+0x58>
mov    %ebp,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @find_largest_square(i32* %0) {
%2 = load i32, i32* %0
%3 = getelementptr inbounds i32, i32* %0, i64 1
%4 = load i32, i32* %3
%5 = icmp slt i32 %2, %4
%6 = select i1 %5, i32 %2, i32 %4
%7 = icmp sgt i32 %6, 0
br i1 %7, label %10, label %16
8: ; preds = %10
%9 = icmp eq i32 %15, %6
br i1 %9, label %16, label %10
10: ; preds = %1, %8
%11 = phi i32 [ %15, %8 ], [ 0, %1 ]
%12 = tail call i32 @next_square(i32 %11, i32 %6)
%13 = tail call i64 @is_perfect_slice_dimension(i32 %12, i32* %0)
%14 = icmp eq i64 %13, 0
%15 = add nuw nsw i32 %11, 1
br i1 %14, label %8, label %16
16: ; preds = %10, %8, %1
%17 = phi i32 [ -1, %1 ], [ -1, %8 ], [ %12, %10 ]
ret i32 %17
}