#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 */
unsigned short logical_truth_counter(bool break_on_condition,
                                     unsigned short condition_matcher_number,
                                     bool *boolean_list,
                                     unsigned short array_size) {
  unsigned short i;
  unsigned short num_of_truths = 0u;
  for (i = 0u; i < array_size; i++) {
    if (boolean_list[i]) {
      num_of_truths++;
    }
    if (break_on_condition && num_of_truths > condition_matcher_number) {
      break;
    }
  }
  return num_of_truths;
}


x86 assembly (clang, -O0):
<logical_truth_counter>:
push   %rbp
mov    %rsp,%rbp
mov    %cx,%ax
mov    %si,%cx
mov    %edi,-0x4(%rbp)
mov    %cx,-0x6(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movw   $0x0,-0x16(%rbp)
movw   $0x0,-0x14(%rbp)
movzwl -0x14(%rbp),%eax
movzwl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jge    1188 <logical_truth_counter+0x88>
mov    -0x10(%rbp),%rax
movzwl -0x14(%rbp),%ecx
cmpl   $0x0,(%rax,%rcx,4)
je     1153 <logical_truth_counter+0x53>
mov    -0x16(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x16(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1172 <logical_truth_counter+0x72>
movzwl -0x16(%rbp),%eax
movzwl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jle    1172 <logical_truth_counter+0x72>
jmp    1188 <logical_truth_counter+0x88>
jmp    1177 <logical_truth_counter+0x77>
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
jmp    1125 <logical_truth_counter+0x25>
movzwl -0x16(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<logical_truth_counter>:
test   %ecx,%ecx
je     113b <logical_truth_counter+0x3b>
movzwl %cx,%r8d
mov    $0x1,%r10d
xor    %eax,%eax
test   %edi,%edi
sete   %r9b
cmpl   $0x1,-0x4(%rdx,%r10,4)
sbb    $0xffff,%ax
cmp    %si,%ax
setbe  %cl
or     %r9b,%cl
cmp    $0x1,%cl
jne    113a <logical_truth_counter+0x3a>
lea    0x1(%r10),%rcx
cmp    %r8,%r10
mov    %rcx,%r10
jb     1110 <logical_truth_counter+0x10>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define zeroext i16 @logical_truth_counter(i32 %0, i16 zeroext %1, i32* nocapture %2, i16 zeroext %3) {
%5 = icmp eq i16 %3, 0
br i1 %5, label %22, label %6
6: ; preds = %4
%7 = icmp eq i32 %0, 0
%8 = zext i16 %3 to i64
br label %9
9: ; preds = %9, %6
%10 = phi i64 [ %19, %9 ], [ 0, %6 ]
%11 = phi i16 [ %16, %9 ], [ 0, %6 ]
%12 = getelementptr inbounds i32, i32* %2, i64 %10
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i16
%16 = add i16 %11, %15
%17 = icmp ule i16 %16, %1
%18 = select i1 %7, i1 true, i1 %17
%19 = add nuw nsw i64 %10, 1
%20 = icmp ult i64 %19, %8
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %9, label %22
22: ; preds = %9, %4
%23 = phi i16 [ 0, %4 ], [ %16, %9 ]
ret i16 %23
}