#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__ check(int *, int *, int, int);
int count(int a[], int b[], int len, int N) {
  int ret = 0;
  for (int num = 1; num <= N; num++) {
    if (check(a, b, len, num))
      ret++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1179 <count+0x69>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <check@plt>
cmp    $0x0,%rax
je     1166 <count+0x56>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116b <count+0x5b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1134 <count+0x24>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    116c <count+0x5c>
mov    %ecx,%r13d
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
neg    %r13d
xor    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1030 <check@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1140 <count+0x30>
jmp    116e <count+0x5e>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @count(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
br label %11
11: ; preds = %26, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %8
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = load i32*, i32** %6
%18 = load i32, i32* %7
%19 = load i32, i32* %10
%20 = call i64 @check(i32* %16, i32* %17, i32 %18, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i32, i32* %9
%24 = add nsw i32 %23, 1
store i32 %24, i32* %9
br label %25
25: ; preds = %22, %15
br label %26
26: ; preds = %25
%27 = load i32, i32* %10
%28 = add nsw i32 %27, 1
store i32 %28, i32* %10
br label %11
29: ; preds = %11
%30 = load i32, i32* %9
ret i32 %30
}

LLVM IR (-O2):
define i32 @count(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %3, 1
br i1 %5, label %6, label %8
6: ; preds = %8, %4
%7 = phi i32 [ 0, %4 ], [ %14, %8 ]
ret i32 %7
8: ; preds = %4, %8
%9 = phi i32 [ %15, %8 ], [ 1, %4 ]
%10 = phi i32 [ %14, %8 ], [ 0, %4 ]
%11 = tail call i64 @check(i32* %0, i32* %1, i32 %2, i32 %9)
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i32
%14 = add nuw nsw i32 %10, %13
%15 = add nuw i32 %9, 1
%16 = icmp eq i32 %9, %3
br i1 %16, label %6, label %8
}