#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(struct kdtree *, double *);
struct kdres *kd_nearest3f(struct kdtree *tree, float x, float y, float z) {
  double pos[3];
  pos[0] = x;
  pos[1] = y;
  pos[2] = z;
  return kd_nearest(tree, pos);
}


x86 assembly (clang, -O0):
<kd_nearest3f>:
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  -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
call   1030 <kd_nearest@plt>
add    $0x30,%rsp
pop    %rbp
ret

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

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

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