#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 angle(double a, double b) {
  double d;
  if (a > b) {
    if ((d = a - b) < M_PI)
      return d;
    else
      return 2 * M_PI - d;
  } else {
    if ((d = b - a) < M_PI)
      return d;
    else
      return 2 * M_PI - d;
  }
}


x86 assembly (clang, -O0):
<angle>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    118a <angle+0x8a>
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  %xmm1,-0x20(%rbp)
mov    0x2eb4(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1151 <angle+0x51>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f1 <angle+0xf1>
mov    0x2e90(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f1 <angle+0xf1>
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  %xmm1,-0x20(%rbp)
mov    0x2e48(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bd <angle+0xbd>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f1 <angle+0xf1>
mov    0x2e24(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<angle>:
ucomisd %xmm1,%xmm0
jbe    1121 <angle+0x21>
subsd  %xmm1,%xmm0
mov    0x2ed7(%rip),%rax
movsd  (%rax),%xmm1
ucomisd %xmm0,%xmm1
jbe    113b <angle+0x3b>
movapd %xmm0,%xmm1
jmp    1136 <angle+0x36>
subsd  %xmm0,%xmm1
mov    0x2ebc(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1148 <angle+0x48>
movapd %xmm1,%xmm0
ret
addsd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret
addsd  %xmm0,%xmm0
subsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @angle(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = load double, double* %5
%9 = fcmp ogt double %7, %8
br i1 %9, label %10, label %23
10: ; preds = %2
%11 = load double, double* %4
%12 = load double, double* %5
%13 = fsub double %11, %12
store double %13, double* %6
%14 = load double, double* @M_PI
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = load double, double* %6
store double %17, double* %3
br label %36
18: ; preds = %10
%19 = load double, double* @M_PI
%20 = load double, double* %6
%21 = fneg double %20
%22 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %19, double %21)
store double %22, double* %3
br label %36
23: ; preds = %2
%24 = load double, double* %5
%25 = load double, double* %4
%26 = fsub double %24, %25
store double %26, double* %6
%27 = load double, double* @M_PI
%28 = fcmp olt double %26, %27
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = load double, double* %6
store double %30, double* %3
br label %36
31: ; preds = %23
%32 = load double, double* @M_PI
%33 = load double, double* %6
%34 = fneg double %33
%35 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %32, double %34)
store double %35, double* %3
br label %36
36: ; preds = %31, %29, %18, %16
%37 = load double, double* %3
ret double %37
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @angle(double %0, double %1) {
%3 = fcmp ogt double %0, %1
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = fsub double %0, %1
%6 = load double, double* @M_PI
%7 = fcmp olt double %5, %6
br i1 %7, label %18, label %8
8: ; preds = %4
%9 = fneg double %5
%10 = tail call double @llvm.fmuladd.f64(double %6, double 2.000000e+00, double %9)
br label %18
11: ; preds = %2
%12 = fsub double %1, %0
%13 = load double, double* @M_PI
%14 = fcmp olt double %12, %13
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = fneg double %12
%17 = tail call double @llvm.fmuladd.f64(double %13, double 2.000000e+00, double %16)
br label %18
18: ; preds = %11, %4, %15, %8
%19 = phi double [ %10, %8 ], [ %17, %15 ], [ %5, %4 ], [ %12, %11 ]
ret double %19
}