#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 NAN;
scalar_t__ fabs(double);
scalar_t__ isnan(double);
double removeExtraneous(double *viableOptions) {
  if (!isnan(viableOptions[0]) && !isnan(viableOptions[1])) {
    double option1;
    double option2;
    if (viableOptions[0] > M_PI)
      option1 = viableOptions[0] - 2 * M_PI;
    else
      option1 = viableOptions[0];
    if (viableOptions[1] > M_PI)
      option2 = viableOptions[1] - 2 * M_PI;
    else
      option2 = viableOptions[1];
    if (fabs(option1) <= fabs(option2))
      return viableOptions[0];
    else
      return viableOptions[1];
  } else if (!isnan(viableOptions[0]) && isnan(viableOptions[1]))
    return viableOptions[0];
  else if (isnan(viableOptions[0]) && !isnan(viableOptions[1]))
    return viableOptions[1];
  else
    return NAN;
}


x86 assembly (clang, -O0):
<removeExtraneous>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    1241 <removeExtraneous+0x121>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    1241 <removeExtraneous+0x121>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2e76(%rip),%rax
ucomisd (%rax),%xmm0
jbe    1199 <removeExtraneous+0x79>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2e5d(%rip),%rax
movsd  (%rax),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11a6 <removeExtraneous+0x86>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    0x2e2a(%rip),%rax
ucomisd (%rax),%xmm0
jbe    11e6 <removeExtraneous+0xc6>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    0x2e10(%rip),%rax
movsd  (%rax),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f4 <removeExtraneous+0xd4>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jg     122e <removeExtraneous+0x10e>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d4 <removeExtraneous+0x1b4>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d4 <removeExtraneous+0x1b4>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    1282 <removeExtraneous+0x162>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1282 <removeExtraneous+0x162>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d4 <removeExtraneous+0x1b4>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     12c4 <removeExtraneous+0x1a4>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    12c4 <removeExtraneous+0x1a4>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d4 <removeExtraneous+0x1b4>
mov    0x2d2d(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeExtraneous>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
jne    1149 <removeExtraneous+0x29>
movsd  0x8(%rbx),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
je     1195 <removeExtraneous+0x75>
movsd  (%rbx),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
je     1184 <removeExtraneous+0x64>
movsd  (%rbx),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
je     1178 <removeExtraneous+0x58>
movsd  0x8(%rbx),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
je     120a <removeExtraneous+0xea>
mov    0x2e79(%rip),%rbx
jmp    120e <removeExtraneous+0xee>
movsd  0x8(%rbx),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
jne    120e <removeExtraneous+0xee>
jmp    1157 <removeExtraneous+0x37>
lea    0x8(%rbx),%r15
mov    0x2e40(%rip),%rax
movsd  (%rax),%xmm5
movsd  0xe54(%rip),%xmm1
mulsd  %xmm5,%xmm1
movsd  (%rbx),%xmm2
movsd  0x8(%rbx),%xmm3
movapd %xmm1,%xmm4
addsd  %xmm2,%xmm4
movapd %xmm5,%xmm0
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm4
andnpd %xmm2,%xmm0
orpd   %xmm4,%xmm0
addsd  %xmm3,%xmm1
cmpltsd %xmm3,%xmm5
andpd  %xmm5,%xmm1
andnpd %xmm3,%xmm5
orpd   %xmm1,%xmm5
movapd %xmm5,(%rsp)
call   1030 <fabs@plt>
mov    %rax,%r14
movaps (%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%r14
cmovg  %r15,%rbx
jmp    120e <removeExtraneous+0xee>
add    $0x8,%rbx
movsd  (%rbx),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@NAN = global double 0.000000e+00
define double @removeExtraneous(double* %0) {
%2 = alloca double
%3 = alloca double*
%4 = alloca double
%5 = alloca double
store double* %0, double** %3
%6 = load double*, double** %3
%7 = getelementptr inbounds double, double* %6, i64 0
%8 = load double, double* %7
%9 = call i64 @isnan(double %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %63, label %11
11: ; preds = %1
%12 = load double*, double** %3
%13 = getelementptr inbounds double, double* %12, i64 1
%14 = load double, double* %13
%15 = call i64 @isnan(double %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %63, label %17
17: ; preds = %11
%18 = load double*, double** %3
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = load double, double* @M_PI
%22 = fcmp ogt double %20, %21
br i1 %22, label %23, label %29
23: ; preds = %17
%24 = load double*, double** %3
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = load double, double* @M_PI
%28 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %27, double %26)
store double %28, double* %4
br label %33
29: ; preds = %17
%30 = load double*, double** %3
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
store double %32, double* %4
br label %33
33: ; preds = %29, %23
%34 = load double*, double** %3
%35 = getelementptr inbounds double, double* %34, i64 1
%36 = load double, double* %35
%37 = load double, double* @M_PI
%38 = fcmp ogt double %36, %37
br i1 %38, label %39, label %45
39: ; preds = %33
%40 = load double*, double** %3
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = load double, double* @M_PI
%44 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %43, double %42)
store double %44, double* %5
br label %49
45: ; preds = %33
%46 = load double*, double** %3
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load double, double* %47
store double %48, double* %5
br label %49
49: ; preds = %45, %39
%50 = load double, double* %4
%51 = call i64 @fabs(double %50)
%52 = load double, double* %5
%53 = call i64 @fabs(double %52)
%54 = icmp sle i64 %51, %53
br i1 %54, label %55, label %59
55: ; preds = %49
%56 = load double*, double** %3
%57 = getelementptr inbounds double, double* %56, i64 0
%58 = load double, double* %57
store double %58, double* %2
br label %97
59: ; preds = %49
%60 = load double*, double** %3
%61 = getelementptr inbounds double, double* %60, i64 1
%62 = load double, double* %61
store double %62, double* %2
br label %97
63: ; preds = %11, %1
%64 = load double*, double** %3
%65 = getelementptr inbounds double, double* %64, i64 0
%66 = load double, double* %65
%67 = call i64 @isnan(double %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %79, label %69
69: ; preds = %63
%70 = load double*, double** %3
%71 = getelementptr inbounds double, double* %70, i64 1
%72 = load double, double* %71
%73 = call i64 @isnan(double %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %69
%76 = load double*, double** %3
%77 = getelementptr inbounds double, double* %76, i64 0
%78 = load double, double* %77
store double %78, double* %2
br label %97
79: ; preds = %69, %63
%80 = load double*, double** %3
%81 = getelementptr inbounds double, double* %80, i64 0
%82 = load double, double* %81
%83 = call i64 @isnan(double %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %95
85: ; preds = %79
%86 = load double*, double** %3
%87 = getelementptr inbounds double, double* %86, i64 1
%88 = load double, double* %87
%89 = call i64 @isnan(double %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %95, label %91
91: ; preds = %85
%92 = load double*, double** %3
%93 = getelementptr inbounds double, double* %92, i64 1
%94 = load double, double* %93
store double %94, double* %2
br label %97
95: ; preds = %85, %79
%96 = load double, double* @NAN
store double %96, double* %2
br label %97
97: ; preds = %95, %91, %75, %59, %55
%98 = load double, double* %2
ret double %98
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@NAN = global double 0.000000e+00
define double @removeExtraneous(double* nocapture %0) {
%2 = load double, double* %0
%3 = tail call i64 @isnan(double %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %24
5: ; preds = %1
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = tail call i64 @isnan(double %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %5
%11 = load double, double* %0
%12 = load double, double* @M_PI
%13 = fcmp ogt double %11, %12
%14 = tail call double @llvm.fmuladd.f64(double %12, double -2.000000e+00, double %11)
%15 = select i1 %13, double %14, double %11
%16 = load double, double* %6
%17 = fcmp ogt double %16, %12
%18 = tail call double @llvm.fmuladd.f64(double %12, double -2.000000e+00, double %16)
%19 = select i1 %17, double %18, double %16
%20 = tail call i64 @fabs(double %15)
%21 = tail call i64 @fabs(double %19)
%22 = icmp sgt i64 %20, %21
%23 = select i1 %22, double* %6, double* %0
br label %43
24: ; preds = %5, %1
%25 = load double, double* %0
%26 = tail call i64 @isnan(double %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = getelementptr inbounds double, double* %0, i64 1
%30 = load double, double* %29
%31 = tail call i64 @isnan(double %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %28, %24
%34 = load double, double* %0
%35 = tail call i64 @isnan(double %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %33
%38 = getelementptr inbounds double, double* %0, i64 1
%39 = load double, double* %38
%40 = tail call i64 @isnan(double %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %37, %33
br label %43
43: ; preds = %37, %28, %42, %10
%44 = phi double* [ @NAN, %42 ], [ %23, %10 ], [ %0, %28 ], [ %38, %37 ]
%45 = load double, double* %44
ret double %45
}