#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 getCircleLen(double r, double a_s, double a_e) {
  double tmp;
  if (a_s > a_e) {
    if (r < 0.0)
      tmp = a_s - a_e;
    else
      tmp = 360.0 + a_e - a_s;
  } else {
    if (r > 0.0)
      tmp = a_e - a_s;
    else
      tmp = 360.0 + a_s - a_e;
  }
  tmp = fabs(r * tmp * 2.0 * 3.1416 / 360.0);
  if (tmp < 1.0)
    tmp = fabs(r) * 2.0 * 3.1416;
  return tmp;
}


x86 assembly (clang, -O0):
<getCircleLen>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1161 <getCircleLen+0x61>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1145 <getCircleLen+0x45>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    115c <getCircleLen+0x5c>
movsd  0xeb3(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11a3 <getCircleLen+0xa3>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1187 <getCircleLen+0x87>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    119e <getCircleLen+0x9e>
movsd  0xe71(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11a3 <getCircleLen+0xa3>
movsd  -0x8(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xe63(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe4f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe33(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps 0xe48(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe1f(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1221 <getCircleLen+0x121>
movsd  -0x8(%rbp),%xmm0
movaps 0xe20(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe0c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf8(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCircleLen>:
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm1
jbe    111a <getCircleLen+0x1a>
ucomisd %xmm0,%xmm3
ja     1132 <getCircleLen+0x32>
addsd  0xee8(%rip),%xmm2
jmp    1120 <getCircleLen+0x20>
ucomisd %xmm3,%xmm0
jbe    112a <getCircleLen+0x2a>
subsd  %xmm1,%xmm2
movapd %xmm2,%xmm1
jmp    1136 <getCircleLen+0x36>
addsd  0xece(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  0xec2(%rip),%xmm3
mulsd  %xmm3,%xmm1
divsd  0xeae(%rip),%xmm1
movapd 0xec6(%rip),%xmm2
andpd  %xmm2,%xmm1
andpd  %xmm2,%xmm0
addsd  %xmm0,%xmm0
movapd %xmm1,%xmm2
cmpltsd 0xe9d(%rip),%xmm2
mulsd  %xmm3,%xmm0
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movapd %xmm2,%xmm0
ret

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

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