#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
int M_PI;
double fmod(double, int);
double sin(double);
void plasmaFunction(int32_t *x_retval, int32_t *y_retval, unsigned int x,
                    unsigned int y, unsigned int w, unsigned int h, double amp,
                    double freq, double t) {
  double time = fmod(t, 2 * M_PI);
  double h_ = (double)h - 1;
  double w_ = (double)w - 1;
  double dx = (-4. / (w_ * w_) * x + 4. / w_) * x;
  double dy = (-4. / (h_ * h_) * y + 4. / h_) * y;
  *x_retval = (int32_t)(65536.0 * ((double)x + amp * (w / 4) * dx *
                                                   sin(freq * y / h + time)));
  *y_retval = (int32_t)(65536.0 * ((double)y + amp * (h / 4) * dy *
                                                   sin(freq * x / w + time)));
}


x86 assembly (clang, -O0):
<plasmaFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
movsd  %xmm2,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
add    %edi,%edi
call   1030 <fmod@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe8e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm5
movaps %xmm5,%xmm2
mulsd  %xmm2,%xmm2
movsd  0xe68(%rip),%xmm0
movaps %xmm0,%xmm1
divsd  %xmm2,%xmm1
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm3
movsd  0xe59(%rip),%xmm2
movaps %xmm2,%xmm4
divsd  %xmm5,%xmm4
mulsd  %xmm3,%xmm1
addsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm3
movaps %xmm3,%xmm1
mulsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm3,%xmm2
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
shr    $0x2,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  -0x80(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd86(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%eax
shr    $0x2,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd04(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plasmaFunction>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %r9d,%ebp
mov    %r8d,%ebx
mov    %ecx,%r13d
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
add    %edi,%edi
movapd %xmm2,%xmm0
call   1030 <fmod@plt>
movapd %xmm0,%xmm8
movsd  %xmm0,0x30(%rsp)
mov    %ebp,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
movsd  0xe83(%rip),%xmm1
mov    %r13d,%eax
cvtsi2sd %rax,%xmm9
movapd %xmm9,%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm2
mov    %ebx,%eax
cvtsi2sd %rax,%xmm3
movsd  %xmm3,0x38(%rsp)
addsd  %xmm3,%xmm1
movsd  0xe5f(%rip),%xmm3
movapd %xmm3,%xmm7
divsd  %xmm1,%xmm7
mulsd  %xmm1,%xmm1
movsd  0xe43(%rip),%xmm5
movapd %xmm5,%xmm4
mov    %r12d,%eax
cvtsi2sd %rax,%xmm6
movsd  %xmm6,0x20(%rsp)
divsd  %xmm1,%xmm4
mulsd  %xmm6,%xmm4
addsd  %xmm7,%xmm4
mulsd  %xmm6,%xmm4
divsd  %xmm2,%xmm3
mulsd  %xmm2,%xmm2
divsd  %xmm2,%xmm5
movsd  %xmm9,0x40(%rsp)
mulsd  %xmm9,%xmm5
addsd  %xmm3,%xmm5
shr    $0x2,%ebx
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  %xmm9,%xmm5
movsd  %xmm5,0x28(%rsp)
mulsd  0x8(%rsp),%xmm1
mulsd  %xmm4,%xmm1
movsd  %xmm1,0x18(%rsp)
addsd  %xmm8,%xmm0
call   1040 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm2
addsd  %xmm2,%xmm0
mulsd  0xdce(%rip),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,(%r15)
shr    $0x2,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x8(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm2,%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0x38(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x40(%rsp),%xmm0
mulsd  0xd7b(%rip),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define void @plasmaFunction(i64* %0, i64* %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6, double %7, double %8) {
%10 = alloca i64*
%11 = alloca i64*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store i64* %0, i64** %10
store i64* %1, i64** %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store double %6, double* %16
store double %7, double* %17
store double %8, double* %18
%24 = load double, double* %18
%25 = load i32, i32* @M_PI
%26 = mul nsw i32 2, %25
%27 = call double @fmod(double %24, i32 %26)
store double %27, double* %19
%28 = load i32, i32* %15
%29 = uitofp i32 %28 to double
%30 = fsub double %29, 1.000000e+00
store double %30, double* %20
%31 = load i32, i32* %14
%32 = uitofp i32 %31 to double
%33 = fsub double %32, 1.000000e+00
store double %33, double* %21
%34 = load double, double* %21
%35 = load double, double* %21
%36 = fmul double %34, %35
%37 = fdiv double -4.000000e+00, %36
%38 = load i32, i32* %12
%39 = uitofp i32 %38 to double
%40 = load double, double* %21
%41 = fdiv double 4.000000e+00, %40
%42 = call double @llvm.fmuladd.f64(double %37, double %39, double %41)
%43 = load i32, i32* %12
%44 = uitofp i32 %43 to double
%45 = fmul double %42, %44
store double %45, double* %22
%46 = load double, double* %20
%47 = load double, double* %20
%48 = fmul double %46, %47
%49 = fdiv double -4.000000e+00, %48
%50 = load i32, i32* %13
%51 = uitofp i32 %50 to double
%52 = load double, double* %20
%53 = fdiv double 4.000000e+00, %52
%54 = call double @llvm.fmuladd.f64(double %49, double %51, double %53)
%55 = load i32, i32* %13
%56 = uitofp i32 %55 to double
%57 = fmul double %54, %56
store double %57, double* %23
%58 = load i32, i32* %12
%59 = uitofp i32 %58 to double
%60 = load double, double* %16
%61 = load i32, i32* %14
%62 = udiv i32 %61, 4
%63 = uitofp i32 %62 to double
%64 = fmul double %60, %63
%65 = load double, double* %22
%66 = fmul double %64, %65
%67 = load double, double* %17
%68 = load i32, i32* %13
%69 = uitofp i32 %68 to double
%70 = fmul double %67, %69
%71 = load i32, i32* %15
%72 = uitofp i32 %71 to double
%73 = fdiv double %70, %72
%74 = load double, double* %19
%75 = fadd double %73, %74
%76 = call double @sin(double %75)
%77 = call double @llvm.fmuladd.f64(double %66, double %76, double %59)
%78 = fmul double 6.553600e+04, %77
%79 = fptosi double %78 to i64
%80 = load i64*, i64** %10
store i64 %79, i64* %80
%81 = load i32, i32* %13
%82 = uitofp i32 %81 to double
%83 = load double, double* %16
%84 = load i32, i32* %15
%85 = udiv i32 %84, 4
%86 = uitofp i32 %85 to double
%87 = fmul double %83, %86
%88 = load double, double* %23
%89 = fmul double %87, %88
%90 = load double, double* %17
%91 = load i32, i32* %12
%92 = uitofp i32 %91 to double
%93 = fmul double %90, %92
%94 = load i32, i32* %14
%95 = uitofp i32 %94 to double
%96 = fdiv double %93, %95
%97 = load double, double* %19
%98 = fadd double %96, %97
%99 = call double @sin(double %98)
%100 = call double @llvm.fmuladd.f64(double %89, double %99, double %82)
%101 = fmul double 6.553600e+04, %100
%102 = fptosi double %101 to i64
%103 = load i64*, i64** %11
store i64 %102, i64* %103
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @plasmaFunction(i64* nocapture writeonly %0, i64* nocapture writeonly %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6, double %7, double %8) {
%10 = load i32, i32* @M_PI
%11 = shl nsw i32 %10, 1
%12 = tail call double @fmod(double %8, i32 %11)
%13 = uitofp i32 %5 to double
%14 = fadd double %13, -1.000000e+00
%15 = uitofp i32 %4 to double
%16 = fadd double %15, -1.000000e+00
%17 = fmul double %16, %16
%18 = fdiv double -4.000000e+00, %17
%19 = uitofp i32 %2 to double
%20 = fdiv double 4.000000e+00, %16
%21 = tail call double @llvm.fmuladd.f64(double %18, double %19, double %20)
%22 = fmul double %21, %19
%23 = fmul double %14, %14
%24 = fdiv double -4.000000e+00, %23
%25 = uitofp i32 %3 to double
%26 = fdiv double 4.000000e+00, %14
%27 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %26)
%28 = fmul double %27, %25
%29 = lshr i32 %4, 2
%30 = uitofp i32 %29 to double
%31 = fmul double %30, %6
%32 = fmul double %31, %22
%33 = fmul double %25, %7
%34 = fdiv double %33, %13
%35 = fadd double %34, %12
%36 = tail call double @sin(double %35)
%37 = tail call double @llvm.fmuladd.f64(double %32, double %36, double %19)
%38 = fmul double %37, 6.553600e+04
%39 = fptosi double %38 to i64
store i64 %39, i64* %0
%40 = lshr i32 %5, 2
%41 = uitofp i32 %40 to double
%42 = fmul double %41, %6
%43 = fmul double %42, %28
%44 = fmul double %19, %7
%45 = fdiv double %44, %15
%46 = fadd double %45, %12
%47 = tail call double @sin(double %46)
%48 = tail call double @llvm.fmuladd.f64(double %43, double %47, double %25)
%49 = fmul double %48, 6.553600e+04
%50 = fptosi double %49 to i64
store i64 %50, i64* %1
ret void
}