#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 fabs(double);
double fmod(double, double);
double symm(double x, double n) {
  const double u = fmod(x, 6.28318530717958647693);
  double temp0 = u - 3.14159265358979323846;
  if (fabs(temp0) < (1.0 - n) * 1.57079632679489661923) {
    temp0 /= 1.0 - n;
  } else if (temp0 > 0.0) {
    temp0 =
        3.14159265358979323846 - (3.14159265358979323846 - temp0) / (n + 1.0);
  } else if (temp0 < 0.0) {
    temp0 =
        3.14159265358979323846 + (3.14159265358979323846 + temp0) / (n + 1.0);
  }
  temp0 += 3.14159265358979323846;
  return x - u + temp0;
}


x86 assembly (clang, -O0):
<symm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xee9(%rip),%xmm1
call   1030 <fmod@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xeca(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movaps 0xec5(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xea1(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11a2 <symm+0x92>
movsd  0xe7e(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122f <symm+0x11f>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11e8 <symm+0xd8>
movsd  0xe54(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xe3f(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe36(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122a <symm+0x11a>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1225 <symm+0x115>
movsd  0xe12(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  0xdfd(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdf4(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122a <symm+0x11a>
jmp    122f <symm+0x11f>
movsd  0xdd9(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symm>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  0xede(%rip),%xmm1
movsd  %xmm0,0x10(%rsp)
call   1030 <fmod@plt>
movsd  0x8(%rsp),%xmm5
movsd  0xecd(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd 0xee9(%rip),%xmm3
andpd  %xmm1,%xmm3
movsd  0xebd(%rip),%xmm2
subsd  %xmm5,%xmm2
movsd  0xeb9(%rip),%xmm4
mulsd  %xmm2,%xmm4
ucomisd %xmm3,%xmm4
jbe    116f <symm+0x5f>
divsd  %xmm2,%xmm1
jmp    11c1 <symm+0xb1>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jbe    119f <symm+0x8f>
movsd  0xe9f(%rip),%xmm2
movapd %xmm2,%xmm3
subsd  %xmm1,%xmm3
addsd  0xe7f(%rip),%xmm5
divsd  %xmm5,%xmm3
subsd  %xmm3,%xmm2
movapd %xmm2,%xmm1
jmp    11c1 <symm+0xb1>
ucomisd %xmm1,%xmm2
jbe    11c1 <symm+0xb1>
movsd  0xe73(%rip),%xmm2
addsd  %xmm2,%xmm1
addsd  0xe57(%rip),%xmm5
divsd  %xmm5,%xmm1
addsd  %xmm2,%xmm1
addsd  0xe57(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @symm(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store double %1, double* %4
%7 = load double, double* %3
%8 = call double @fmod(double %7, double 0x401921FB54442D18)
store double %8, double* %5
%9 = load double, double* %5
%10 = fsub double %9, 0x400921FB54442D18
store double %10, double* %6
%11 = load double, double* %6
%12 = call double @llvm.fabs.f64(double %11)
%13 = load double, double* %4
%14 = fsub double 1.000000e+00, %13
%15 = fmul double %14, 0x3FF921FB54442D18
%16 = fcmp olt double %12, %15
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load double, double* %4
%19 = fsub double 1.000000e+00, %18
%20 = load double, double* %6
%21 = fdiv double %20, %19
store double %21, double* %6
br label %44
22: ; preds = %2
%23 = load double, double* %6
%24 = fcmp ogt double %23, 0.000000e+00
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load double, double* %6
%27 = fsub double 0x400921FB54442D18, %26
%28 = load double, double* %4
%29 = fadd double %28, 1.000000e+00
%30 = fdiv double %27, %29
%31 = fsub double 0x400921FB54442D18, %30
store double %31, double* %6
br label %43
32: ; preds = %22
%33 = load double, double* %6
%34 = fcmp olt double %33, 0.000000e+00
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = load double, double* %6
%37 = fadd double 0x400921FB54442D18, %36
%38 = load double, double* %4
%39 = fadd double %38, 1.000000e+00
%40 = fdiv double %37, %39
%41 = fadd double 0x400921FB54442D18, %40
store double %41, double* %6
br label %42
42: ; preds = %35, %32
br label %43
43: ; preds = %42, %25
br label %44
44: ; preds = %43, %17
%45 = load double, double* %6
%46 = fadd double %45, 0x400921FB54442D18
store double %46, double* %6
%47 = load double, double* %3
%48 = load double, double* %5
%49 = fsub double %47, %48
%50 = load double, double* %6
%51 = fadd double %49, %50
ret double %51
}

LLVM IR (-O2):
define double @symm(double %0, double %1) {
%3 = tail call double @fmod(double %0, double 0x401921FB54442D18)
%4 = fadd double %3, 0xC00921FB54442D18
%5 = tail call double @llvm.fabs.f64(double %4)
%6 = fsub double 1.000000e+00, %1
%7 = fmul double %6, 0x3FF921FB54442D18
%8 = fcmp olt double %5, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = fdiv double %4, %6
br label %25
11: ; preds = %2
%12 = fcmp ogt double %4, 0.000000e+00
br i1 %12, label %13, label %18
13: ; preds = %11
%14 = fsub double 0x400921FB54442D18, %4
%15 = fadd double %1, 1.000000e+00
%16 = fdiv double %14, %15
%17 = fsub double 0x400921FB54442D18, %16
br label %25
18: ; preds = %11
%19 = fcmp olt double %4, 0.000000e+00
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = fadd double %4, 0x400921FB54442D18
%22 = fadd double %1, 1.000000e+00
%23 = fdiv double %21, %22
%24 = fadd double %23, 0x400921FB54442D18
br label %25
25: ; preds = %13, %20, %18, %9
%26 = phi double [ %10, %9 ], [ %17, %13 ], [ %24, %20 ], [ %4, %18 ]
%27 = fadd double %26, 0x400921FB54442D18
%28 = fsub double %0, %3
%29 = fadd double %28, %27
ret double %29
}