float _cosf(float x) {
  float y;
  float xn;
  float f, g;
  float result;
  float x_int;
  float x_fract;
  long int exp;
  long int n;
  const float NaN = 0x1.002468p+128;
  const float domain = ((102940.0F));
  const long int *const domain_ptr = (long int *)(&domain);
  long int *const x_ptr = (long int *)(&x);
  if (*x_ptr < 0)
    x = -x;
  exp = *x_ptr & 0X7F800000;
  if (exp == 0X7F800000)
    return NaN;
  if (exp == 0)
    return 1.0F;
  if (*x_ptr > *domain_ptr)
    return 0.0F;
  y = ((float)(x) + (float)((float)(1.5707963267948966192313216916398L)));
  n = ((
      long)(((float)(((float)(y) *
                      (float)((float)(0.31830988618379067153776752674503L)))) +
             (float)(0.5F))));
  xn = ((float)(n));
  xn = ((float)(xn) - (float)(0.5F));
  x_int = ((float)(((long)(x))));
  x_fract = ((float)(x) - (float)(x_int));
  f = ((float)(x_int) - (float)(((float)(xn) * (float)((3.140625F)))));
  f = ((float)(f) + (float)(x_fract));
  f = ((float)(f) - (float)(((float)(xn) * (float)((9.670257568359375e-4F)))));
  f = ((float)(f) -
       (float)(((float)(xn) * (float)((6.27832957300962643383279502884e-7F)))));
  if (fabsf(f) >= (+3.452669830012e-4F)) {
    g = ((float)(f) * (float)(f));
    result = ((float)(g) * (float)((+0.2601903036e-5F)));
    result = ((float)(result) + (float)((-0.1980741872e-3F)));
    result = ((float)(result) * (float)(g));
    result = ((float)(result) + (float)((+0.8333025139e-2F)));
    result = ((float)(result) * (float)(g));
    result = ((float)(result) + (float)((-0.1666665668e+0F)));
    result = ((float)(result) * (float)(g));
    result = ((float)(result) * (float)(f));
    f = ((float)(result) + (float)(f));
  }
  return ((n & 1) ? -f : f);
}


