#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__ fmod(double, int);
int removeFives(double arr[], int size) {
  int j = 0, i = 0;
  for (i = 0, j = 0; j < size; ++j)
    if (fmod(arr[j], 5) != 0) {
      arr[i] = arr[j];
      ++i;
    }
  return i;
}


x86 assembly (clang, -O0):
<removeFives>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119e <removeFives+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x5,%edi
call   1030 <fmod@plt>
cmp    $0x0,%rax
je     118b <removeFives+0x7b>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1190 <removeFives+0x80>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113b <removeFives+0x2b>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeFives>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1163 <removeFives+0x53>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
xor    %r12d,%r12d
jmp    1139 <removeFives+0x29>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1166 <removeFives+0x56>
movsd  (%r14,%rbx,8),%xmm0
mov    $0x5,%edi
call   1030 <fmod@plt>
test   %rax,%rax
je     1130 <removeFives+0x20>
movsd  (%r14,%rbx,8),%xmm0
movslq %r12d,%r12
movsd  %xmm0,(%r14,%r12,8)
add    $0x1,%r12d
jmp    1130 <removeFives+0x20>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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