#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, c, emty, 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,-0x10(%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    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x18,-0x10(%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    -0x10(%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
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %4
store i32 23, i32* %1
br label %5
5: ; preds = %23, %0
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %26
8: ; preds = %5
br label %9
9: ; preds = %13, %8
%10 = load i32, i32* %1
%11 = call i64 @find_empty_count_in_row(i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i32, i32* %1
%15 = call i32 @clear_filled_rows_board(i32 1, i32 %14)
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 24
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
br label %9
22: ; preds = %9
br label %23
23: ; preds = %22
%24 = load i32, i32* %1
%25 = add nsw i32 %24, -1
store i32 %25, i32* %1
br label %5
26: ; preds = %5
%27 = load i32, i32* %4
ret i32 %27
}

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
}