x86 assembly (clang, -O0):
<_cosf>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
movss  0xef3(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xee2(%rip),%xmm0
movss  %xmm0,-0x40(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmpq   $0x0,(%rax)
jge    1158 <_cosf+0x58>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%rax
and    $0x7f800000,%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x7f800000,-0x30(%rbp)
7f
jne    1189 <_cosf+0x89>
movss  0xe85(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13d7 <_cosf+0x2d7>
cmpq   $0x0,-0x30(%rbp)
jne    11a6 <_cosf+0xa6>
movss  0xe98(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13d7 <_cosf+0x2d7>
mov    -0x50(%rbp),%rax
mov    (%rax),%rax
mov    -0x48(%rbp),%rcx
cmp    (%rcx),%rax
jle    11c7 <_cosf+0xc7>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13d7 <_cosf+0x2d7>
movss  0xe51(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe36(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe26(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %rax,-0x38(%rbp)
cvtsi2ssq -0x38(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe01(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
cvttss2si -0x8(%rbp),%rax
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
subss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xdb6(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xd77(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xd47(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movaps 0xd62(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xd1e(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1395 <_cosf+0x295>
movss  -0x14(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xd26(%rip),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xd10(%rip),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xceb(%rip),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xcc6(%rip),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x38(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     13c3 <_cosf+0x2c3>
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x54(%rbp)
jmp    13cd <_cosf+0x2cd>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x54(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<_cosf>:
movss  %xmm0,-0x10(%rsp)
movl   $0x47c90e00,-0x8(%rsp)
47
mov    -0x10(%rsp),%rax
test   %rax,%rax
jns    112a <_cosf+0x2a>
xorps  0xee1(%rip),%xmm0
movss  %xmm0,-0x10(%rsp)
mov    -0x10(%rsp),%rax
mov    %eax,%ecx
and    $0x7f800000,%ecx
cmp    $0x7f800000,%rcx
je     1149 <_cosf+0x49>
test   %rcx,%rcx
jne    1152 <_cosf+0x52>
movss  0xedc(%rip),%xmm0
ret
movss  0xecf(%rip),%xmm0
ret
xorps  %xmm0,%xmm0
cmp    -0x8(%rsp),%rax
jg     1230 <_cosf+0x130>
movd   %eax,%xmm1
movss  0xebc(%rip),%xmm0
addss  %xmm1,%xmm0
mulss  0xeb4(%rip),%xmm0
addss  0xeb0(%rip),%xmm0
cvttss2si %xmm0,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xe9f(%rip),%xmm0
cvttss2si %xmm1,%rcx
cvtsi2ss %rcx,%xmm2
subss  %xmm2,%xmm1
movss  0xe8d(%rip),%xmm3
mulss  %xmm0,%xmm3
addss  %xmm2,%xmm3
addss  %xmm1,%xmm3
movss  0xe7d(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  %xmm3,%xmm1
mulss  0xe71(%rip),%xmm0
addss  %xmm1,%xmm0
movaps 0xe36(%rip),%xmm1
andps  %xmm0,%xmm1
ucomiss 0xe60(%rip),%xmm1
jb     1225 <_cosf+0x125>
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  0xe53(%rip),%xmm2
mulss  %xmm1,%xmm2
addss  0xe4b(%rip),%xmm2
mulss  %xmm1,%xmm2
addss  0xe43(%rip),%xmm2
mulss  %xmm1,%xmm2
addss  0xe3b(%rip),%xmm2
mulss  %xmm1,%xmm2
mulss  %xmm0,%xmm2
addss  %xmm2,%xmm0
test   $0x1,%al
je     1230 <_cosf+0x130>
xorps  0xdd0(%rip),%xmm0
ret

LLVM IR (-O0):
define float @_cosf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca i64
%12 = alloca i64
%13 = alloca float
%14 = alloca float
%15 = alloca i64*
%16 = alloca i64*
store float %0, float* %3
store float 0x7FF0000000000000, float* %13
store float 1.029400e+05, float* %14
%17 = bitcast float* %14 to i64*
store i64* %17, i64** %15
%18 = bitcast float* %3 to i64*
store i64* %18, i64** %16
%19 = load i64*, i64** %16
%20 = load i64, i64* %19
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %1
%23 = load float, float* %3
%24 = fneg float %23
store float %24, float* %3
br label %25
25: ; preds = %22, %1
%26 = load i64*, i64** %16
%27 = load i64, i64* %26
%28 = and i64 %27, 2139095040
store i64 %28, i64* %11
%29 = load i64, i64* %11
%30 = icmp eq i64 %29, 2139095040
br i1 %30, label %31, label %32
31: ; preds = %25
store float 0x7FF0000000000000, float* %2
br label %115
32: ; preds = %25
%33 = load i64, i64* %11
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
store float 1.000000e+00, float* %2
br label %115
36: ; preds = %32
%37 = load i64*, i64** %16
%38 = load i64, i64* %37
%39 = load i64*, i64** %15
%40 = load i64, i64* %39
%41 = icmp sgt i64 %38, %40
br i1 %41, label %42, label %43
42: ; preds = %36
store float 0.000000e+00, float* %2
br label %115
43: ; preds = %36
%44 = load float, float* %3
%45 = fadd float %44, 0x3FF921FB60000000
store float %45, float* %4
%46 = load float, float* %4
%47 = call float @llvm.fmuladd.f32(float %46, float 0x3FD45F3060000000, float 5.000000e-01)
%48 = fptosi float %47 to i64
store i64 %48, i64* %12
%49 = load i64, i64* %12
%50 = sitofp i64 %49 to float
store float %50, float* %5
%51 = load float, float* %5
%52 = fsub float %51, 5.000000e-01
store float %52, float* %5
%53 = load float, float* %3
%54 = fptosi float %53 to i64
%55 = sitofp i64 %54 to float
store float %55, float* %9
%56 = load float, float* %3
%57 = load float, float* %9
%58 = fsub float %56, %57
store float %58, float* %10
%59 = load float, float* %9
%60 = load float, float* %5
%61 = fneg float %60
%62 = call float @llvm.fmuladd.f32(float %61, float 0x4009200000000000, float %59)
store float %62, float* %6
%63 = load float, float* %6
%64 = load float, float* %10
%65 = fadd float %63, %64
store float %65, float* %6
%66 = load float, float* %6
%67 = load float, float* %5
%68 = fneg float %67
%69 = call float @llvm.fmuladd.f32(float %68, float 0x3F4FB00000000000, float %66)
store float %69, float* %6
%70 = load float, float* %6
%71 = load float, float* %5
%72 = fneg float %71
%73 = call float @llvm.fmuladd.f32(float %72, float 0x3EA5110B40000000, float %70)
store float %73, float* %6
%74 = load float, float* %6
%75 = call float @llvm.fabs.f32(float %74)
%76 = fcmp oge float %75, 0x3F36A09E60000000
br i1 %76, label %77, label %104
77: ; preds = %43
%78 = load float, float* %6
%79 = load float, float* %6
%80 = fmul float %78, %79
store float %80, float* %7
%81 = load float, float* %7
%82 = fmul float %81, 0x3EC5D38B60000000
store float %82, float* %8
%83 = load float, float* %8
%84 = fadd float %83, 0xBF29F64440000000
store float %84, float* %8
%85 = load float, float* %8
%86 = load float, float* %7
%87 = fmul float %85, %86
store float %87, float* %8
%88 = load float, float* %8
%89 = fadd float %88, 0x3F8110E7C0000000
store float %89, float* %8
%90 = load float, float* %8
%91 = load float, float* %7
%92 = fmul float %90, %91
store float %92, float* %8
%93 = load float, float* %8
%94 = fadd float %93, 0xBFC5555480000000
store float %94, float* %8
%95 = load float, float* %8
%96 = load float, float* %7
%97 = fmul float %95, %96
store float %97, float* %8
%98 = load float, float* %8
%99 = load float, float* %6
%100 = fmul float %98, %99
store float %100, float* %8
%101 = load float, float* %8
%102 = load float, float* %6
%103 = fadd float %101, %102
store float %103, float* %6
br label %104
104: ; preds = %77, %43
%105 = load i64, i64* %12
%106 = and i64 %105, 1
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %104
%109 = load float, float* %6
%110 = fneg float %109
br label %113
111: ; preds = %104
%112 = load float, float* %6
br label %113
113: ; preds = %111, %108
%114 = phi float [ %110, %108 ], [ %112, %111 ]
store float %114, float* %2
br label %115
115: ; preds = %113, %42, %35, %31
%116 = load float, float* %2
ret float %116
}

LLVM IR (-O2):
define float @_cosf(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %2
%4 = bitcast float* %3 to i8*
store float 1.029400e+05, float* %3
%5 = bitcast float* %2 to i64*
%6 = load i64, i64* %5
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = fneg float %0
store float %9, float* %2
%10 = load i64, i64* %5
br label %11
11: ; preds = %8, %1
%12 = phi i64 [ %10, %8 ], [ %6, %1 ]
%13 = trunc i64 %12 to i32
%14 = bitcast i32 %13 to float
%15 = and i64 %12, 2139095040
switch i64 %15, label %17 [
i64 2139095040, label %54
i64 0, label %16
]
16: ; preds = %11
br label %54
17: ; preds = %11
%18 = bitcast float* %3 to i64*
%19 = load i64, i64* %18
%20 = icmp sgt i64 %12, %19
br i1 %20, label %54, label %21
21: ; preds = %17
%22 = fadd float %14, 0x3FF921FB60000000
%23 = tail call float @llvm.fmuladd.f32(float %22, float 0x3FD45F3060000000, float 5.000000e-01)
%24 = fptosi float %23 to i64
%25 = sitofp i64 %24 to float
%26 = fadd float %25, -5.000000e-01
%27 = fptosi float %14 to i64
%28 = sitofp i64 %27 to float
%29 = fsub float %14, %28
%30 = fneg float %26
%31 = tail call float @llvm.fmuladd.f32(float %30, float 0x4009200000000000, float %28)
%32 = fadd float %29, %31
%33 = tail call float @llvm.fmuladd.f32(float %30, float 0x3F4FB00000000000, float %32)
%34 = tail call float @llvm.fmuladd.f32(float %30, float 0x3EA5110B40000000, float %33)
%35 = tail call float @llvm.fabs.f32(float %34)
%36 = fcmp ult float %35, 0x3F36A09E60000000
br i1 %36, label %48, label %37
37: ; preds = %21
%38 = fmul float %34, %34
%39 = fmul float %38, 0x3EC5D38B60000000
%40 = fadd float %39, 0xBF29F64440000000
%41 = fmul float %38, %40
%42 = fadd float %41, 0x3F8110E7C0000000
%43 = fmul float %38, %42
%44 = fadd float %43, 0xBFC5555480000000
%45 = fmul float %38, %44
%46 = fmul float %34, %45
%47 = fadd float %34, %46
br label %48
48: ; preds = %37, %21
%49 = phi float [ %47, %37 ], [ %34, %21 ]
%50 = and i64 %24, 1
%51 = icmp eq i64 %50, 0
%52 = fneg float %49
%53 = select i1 %51, float %49, float %52
br label %54
54: ; preds = %17, %11, %48, %16
%55 = phi float [ 1.000000e+00, %16 ], [ %53, %48 ], [ 0x7FF0000000000000, %11 ], [ 0.000000e+00, %17 ]
ret float %55
}