#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 */
int noise(int, int);
float smooth_noise(int x, int y) {
  float corners;
  float center;
  float sides;
  corners = (noise(x - 1, y - 1) + noise(x + 1, y - 1) + noise(x - 1, x + 1) +
             noise(x + 1, y + 1)) /
            16;
  sides =
      (noise(x - 1, y) + noise(x + 1, y) + noise(x, y - 1) + noise(x, y + 1)) /
      8;
  center = noise(x, y) / 4;
  return (corners + sides + center);
}


x86 assembly (clang, -O0):
<smooth_noise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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>
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <noise@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x4(%rbp),%esi
add    $0x1,%esi
call   1030 <noise@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
call   1030 <noise@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
call   1030 <noise@plt>
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
call   1030 <noise@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <noise@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
call   1030 <noise@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <noise@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smooth_noise>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %edi,%r12d
lea    -0x1(%r12),%r13d
lea    -0x1(%rsi),%ebp
mov    %ebp,0x8(%rsp)
mov    %r13d,%edi
mov    %ebp,%esi
call   1030 <noise@plt>
mov    %eax,%r14d
lea    0x1(%r12),%ebx
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <noise@plt>
mov    %eax,%r15d
add    %r14d,%r15d
mov    %r13d,%edi
mov    %ebx,%esi
call   1030 <noise@plt>
mov    %eax,%ebp
add    %r15d,%ebp
mov    0x10(%rsp),%r14
lea    0x1(%r14),%r15d
mov    %ebx,%edi
mov    %r15d,%esi
call   1030 <noise@plt>
mov    %ebp,%ecx
add    %eax,%ecx
lea    0xf(%rax,%rbp,1),%eax
cmovns %ecx,%eax
sar    $0x4,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r13d,%edi
mov    %r14d,%esi
call   1030 <noise@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r14d,%esi
call   1030 <noise@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r12d,%edi
mov    0x8(%rsp),%esi
call   1030 <noise@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r12d,%edi
mov    %r15d,%esi
call   1030 <noise@plt>
mov    %ebp,%ecx
add    %eax,%ecx
lea    0x7(%rax,%rbp,1),%eax
cmovns %ecx,%eax
sar    $0x3,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %r12d,%edi
mov    %r14d,%esi
call   1030 <noise@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x2,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
addss  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define float @smooth_noise(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
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 i32 @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 i32 @noise(i32 %14, i32 %16)
%18 = add nsw i32 %12, %17
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 1
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
%23 = call i32 @noise(i32 %20, i32 %22)
%24 = add nsw i32 %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 i32 @noise(i32 %26, i32 %28)
%30 = add nsw i32 %24, %29
%31 = sdiv i32 %30, 16
%32 = sitofp i32 %31 to float
store float %32, float* %5
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 1
%35 = load i32, i32* %4
%36 = call i32 @noise(i32 %34, i32 %35)
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
%39 = load i32, i32* %4
%40 = call i32 @noise(i32 %38, i32 %39)
%41 = add nsw i32 %36, %40
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = sub nsw i32 %43, 1
%45 = call i32 @noise(i32 %42, i32 %44)
%46 = add nsw i32 %41, %45
%47 = load i32, i32* %3
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
%50 = call i32 @noise(i32 %47, i32 %49)
%51 = add nsw i32 %46, %50
%52 = sdiv i32 %51, 8
%53 = sitofp i32 %52 to float
store float %53, float* %7
%54 = load i32, i32* %3
%55 = load i32, i32* %4
%56 = call i32 @noise(i32 %54, i32 %55)
%57 = sdiv i32 %56, 4
%58 = sitofp i32 %57 to float
store float %58, float* %6
%59 = load float, float* %5
%60 = load float, float* %7
%61 = fadd float %59, %60
%62 = load float, float* %6
%63 = fadd float %61, %62
ret float %63
}

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