#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*/ assert(int /*<<< orphan*/);
double floor(double);
extern void grid_calcDistToCellCenter(double *realGridPos, double *dist) {
  assert(realGridPos != NULL);
  assert(dist != NULL);
  for (int i = 0; i < 3; i++)
    dist[i] = realGridPos[i] - (floor(realGridPos[i]) + 0.5);
}


x86 assembly (clang, -O0):
<grid_calcDistToCellCenter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11bc <grid_calcDistToCellCenter+0x9c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe67(%rip),%xmm2
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <grid_calcDistToCellCenter+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_calcDistToCellCenter>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
movsd  (%rbx),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <floor@plt>
addsd  0xea4(%rip),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <floor@plt>
addsd  0xe7f(%rip),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rbx),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <floor@plt>
addsd  0xe59(%rip),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @grid_calcDistToCellCenter(double* %0, double* writeonly %1) {
%3 = icmp ne double* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne double* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = load double, double* %0
%10 = tail call double @llvm.floor.f64(double %9)
%11 = fadd double %10, 5.000000e-01
%12 = fsub double %9, %11
store double %12, double* %1
%13 = getelementptr inbounds double, double* %0, i64 1
%14 = load double, double* %13
%15 = tail call double @llvm.floor.f64(double %14)
%16 = fadd double %15, 5.000000e-01
%17 = fsub double %14, %16
%18 = getelementptr inbounds double, double* %1, i64 1
store double %17, double* %18
%19 = getelementptr inbounds double, double* %0, i64 2
%20 = load double, double* %19
%21 = tail call double @llvm.floor.f64(double %20)
%22 = fadd double %21, 5.000000e-01
%23 = fsub double %20, %22
%24 = getelementptr inbounds double, double* %1, i64 2
store double %23, double* %24
ret void
}