#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 */
double K(int *, int *, double *, int);
scalar_t__ floor(double);
double noise_sample(double x, double y, double z) {
  int hi, A[3] = {0, 0, 0};
  int lo, i[3];
  double v[3];
  double s;
  s = (x + y + z) / 3.0;
  i[0] = (int)floor(x + s);
  i[1] = (int)floor(y + s);
  i[2] = (int)floor(z + s);
  s = (i[0] + i[1] + i[2]) / 6.0;
  v[0] = x - i[0] + s;
  v[1] = y - i[1] + s;
  v[2] = z - i[2] + s;
  hi = (v[0] >= v[2]) ? ((v[0] >= v[1]) ? 0 : 1) : ((v[1] >= v[2]) ? 1 : 2);
  lo = (v[0] < v[2]) ? ((v[0] < v[1]) ? 0 : 1) : ((v[1] < v[2]) ? 1 : 2);
  return K(A, i, v, hi) + K(A, i, v, 3 - hi - lo) + K(A, i, v, lo) +
         K(A, i, v, 0);
}


x86 assembly (clang, -O0):
<noise_sample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe97(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
call   1050 <floor@plt>
mov    %eax,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
call   1050 <floor@plt>
mov    %eax,-0x34(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
call   1050 <floor@plt>
mov    %eax,-0x30(%rbp)
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
add    -0x30(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe3b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x38(%rbp),%xmm1
subsd  %xmm1,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
subsd  %xmm1,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
subsd  %xmm1,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x50(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jb     1246 <noise_sample+0x116>
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mov    $0x1,%eax
xor    %ecx,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
mov    %eax,-0x5c(%rbp)
jmp    1264 <noise_sample+0x134>
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    $0x2,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    129e <noise_sample+0x16e>
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
mov    $0x1,%eax
xor    %ecx,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x60(%rbp)
jmp    12bc <noise_sample+0x18c>
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
mov    $0x2,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <K@plt>
movsd  %xmm0,-0x78(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    $0x3,%ecx
sub    -0x1c(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
call   1040 <K@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1040 <K@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x50(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <K@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
addsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<noise_sample>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x10(%rsp)
movapd %xmm0,%xmm3
movsd  %xmm0,0x28(%rsp)
movl   $0x0,0x38(%rsp)
movq   $0x0,0x30(%rsp)
addsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
divsd  0xe9e(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  %xmm3,%xmm0
call   1040 <floor@plt>
mov    %rax,%rbx
mov    %ebx,0x1c(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
call   1040 <floor@plt>
mov    %rax,%rbp
mov    %ebp,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
call   1040 <floor@plt>
lea    (%rbx,%rax,1),%ecx
add    %ebp,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
divsd  0xe54(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  0x28(%rsp),%xmm4
subsd  %xmm1,%xmm4
addsd  %xmm0,%xmm4
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  0x10(%rsp),%xmm3
subsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  (%rsp),%xmm2
subsd  %xmm1,%xmm2
xor    %ebx,%ebx
ucomisd %xmm3,%xmm4
addsd  %xmm0,%xmm2
setb   %bl
ucomisd %xmm2,%xmm3
mov    %eax,0x24(%rsp)
mov    $0x2,%eax
adc    $0xffffffff,%eax
ucomisd %xmm2,%xmm4
cmovb  %eax,%ebx
movsd  %xmm4,0x40(%rsp)
xor    %ebp,%ebp
ucomisd %xmm4,%xmm3
movsd  %xmm3,0x48(%rsp)
setbe  %bpl
xor    %eax,%eax
ucomisd %xmm3,%xmm2
seta   %al
mov    $0x2,%ecx
sub    %eax,%ecx
ucomisd %xmm4,%xmm2
movsd  %xmm2,0x50(%rsp)
cmovbe %ecx,%ebp
lea    0x30(%rsp),%r14
lea    0x1c(%rsp),%r15
lea    0x40(%rsp),%r12
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebx,%ecx
call   1030 <K@plt>
movsd  %xmm0,(%rsp)
xor    $0x3,%ebx
sub    %ebp,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebx,%ecx
call   1030 <K@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1030 <K@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
call   1030 <K@plt>
addsd  (%rsp),%xmm0
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @noise_sample(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca [3 x i32]
%9 = alloca i32
%10 = alloca [3 x i32]
%11 = alloca [3 x double]
%12 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%13 = bitcast [3 x i32]* %8 to i8*
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fadd double %14, %15
%17 = load double, double* %6
%18 = fadd double %16, %17
%19 = fdiv double %18, 3.000000e+00
store double %19, double* %12
%20 = load double, double* %4
%21 = load double, double* %12
%22 = fadd double %20, %21
%23 = call i64 @floor(double %22)
%24 = trunc i64 %23 to i32
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
store i32 %24, i32* %25
%26 = load double, double* %5
%27 = load double, double* %12
%28 = fadd double %26, %27
%29 = call i64 @floor(double %28)
%30 = trunc i64 %29 to i32
%31 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
store i32 %30, i32* %31
%32 = load double, double* %6
%33 = load double, double* %12
%34 = fadd double %32, %33
%35 = call i64 @floor(double %34)
%36 = trunc i64 %35 to i32
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
store i32 %36, i32* %37
%38 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%39 = load i32, i32* %38
%40 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
%41 = load i32, i32* %40
%42 = add nsw i32 %39, %41
%43 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
%44 = load i32, i32* %43
%45 = add nsw i32 %42, %44
%46 = sitofp i32 %45 to double
%47 = fdiv double %46, 6.000000e+00
store double %47, double* %12
%48 = load double, double* %4
%49 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%50 = load i32, i32* %49
%51 = sitofp i32 %50 to double
%52 = fsub double %48, %51
%53 = load double, double* %12
%54 = fadd double %52, %53
%55 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
store double %54, double* %55
%56 = load double, double* %5
%57 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
%58 = load i32, i32* %57
%59 = sitofp i32 %58 to double
%60 = fsub double %56, %59
%61 = load double, double* %12
%62 = fadd double %60, %61
%63 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
store double %62, double* %63
%64 = load double, double* %6
%65 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
%66 = load i32, i32* %65
%67 = sitofp i32 %66 to double
%68 = fsub double %64, %67
%69 = load double, double* %12
%70 = fadd double %68, %69
%71 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
store double %70, double* %71
%72 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%73 = load double, double* %72
%74 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%75 = load double, double* %74
%76 = fcmp oge double %73, %75
br i1 %76, label %77, label %85
77: ; preds = %3
%78 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%79 = load double, double* %78
%80 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%81 = load double, double* %80
%82 = fcmp oge double %79, %81
%83 = zext i1 %82 to i64
%84 = select i1 %82, i32 0, i32 1
br label %93
85: ; preds = %3
%86 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%87 = load double, double* %86
%88 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%89 = load double, double* %88
%90 = fcmp oge double %87, %89
%91 = zext i1 %90 to i64
%92 = select i1 %90, i32 1, i32 2
br label %93
93: ; preds = %85, %77
%94 = phi i32 [ %84, %77 ], [ %92, %85 ]
store i32 %94, i32* %7
%95 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%96 = load double, double* %95
%97 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%98 = load double, double* %97
%99 = fcmp olt double %96, %98
br i1 %99, label %100, label %108
100: ; preds = %93
%101 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%102 = load double, double* %101
%103 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%104 = load double, double* %103
%105 = fcmp olt double %102, %104
%106 = zext i1 %105 to i64
%107 = select i1 %105, i32 0, i32 1
br label %116
108: ; preds = %93
%109 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%110 = load double, double* %109
%111 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%112 = load double, double* %111
%113 = fcmp olt double %110, %112
%114 = zext i1 %113 to i64
%115 = select i1 %113, i32 1, i32 2
br label %116
116: ; preds = %108, %100
%117 = phi i32 [ %107, %100 ], [ %115, %108 ]
store i32 %117, i32* %9
%118 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%119 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%120 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%121 = load i32, i32* %7
%122 = call double @K(i32* %118, i32* %119, double* %120, i32 %121)
%123 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%124 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%125 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%126 = load i32, i32* %7
%127 = sub nsw i32 3, %126
%128 = load i32, i32* %9
%129 = sub nsw i32 %127, %128
%130 = call double @K(i32* %123, i32* %124, double* %125, i32 %129)
%131 = fadd double %122, %130
%132 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%133 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%134 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%135 = load i32, i32* %9
%136 = call double @K(i32* %132, i32* %133, double* %134, i32 %135)
%137 = fadd double %131, %136
%138 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%139 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%140 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%141 = call double @K(i32* %138, i32* %139, double* %140, i32 0)
%142 = fadd double %137, %141
ret double %142
}

LLVM IR (-O2):
define double @noise_sample(double %0, double %1, double %2) {
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = alloca [3 x double]
%7 = bitcast [3 x i32]* %4 to i8*
%8 = bitcast [3 x i32]* %5 to i8*
%9 = bitcast [3 x double]* %6 to i8*
%10 = fadd double %0, %1
%11 = fadd double %10, %2
%12 = fdiv double %11, 3.000000e+00
%13 = fadd double %12, %0
%14 = tail call i64 @floor(double %13)
%15 = trunc i64 %14 to i32
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
store i32 %15, i32* %16
%17 = fadd double %12, %1
%18 = tail call i64 @floor(double %17)
%19 = trunc i64 %18 to i32
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 1
store i32 %19, i32* %20
%21 = fadd double %12, %2
%22 = tail call i64 @floor(double %21)
%23 = trunc i64 %22 to i32
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 2
store i32 %23, i32* %24
%25 = add i32 %15, %23
%26 = add i32 %25, %19
%27 = sitofp i32 %26 to double
%28 = fdiv double %27, 6.000000e+00
%29 = sitofp i32 %15 to double
%30 = fsub double %0, %29
%31 = fadd double %30, %28
%32 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
store double %31, double* %32
%33 = sitofp i32 %19 to double
%34 = fsub double %1, %33
%35 = fadd double %34, %28
%36 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
store double %35, double* %36
%37 = sitofp i32 %23 to double
%38 = fsub double %2, %37
%39 = fadd double %38, %28
%40 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %39, double* %40
%41 = fcmp ult double %31, %39
%42 = fcmp ult double %31, %35
%43 = zext i1 %42 to i32
%44 = fcmp oge double %35, %39
%45 = select i1 %44, i32 1, i32 2
%46 = select i1 %41, i32 %45, i32 %43
%47 = fcmp olt double %31, %39
%48 = fcmp uge double %31, %35
%49 = zext i1 %48 to i32
%50 = fcmp olt double %35, %39
%51 = select i1 %50, i32 1, i32 2
%52 = select i1 %47, i32 %49, i32 %51
%53 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%54 = call double @K(i32* %53, i32* %16, double* %32, i32 %46)
%55 = xor i32 %46, 3
%56 = sub nsw i32 %55, %52
%57 = call double @K(i32* %53, i32* %16, double* %32, i32 %56)
%58 = fadd double %54, %57
%59 = call double @K(i32* %53, i32* %16, double* %32, i32 %52)
%60 = fadd double %58, %59
%61 = call double @K(i32* %53, i32* %16, double* %32, i32 0)
%62 = fadd double %60, %61
ret double %62
}