int check_value_exist(double *atributes, int *atributes_found,
                      double new_value) {
  assert(atributes);
  assert(atributes_found);
  if (*atributes_found < 1)
    return -1;
  int i = 0;
  while (i < *atributes_found) {
    if (new_value == atributes[i]) {
      return 1;
    }
    i++;
  }
  atributes[i] = new_value;
  (*atributes_found)++;
  return 0;
}


x86 assembly (clang, -O0):
<check_value_exist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x1,(%rax)
jge    1154 <check_value_exist+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <check_value_exist+0xb6>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    11a2 <check_value_exist+0x92>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jne    1194 <check_value_exist+0x84>
jp     1194 <check_value_exist+0x84>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <check_value_exist+0xb6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115b <check_value_exist+0x4b>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_value_exist>:
push   %r14
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <assert@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <assert@plt>
mov    (%r14),%eax
test   %eax,%eax
jle    1165 <check_value_exist+0x55>
xor    %ecx,%ecx
movsd  (%rsp),%xmm1
xchg   %ax,%ax
movsd  (%rbx,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jne    114d <check_value_exist+0x3d>
jnp    116c <check_value_exist+0x5c>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1140 <check_value_exist+0x30>
movsd  %xmm1,(%rbx,%rax,8)
add    $0x1,%eax
mov    %eax,(%r14)
xor    %eax,%eax
jmp    1171 <check_value_exist+0x61>
mov    $0xffffffff,%eax
jmp    1171 <check_value_exist+0x61>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @check_value_exist(double* %0, i32* %1, double %2) {
%4 = tail call i32 (double*, ...) bitcast (i32 (...)* @assert to i32 (double*, ...)*)(double* %0)
%5 = tail call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %22, label %8
8: ; preds = %3
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %15
%11 = phi i64 [ 0, %8 ], [ %16, %15 ]
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = fcmp oeq double %13, %2
br i1 %14, label %22, label %15
15: ; preds = %10
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %18, label %10
18: ; preds = %15
%19 = zext i32 %6 to i64
%20 = getelementptr inbounds double, double* %0, i64 %19
store double %2, double* %20
%21 = add nsw i32 %6, 1
store i32 %21, i32* %1
br label %22
22: ; preds = %10, %18, %3
%23 = phi i32 [ -1, %3 ], [ 0, %18 ], [ 1, %10 ]
ret i32 %23
}