#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double fabs(double);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
double *realloc(double *, int);
int /*<<< orphan*/ stderr;
int get_uniques(double *data_array, int size, double **delivery_uniques) {
  double last_value = data_array[0];
  double *uniques;
  int new_size = 1;
  int old_index;
  int new_index = 1;
  double *temp;
  uniques = (double *)malloc(size * sizeof(double));
  uniques[0] = last_value;
  for (old_index = 1; old_index < size; old_index++) {
    if (!(fabs(last_value - data_array[old_index]) <= .0001)) {
      uniques[new_index] = data_array[old_index];
      new_index++;
      new_size++;
      last_value = data_array[old_index];
    }
  }
  temp = realloc(uniques, new_size * sizeof(double));
  if (temp == NULL) {
    free(uniques);
    fputs("Error allocating memory", stderr);
    exit(EXIT_FAILURE);
  }
  uniques = temp;
  *delivery_uniques = uniques;
  return (new_size);
}


x86 assembly (clang, -O0):
<get_uniques>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x34(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1231 <get_uniques+0xe1>
movsd  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
movaps 0xe46(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe2a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    121e <get_uniques+0xce>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1223 <get_uniques+0xd3>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11a5 <get_uniques+0x55>
mov    -0x28(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1060 <realloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    127f <get_uniques+0x12f>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
lea    0xdb4(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_uniques>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %esi,%r13d
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x0(,%r13,8),%edi
call   1050 <malloc@plt>
movsd  0x8(%rsp),%xmm4
mov    %rax,%r15
movsd  %xmm4,(%rax)
mov    $0x1,%r12d
cmp    $0x2,%r13d
jl     11f7 <get_uniques+0xa7>
mov    %r13d,%eax
mov    $0x1,%ecx
mov    $0x1,%edx
movapd 0xe55(%rip),%xmm0
movsd  0xe5d(%rip),%xmm1
mov    $0x1,%r12d
jmp    11c9 <get_uniques+0x79>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rdx
cmp    %rdx,%rax
je     11f7 <get_uniques+0xa7>
movsd  (%rbx,%rdx,8),%xmm2
movapd %xmm4,%xmm3
subsd  %xmm2,%xmm3
andpd  %xmm0,%xmm3
ucomisd %xmm3,%xmm1
jae    11c0 <get_uniques+0x70>
movslq %ecx,%rcx
movsd  %xmm2,(%r15,%rcx,8)
add    $0x1,%ecx
add    $0x1,%r12d
movsd  (%rbx,%rdx,8),%xmm4
jmp    11c0 <get_uniques+0x70>
lea    0x0(,%r12,8),%esi
mov    %r15,%rdi
call   1060 <realloc@plt>
test   %rax,%rax
je     1220 <get_uniques+0xd0>
mov    %rax,(%r14)
mov    %r12d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%esi
lea    0xde0(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Error allocating memory\00"
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @get_uniques(double* %0, i32 %1, double** %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double**
%7 = alloca double
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
store double* %0, double** %4
store i32 %1, i32* %5
store double** %2, double*** %6
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
store double %15, double* %7
store i32 1, i32* %9
store i32 1, i32* %11
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 8
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to double*
store double* %21, double** %8
%22 = load double, double* %7
%23 = load double*, double** %8
%24 = getelementptr inbounds double, double* %23, i64 0
store double %22, double* %24
store i32 1, i32* %10
br label %25
25: ; preds = %59, %3
%26 = load i32, i32* %10
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %62
29: ; preds = %25
%30 = load double, double* %7
%31 = load double*, double** %4
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = fsub double %30, %35
%37 = call double @llvm.fabs.f64(double %36)
%38 = fcmp ole double %37, 1.000000e-04
br i1 %38, label %58, label %39
39: ; preds = %29
%40 = load double*, double** %4
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = load double*, double** %8
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
store double %44, double* %48
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
%53 = load double*, double** %4
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
store double %57, double* %7
br label %58
58: ; preds = %39, %29
br label %59
59: ; preds = %58
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
br label %25
62: ; preds = %25
%63 = load double*, double** %8
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = mul i64 %65, 8
%67 = trunc i64 %66 to i32
%68 = call double* @realloc(double* %63, i32 %67)
store double* %68, double** %12
%69 = load double*, double** %12
%70 = icmp eq double* %69, null
br i1 %70, label %71, label %78
71: ; preds = %62
%72 = load double*, double** %8
%73 = call i32 @free(double* %72)
%74 = load i32, i32* @stderr
%75 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %74)
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %62
%79 = load double*, double** %12
store double* %79, double** %8
%80 = load double*, double** %8
%81 = load double**, double*** %6
store double* %80, double** %81
%82 = load i32, i32* %9
ret i32 %82
}

LLVM IR (-O2):
@.str = [24 x i8] c"Error allocating memory\00"
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @get_uniques(double* nocapture %0, i32 %1, double** nocapture writeonly %2) {
%4 = load double, double* %0
%5 = shl i32 %1, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to double*
store double %4, double* %7
%8 = icmp sgt i32 %1, 1
br i1 %8, label %9, label %33
9: ; preds = %3
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %9, %27
%12 = phi i64 [ 1, %9 ], [ %31, %27 ]
%13 = phi double [ %4, %9 ], [ %30, %27 ]
%14 = phi i32 [ 1, %9 ], [ %29, %27 ]
%15 = phi i32 [ 1, %9 ], [ %28, %27 ]
%16 = getelementptr inbounds double, double* %0, i64 %12
%17 = load double, double* %16
%18 = fsub double %13, %17
%19 = tail call double @llvm.fabs.f64(double %18)
%20 = fcmp ugt double %19, 1.000000e-04
br i1 %20, label %21, label %27
21: ; preds = %11
%22 = sext i32 %14 to i64
%23 = getelementptr inbounds double, double* %7, i64 %22
store double %17, double* %23
%24 = add nsw i32 %14, 1
%25 = add nsw i32 %15, 1
%26 = load double, double* %16
br label %27
27: ; preds = %11, %21
%28 = phi i32 [ %15, %11 ], [ %25, %21 ]
%29 = phi i32 [ %14, %11 ], [ %24, %21 ]
%30 = phi double [ %13, %11 ], [ %26, %21 ]
%31 = add nuw nsw i64 %12, 1
%32 = icmp eq i64 %31, %10
br i1 %32, label %33, label %11
33: ; preds = %27, %3
%34 = phi i32 [ 1, %3 ], [ %28, %27 ]
%35 = shl i32 %34, 3
%36 = tail call double* @realloc(double* %7, i32 %35)
%37 = icmp eq double* %36, null
br i1 %37, label %38, label %44
38: ; preds = %33
%39 = tail call i32 @free(double* %7)
%40 = load i32, i32* @stderr
%41 = tail call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = tail call i32 @exit(i32 %42)
unreachable
44: ; preds = %33
store double* %36, double** %2
ret i32 %34
}