#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 maxDifference(int *, int, int);
int tooManyDetect(int *arrCount, int *arrTooMany, int size, int maxDiff,
                  int id) {
  int i;
  for (i = 0; i < size; i++) {
    if (maxDifference(arrCount, i, size) >= maxDiff)
      arrTooMany[i] = 1;
    else
      arrTooMany[i] = -1;
  }
  return arrTooMany[id];
}


x86 assembly (clang, -O0):
<tooManyDetect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118b <tooManyDetect+0x7b>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <maxDifference@plt>
cmp    -0x18(%rbp),%eax
jl     1169 <tooManyDetect+0x59>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    1178 <tooManyDetect+0x68>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    117d <tooManyDetect+0x6d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1131 <tooManyDetect+0x21>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tooManyDetect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rsi,%r12
test   %edx,%edx
jle    1157 <tooManyDetect+0x47>
mov    %ecx,%r15d
mov    %rdi,%r13
mov    %edx,%ebx
xor    %ebp,%ebp
nop
mov    %r13,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <maxDifference@plt>
xor    %ecx,%ecx
cmp    %r15d,%eax
setge  %cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
mov    %eax,(%r12,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <tooManyDetect+0x20>
movslq %r14d,%rax
mov    (%r12,%rax,4),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @tooManyDetect(i32* %0, i32* nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %18
7: ; preds = %5
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %16, %9 ]
%11 = trunc i64 %10 to i32
%12 = tail call i32 @maxDifference(i32* %0, i32 %11, i32 %2)
%13 = icmp slt i32 %12, %3
%14 = select i1 %13, i32 -1, i32 1
%15 = getelementptr inbounds i32, i32* %1, i64 %10
store i32 %14, i32* %15
%16 = add nuw nsw i64 %10, 1
%17 = icmp eq i64 %16, %8
br i1 %17, label %18, label %9
18: ; preds = %9, %5
%19 = sext i32 %4 to i64
%20 = getelementptr inbounds i32, i32* %1, i64 %19
%21 = load i32, i32* %20
ret i32 %21
}