#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*/ assert(int);
int /*<<< orphan*/ clear_filled_rows_board(int, int);
scalar_t__ find_empty_count_in_row(int);
int clear_all_filled_rows_board(void) {
  int r, rows_cleared = 0;
  for (r = 24 - 1; r > 1; r--) {
    while (find_empty_count_in_row(r) == 0) {
      clear_filled_rows_board(1, r);
      rows_cleared++;
      assert(rows_cleared < 24);
    }
  }
  return rows_cleared;
}


x86 assembly (clang, -O0):
<clear_all_filled_rows_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x17,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    11a6 <clear_all_filled_rows_board+0x76>
jmp    1155 <clear_all_filled_rows_board+0x25>
mov    -0x4(%rbp),%edi
call   1030 <find_empty_count_in_row@plt>
cmp    $0x0,%rax
jne    1193 <clear_all_filled_rows_board+0x63>
mov    -0x4(%rbp),%esi
mov    $0x1,%edi
call   1050 <clear_filled_rows_board@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x18,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
jmp    1155 <clear_all_filled_rows_board+0x25>
jmp    1198 <clear_all_filled_rows_board+0x68>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1146 <clear_all_filled_rows_board+0x16>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_all_filled_rows_board>:
push   %rbp
push   %r14
push   %rbx
mov    $0x17,%r14d
xor    %ebp,%ebp
jmp    114d <clear_all_filled_rows_board+0x1d>
xchg   %ax,%ax
lea    -0x1(%r14),%eax
cmp    $0x2,%r14d
mov    %eax,%r14d
jbe    118f <clear_all_filled_rows_board+0x5f>
mov    %r14d,%edi
call   1030 <find_empty_count_in_row@plt>
test   %rax,%rax
jne    1140 <clear_all_filled_rows_board+0x10>
mov    %ebp,%ebx
nopl   0x0(%rax)
mov    $0x1,%edi
mov    %r14d,%esi
call   1050 <clear_filled_rows_board@plt>
lea    0x1(%rbx),%ebp
xor    %edi,%edi
cmp    $0x17,%ebx
setl   %dil
call   1040 <assert@plt>
mov    %r14d,%edi
call   1030 <find_empty_count_in_row@plt>
mov    %ebp,%ebx
test   %rax,%rax
je     1160 <clear_all_filled_rows_board+0x30>
jmp    1140 <clear_all_filled_rows_board+0x10>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @clear_all_filled_rows_board() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
store i32 23, i32* %1
br label %3
3: ; preds = %21, %0
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 1
br i1 %5, label %6, label %24
6: ; preds = %3
br label %7
7: ; preds = %11, %6
%8 = load i32, i32* %1
%9 = call i64 @find_empty_count_in_row(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = load i32, i32* %1
%13 = call i32 @clear_filled_rows_board(i32 1, i32 %12)
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 24
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
br label %7
20: ; preds = %7
br label %21
21: ; preds = %20
%22 = load i32, i32* %1
%23 = add nsw i32 %22, -1
store i32 %23, i32* %1
br label %3
24: ; preds = %3
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @clear_all_filled_rows_board() {
br label %1
1: ; preds = %0, %15
%2 = phi i32 [ 0, %0 ], [ %16, %15 ]
%3 = phi i32 [ 23, %0 ], [ %17, %15 ]
%4 = tail call i64 @find_empty_count_in_row(i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %1, %6
%7 = phi i32 [ %9, %6 ], [ %2, %1 ]
%8 = tail call i32 @clear_filled_rows_board(i32 1, i32 %3)
%9 = add nsw i32 %7, 1
%10 = icmp slt i32 %7, 23
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i64 @find_empty_count_in_row(i32 %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %6, label %15
15: ; preds = %6, %1
%16 = phi i32 [ %2, %1 ], [ %9, %6 ]
%17 = add nsw i32 %3, -1
%18 = icmp ugt i32 %3, 2
br i1 %18, label %1, label %19
19: ; preds = %15
ret i32 %16
}