unsigned int condense_array(double *a, double *b, const double target,
                            const unsigned int n) {
  double *tmp =
      ((double *)smalloc((n) * sizeof(double),
                         "/scratch/repos/new/home/jordi_armengol_estape/"
                         "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                         "michel2323/omp_amg/refs/heads/master/amg_setup.c",
                         1894));
  init_array(tmp, n, 0.0);
  unsigned int i, counter = 0;
  for (i = 0; i < n; i++) {
    if (b[i] != target)
      tmp[counter++] = a[i];
  }
  memcpy(a, tmp, counter * sizeof(double));
  free(tmp);
  return counter;
}


x86 assembly (clang, -O0):
<condense_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%edi
shl    $0x3,%rdi
lea    0xe98(%rip),%rsi
mov    $0x766,%edx
mov    $0x0,%al
call   1060 <smalloc@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xorps  %xmm0,%xmm0
mov    $0x1,%al
call   1040 <init_array@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11fc <condense_array+0xbc>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11c7 <condense_array+0x87>
jp     11c7 <condense_array+0x87>
jmp    11e9 <condense_array+0xa9>
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x30(%rbp)
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11ee <condense_array+0xae>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1199 <condense_array+0x59>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%eax
mov    %eax,%edx
shl    $0x3,%rdx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<condense_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
movsd  %xmm0,(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%r13d
lea    0x0(,%r13,8),%rdi
lea    0xe95(%rip),%rsi
xor    %ebp,%ebp
mov    $0x766,%edx
xor    %eax,%eax
call   1060 <smalloc@plt>
movslq %eax,%r15
xorpd  %xmm0,%xmm0
mov    %r15,%rdi
mov    %r12d,%esi
mov    $0x1,%al
call   1040 <init_array@plt>
test   %r12d,%r12d
je     11c1 <condense_array+0x81>
cmp    $0x1,%r12d
jne    11eb <condense_array+0xab>
xor    %eax,%eax
xor    %ebp,%ebp
test   $0x1,%r13b
je     11c1 <condense_array+0x81>
movsd  (%rbx,%rax,8),%xmm0
ucomisd (%rsp),%xmm0
jne    11b0 <condense_array+0x70>
jnp    11c1 <condense_array+0x81>
movsd  (%r14,%rax,8),%xmm0
mov    %ebp,%eax
add    $0x1,%ebp
movsd  %xmm0,(%r15,%rax,8)
mov    %ebp,%edx
shl    $0x3,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <memcpy@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13d,%ecx
and    $0xfffffffe,%ecx
xor    %eax,%eax
xor    %ebp,%ebp
movsd  (%rsp),%xmm1
jmp    1209 <condense_array+0xc9>
nopl   0x0(%rax)
add    $0x2,%rax
cmp    %rax,%rcx
je     119c <condense_array+0x5c>
movsd  (%rbx,%rax,8),%xmm0
ucomisd %xmm1,%xmm0
jne    1216 <condense_array+0xd6>
jnp    1227 <condense_array+0xe7>
movsd  (%r14,%rax,8),%xmm0
mov    %ebp,%edx
add    $0x1,%ebp
movsd  %xmm0,(%r15,%rdx,8)
movsd  0x8(%rbx,%rax,8),%xmm0
ucomisd %xmm1,%xmm0
jne    1235 <condense_array+0xf5>
jnp    1200 <condense_array+0xc0>
movsd  0x8(%r14,%rax,8),%xmm0
mov    %ebp,%edx
add    $0x1,%ebp
movsd  %xmm0,(%r15,%rdx,8)
jmp    1200 <condense_array+0xc0>

LLVM IR (-O0):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/michel2323/omp_amg/refs/heads/master/amg_setup.c\00"
define i32 @condense_array(double* %0, double* %1, double %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double %2, double* %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = zext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = call i32 (i64, i8*, i32, ...) bitcast (i32 (...)* @smalloc to i32 (i64, i8*, i32, ...)*)(i64 %14, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 1894)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to double*
store double* %17, double** %9
%18 = load double*, double** %9
%19 = load i32, i32* %8
%20 = call i32 (double*, i32, double, ...) bitcast (i32 (...)* @init_array to i32 (double*, i32, double, ...)*)(double* %18, i32 %19, double 0.000000e+00)
store i32 0, i32* %11
store i32 0, i32* %10
br label %21
21: ; preds = %45, %4
%22 = load i32, i32* %10
%23 = load i32, i32* %8
%24 = icmp ult i32 %22, %23
br i1 %24, label %25, label %48
25: ; preds = %21
%26 = load double*, double** %6
%27 = load i32, i32* %10
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = load double, double* %7
%32 = fcmp une double %30, %31
br i1 %32, label %33, label %44
33: ; preds = %25
%34 = load double*, double** %5
%35 = load i32, i32* %10
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = load double*, double** %9
%40 = load i32, i32* %11
%41 = add i32 %40, 1
store i32 %41, i32* %11
%42 = zext i32 %40 to i64
%43 = getelementptr inbounds double, double* %39, i64 %42
store double %38, double* %43
br label %44
44: ; preds = %33, %25
br label %45
45: ; preds = %44
%46 = load i32, i32* %10
%47 = add i32 %46, 1
store i32 %47, i32* %10
br label %21
48: ; preds = %21
%49 = load double*, double** %5
%50 = bitcast double* %49 to i8*
%51 = load double*, double** %9
%52 = bitcast double* %51 to i8*
%53 = load i32, i32* %11
%54 = zext i32 %53 to i64
%55 = mul i64 %54, 8
%56 = load double*, double** %9
%57 = bitcast double* %56 to i8*
%58 = load i32, i32* %11
ret i32 %58
}

LLVM IR (-O2):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/michel2323/omp_amg/refs/heads/master/amg_setup.c\00"
define i32 @condense_array(double* nocapture %0, double* nocapture %1, double %2, i32 %3) {
%5 = zext i32 %3 to i64
%6 = shl nuw nsw i64 %5, 3
%7 = tail call i32 (i64, i8*, i32, ...) bitcast (i32 (...)* @smalloc to i32 (i64, i8*, i32, ...)*)(i64 %6, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 1894)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to double*
%10 = tail call i32 (double*, i32, double, ...) bitcast (i32 (...)* @init_array to i32 (double*, i32, double, ...)*)(double* %9, i32 %3, double 0.000000e+00)
%11 = icmp eq i32 %3, 0
br i1 %11, label %62, label %12
12: ; preds = %4
%13 = and i64 %5, 1
%14 = icmp eq i32 %3, 1
br i1 %14, label %47, label %15
15: ; preds = %12
%16 = and i64 %5, 4294967294
br label %17
17: ; preds = %42, %15
%18 = phi i64 [ 0, %15 ], [ %44, %42 ]
%19 = phi i32 [ 0, %15 ], [ %43, %42 ]
%20 = phi i64 [ 0, %15 ], [ %45, %42 ]
%21 = getelementptr inbounds double, double* %1, i64 %18
%22 = load double, double* %21
%23 = fcmp une double %22, %2
br i1 %23, label %24, label %30
24: ; preds = %17
%25 = getelementptr inbounds double, double* %0, i64 %18
%26 = load double, double* %25
%27 = add i32 %19, 1
%28 = zext i32 %19 to i64
%29 = getelementptr inbounds double, double* %9, i64 %28
store double %26, double* %29
br label %30
30: ; preds = %17, %24
%31 = phi i32 [ %27, %24 ], [ %19, %17 ]
%32 = or i64 %18, 1
%33 = getelementptr inbounds double, double* %1, i64 %32
%34 = load double, double* %33
%35 = fcmp une double %34, %2
br i1 %35, label %36, label %42
36: ; preds = %30
%37 = getelementptr inbounds double, double* %0, i64 %32
%38 = load double, double* %37
%39 = add i32 %31, 1
%40 = zext i32 %31 to i64
%41 = getelementptr inbounds double, double* %9, i64 %40
store double %38, double* %41
br label %42
42: ; preds = %36, %30
%43 = phi i32 [ %39, %36 ], [ %31, %30 ]
%44 = add nuw nsw i64 %18, 2
%45 = add i64 %20, 2
%46 = icmp eq i64 %45, %16
br i1 %46, label %47, label %17
47: ; preds = %42, %12
%48 = phi i32 [ undef, %12 ], [ %43, %42 ]
%49 = phi i64 [ 0, %12 ], [ %44, %42 ]
%50 = phi i32 [ 0, %12 ], [ %43, %42 ]
%51 = icmp eq i64 %13, 0
br i1 %51, label %62, label %52
52: ; preds = %47
%53 = getelementptr inbounds double, double* %1, i64 %49
%54 = load double, double* %53
%55 = fcmp une double %54, %2
br i1 %55, label %56, label %62
56: ; preds = %52
%57 = getelementptr inbounds double, double* %0, i64 %49
%58 = load double, double* %57
%59 = add i32 %50, 1
%60 = zext i32 %50 to i64
%61 = getelementptr inbounds double, double* %9, i64 %60
store double %58, double* %61
br label %62
62: ; preds = %47, %56, %52, %4
%63 = phi i32 [ 0, %4 ], [ %48, %47 ], [ %59, %56 ], [ %50, %52 ]
%64 = bitcast double* %0 to i8*
%65 = inttoptr i64 %8 to i8*
%66 = zext i32 %63 to i64
%67 = shl nuw nsw i64 %66, 3
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %64, i8* align 8 %65, i64 %67, i1 false)
tail call void @free(i8* %65)
ret i32 %63
}