#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 */
scalar_t__ contains_angle(double, double, double);
double get_arc_angle(double start_angle, double intermediate_angle,
                     double end_angle) {
  if (start_angle < 0) {
    start_angle += 360;
  }
  if (intermediate_angle < 0) {
    intermediate_angle += 360;
  }
  if (end_angle < 0) {
    end_angle += 360;
  }
  double arcAngle = end_angle - start_angle;
  if (start_angle < end_angle) {
    return contains_angle(start_angle, arcAngle, intermediate_angle)
               ? arcAngle
               : arcAngle - 360;
  } else {
    return contains_angle(start_angle, arcAngle + 360, intermediate_angle)
               ? arcAngle + 360
               : arcAngle;
  }
}


x86 assembly (clang, -O0):
<get_arc_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1147 <get_arc_angle+0x37>
movsd  0xec3(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1167 <get_arc_angle+0x57>
movsd  0xea3(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1187 <get_arc_angle+0x77>
movsd  0xe83(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11fc <get_arc_angle+0xec>
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <contains_angle@plt>
cmp    $0x0,%rax
je     11d7 <get_arc_angle+0xc7>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11ed <get_arc_angle+0xdd>
movsd  -0x28(%rbp),%xmm0
movsd  0xe1c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124d <get_arc_angle+0x13d>
movsd  -0x10(%rbp),%xmm0
movsd  0xdf7(%rip),%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <contains_angle@plt>
cmp    $0x0,%rax
je     1239 <get_arc_angle+0x129>
movsd  0xdd6(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1243 <get_arc_angle+0x133>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_arc_angle>:
sub    $0x18,%rsp
movapd %xmm2,%xmm3
movapd %xmm0,%xmm2
movsd  0xedc(%rip),%xmm4
movapd %xmm0,%xmm5
addsd  %xmm4,%xmm5
xorpd  %xmm6,%xmm6
cmpltsd %xmm6,%xmm0
andpd  %xmm0,%xmm5
andnpd %xmm2,%xmm0
orpd   %xmm5,%xmm0
movapd %xmm1,%xmm5
addsd  %xmm4,%xmm5
movapd %xmm1,%xmm2
cmpltsd %xmm6,%xmm2
andpd  %xmm2,%xmm5
andnpd %xmm1,%xmm2
orpd   %xmm5,%xmm2
addsd  %xmm3,%xmm4
movapd %xmm3,%xmm1
cmpltsd %xmm6,%xmm1
andpd  %xmm1,%xmm4
andnpd %xmm3,%xmm1
orpd   %xmm4,%xmm1
ucomisd %xmm0,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
jbe    1199 <get_arc_angle+0x89>
call   1030 <contains_angle@plt>
test   %rax,%rax
je     11c8 <get_arc_angle+0xb8>
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0xe5f(%rip),%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,0x10(%rsp)
movapd %xmm3,%xmm1
call   1030 <contains_angle@plt>
movaps (%rsp),%xmm0
test   %rax,%rax
je     11c3 <get_arc_angle+0xb3>
movsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
movapd (%rsp),%xmm0
addsd  0xe33(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @get_arc_angle(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%9 = load double, double* %5
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load double, double* %5
%13 = fadd double %12, 3.600000e+02
store double %13, double* %5
br label %14
14: ; preds = %11, %3
%15 = load double, double* %6
%16 = fcmp olt double %15, 0.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load double, double* %6
%19 = fadd double %18, 3.600000e+02
store double %19, double* %6
br label %20
20: ; preds = %17, %14
%21 = load double, double* %7
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load double, double* %7
%25 = fadd double %24, 3.600000e+02
store double %25, double* %7
br label %26
26: ; preds = %23, %20
%27 = load double, double* %7
%28 = load double, double* %5
%29 = fsub double %27, %28
store double %29, double* %8
%30 = load double, double* %5
%31 = load double, double* %7
%32 = fcmp olt double %30, %31
br i1 %32, label %33, label %46
33: ; preds = %26
%34 = load double, double* %5
%35 = load double, double* %8
%36 = load double, double* %6
%37 = call i64 @contains_angle(double %34, double %35, double %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = load double, double* %8
br label %44
41: ; preds = %33
%42 = load double, double* %8
%43 = fsub double %42, 3.600000e+02
br label %44
44: ; preds = %41, %39
%45 = phi double [ %40, %39 ], [ %43, %41 ]
store double %45, double* %4
br label %60
46: ; preds = %26
%47 = load double, double* %5
%48 = load double, double* %8
%49 = fadd double %48, 3.600000e+02
%50 = load double, double* %6
%51 = call i64 @contains_angle(double %47, double %49, double %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %46
%54 = load double, double* %8
%55 = fadd double %54, 3.600000e+02
br label %58
56: ; preds = %46
%57 = load double, double* %8
br label %58
58: ; preds = %56, %53
%59 = phi double [ %55, %53 ], [ %57, %56 ]
store double %59, double* %4
br label %60
60: ; preds = %58, %44
%61 = load double, double* %4
ret double %61
}

LLVM IR (-O2):
define double @get_arc_angle(double %0, double %1, double %2) {
%4 = fcmp olt double %0, 0.000000e+00
%5 = fadd double %0, 3.600000e+02
%6 = select i1 %4, double %5, double %0
%7 = fcmp olt double %1, 0.000000e+00
%8 = fadd double %1, 3.600000e+02
%9 = select i1 %7, double %8, double %1
%10 = fcmp olt double %2, 0.000000e+00
%11 = fadd double %2, 3.600000e+02
%12 = select i1 %10, double %11, double %2
%13 = fsub double %12, %6
%14 = fcmp olt double %6, %12
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = tail call i64 @contains_angle(double %6, double %13, double %9)
%17 = icmp eq i64 %16, 0
%18 = fadd double %13, -3.600000e+02
%19 = select i1 %17, double %18, double %13
br label %25
20: ; preds = %3
%21 = fadd double %13, 3.600000e+02
%22 = tail call i64 @contains_angle(double %6, double %21, double %9)
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, double %13, double %21
br label %25
25: ; preds = %20, %15
%26 = phi double [ %19, %15 ], [ %24, %20 ]
ret double %26
}