#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 cos0_hi(double);
double cos0_lo(double);
double sin0_hi(double);
double sin0_lo(double);
double eval_sin(int hilo, int j, double x) {
  if (hilo == 1) {
    switch (j) {
    case 0:
      return (sin0_hi(x));
    case 1:
      if (x < 0)
        return (cos0_hi(x));
      else
        return (cos0_lo(x));
    case 2:
      return (-sin0_hi(x));
    case 3:
      if (x < 0)
        return (-cos0_hi(x));
      else
        return (-cos0_lo(x));
    }
  } else {
    switch (j) {
    case 0:
      return (sin0_lo(x));
    case 1:
      if (x < 0)
        return (cos0_lo(x));
      else
        return (cos0_hi(x));
    case 2:
      return (-sin0_lo(x));
    case 3:
      if (x < 0)
        return (-cos0_lo(x));
      else
        return (-cos0_hi(x));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<eval_sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1260 <eval_sin+0x120>
mov    -0x10(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     125b <eval_sin+0x11b>
mov    -0x20(%rbp),%rax
lea    0xe97(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x18(%rbp),%xmm0
call   1060 <sin0_hi@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11b8 <eval_sin+0x78>
movsd  -0x18(%rbp),%xmm0
call   1030 <cos0_hi@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
movsd  -0x18(%rbp),%xmm0
call   1050 <cos0_lo@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
movsd  -0x18(%rbp),%xmm0
call   1060 <sin0_hi@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1230 <eval_sin+0xf0>
movsd  -0x18(%rbp),%xmm0
call   1030 <cos0_hi@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
movsd  -0x18(%rbp),%xmm0
call   1050 <cos0_lo@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
jmp    1363 <eval_sin+0x223>
mov    -0x10(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     135e <eval_sin+0x21e>
mov    -0x28(%rbp),%rax
lea    0xd84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x18(%rbp),%xmm0
call   1040 <sin0_lo@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    12bb <eval_sin+0x17b>
movsd  -0x18(%rbp),%xmm0
call   1050 <cos0_lo@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
movsd  -0x18(%rbp),%xmm0
call   1030 <cos0_hi@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
movsd  -0x18(%rbp),%xmm0
call   1040 <sin0_lo@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1333 <eval_sin+0x1f3>
movsd  -0x18(%rbp),%xmm0
call   1050 <cos0_lo@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
movsd  -0x18(%rbp),%xmm0
call   1030 <cos0_hi@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136b <eval_sin+0x22b>
jmp    1363 <eval_sin+0x223>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_sin>:
push   %rax
cmp    $0x1,%edi
jne    1163 <eval_sin+0x23>
cmp    $0x3,%esi
ja     1180 <eval_sin+0x40>
mov    %esi,%eax
lea    0xecc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
pop    %rax
jmp    1060 <sin0_hi@plt>
cmp    $0x3,%esi
ja     1180 <eval_sin+0x40>
mov    %esi,%eax
lea    0xe9f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
pop    %rax
jmp    1040 <sin0_lo@plt>
xorps  %xmm0,%xmm0
pop    %rax
ret
call   1060 <sin0_hi@plt>
jmp    11b3 <eval_sin+0x73>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11ae <eval_sin+0x6e>
call   1050 <cos0_lo@plt>
jmp    11b3 <eval_sin+0x73>
call   1040 <sin0_lo@plt>
jmp    11b3 <eval_sin+0x73>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1196 <eval_sin+0x56>
call   1030 <cos0_hi@plt>
xorpd  0xe45(%rip),%xmm0
pop    %rax
ret
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11d7 <eval_sin+0x97>
pop    %rax
jmp    1050 <cos0_lo@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11c7 <eval_sin+0x87>
pop    %rax
jmp    1030 <cos0_hi@plt>

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

LLVM IR (-O2):
define double @eval_sin(i32 %0, i32 %1, double %2) {
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %25
5: ; preds = %3
switch i32 %1, label %45 [
i32 0, label %6
i32 1, label %8
i32 2, label %14
i32 3, label %17
]
6: ; preds = %5
%7 = tail call double @sin0_hi(double %2)
br label %45
8: ; preds = %5
%9 = fcmp olt double %2, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call double @cos0_hi(double %2)
br label %45
12: ; preds = %8
%13 = tail call double @cos0_lo(double %2)
br label %45
14: ; preds = %5
%15 = tail call double @sin0_hi(double %2)
%16 = fneg double %15
br label %45
17: ; preds = %5
%18 = fcmp olt double %2, 0.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = tail call double @cos0_hi(double %2)
%21 = fneg double %20
br label %45
22: ; preds = %17
%23 = tail call double @cos0_lo(double %2)
%24 = fneg double %23
br label %45
25: ; preds = %3
switch i32 %1, label %45 [
i32 0, label %26
i32 1, label %28
i32 2, label %34
i32 3, label %37
]
26: ; preds = %25
%27 = tail call double @sin0_lo(double %2)
br label %45
28: ; preds = %25
%29 = fcmp olt double %2, 0.000000e+00
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = tail call double @cos0_lo(double %2)
br label %45
32: ; preds = %28
%33 = tail call double @cos0_hi(double %2)
br label %45
34: ; preds = %25
%35 = tail call double @sin0_lo(double %2)
%36 = fneg double %35
br label %45
37: ; preds = %25
%38 = fcmp olt double %2, 0.000000e+00
br i1 %38, label %39, label %42
39: ; preds = %37
%40 = tail call double @cos0_lo(double %2)
%41 = fneg double %40
br label %45
42: ; preds = %37
%43 = tail call double @cos0_hi(double %2)
%44 = fneg double %43
br label %45
45: ; preds = %5, %25, %42, %39, %34, %32, %30, %26, %22, %19, %14, %12, %10, %6
%46 = phi double [ %21, %19 ], [ %24, %22 ], [ %16, %14 ], [ %11, %10 ], [ %13, %12 ], [ %7, %6 ], [ %41, %39 ], [ %44, %42 ], [ %36, %34 ], [ %31, %30 ], [ %33, %32 ], [ %27, %26 ], [ 0.000000e+00, %25 ], [ 0.000000e+00, %5 ]
ret double %46
}