#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 */
float perlin_interpolate(float const, float const, float const);
float perlin_smooth_noise_3d(int const, int const, int const);
float perlin_interpolated_noise_3d(const float x, const float y,
                                   const float z) {
  const int integer_X = (int)x;
  const float fractional_X = x - integer_X;
  const int integer_Y = (int)y;
  const float fractional_Y = y - integer_Y;
  const int integer_Z = (int)z;
  const float fractional_Z = z - integer_Z;
  const float a = perlin_smooth_noise_3d(integer_X, integer_Y, integer_Z);
  const float b = perlin_smooth_noise_3d(integer_X + 1, integer_Y, integer_Z);
  const float c = perlin_smooth_noise_3d(integer_X, integer_Y + 1, integer_Z);
  const float d = perlin_smooth_noise_3d(integer_X, integer_Y, integer_Z + 1);
  const float e =
      perlin_smooth_noise_3d(integer_X + 1, integer_Y + 1, integer_Z);
  const float f =
      perlin_smooth_noise_3d(integer_X, integer_Y + 1, integer_Z + 1);
  const float g =
      perlin_smooth_noise_3d(integer_X + 1, integer_Y, integer_Z + 1);
  const float h =
      perlin_smooth_noise_3d(integer_X + 1, integer_Y + 1, integer_Z + 1);
  const float i1 = perlin_interpolate(a, b, fractional_X);
  const float i2 = perlin_interpolate(c, d, fractional_X);
  const float i3 = perlin_interpolate(e, f, fractional_X);
  const float i4 = perlin_interpolate(g, h, fractional_X);
  const float y1 = perlin_interpolate(i1, i2, fractional_Y);
  const float y2 = perlin_interpolate(i3, i4, fractional_Y);
  return perlin_interpolate(y1, y2, fractional_Z);
}


