#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 raw_noise_4d(float const, float const, float const, float const);
float octave_noise_4d(const float octaves, const float persistence,
                      const float scale, const float x, const float y,
                      const float z, const float w) {
  float total = 0;
  float frequency = scale;
  float amplitude = 1;
  float maxAmplitude = 0;
  for (int i = 0; i < octaves; i++) {
    total += raw_noise_4d(x * frequency, y * frequency, z * frequency,
                          w * frequency) *
             amplitude;
    frequency *= 2;
    maxAmplitude += amplitude;
    amplitude *= persistence;
  }
  return total / maxAmplitude;
}


x86 assembly (clang, -O0):
<octave_noise_4d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  %xmm4,-0x14(%rbp)
movss  %xmm5,-0x18(%rbp)
movss  %xmm6,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xeab(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cvtsi2ssl -0x30(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11fe <octave_noise_4d+0xee>
movss  -0x10(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
mulss  -0x24(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
mulss  -0x24(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm3
mulss  -0x24(%rbp),%xmm3
call   1030 <raw_noise_4d@plt>
movss  -0x28(%rbp),%xmm2
movss  -0x20(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe3c(%rip),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x28(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1169 <octave_noise_4d+0x59>
movss  -0x20(%rbp),%xmm0
divss  -0x2c(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<octave_noise_4d>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm10,%xmm10
ucomiss %xmm10,%xmm0
jbe    1212 <octave_noise_4d+0x102>
movss  0xed9(%rip),%xmm7
mov    $0x1,%ebx
xorps  %xmm9,%xmm9
movss  %xmm6,0x20(%rsp)
movss  %xmm5,0x1c(%rsp)
movss  %xmm4,0x18(%rsp)
movss  %xmm3,0x14(%rsp)
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
movss  %xmm7,0x24(%rsp)
movss  %xmm9,0x28(%rsp)
movss  %xmm10,0x2c(%rsp)
movss  %xmm2,0x8(%rsp)
movaps %xmm2,%xmm0
mulss  %xmm3,%xmm0
movaps %xmm2,%xmm1
mulss  %xmm4,%xmm1
movss  0x8(%rsp),%xmm2
mulss  %xmm5,%xmm2
movss  0x8(%rsp),%xmm3
mulss  %xmm6,%xmm3
call   1030 <raw_noise_4d@plt>
movss  0x24(%rsp),%xmm7
movss  0x28(%rsp),%xmm9
movss  0x10(%rsp),%xmm1
movss  0x2c(%rsp),%xmm10
movss  0x8(%rsp),%xmm2
movss  0x14(%rsp),%xmm3
movss  0x18(%rsp),%xmm4
movss  0x1c(%rsp),%xmm5
movss  0x20(%rsp),%xmm6
mulss  %xmm7,%xmm0
addss  %xmm0,%xmm9
addss  %xmm2,%xmm2
addss  %xmm7,%xmm10
xorps  %xmm8,%xmm8
cvtsi2ss %ebx,%xmm8
mulss  %xmm1,%xmm7
add    $0x1,%ebx
movss  0xc(%rsp),%xmm0
ucomiss %xmm8,%xmm0
ja     1160 <octave_noise_4d+0x50>
divss  %xmm10,%xmm9
jmp    121b <octave_noise_4d+0x10b>
movss  0xde5(%rip),%xmm9
movaps %xmm9,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @octave_noise_4d(float %0, float %1, float %2, float %3, float %4, float %5, float %6) {
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca i32
store float %0, float* %8
store float %1, float* %9
store float %2, float* %10
store float %3, float* %11
store float %4, float* %12
store float %5, float* %13
store float %6, float* %14
store float 0.000000e+00, float* %15
%20 = load float, float* %10
store float %20, float* %16
store float 1.000000e+00, float* %17
store float 0.000000e+00, float* %18
store i32 0, i32* %19
br label %21
21: ; preds = %51, %7
%22 = load i32, i32* %19
%23 = sitofp i32 %22 to float
%24 = load float, float* %8
%25 = fcmp olt float %23, %24
br i1 %25, label %26, label %54
26: ; preds = %21
%27 = load float, float* %11
%28 = load float, float* %16
%29 = fmul float %27, %28
%30 = load float, float* %12
%31 = load float, float* %16
%32 = fmul float %30, %31
%33 = load float, float* %13
%34 = load float, float* %16
%35 = fmul float %33, %34
%36 = load float, float* %14
%37 = load float, float* %16
%38 = fmul float %36, %37
%39 = call float @raw_noise_4d(float %29, float %32, float %35, float %38)
%40 = load float, float* %17
%41 = load float, float* %15
%42 = call float @llvm.fmuladd.f32(float %39, float %40, float %41)
store float %42, float* %15
%43 = load float, float* %16
%44 = fmul float %43, 2.000000e+00
store float %44, float* %16
%45 = load float, float* %17
%46 = load float, float* %18
%47 = fadd float %46, %45
store float %47, float* %18
%48 = load float, float* %9
%49 = load float, float* %17
%50 = fmul float %49, %48
store float %50, float* %17
br label %51
51: ; preds = %26
%52 = load i32, i32* %19
%53 = add nsw i32 %52, 1
store i32 %53, i32* %19
br label %21
54: ; preds = %21
%55 = load float, float* %15
%56 = load float, float* %18
%57 = fdiv float %55, %56
ret float %57
}

LLVM IR (-O2):
define float @octave_noise_4d(float %0, float %1, float %2, float %3, float %4, float %5, float %6) {
%8 = fcmp ogt float %0, 0.000000e+00
br i1 %8, label %13, label %11
9: ; preds = %13
%10 = fdiv float %24, %26
br label %11
11: ; preds = %9, %7
%12 = phi float [ %10, %9 ], [ 0x7FF8000000000000, %7 ]
ret float %12
13: ; preds = %7, %13
%14 = phi i32 [ %28, %13 ], [ 0, %7 ]
%15 = phi float [ %26, %13 ], [ 0.000000e+00, %7 ]
%16 = phi float [ %27, %13 ], [ 1.000000e+00, %7 ]
%17 = phi float [ %25, %13 ], [ %2, %7 ]
%18 = phi float [ %24, %13 ], [ 0.000000e+00, %7 ]
%19 = fmul float %17, %3
%20 = fmul float %17, %4
%21 = fmul float %17, %5
%22 = fmul float %17, %6
%23 = tail call float @raw_noise_4d(float %19, float %20, float %21, float %22)
%24 = tail call float @llvm.fmuladd.f32(float %23, float %16, float %18)
%25 = fmul float %17, 2.000000e+00
%26 = fadd float %16, %15
%27 = fmul float %16, %1
%28 = add nuw nsw i32 %14, 1
%29 = sitofp i32 %28 to float
%30 = fcmp olt float %29, %0
br i1 %30, label %13, label %9
}