#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 Noise(int, int);
double SmoothNoise(int x, int y) {
  double corners, sides, center;
  corners = (Noise(x - 1, y - 1) + Noise(x + 1, y - 1) + Noise(x - 1, y + 1) +
             Noise(x + 1, y + 1)) /
            16.0;
  sides =
      (Noise(x - 1, y) + Noise(x + 1, y) + Noise(x, y - 1) + Noise(x, y + 1)) /
      8.0;
  center = Noise(x, y) / 4.0;
  return corners + sides + center;
}


x86 assembly (clang, -O0):
<SmoothNoise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <Noise@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <Noise@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
call   1030 <Noise@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
call   1030 <Noise@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe73(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
call   1030 <Noise@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
call   1030 <Noise@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <Noise@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
call   1030 <Noise@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xdef(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <Noise@plt>
movsd  0xdcb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SmoothNoise>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %esi,%r14d
mov    %edi,%r13d
lea    -0x1(%r13),%ebp
lea    -0x1(%r14),%r15d
mov    %ebp,%edi
mov    %r15d,%esi
call   1030 <Noise@plt>
movapd %xmm0,0x40(%rsp)
lea    0x1(%r13),%ebx
mov    %ebx,%edi
mov    %r15d,%esi
call   1030 <Noise@plt>
movapd %xmm0,(%rsp)
lea    0x1(%r14),%r12d
mov    %ebp,%edi
mov    %r12d,%esi
call   1030 <Noise@plt>
movapd %xmm0,0x10(%rsp)
mov    %ebx,%edi
mov    %r12d,%esi
call   1030 <Noise@plt>
movapd %xmm0,0x20(%rsp)
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <Noise@plt>
movapd %xmm0,0x30(%rsp)
mov    %ebx,%edi
mov    %r14d,%esi
call   1030 <Noise@plt>
movapd 0x40(%rsp),%xmm2
unpcklpd 0x30(%rsp),%xmm2
movapd (%rsp),%xmm1
unpcklpd %xmm0,%xmm1
addpd  %xmm2,%xmm1
movapd %xmm1,(%rsp)
mov    %r13d,%edi
mov    %r15d,%esi
call   1030 <Noise@plt>
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
addpd  (%rsp),%xmm1
movapd %xmm1,0x10(%rsp)
mov    %r13d,%edi
mov    %r12d,%esi
call   1030 <Noise@plt>
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
addpd  0x10(%rsp),%xmm1
mulpd  0xe12(%rip),%xmm1
movapd %xmm1,0x20(%rsp)
mov    %r13d,%edi
mov    %r14d,%esi
call   1030 <Noise@plt>
mulsd  0xe09(%rip),%xmm0
movapd 0x20(%rsp),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @SmoothNoise(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
%10 = load i32, i32* %4
%11 = sub nsw i32 %10, 1
%12 = call double @Noise(i32 %9, i32 %11)
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 1
%17 = call double @Noise(i32 %14, i32 %16)
%18 = fadd double %12, %17
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 1
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
%23 = call double @Noise(i32 %20, i32 %22)
%24 = fadd double %18, %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
%29 = call double @Noise(i32 %26, i32 %28)
%30 = fadd double %24, %29
%31 = fdiv double %30, 1.600000e+01
store double %31, double* %5
%32 = load i32, i32* %3
%33 = sub nsw i32 %32, 1
%34 = load i32, i32* %4
%35 = call double @Noise(i32 %33, i32 %34)
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
%38 = load i32, i32* %4
%39 = call double @Noise(i32 %37, i32 %38)
%40 = fadd double %35, %39
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = sub nsw i32 %42, 1
%44 = call double @Noise(i32 %41, i32 %43)
%45 = fadd double %40, %44
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
%49 = call double @Noise(i32 %46, i32 %48)
%50 = fadd double %45, %49
%51 = fdiv double %50, 8.000000e+00
store double %51, double* %6
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = call double @Noise(i32 %52, i32 %53)
%55 = fdiv double %54, 4.000000e+00
store double %55, double* %7
%56 = load double, double* %5
%57 = load double, double* %6
%58 = fadd double %56, %57
%59 = load double, double* %7
%60 = fadd double %58, %59
ret double %60
}

LLVM IR (-O2):
define double @SmoothNoise(i32 %0, i32 %1) {
%3 = add nsw i32 %0, -1
%4 = add nsw i32 %1, -1
%5 = tail call double @Noise(i32 %3, i32 %4)
%6 = add nsw i32 %0, 1
%7 = tail call double @Noise(i32 %6, i32 %4)
%8 = add nsw i32 %1, 1
%9 = tail call double @Noise(i32 %3, i32 %8)
%10 = tail call double @Noise(i32 %6, i32 %8)
%11 = tail call double @Noise(i32 %3, i32 %1)
%12 = tail call double @Noise(i32 %6, i32 %1)
%13 = insertelement <2 x double> poison, double %5, i64 0
%14 = insertelement <2 x double> %13, double %11, i64 1
%15 = insertelement <2 x double> poison, double %7, i64 0
%16 = insertelement <2 x double> %15, double %12, i64 1
%17 = fadd <2 x double> %14, %16
%18 = tail call double @Noise(i32 %0, i32 %4)
%19 = insertelement <2 x double> poison, double %9, i64 0
%20 = insertelement <2 x double> %19, double %18, i64 1
%21 = fadd <2 x double> %17, %20
%22 = tail call double @Noise(i32 %0, i32 %8)
%23 = insertelement <2 x double> poison, double %10, i64 0
%24 = insertelement <2 x double> %23, double %22, i64 1
%25 = fadd <2 x double> %21, %24
%26 = fmul <2 x double> %25, <double 6.250000e-02, double 1.250000e-01>
%27 = tail call double @Noise(i32 %0, i32 %1)
%28 = fmul double %27, 2.500000e-01
%29 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%30 = fadd <2 x double> %26, %29
%31 = extractelement <2 x double> %30, i64 0
%32 = fadd double %28, %31
ret double %32
}