#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 */
int abs(int);
double cos(double);
scalar_t__ floor(double);
double fmod(double, double);
double sin(double);
void sincosd(double angle, double *s, double *c) {
  int i;
  if (fmod(angle, 90.0) == 0.0) {
    i = abs((int)floor(angle / 90.0 + 0.5)) % 4;
    switch (i) {
    case 0:
      *s = 0.0;
      *c = 1.0;
      return;
    case 1:
      *s = (angle > 0.0) ? 1.0 : -1.0;
      *c = 0.0;
      return;
    case 2:
      *s = 0.0;
      *c = -1.0;
      return;
    case 3:
      *s = (angle > 0.0) ? -1.0 : 1.0;
      *c = 0.0;
      return;
    }
  }
  *s = sin(angle * 3.141592653589793238462643 / 180.0);
  *c = cos(angle * 3.141592653589793238462643 / 180.0);
  return;
}


x86 assembly (clang, -O0):
<sincosd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
call   1040 <fmod@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12b9 <sincosd+0x169>
jp     12b9 <sincosd+0x169>
movsd  -0x8(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe65(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1070 <floor@plt>
mov    %eax,%edi
call   1030 <abs@plt>
mov    %eax,%edx
add    $0x3,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     12b4 <sincosd+0x164>
mov    -0x28(%rbp),%rax
lea    0xe4d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe15(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1305 <sincosd+0x1b5>
movsd  -0x8(%rbp),%xmm1
movsd  0xdff(%rip),%xmm3
movsd  0xdef(%rip),%xmm2
xorps  %xmm0,%xmm0
cmpltsd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1305 <sincosd+0x1b5>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xda9(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1305 <sincosd+0x1b5>
movsd  -0x8(%rbp),%xmm1
movsd  0xd93(%rip),%xmm3
movsd  0xd93(%rip),%xmm2
xorps  %xmm0,%xmm0
cmpltsd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1305 <sincosd+0x1b5>
jmp    12b9 <sincosd+0x169>
movsd  0xd67(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xd52(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd41(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xd2c(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <cos@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sincosd>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0xeae(%rip),%xmm1
movsd  %xmm0,(%rsp)
call   1030 <fmod@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ad <sincosd+0x6d>
jp     11ad <sincosd+0x6d>
movsd  (%rsp),%xmm0
divsd  0xe8b(%rip),%xmm0
addsd  0xe9b(%rip),%xmm0
call   1060 <floor@plt>
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
and    $0x3,%ecx
lea    0xebd(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movq   $0x0,(%rbx)
movsd  0xe7d(%rip),%xmm0
jmp    122a <sincosd+0xea>
movsd  (%rsp),%xmm0
mulsd  0xe4e(%rip),%xmm0
divsd  0xe4e(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,(%rbx)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
jmp    122a <sincosd+0xea>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
lea    0xe4b(%rip),%rcx
jmp    1221 <sincosd+0xe1>
movq   $0x0,(%rbx)
movsd  0xe1a(%rip),%xmm0
jmp    122a <sincosd+0xea>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
lea    0xe0f(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm1
movsd  %xmm1,(%rbx)
movsd  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @sincosd(double %0, double* %1, double* %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
store double %0, double* %4
store double* %1, double** %5
store double* %2, double** %6
%8 = load double, double* %4
%9 = call double @fmod(double %8, double 9.000000e+01)
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %41
11: ; preds = %3
%12 = load double, double* %4
%13 = fdiv double %12, 9.000000e+01
%14 = fadd double %13, 5.000000e-01
%15 = call i64 @floor(double %14)
%16 = trunc i64 %15 to i32
%17 = call i32 @abs(i32 %16)
%18 = srem i32 %17, 4
store i32 %18, i32* %7
%19 = load i32, i32* %7
switch i32 %19, label %40 [
i32 0, label %20
i32 1, label %23
i32 2, label %30
i32 3, label %33
]
20: ; preds = %11
%21 = load double*, double** %5
store double 0.000000e+00, double* %21
%22 = load double*, double** %6
store double 1.000000e+00, double* %22
br label %52
23: ; preds = %11
%24 = load double, double* %4
%25 = fcmp ogt double %24, 0.000000e+00
%26 = zext i1 %25 to i64
%27 = select i1 %25, double 1.000000e+00, double -1.000000e+00
%28 = load double*, double** %5
store double %27, double* %28
%29 = load double*, double** %6
store double 0.000000e+00, double* %29
br label %52
30: ; preds = %11
%31 = load double*, double** %5
store double 0.000000e+00, double* %31
%32 = load double*, double** %6
store double -1.000000e+00, double* %32
br label %52
33: ; preds = %11
%34 = load double, double* %4
%35 = fcmp ogt double %34, 0.000000e+00
%36 = zext i1 %35 to i64
%37 = select i1 %35, double -1.000000e+00, double 1.000000e+00
%38 = load double*, double** %5
store double %37, double* %38
%39 = load double*, double** %6
store double 0.000000e+00, double* %39
br label %52
40: ; preds = %11
br label %41
41: ; preds = %40, %3
%42 = load double, double* %4
%43 = fmul double %42, 0x400921FB54442D18
%44 = fdiv double %43, 1.800000e+02
%45 = call double @sin(double %44)
%46 = load double*, double** %5
store double %45, double* %46
%47 = load double, double* %4
%48 = fmul double %47, 0x400921FB54442D18
%49 = fdiv double %48, 1.800000e+02
%50 = call double @cos(double %49)
%51 = load double*, double** %6
store double %50, double* %51
br label %52
52: ; preds = %41, %33, %30, %23, %20
ret void
}

LLVM IR (-O2):
define void @sincosd(double %0, double* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = tail call double @fmod(double %0, double 9.000000e+01)
%5 = fcmp oeq double %4, 0.000000e+00
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = fdiv double %0, 9.000000e+01
%8 = fadd double %7, 5.000000e-01
%9 = tail call i64 @floor(double %8)
%10 = trunc i64 %9 to i32
%11 = tail call i32 @llvm.abs.i32(i32 %10, i1 true)
%12 = and i32 %11, 3
switch i32 %12, label %21 [
i32 0, label %13
i32 1, label %14
i32 2, label %17
i32 3, label %18
]
13: ; preds = %6
store double 0.000000e+00, double* %1
br label %27
14: ; preds = %6
%15 = fcmp ogt double %0, 0.000000e+00
%16 = select i1 %15, double 1.000000e+00, double -1.000000e+00
store double %16, double* %1
br label %27
17: ; preds = %6
store double 0.000000e+00, double* %1
br label %27
18: ; preds = %6
%19 = fcmp ogt double %0, 0.000000e+00
%20 = select i1 %19, double -1.000000e+00, double 1.000000e+00
store double %20, double* %1
br label %27
21: ; preds = %6
unreachable
22: ; preds = %3
%23 = fmul double %0, 0x400921FB54442D18
%24 = fdiv double %23, 1.800000e+02
%25 = tail call double @sin(double %24)
store double %25, double* %1
%26 = tail call double @cos(double %24)
br label %27
27: ; preds = %22, %18, %17, %14, %13
%28 = phi double [ %26, %22 ], [ 0.000000e+00, %18 ], [ -1.000000e+00, %17 ], [ 0.000000e+00, %14 ], [ 1.000000e+00, %13 ]
store double %28, double* %2
ret void
}