#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 absAngle(double);
void calcBisector(double currCourse, const double nextCourse, double *bisector,
                  double *bisectorOpposite) {
  currCourse = absAngle(currCourse + M_PI);
  double diff = currCourse - nextCourse;
  if (diff > 0) {
    diff = absAngle(diff);
    *bisector = absAngle(currCourse - diff / 2);
  } else {
    diff = absAngle(-diff);
    *bisector = absAngle(currCourse + diff / 2);
  }
  *bisectorOpposite = absAngle(*bisector + M_PI);
}


x86 assembly (clang, -O0):
<calcBisector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2eb2(%rip),%rax
addsd  (%rax),%xmm0
call   1030 <absAngle@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a0 <calcBisector+0x90>
movsd  -0x28(%rbp),%xmm0
call   1030 <absAngle@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe7a(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
call   1030 <absAngle@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11ed <calcBisector+0xdd>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <absAngle@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe28(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
call   1030 <absAngle@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2dec(%rip),%rax
addsd  (%rax),%xmm0
call   1030 <absAngle@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcBisector>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm1,0x8(%rsp)
mov    0x2ebc(%rip),%r15
addsd  (%r15),%xmm0
call   1030 <absAngle@plt>
movsd  %xmm0,(%rsp)
subsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    115a <calcBisector+0x4a>
call   1030 <absAngle@plt>
mulsd  0xec0(%rip),%xmm0
jmp    116f <calcBisector+0x5f>
xorpd  0xe9e(%rip),%xmm0
call   1030 <absAngle@plt>
mulsd  0xea1(%rip),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <absAngle@plt>
movsd  %xmm0,(%rbx)
addsd  (%r15),%xmm0
call   1030 <absAngle@plt>
movsd  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @calcBisector(double %0, double %1, double* %2, double* %3) {
%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
store double* %3, double** %8
%10 = load double, double* %5
%11 = load double, double* @M_PI
%12 = fadd double %10, %11
%13 = call double @absAngle(double %12)
store double %13, double* %5
%14 = load double, double* %5
%15 = load double, double* %6
%16 = fsub double %14, %15
store double %16, double* %9
%17 = load double, double* %9
%18 = fcmp ogt double %17, 0.000000e+00
br i1 %18, label %19, label %28
19: ; preds = %4
%20 = load double, double* %9
%21 = call double @absAngle(double %20)
store double %21, double* %9
%22 = load double, double* %5
%23 = load double, double* %9
%24 = fdiv double %23, 2.000000e+00
%25 = fsub double %22, %24
%26 = call double @absAngle(double %25)
%27 = load double*, double** %7
store double %26, double* %27
br label %38
28: ; preds = %4
%29 = load double, double* %9
%30 = fneg double %29
%31 = call double @absAngle(double %30)
store double %31, double* %9
%32 = load double, double* %5
%33 = load double, double* %9
%34 = fdiv double %33, 2.000000e+00
%35 = fadd double %32, %34
%36 = call double @absAngle(double %35)
%37 = load double*, double** %7
store double %36, double* %37
br label %38
38: ; preds = %28, %19
%39 = load double*, double** %7
%40 = load double, double* %39
%41 = load double, double* @M_PI
%42 = fadd double %40, %41
%43 = call double @absAngle(double %42)
%44 = load double*, double** %8
store double %43, double* %44
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @calcBisector(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = load double, double* @M_PI
%6 = fadd double %5, %0
%7 = tail call double @absAngle(double %6)
%8 = fsub double %7, %1
%9 = fcmp ogt double %8, 0.000000e+00
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = tail call double @absAngle(double %8)
%12 = fmul double %11, 5.000000e-01
%13 = fsub double %7, %12
br label %19
14: ; preds = %4
%15 = fneg double %8
%16 = tail call double @absAngle(double %15)
%17 = fmul double %16, 5.000000e-01
%18 = fadd double %7, %17
br label %19
19: ; preds = %14, %10
%20 = phi double [ %18, %14 ], [ %13, %10 ]
%21 = tail call double @absAngle(double %20)
store double %21, double* %2
%22 = load double, double* @M_PI
%23 = fadd double %21, %22
%24 = tail call double @absAngle(double %23)
store double %24, double* %3
ret void
}