#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 normalize_angle(double);
int contains_angle(double start_angle, double arc_angle, double target_angle) {
  if (arc_angle >= 360.0 || arc_angle <= -360.0) {
    return 1;
  }
  start_angle = normalize_angle(start_angle);
  double endAngle = start_angle + arc_angle;
  double theta2 = normalize_angle(target_angle);
  if (arc_angle >= 0.0) {
    if ((endAngle > 180.0) && (theta2 < start_angle)) {
      return theta2 + 360 <= endAngle;
    } else {
      return ((theta2 >= start_angle) && (theta2 <= endAngle));
    }
  } else {
    if ((endAngle <= -180.0) && (theta2 >= start_angle)) {
      return theta2 - 360.0 >= endAngle;
    } else {
      return (theta2 >= endAngle) && (theta2 <= start_angle);
    }
  }
}


x86 assembly (clang, -O0):
<contains_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xecc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1151 <contains_angle+0x41>
movsd  0xec2(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     115d <contains_angle+0x4d>
movl   $0x1,-0x4(%rbp)
jmp    12a3 <contains_angle+0x193>
movsd  -0x10(%rbp),%xmm0
call   1030 <normalize_angle@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <normalize_angle@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1226 <contains_angle+0x116>
movsd  -0x28(%rbp),%xmm0
movsd  0xe6f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ed <contains_angle+0xdd>
movsd  -0x30(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ed <contains_angle+0xdd>
movsd  0xe31(%rip),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <contains_angle+0x193>
movsd  -0x30(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x31(%rbp)
jb     1216 <contains_angle+0x106>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <contains_angle+0x193>
movsd  0xde2(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     126f <contains_angle+0x15f>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     126f <contains_angle+0x15f>
movsd  -0x30(%rbp),%xmm0
movsd  0xdaa(%rip),%xmm1
subsd  %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <contains_angle+0x193>
movsd  -0x30(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x28(%rbp),%xmm0
mov    %al,-0x32(%rbp)
jb     1298 <contains_angle+0x188>
movsd  -0x30(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<contains_angle>:
sub    $0x28,%rsp
ucomisd 0xee4(%rip),%xmm1
mov    $0x1,%eax
jae    11f9 <contains_angle+0xe9>
movsd  0xed9(%rip),%xmm3
ucomisd %xmm1,%xmm3
jae    11f9 <contains_angle+0xe9>
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x20(%rsp)
call   1030 <normalize_angle@plt>
movsd  %xmm0,0x10(%rsp)
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <normalize_angle@plt>
xorpd  %xmm1,%xmm1
movsd  0x18(%rsp),%xmm2
ucomisd %xmm1,%xmm2
jae    11ac <contains_angle+0x9c>
movsd  0xe99(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
ucomisd %xmm2,%xmm1
movapd %xmm2,%xmm1
movsd  0x10(%rsp),%xmm2
jb     11d9 <contains_angle+0xc9>
ucomisd %xmm2,%xmm0
jb     11d9 <contains_angle+0xc9>
addsd  0xe65(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
jmp    11f6 <contains_angle+0xe6>
movsd  0x8(%rsp),%xmm1
ucomisd 0xe56(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
jbe    11e6 <contains_angle+0xd6>
ucomisd %xmm0,%xmm2
jbe    11e6 <contains_angle+0xd6>
addsd  0xe30(%rip),%xmm0
ucomisd %xmm0,%xmm1
setae  %al
jmp    11f6 <contains_angle+0xe6>
ucomisd %xmm1,%xmm0
setae  %cl
ucomisd %xmm0,%xmm2
jmp    11f1 <contains_angle+0xe1>
ucomisd %xmm2,%xmm0
setae  %cl
ucomisd %xmm0,%xmm1
setae  %al
and    %cl,%al
movzbl %al,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @contains_angle(double %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%10 = load double, double* %6
%11 = fcmp oge double %10, 3.600000e+02
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load double, double* %6
%14 = fcmp ole double %13, -3.600000e+02
br i1 %14, label %15, label %16
15: ; preds = %12, %3
store i32 1, i32* %4
br label %74
16: ; preds = %12
%17 = load double, double* %5
%18 = call double @normalize_angle(double %17)
store double %18, double* %5
%19 = load double, double* %5
%20 = load double, double* %6
%21 = fadd double %19, %20
store double %21, double* %8
%22 = load double, double* %7
%23 = call double @normalize_angle(double %22)
store double %23, double* %9
%24 = load double, double* %6
%25 = fcmp oge double %24, 0.000000e+00
br i1 %25, label %26, label %50
26: ; preds = %16
%27 = load double, double* %8
%28 = fcmp ogt double %27, 1.800000e+02
br i1 %28, label %29, label %39
29: ; preds = %26
%30 = load double, double* %9
%31 = load double, double* %5
%32 = fcmp olt double %30, %31
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load double, double* %9
%35 = fadd double %34, 3.600000e+02
%36 = load double, double* %8
%37 = fcmp ole double %35, %36
%38 = zext i1 %37 to i32
store i32 %38, i32* %4
br label %74
39: ; preds = %29, %26
%40 = load double, double* %9
%41 = load double, double* %5
%42 = fcmp oge double %40, %41
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load double, double* %9
%45 = load double, double* %8
%46 = fcmp ole double %44, %45
br label %47
47: ; preds = %43, %39
%48 = phi i1 [ false, %39 ], [ %46, %43 ]
%49 = zext i1 %48 to i32
store i32 %49, i32* %4
br label %74
50: ; preds = %16
%51 = load double, double* %8
%52 = fcmp ole double %51, -1.800000e+02
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = load double, double* %9
%55 = load double, double* %5
%56 = fcmp oge double %54, %55
br i1 %56, label %57, label %63
57: ; preds = %53
%58 = load double, double* %9
%59 = fsub double %58, 3.600000e+02
%60 = load double, double* %8
%61 = fcmp oge double %59, %60
%62 = zext i1 %61 to i32
store i32 %62, i32* %4
br label %74
63: ; preds = %53, %50
%64 = load double, double* %9
%65 = load double, double* %8
%66 = fcmp oge double %64, %65
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = load double, double* %9
%69 = load double, double* %5
%70 = fcmp ole double %68, %69
br label %71
71: ; preds = %67, %63
%72 = phi i1 [ false, %63 ], [ %70, %67 ]
%73 = zext i1 %72 to i32
store i32 %73, i32* %4
br label %74
74: ; preds = %71, %57, %47, %33, %15
%75 = load i32, i32* %4
ret i32 %75
}

LLVM IR (-O2):
define i32 @contains_angle(double %0, double %1, double %2) {
%4 = fcmp oge double %1, 3.600000e+02
%5 = fcmp ole double %1, -3.600000e+02
%6 = or i1 %4, %5
br i1 %6, label %37, label %7
7: ; preds = %3
%8 = tail call double @normalize_angle(double %0)
%9 = fadd double %8, %1
%10 = tail call double @normalize_angle(double %2)
%11 = fcmp ult double %1, 0.000000e+00
br i1 %11, label %23, label %12
12: ; preds = %7
%13 = fcmp ogt double %9, 1.800000e+02
%14 = fcmp olt double %10, %8
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = fadd double %10, 3.600000e+02
%18 = fcmp ole double %17, %9
br label %34
19: ; preds = %12
%20 = fcmp oge double %10, %8
%21 = fcmp ole double %10, %9
%22 = and i1 %20, %21
br label %34
23: ; preds = %7
%24 = fcmp ugt double %9, -1.800000e+02
%25 = fcmp ult double %10, %8
%26 = select i1 %24, i1 true, i1 %25
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = fadd double %10, -3.600000e+02
%29 = fcmp oge double %28, %9
br label %34
30: ; preds = %23
%31 = fcmp oge double %10, %9
%32 = fcmp ole double %10, %8
%33 = and i1 %31, %32
br label %34
34: ; preds = %30, %27, %19, %16
%35 = phi i1 [ %18, %16 ], [ %22, %19 ], [ %29, %27 ], [ %33, %30 ]
%36 = zext i1 %35 to i32
br label %37
37: ; preds = %3, %34
%38 = phi i32 [ %36, %34 ], [ 1, %3 ]
ret i32 %38
}