#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 M_PI;
double cos(double);
int /*<<< orphan*/ round(double);
double sign_flat(int /*<<< orphan*/);
double sin(double);
double dg_wobble(double frac_x, double frac_y, double mscale, double mrscale) {
  double r =
      sign_flat(round((cos(2.0 * M_PI * frac_x) * sin(2.0 * M_PI * frac_y)) *
                      mscale)) *
      mrscale;
  return r;
}


x86 assembly (clang, -O0):
<dg_wobble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  0xe9c(%rip),%xmm0
mov    0x2e7d(%rip),%rax
mulsd  (%rax),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe7a(%rip),%xmm0
mov    0x2e5b(%rip),%rax
mulsd  (%rax),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1060 <round@plt>
mov    %eax,%edi
call   1030 <sign_flat@plt>
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dg_wobble>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
mov    0x2e8a(%rip),%rbx
movsd  (%rbx),%xmm1
addsd  %xmm1,%xmm1
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  (%rbx),%xmm0
addsd  %xmm0,%xmm0
mulsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  (%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1060 <round@plt>
mov    %eax,%edi
call   1030 <sign_flat@plt>
mulsd  0x18(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @dg_wobble(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%10 = load double, double* @M_PI
%11 = fmul double 2.000000e+00, %10
%12 = load double, double* %5
%13 = fmul double %11, %12
%14 = call double @cos(double %13)
%15 = load double, double* @M_PI
%16 = fmul double 2.000000e+00, %15
%17 = load double, double* %6
%18 = fmul double %16, %17
%19 = call double @sin(double %18)
%20 = fmul double %14, %19
%21 = load double, double* %7
%22 = fmul double %20, %21
%23 = call i32 @round(double %22)
%24 = call double @sign_flat(i32 %23)
%25 = load double, double* %8
%26 = fmul double %24, %25
store double %26, double* %9
%27 = load double, double* %9
ret double %27
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @dg_wobble(double %0, double %1, double %2, double %3) {
%5 = load double, double* @M_PI
%6 = fmul double %5, 2.000000e+00
%7 = fmul double %6, %0
%8 = tail call double @cos(double %7)
%9 = load double, double* @M_PI
%10 = fmul double %9, 2.000000e+00
%11 = fmul double %10, %1
%12 = tail call double @sin(double %11)
%13 = fmul double %8, %12
%14 = fmul double %13, %2
%15 = tail call i32 @round(double %14)
%16 = tail call double @sign_flat(i32 %15)
%17 = fmul double %16, %3
ret double %17
}