#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 modff(double, float *);
float sinus(float arg, int quad) {
  float e, f;
  int k;
  float ysq;
  float x, y;
  float temp1, temp2;
  x = arg;
  if (x < 0) {
    x = -x;
    quad = quad + 2;
  }
  x = x * 0.636619772367581;
  if (x > 32764) {
    y = modff(x, &e);
    e = e + quad;
    modff(0.25 * e, &f);
    quad = e - 4 * f;
  } else {
    k = x;
    y = x - k;
    quad = (quad + k) & 03;
  }
  if (quad & 01)
    y = 1 - y;
  if (quad > 1)
    y = -y;
  ysq = y * y;
  temp1 = ((((0.145968840666577e3 * ysq + -0.138472724998245e5) * ysq +
             0.440103053537527e6) *
                ysq +
            -0.494290810090284e7) *
               ysq +
           0.135788409787738e8) *
          y;
  temp2 = ((((ysq + 0.132653490878614e3) * ysq + 0.946309610153821e4) * ysq +
            0.408179225234330e6) *
               ysq +
           0.864455865292253e7);
  return (temp1 / temp2);
}


x86 assembly (clang, -O0):
<sinus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    1157 <sinus+0x47>
movss  -0x1c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea8(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xe7e(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11f9 <sinus+0xe9>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    -0xc(%rbp),%rdi
call   1030 <modff@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe52(%rip),%xmm0
mulsd  %xmm1,%xmm0
lea    -0x10(%rbp),%rdi
call   1030 <modff@plt>
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
movss  0xe1f(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
jmp    1220 <sinus+0x110>
cvttss2si -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    -0x14(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1241 <sinus+0x131>
movss  0xdd1(%rip),%xmm0
subss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1262 <sinus+0x152>
movss  -0x20(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdd2(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xda9(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd88(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd67(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd34(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd13(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xcf2(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xcd1(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
divss  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinus>:
push   %rbx
sub    $0x20,%rsp
lea    0x2(%rdi),%ebx
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
movaps 0xedb(%rip),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm0,%xmm3
cmpltss %xmm1,%xmm3
andps  %xmm3,%xmm2
andnps %xmm0,%xmm3
orps   %xmm2,%xmm3
cmovbe %edi,%ebx
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
mulsd  0xec5(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
ucomiss 0xf0f(%rip),%xmm1
jbe    11c1 <sinus+0xb1>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xc(%rsp),%rdi
call   1030 <modff@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
addss  0xc(%rsp),%xmm1
movss  %xmm1,0x4(%rsp)
movaps %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe85(%rip),%xmm0
lea    0x8(%rsp),%rdi
call   1030 <modff@plt>
movaps 0x10(%rsp),%xmm1
movss  0x8(%rsp),%xmm0
mulss  0xebc(%rip),%xmm0
addss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%ebx
test   $0x1,%bl
jne    11da <sinus+0xca>
jmp    11e9 <sinus+0xd9>
cvttss2si %xmm1,%eax
cvttps2dq %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
subss  %xmm0,%xmm1
add    %eax,%ebx
and    $0x3,%ebx
test   $0x1,%bl
je     11e9 <sinus+0xd9>
movss  0xe8e(%rip),%xmm0
subss  %xmm1,%xmm0
movaps %xmm0,%xmm1
cmp    $0x2,%ebx
jl     11f5 <sinus+0xe5>
xorps  0xe0b(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulss  %xmm1,%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe14(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe10(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe0c(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe08(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe04(%rip),%xmm2
mulsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movsd  0xdf9(%rip),%xmm2
addsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
addsd  0xdf1(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xded(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xde9(%rip),%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
divss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @sinus(float %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float %0, float* %3
store i32 %1, i32* %4
%13 = load float, float* %3
store float %13, float* %9
%14 = load float, float* %9
%15 = fcmp olt float %14, 0.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load float, float* %9
%18 = fneg float %17
store float %18, float* %9
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 2
store i32 %20, i32* %4
br label %21
21: ; preds = %16, %2
%22 = load float, float* %9
%23 = fpext float %22 to double
%24 = fmul double %23, 0x3FE45F306DC9C880
%25 = fptrunc double %24 to float
store float %25, float* %9
%26 = load float, float* %9
%27 = fcmp ogt float %26, 3.276400e+04
br i1 %27, label %28, label %44
28: ; preds = %21
%29 = load float, float* %9
%30 = fpext float %29 to double
%31 = call float @modff(double %30, float* %5)
store float %31, float* %10
%32 = load float, float* %5
%33 = load i32, i32* %4
%34 = sitofp i32 %33 to float
%35 = fadd float %32, %34
store float %35, float* %5
%36 = load float, float* %5
%37 = fpext float %36 to double
%38 = fmul double 2.500000e-01, %37
%39 = call float @modff(double %38, float* %6)
%40 = load float, float* %5
%41 = load float, float* %6
%42 = call float @llvm.fmuladd.f32(float -4.000000e+00, float %41, float %40)
%43 = fptosi float %42 to i32
store i32 %43, i32* %4
br label %55
44: ; preds = %21
%45 = load float, float* %9
%46 = fptosi float %45 to i32
store i32 %46, i32* %7
%47 = load float, float* %9
%48 = load i32, i32* %7
%49 = sitofp i32 %48 to float
%50 = fsub float %47, %49
store float %50, float* %10
%51 = load i32, i32* %4
%52 = load i32, i32* %7
%53 = add nsw i32 %51, %52
%54 = and i32 %53, 3
store i32 %54, i32* %4
br label %55
55: ; preds = %44, %28
%56 = load i32, i32* %4
%57 = and i32 %56, 1
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load float, float* %10
%61 = fsub float 1.000000e+00, %60
store float %61, float* %10
br label %62
62: ; preds = %59, %55
%63 = load i32, i32* %4
%64 = icmp sgt i32 %63, 1
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load float, float* %10
%67 = fneg float %66
store float %67, float* %10
br label %68
68: ; preds = %65, %62
%69 = load float, float* %10
%70 = load float, float* %10
%71 = fmul float %69, %70
store float %71, float* %8
%72 = load float, float* %8
%73 = fpext float %72 to double
%74 = call double @llvm.fmuladd.f64(double 0x40623F00BE243F75, double %73, double 0xC0CB0BA2E1463532)
%75 = load float, float* %8
%76 = fpext float %75 to double
%77 = call double @llvm.fmuladd.f64(double %74, double %76, double 0x411ADC9C36D28A9E)
%78 = load float, float* %8
%79 = fpext float %78 to double
%80 = call double @llvm.fmuladd.f64(double %77, double %79, double 0xC152DB0F0675312F)
%81 = load float, float* %8
%82 = fpext float %81 to double
%83 = call double @llvm.fmuladd.f64(double %80, double %82, double 0x4169E64B1F521D6F)
%84 = load float, float* %10
%85 = fpext float %84 to double
%86 = fmul double %83, %85
%87 = fptrunc double %86 to float
store float %87, float* %11
%88 = load float, float* %8
%89 = fpext float %88 to double
%90 = fadd double %89, 0x406094E965B3FC35
%91 = load float, float* %8
%92 = fpext float %91 to double
%93 = call double @llvm.fmuladd.f64(double %90, double %92, double 0x40C27B8C4D0E21DB)
%94 = load float, float* %8
%95 = fpext float %94 to double
%96 = call double @llvm.fmuladd.f64(double %93, double %95, double 0x4118E9CCE6A3D405)
%97 = load float, float* %8
%98 = fpext float %97 to double
%99 = call double @llvm.fmuladd.f64(double %96, double %98, double 0x41607CF9D4E4BDCA)
%100 = fptrunc double %99 to float
store float %100, float* %12
%101 = load float, float* %11
%102 = load float, float* %12
%103 = fdiv float %101, %102
ret float %103
}

LLVM IR (-O2):
define float @sinus(float %0, i32 %1) {
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %3 to i8*
%6 = bitcast float* %4 to i8*
%7 = fcmp olt float %0, 0.000000e+00
%8 = fneg float %0
%9 = add nsw i32 %1, 2
%10 = select i1 %7, float %8, float %0
%11 = select i1 %7, i32 %9, i32 %1
%12 = fpext float %10 to double
%13 = fmul double %12, 0x3FE45F306DC9C880
%14 = fptrunc double %13 to float
%15 = fcmp ogt float %14, 3.276400e+04
br i1 %15, label %16, label %28
16: ; preds = %2
%17 = fpext float %14 to double
%18 = call float @modff(double %17, float* %3)
%19 = load float, float* %3
%20 = sitofp i32 %11 to float
%21 = fadd float %19, %20
%22 = fpext float %21 to double
%23 = fmul double %22, 2.500000e-01
%24 = call float @modff(double %23, float* %4)
%25 = load float, float* %4
%26 = tail call float @llvm.fmuladd.f32(float %25, float -4.000000e+00, float %21)
%27 = fptosi float %26 to i32
br label %34
28: ; preds = %2
%29 = fptosi float %14 to i32
%30 = sitofp i32 %29 to float
%31 = fsub float %14, %30
%32 = add nsw i32 %11, %29
%33 = and i32 %32, 3
br label %34
34: ; preds = %28, %16
%35 = phi float [ %18, %16 ], [ %31, %28 ]
%36 = phi i32 [ %27, %16 ], [ %33, %28 ]
%37 = and i32 %36, 1
%38 = icmp eq i32 %37, 0
%39 = fsub float 1.000000e+00, %35
%40 = select i1 %38, float %35, float %39
%41 = icmp sgt i32 %36, 1
%42 = fneg float %40
%43 = select i1 %41, float %42, float %40
%44 = fmul float %43, %43
%45 = fpext float %44 to double
%46 = tail call double @llvm.fmuladd.f64(double %45, double 0x40623F00BE243F75, double 0xC0CB0BA2E1463532)
%47 = tail call double @llvm.fmuladd.f64(double %46, double %45, double 0x411ADC9C36D28A9E)
%48 = tail call double @llvm.fmuladd.f64(double %47, double %45, double 0xC152DB0F0675312F)
%49 = tail call double @llvm.fmuladd.f64(double %48, double %45, double 0x4169E64B1F521D6F)
%50 = fpext float %43 to double
%51 = fmul double %49, %50
%52 = fptrunc double %51 to float
%53 = fadd double %45, 0x406094E965B3FC35
%54 = tail call double @llvm.fmuladd.f64(double %53, double %45, double 0x40C27B8C4D0E21DB)
%55 = tail call double @llvm.fmuladd.f64(double %54, double %45, double 0x4118E9CCE6A3D405)
%56 = tail call double @llvm.fmuladd.f64(double %55, double %45, double 0x41607CF9D4E4BDCA)
%57 = fptrunc double %56 to float
%58 = fdiv float %52, %57
ret float %58
}