#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 M_PI;
double wrap_phi(double phi) {
  if (phi < 0)
    return wrap_phi(phi + 2 * M_PI);
  else if (phi >= 2 * M_PI)
    return wrap_phi(phi - 2 * M_PI);
  else
    return phi;
}


x86 assembly (clang, -O0):
<wrap_phi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1153 <wrap_phi+0x43>
movsd  -0x10(%rbp),%xmm0
mov    0x2eb1(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
call   1030 <wrap_phi@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11a4 <wrap_phi+0x94>
movsd  -0x10(%rbp),%xmm0
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
ucomisd %xmm1,%xmm0
jb     119a <wrap_phi+0x8a>
movsd  -0x10(%rbp),%xmm0
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
call   1030 <wrap_phi@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11a4 <wrap_phi+0x94>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wrap_phi>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
cvtsi2sd %eax,%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jbe    112a <wrap_phi+0x2a>
nopl   0x0(%rax)
addsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
ja     1120 <wrap_phi+0x20>
ucomisd %xmm1,%xmm0
jb     113c <wrap_phi+0x3c>
subsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    112a <wrap_phi+0x2a>
jmp    1120 <wrap_phi+0x20>
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @wrap_phi(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp olt double %4, 0.000000e+00
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load double, double* %3
%8 = load i32, i32* @M_PI
%9 = mul nsw i32 2, %8
%10 = sitofp i32 %9 to double
%11 = fadd double %7, %10
%12 = call double @wrap_phi(double %11)
store double %12, double* %2
br label %28
13: ; preds = %1
%14 = load double, double* %3
%15 = load i32, i32* @M_PI
%16 = mul nsw i32 2, %15
%17 = sitofp i32 %16 to double
%18 = fcmp oge double %14, %17
br i1 %18, label %19, label %26
19: ; preds = %13
%20 = load double, double* %3
%21 = load i32, i32* @M_PI
%22 = mul nsw i32 2, %21
%23 = sitofp i32 %22 to double
%24 = fsub double %20, %23
%25 = call double @wrap_phi(double %24)
store double %25, double* %2
br label %28
26: ; preds = %13
%27 = load double, double* %3
store double %27, double* %2
br label %28
28: ; preds = %26, %19, %6
%29 = load double, double* %2
ret double %29
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @wrap_phi(double %0) {
%2 = load i32, i32* @M_PI
%3 = shl nsw i32 %2, 1
%4 = sitofp i32 %3 to double
br label %5
5: ; preds = %10, %1
%6 = phi double [ %0, %1 ], [ %11, %10 ]
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = fadd double %6, %4
br label %10
10: ; preds = %8, %14
%11 = phi double [ %9, %8 ], [ %15, %14 ]
br label %5
12: ; preds = %5
%13 = fcmp ult double %6, %4
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = fsub double %6, %4
br label %10
16: ; preds = %12
ret double %6
}