x86 assembly (clang, -O0):
<perlin_interpolated_noise_3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
cvttss2si -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
cvttss2si -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
cvttss2si -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,-0x2c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x20(%rbp),%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,-0x34(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x20(%rbp),%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,-0x3c(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,-0x44(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,-0x48(%rbp)
movss  -0x30(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,-0x4c(%rbp)
movss  -0x38(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,-0x50(%rbp)
movss  -0x40(%rbp),%xmm0
movss  -0x44(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,-0x54(%rbp)
movss  -0x48(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,-0x58(%rbp)
movss  -0x50(%rbp),%xmm0
movss  -0x54(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,-0x5c(%rbp)
movss  -0x58(%rbp),%xmm0
movss  -0x5c(%rbp),%xmm1
movss  -0x24(%rbp),%xmm2
call   1030 <perlin_interpolate@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perlin_interpolated_noise_3d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
cvttss2si %xmm0,%r12d
cvttps2dq %xmm0,%xmm3
cvtdq2ps %xmm3,%xmm3
subss  %xmm3,%xmm0
movaps %xmm0,0x20(%rsp)
cvttss2si %xmm1,%r14d
cvttps2dq %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
cvttss2si %xmm2,%ebp
subss  %xmm0,%xmm1
movaps %xmm1,0x30(%rsp)
cvttps2dq %xmm2,%xmm0
cvtdq2ps %xmm0,%xmm0
subss  %xmm0,%xmm2
movaps %xmm2,0x40(%rsp)
mov    %r12d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,(%rsp)
lea    0x1(%r12),%r15d
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,0x8(%rsp)
lea    0x1(%r14),%r13d
mov    %r12d,%edi
mov    %r13d,%esi
mov    %ebp,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,0x4(%rsp)
lea    0x1(%rbp),%ebx
mov    %r12d,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,0x1c(%rsp)
mov    %r15d,%edi
mov    %r13d,%esi
mov    %ebp,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,0x18(%rsp)
mov    %r12d,%edi
mov    %r13d,%esi
mov    %ebx,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,0x14(%rsp)
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,0x10(%rsp)
mov    %r15d,%edi
mov    %r13d,%esi
mov    %ebx,%edx
call   1040 <perlin_smooth_noise_3d@plt>
movss  %xmm0,0xc(%rsp)
movss  (%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movaps 0x20(%rsp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,(%rsp)
movss  0x4(%rsp),%xmm0
movss  0x1c(%rsp),%xmm1
movaps 0x20(%rsp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,0x8(%rsp)
movss  0x18(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
movaps 0x20(%rsp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,0x4(%rsp)
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
movaps 0x20(%rsp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,0x20(%rsp)
movss  (%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movaps 0x30(%rsp),%xmm2
call   1030 <perlin_interpolate@plt>
movss  %xmm0,(%rsp)
movss  0x4(%rsp),%xmm0
movss  0x20(%rsp),%xmm1
movaps 0x30(%rsp),%xmm2
call   1030 <perlin_interpolate@plt>
movaps %xmm0,%xmm1
movss  (%rsp),%xmm0
movaps 0x40(%rsp),%xmm2
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <perlin_interpolate@plt>

LLVM IR (-O0):
define float @perlin_interpolated_noise_3d(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca float
%9 = alloca i32
%10 = alloca float
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float
%23 = alloca float
%24 = alloca float
%25 = alloca float
%26 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%27 = load float, float* %4
%28 = fptosi float %27 to i32
store i32 %28, i32* %7
%29 = load float, float* %4
%30 = load i32, i32* %7
%31 = sitofp i32 %30 to float
%32 = fsub float %29, %31
store float %32, float* %8
%33 = load float, float* %5
%34 = fptosi float %33 to i32
store i32 %34, i32* %9
%35 = load float, float* %5
%36 = load i32, i32* %9
%37 = sitofp i32 %36 to float
%38 = fsub float %35, %37
store float %38, float* %10
%39 = load float, float* %6
%40 = fptosi float %39 to i32
store i32 %40, i32* %11
%41 = load float, float* %6
%42 = load i32, i32* %11
%43 = sitofp i32 %42 to float
%44 = fsub float %41, %43
store float %44, float* %12
%45 = load i32, i32* %7
%46 = load i32, i32* %9
%47 = load i32, i32* %11
%48 = call float @perlin_smooth_noise_3d(i32 %45, i32 %46, i32 %47)
store float %48, float* %13
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
%51 = load i32, i32* %9
%52 = load i32, i32* %11
%53 = call float @perlin_smooth_noise_3d(i32 %50, i32 %51, i32 %52)
store float %53, float* %14
%54 = load i32, i32* %7
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
%57 = load i32, i32* %11
%58 = call float @perlin_smooth_noise_3d(i32 %54, i32 %56, i32 %57)
store float %58, float* %15
%59 = load i32, i32* %7
%60 = load i32, i32* %9
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
%63 = call float @perlin_smooth_noise_3d(i32 %59, i32 %60, i32 %62)
store float %63, float* %16
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
%68 = load i32, i32* %11
%69 = call float @perlin_smooth_noise_3d(i32 %65, i32 %67, i32 %68)
store float %69, float* %17
%70 = load i32, i32* %7
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
%75 = call float @perlin_smooth_noise_3d(i32 %70, i32 %72, i32 %74)
store float %75, float* %18
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
%78 = load i32, i32* %9
%79 = load i32, i32* %11
%80 = add nsw i32 %79, 1
%81 = call float @perlin_smooth_noise_3d(i32 %77, i32 %78, i32 %80)
store float %81, float* %19
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
%84 = load i32, i32* %9
%85 = add nsw i32 %84, 1
%86 = load i32, i32* %11
%87 = add nsw i32 %86, 1
%88 = call float @perlin_smooth_noise_3d(i32 %83, i32 %85, i32 %87)
store float %88, float* %20
%89 = load float, float* %13
%90 = load float, float* %14
%91 = load float, float* %8
%92 = call float @perlin_interpolate(float %89, float %90, float %91)
store float %92, float* %21
%93 = load float, float* %15
%94 = load float, float* %16
%95 = load float, float* %8
%96 = call float @perlin_interpolate(float %93, float %94, float %95)
store float %96, float* %22
%97 = load float, float* %17
%98 = load float, float* %18
%99 = load float, float* %8
%100 = call float @perlin_interpolate(float %97, float %98, float %99)
store float %100, float* %23
%101 = load float, float* %19
%102 = load float, float* %20
%103 = load float, float* %8
%104 = call float @perlin_interpolate(float %101, float %102, float %103)
store float %104, float* %24
%105 = load float, float* %21
%106 = load float, float* %22
%107 = load float, float* %10
%108 = call float @perlin_interpolate(float %105, float %106, float %107)
store float %108, float* %25
%109 = load float, float* %23
%110 = load float, float* %24
%111 = load float, float* %10
%112 = call float @perlin_interpolate(float %109, float %110, float %111)
store float %112, float* %26
%113 = load float, float* %25
%114 = load float, float* %26
%115 = load float, float* %12
%116 = call float @perlin_interpolate(float %113, float %114, float %115)
ret float %116
}

LLVM IR (-O2):
define float @perlin_interpolated_noise_3d(float %0, float %1, float %2) {
%4 = fptosi float %0 to i32
%5 = sitofp i32 %4 to float
%6 = fsub float %0, %5
%7 = fptosi float %1 to i32
%8 = sitofp i32 %7 to float
%9 = fsub float %1, %8
%10 = fptosi float %2 to i32
%11 = sitofp i32 %10 to float
%12 = fsub float %2, %11
%13 = tail call float @perlin_smooth_noise_3d(i32 %4, i32 %7, i32 %10)
%14 = add nsw i32 %4, 1
%15 = tail call float @perlin_smooth_noise_3d(i32 %14, i32 %7, i32 %10)
%16 = add nsw i32 %7, 1
%17 = tail call float @perlin_smooth_noise_3d(i32 %4, i32 %16, i32 %10)
%18 = add nsw i32 %10, 1
%19 = tail call float @perlin_smooth_noise_3d(i32 %4, i32 %7, i32 %18)
%20 = tail call float @perlin_smooth_noise_3d(i32 %14, i32 %16, i32 %10)
%21 = tail call float @perlin_smooth_noise_3d(i32 %4, i32 %16, i32 %18)
%22 = tail call float @perlin_smooth_noise_3d(i32 %14, i32 %7, i32 %18)
%23 = tail call float @perlin_smooth_noise_3d(i32 %14, i32 %16, i32 %18)
%24 = tail call float @perlin_interpolate(float %13, float %15, float %6)
%25 = tail call float @perlin_interpolate(float %17, float %19, float %6)
%26 = tail call float @perlin_interpolate(float %20, float %21, float %6)
%27 = tail call float @perlin_interpolate(float %22, float %23, float %6)
%28 = tail call float @perlin_interpolate(float %24, float %25, float %9)
%29 = tail call float @perlin_interpolate(float %26, float %27, float %9)
%30 = tail call float @perlin_interpolate(float %28, float %29, float %12)
ret float %30
}