#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 tdFLerp(float, float, float);
float tdNoiseAt(int, int);
float tdFNoiseAt(float x, float y) {
  int ix = x;
  int iy = y;
  float fx = x - ix;
  float fy = y - iy;
  float a = tdNoiseAt(ix, iy);
  float b = tdNoiseAt(ix + 1, iy);
  float c = tdNoiseAt(ix, iy + 1);
  float d = tdNoiseAt(ix + 1, iy + 1);
  float top = tdFLerp(a, b, fx);
  float bottom = tdFLerp(c, d, fx);
  return tdFLerp(top, bottom, fy);
}


x86 assembly (clang, -O0):
<tdFNoiseAt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
cvttss2si -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cvttss2si -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <tdNoiseAt@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    -0x10(%rbp),%esi
call   1040 <tdNoiseAt@plt>
movss  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1040 <tdNoiseAt@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1040 <tdNoiseAt@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1030 <tdFLerp@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1030 <tdFLerp@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
call   1030 <tdFLerp@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tdFNoiseAt>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
cvttss2si %xmm0,%r14d
cvttss2si %xmm1,%ebx
cvttps2dq %xmm0,%xmm2
cvtdq2ps %xmm2,%xmm2
subss  %xmm2,%xmm0
movaps %xmm0,0x10(%rsp)
cvttps2dq %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
subss  %xmm0,%xmm1
movaps %xmm1,0x20(%rsp)
mov    %r14d,%edi
mov    %ebx,%esi
call   1040 <tdNoiseAt@plt>
movss  %xmm0,(%rsp)
lea    0x1(%r14),%ebp
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <tdNoiseAt@plt>
movss  %xmm0,0xc(%rsp)
add    $0x1,%ebx
mov    %r14d,%edi
mov    %ebx,%esi
call   1040 <tdNoiseAt@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <tdNoiseAt@plt>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
movss  0xc(%rsp),%xmm1
movaps 0x10(%rsp),%xmm2
call   1030 <tdFLerp@plt>
movss  %xmm0,(%rsp)
movss  0x8(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
movaps 0x10(%rsp),%xmm2
call   1030 <tdFLerp@plt>
movaps %xmm0,%xmm1
movss  (%rsp),%xmm0
movaps 0x20(%rsp),%xmm2
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <tdFLerp@plt>

LLVM IR (-O0):
define float @tdFNoiseAt(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
store float %0, float* %3
store float %1, float* %4
%15 = load float, float* %3
%16 = fptosi float %15 to i32
store i32 %16, i32* %5
%17 = load float, float* %4
%18 = fptosi float %17 to i32
store i32 %18, i32* %6
%19 = load float, float* %3
%20 = load i32, i32* %5
%21 = sitofp i32 %20 to float
%22 = fsub float %19, %21
store float %22, float* %7
%23 = load float, float* %4
%24 = load i32, i32* %6
%25 = sitofp i32 %24 to float
%26 = fsub float %23, %25
store float %26, float* %8
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call float @tdNoiseAt(i32 %27, i32 %28)
store float %29, float* %9
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
%32 = load i32, i32* %6
%33 = call float @tdNoiseAt(i32 %31, i32 %32)
store float %33, float* %10
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
%37 = call float @tdNoiseAt(i32 %34, i32 %36)
store float %37, float* %11
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
%42 = call float @tdNoiseAt(i32 %39, i32 %41)
store float %42, float* %12
%43 = load float, float* %9
%44 = load float, float* %10
%45 = load float, float* %7
%46 = call float @tdFLerp(float %43, float %44, float %45)
store float %46, float* %13
%47 = load float, float* %11
%48 = load float, float* %12
%49 = load float, float* %7
%50 = call float @tdFLerp(float %47, float %48, float %49)
store float %50, float* %14
%51 = load float, float* %13
%52 = load float, float* %14
%53 = load float, float* %8
%54 = call float @tdFLerp(float %51, float %52, float %53)
ret float %54
}

LLVM IR (-O2):
define float @tdFNoiseAt(float %0, float %1) {
%3 = fptosi float %0 to i32
%4 = fptosi float %1 to i32
%5 = sitofp i32 %3 to float
%6 = fsub float %0, %5
%7 = sitofp i32 %4 to float
%8 = fsub float %1, %7
%9 = tail call float @tdNoiseAt(i32 %3, i32 %4)
%10 = add nsw i32 %3, 1
%11 = tail call float @tdNoiseAt(i32 %10, i32 %4)
%12 = add nsw i32 %4, 1
%13 = tail call float @tdNoiseAt(i32 %3, i32 %12)
%14 = tail call float @tdNoiseAt(i32 %10, i32 %12)
%15 = tail call float @tdFLerp(float %9, float %11, float %6)
%16 = tail call float @tdFLerp(float %13, float %14, float %6)
%17 = tail call float @tdFLerp(float %15, float %16, float %8)
ret float %17
}