#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*/ clear_count(int *, int);
int /*<<< orphan*/ flood_count(int *, int, int, int, int, int *);
int check_capacity(int *board, int w, int h, int i) {
  int n = board[i];
  flood_count(board, w, h, i, board[i], &n);
  clear_count(board, w * h);
  return n == 0;
}


x86 assembly (clang, -O0):
<check_capacity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%r8
mov    (%rax,%r8,4),%r8d
lea    -0x18(%rbp),%r9
call   1030 <flood_count@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
call   1040 <clear_count@plt>
cmpl   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_capacity>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%rbp
movslq %ecx,%rcx
mov    (%rdi,%rcx,4),%r8d
mov    %r8d,0xc(%rsp)
lea    0xc(%rsp),%r9
call   1030 <flood_count@plt>
imul   %r14d,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <clear_count@plt>
xor    %eax,%eax
cmpl   $0x0,0xc(%rsp)
sete   %al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_capacity(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* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = load i32, i32* %13
store i32 %14, i32* %9
%15 = load i32*, i32** %5
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = load i32*, i32** %5
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @flood_count(i32* %15, i32 %16, i32 %17, i32 %18, i32 %23, i32* %9)
%25 = load i32*, i32** %5
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = mul nsw i32 %26, %27
%29 = call i32 @clear_count(i32* %25, i32 %28)
%30 = load i32, i32* %9
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i32
ret i32 %32
}

LLVM IR (-O2):
define i32 @check_capacity(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
store i32 %9, i32* %5
%10 = call i32 @flood_count(i32* %0, i32 %1, i32 %2, i32 %3, i32 %9, i32* %5)
%11 = mul nsw i32 %2, %1
%12 = call i32 @clear_count(i32* %0, i32 %11)
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
ret i32 %15
}