#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 */
float fmodf(float, double);
float fa_fast_cos(float angle) {
  float real_angle;
  float square, result;
  int sign;
  angle = angle + 6.28318530717958647692;
  angle = fmodf(angle, 6.28318530717958647692);
  if (angle <= 3.14159265358979323846) {
    real_angle = 3.14159265358979323846 - angle;
    sign = ((1.57079632679489661923 - angle) >= 0 ? 1 : -1);
    angle = ((real_angle) < (angle) ? (real_angle) : (angle));
  } else {
    angle = angle - 3.14159265358979323846;
    real_angle = 3.14159265358979323846 - angle;
    sign = ((angle - 1.57079632679489661923) >= 0 ? 1 : -1);
    angle = ((real_angle) < (angle) ? (real_angle) : (angle));
  }
  square = angle * angle;
  result = 3.705e-02f;
  result *= square;
  result -= 4.967e-01f;
  result *= square;
  result += 1.0f;
  return result * sign;
}


x86 assembly (clang, -O0):
<fa_fast_cos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeda(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movsd  0xec0(%rip),%xmm1
call   1030 <fmodf@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe9d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11f2 <fa_fast_cos+0xe2>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe82(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe74(%rip),%xmm0
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
mov    %eax,-0x14(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11d9 <fa_fast_cos+0xc9>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11e3 <fa_fast_cos+0xd3>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1290 <fa_fast_cos+0x180>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdfd(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xddf(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd1(%rip),%xmm1
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
mov    %eax,-0x14(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    127c <fa_fast_cos+0x16c>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1286 <fa_fast_cos+0x176>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xd79(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xd54(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xd30(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
mulss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fa_fast_cos>:
push   %rax
cvtss2sd %xmm0,%xmm0
movsd  0xee3(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <fmodf@plt>
cvtss2sd %xmm0,%xmm2
movsd  0xed2(%rip),%xmm1
ucomisd %xmm2,%xmm1
jae    116e <fa_fast_cos+0x5e>
addsd  0xed4(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
subsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
addsd  0xebe(%rip),%xmm2
xorpd  %xmm3,%xmm3
xor    %eax,%eax
ucomisd %xmm3,%xmm2
jmp    118c <fa_fast_cos+0x7c>
subsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
movsd  0xe92(%rip),%xmm3
subsd  %xmm2,%xmm3
xorpd  %xmm2,%xmm2
xor    %eax,%eax
ucomisd %xmm2,%xmm3
setae  %al
add    %eax,%eax
add    $0xffffffff,%eax
minss  %xmm0,%xmm1
mulss  %xmm1,%xmm1
movss  0xe84(%rip),%xmm2
mulss  %xmm1,%xmm2
addss  0xe7c(%rip),%xmm2
mulss  %xmm1,%xmm2
addss  0xe74(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  %xmm2,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define float @fa_fast_cos(float %0) {
%2 = fpext float %0 to double
%3 = fadd double %2, 0x401921FB54442D18
%4 = fptrunc double %3 to float
%5 = tail call float @fmodf(float %4, double 0x401921FB54442D18)
%6 = fpext float %5 to double
%7 = fcmp ugt double %6, 0x400921FB54442D18
br i1 %7, label %16, label %8
8: ; preds = %1
%9 = fsub double 0x400921FB54442D18, %6
%10 = fptrunc double %9 to float
%11 = fsub double 0x3FF921FB54442D18, %6
%12 = fcmp oge double %11, 0.000000e+00
%13 = select i1 %12, i32 1, i32 -1
%14 = fcmp ogt float %5, %10
%15 = select i1 %14, float %10, float %5
br label %27
16: ; preds = %1
%17 = fadd double %6, 0xC00921FB54442D18
%18 = fptrunc double %17 to float
%19 = fpext float %18 to double
%20 = fsub double 0x400921FB54442D18, %19
%21 = fptrunc double %20 to float
%22 = fadd double %19, 0xBFF921FB54442D18
%23 = fcmp oge double %22, 0.000000e+00
%24 = select i1 %23, i32 1, i32 -1
%25 = fcmp olt float %21, %18
%26 = select i1 %25, float %21, float %18
br label %27
27: ; preds = %16, %8
%28 = phi float [ %15, %8 ], [ %26, %16 ]
%29 = phi i32 [ %13, %8 ], [ %24, %16 ]
%30 = fmul float %28, %28
%31 = fmul float %30, 0x3FA2F837C0000000
%32 = fadd float %31, 0xBFDFC9EEC0000000
%33 = fmul float %30, %32
%34 = fadd float %33, 1.000000e+00
%35 = sitofp i32 %29 to float
%36 = fmul float %34, %35
ret float %36
}