#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 */
struct kdtree {
  int dummy;
};
struct kdres {
  int dummy;
};

/* Variables and functions */
struct kdres *kd_nearest_range(struct kdtree *, double *, float);
struct kdres *kd_nearest_range3f(struct kdtree *tree, float x, float y, float z,
                                 float range) {
  double buf[3];
  buf[0] = x;
  buf[1] = y;
  buf[2] = z;
  return kd_nearest_range(tree, buf, range);
}


x86 assembly (clang, -O0):
<kd_nearest_range3f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
movss  -0x18(%rbp),%xmm0
call   1030 <kd_nearest_range@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kd_nearest_range3f>:
sub    $0x18,%rsp
unpcklps %xmm1,%xmm0
cvtps2pd %xmm0,%xmm1
movaps %xmm3,%xmm0
movaps %xmm1,(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %rsp,%rsi
call   1030 <kd_nearest_range@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.kdres = type { i32 }
%struct.kdtree = type { i32 }
define %struct.kdres* @kd_nearest_range3f(%struct.kdtree* %0, float %1, float %2, float %3, float %4) {
%6 = alloca %struct.kdtree*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca [3 x double]
store %struct.kdtree* %0, %struct.kdtree** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%12 = load float, float* %7
%13 = fpext float %12 to double
%14 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
store double %13, double* %14
%15 = load float, float* %8
%16 = fpext float %15 to double
%17 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
store double %16, double* %17
%18 = load float, float* %9
%19 = fpext float %18 to double
%20 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
store double %19, double* %20
%21 = load %struct.kdtree*, %struct.kdtree** %6
%22 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%23 = load float, float* %10
%24 = call %struct.kdres* @kd_nearest_range(%struct.kdtree* %21, double* %22, float %23)
ret %struct.kdres* %24
}

LLVM IR (-O2):
%struct.kdres = type { i32 }
%struct.kdtree = type { i32 }
define %struct.kdres* @kd_nearest_range3f(%struct.kdtree* %0, float %1, float %2, float %3, float %4) {
%6 = alloca [3 x double]
%7 = bitcast [3 x double]* %6 to i8*
%8 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%9 = insertelement <2 x float> poison, float %1, i64 0
%10 = insertelement <2 x float> %9, float %2, i64 1
%11 = fpext <2 x float> %10 to <2 x double>
%12 = bitcast [3 x double]* %6 to <2 x double>*
store <2 x double> %11, <2 x double>* %12
%13 = fpext float %3 to double
%14 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %13, double* %14
%15 = call %struct.kdres* @kd_nearest_range(%struct.kdtree* %0, double* %8, float %4)
ret %struct.kdres* %15
}