#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 */
typedef scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
scalar_t__ floor(double const);
extern void grid_convertRealGridPosToGridPos(const double *realGridPos,
                                             uint32_t *gridPos) {
  assert(realGridPos != NULL);
  assert(gridPos != NULL);
  for (int i = 0; i < 3; i++)
    gridPos[i] = (uint32_t)floor(realGridPos[i]);
}


x86 assembly (clang, -O0):
<grid_convertRealGridPosToGridPos>:
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    1194 <grid_convertRealGridPosToGridPos+0x74>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <floor@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <grid_convertRealGridPosToGridPos+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_convertRealGridPosToGridPos>:
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
call   1040 <floor@plt>
mov    %rax,(%r14)
movsd  0x8(%rbx),%xmm0
call   1040 <floor@plt>
mov    %rax,0x8(%r14)
movsd  0x10(%rbx),%xmm0
call   1040 <floor@plt>
mov    %rax,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @grid_convertRealGridPosToGridPos(double* %0, i64* %1) {
%3 = alloca double*
%4 = alloca i64*
%5 = alloca i32
store double* %0, double** %3
store i64* %1, i64** %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 i64*, i64** %4
%11 = icmp ne i64* %10, null
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
store i32 0, i32* %5
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %31
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 = call i64 @floor(double %22)
%24 = load i64*, i64** %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i64, i64* %24, i64 %26
store i64 %23, i64* %27
br label %28
28: ; preds = %17
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %14
31: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @grid_convertRealGridPosToGridPos(double* %0, i64* writeonly %1) {
%3 = icmp ne double* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i64* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = load double, double* %0
%10 = tail call i64 @floor(double %9)
store i64 %10, i64* %1
%11 = getelementptr inbounds double, double* %0, i64 1
%12 = load double, double* %11
%13 = tail call i64 @floor(double %12)
%14 = getelementptr inbounds i64, i64* %1, i64 1
store i64 %13, i64* %14
%15 = getelementptr inbounds double, double* %0, i64 2
%16 = load double, double* %15
%17 = tail call i64 @floor(double %16)
%18 = getelementptr inbounds i64, i64* %1, i64 2
store i64 %17, i64* %18
ret void
}