#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_in_box(double const *const, double const *, int, double);
int box_counter(const double *const *data, int t, int n, double epsilon,
                int *box_count) {
  const double *median_points[t];
  int num = 0;
  for (int i = 0; i < t; i++) {
    int flag = 0;
    for (int j = 0; j < num; j++) {
      if (check_in_box(data[i], median_points[j], n, epsilon)) {
        box_count[j]++;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      median_points[num] = data[i];
      box_count[num] = 1;
      num++;
    }
  }
  return num;
}


x86 assembly (clang, -O0):
<box_counter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1232 <box_counter+0x122>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11e5 <box_counter+0xd5>
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x38(%rbp),%rdx
mov    (%rcx,%rdx,8),%rdi
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x10(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
call   1030 <check_in_box@plt>
cmp    $0x0,%rax
je     11d2 <box_counter+0xc2>
mov    -0x20(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
movl   $0x1,-0x3c(%rbp)
jmp    11e5 <box_counter+0xd5>
jmp    11d7 <box_counter+0xc7>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    117a <box_counter+0x6a>
cmpl   $0x0,-0x3c(%rbp)
jne    121f <box_counter+0x10f>
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x38(%rbp),%rdx
mov    (%rcx,%rdx,8),%rdx
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1224 <box_counter+0x114>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1160 <box_counter+0x50>
mov    -0x34(%rbp),%eax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box_counter>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,-0x38(%rbp)
movsd  %xmm0,-0x48(%rbp)
mov    %edx,-0x30(%rbp)
mov    %esi,%eax
mov    %rsp,%r14
mov    %rax,-0x40(%rbp)
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
test   %esi,%esi
jle    11db <box_counter+0xcb>
mov    %rdi,%rbx
xor    %r13d,%r13d
movl   $0x0,-0x2c(%rbp)
jmp    1189 <box_counter+0x79>
nop
mov    (%rbx,%r13,8),%rax
mov    -0x2c(%rbp),%edx
movslq %edx,%rcx
mov    %rax,(%r14,%rcx,8)
mov    -0x38(%rbp),%rax
movl   $0x1,(%rax,%rcx,4)
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
add    $0x1,%r13
cmp    -0x40(%rbp),%r13
je     11e2 <box_counter+0xd2>
cmpl   $0x0,-0x2c(%rbp)
jle    1160 <box_counter+0x50>
mov    -0x2c(%rbp),%r12d
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%r13,8),%rdi
mov    (%r14,%r15,8),%rsi
mov    -0x30(%rbp),%edx
movsd  -0x48(%rbp),%xmm0
call   1030 <check_in_box@plt>
test   %rax,%rax
jne    11d0 <box_counter+0xc0>
add    $0x1,%r15
cmp    %r15,%r12
jne    11a0 <box_counter+0x90>
jmp    1160 <box_counter+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x38(%rbp),%rax
addl   $0x1,(%rax,%r15,4)
jmp    117f <box_counter+0x6f>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @box_counter(double** %0, i32 %1, i32 %2, double %3, i32* %4) {
%6 = alloca double**
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store double** %0, double*** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double %3, double* %9
store i32* %4, i32** %10
%17 = load i32, i32* %7
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %11
%20 = alloca double*, i64 %18
store i64 %18, i64* %12
store i32 0, i32* %13
store i32 0, i32* %14
br label %21
21: ; preds = %74, %5
%22 = load i32, i32* %14
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %77
25: ; preds = %21
store i32 0, i32* %15
store i32 0, i32* %16
br label %26
26: ; preds = %52, %25
%27 = load i32, i32* %16
%28 = load i32, i32* %13
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %55
30: ; preds = %26
%31 = load double**, double*** %6
%32 = load i32, i32* %14
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double*, double** %31, i64 %33
%35 = load double*, double** %34
%36 = load i32, i32* %16
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double*, double** %20, i64 %37
%39 = load double*, double** %38
%40 = load i32, i32* %8
%41 = load double, double* %9
%42 = call i64 @check_in_box(double* %35, double* %39, i32 %40, double %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %30
%45 = load i32*, i32** %10
%46 = load i32, i32* %16
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = add nsw i32 %49, 1
store i32 %50, i32* %48
store i32 1, i32* %15
br label %55
51: ; preds = %30
br label %52
52: ; preds = %51
%53 = load i32, i32* %16
%54 = add nsw i32 %53, 1
store i32 %54, i32* %16
br label %26
55: ; preds = %44, %26
%56 = load i32, i32* %15
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %73
58: ; preds = %55
%59 = load double**, double*** %6
%60 = load i32, i32* %14
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double*, double** %59, i64 %61
%63 = load double*, double** %62
%64 = load i32, i32* %13
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double*, double** %20, i64 %65
store double* %63, double** %66
%67 = load i32*, i32** %10
%68 = load i32, i32* %13
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
store i32 1, i32* %70
%71 = load i32, i32* %13
%72 = add nsw i32 %71, 1
store i32 %72, i32* %13
br label %73
73: ; preds = %58, %55
br label %74
74: ; preds = %73
%75 = load i32, i32* %14
%76 = add nsw i32 %75, 1
store i32 %76, i32* %14
br label %21
77: ; preds = %21
%78 = load i32, i32* %13
%79 = load i8*, i8** %11
ret i32 %78
}

LLVM IR (-O2):
define i32 @box_counter(double** nocapture %0, i32 %1, i32 %2, double %3, i32* nocapture %4) {
%6 = zext i32 %1 to i64
%7 = alloca double*, i64 %6
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %16
9: ; preds = %5, %40
%10 = phi i64 [ %42, %40 ], [ 0, %5 ]
%11 = phi i32 [ %41, %40 ], [ 0, %5 ]
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = getelementptr inbounds double*, double** %0, i64 %10
%15 = zext i32 %11 to i64
br label %18
16: ; preds = %40, %5
%17 = phi i32 [ 0, %5 ], [ %41, %40 ]
ret i32 %17
18: ; preds = %13, %30
%19 = phi i64 [ 0, %13 ], [ %31, %30 ]
%20 = load double*, double** %14
%21 = getelementptr inbounds double*, double** %7, i64 %19
%22 = load double*, double** %21
%23 = tail call i64 @check_in_box(double* %20, double* %22, i32 %2, double %3)
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %18
%26 = and i64 %19, 4294967295
%27 = getelementptr inbounds i32, i32* %4, i64 %26
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
store i32 %29, i32* %27
br label %40
30: ; preds = %18
%31 = add nuw nsw i64 %19, 1
%32 = icmp eq i64 %31, %15
br i1 %32, label %33, label %18
33: ; preds = %30, %9
%34 = getelementptr inbounds double*, double** %0, i64 %10
%35 = load double*, double** %34
%36 = sext i32 %11 to i64
%37 = getelementptr inbounds double*, double** %7, i64 %36
store double* %35, double** %37
%38 = getelementptr inbounds i32, i32* %4, i64 %36
store i32 1, i32* %38
%39 = add nsw i32 %11, 1
br label %40
40: ; preds = %25, %33
%41 = phi i32 [ %39, %33 ], [ %11, %25 ]
%42 = add nuw nsw i64 %10, 1
%43 = icmp eq i64 %42, %6
br i1 %43, label %16, label %9
}