#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 exponential(double, int);
double factorial(int);
double cos1(double sita) {
  double re = 1;
  double an = sita;
  int i;
  int t = 3;
  while (an > 2 * 3.14159265358979)
    an -= 2 * 3.14159265358979;
  if (an >= 0 && an <= 3.14159265358979 / 2) {
    for (i = 2; i < 12; i += 2, t++) {
      re += exponential(-1, t) * (exponential(sita, i) / factorial(i));
    }
  } else if (an > 3.14159265358979 / 2 && an <= 3.14159265358979) {
    an = 3.14159265358979 - an;
    for (i = 2; i < 12; i += 2, t++) {
      re += exponential(-1, t) * (exponential(sita, i) / factorial(i));
    }
  } else if (an > 3.14159265358979 && an <= 3 * 3.14159265358979 / 2) {
    an -= 3.14159265358979;
    for (i = 2; i < 12; i += 2, t++) {
      re += exponential(-1, t) * (exponential(sita, i) / factorial(i));
    }
  } else {
    an = 2 * 3.14159265358979 - an;
    for (i = 2; i < 12; i += 2, t++) {
      re += exponential(-1, t) * (exponential(sita, i) / factorial(i));
    }
  }
  return re;
}


x86 assembly (clang, -O0):
<cos1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x3,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xeb0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117d <cos1+0x5d>
movsd  -0x18(%rbp),%xmm0
movsd  0xe99(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    114b <cos1+0x2b>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1221 <cos1+0x101>
movsd  0xe79(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1221 <cos1+0x101>
movl   $0x2,-0x1c(%rbp)
cmpl   $0xc,-0x1c(%rbp)
jge    121c <cos1+0xfc>
mov    -0x20(%rbp),%edi
movsd  0xe6a(%rip),%xmm0
call   1040 <exponential@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1040 <exponential@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <factorial@plt>
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a9 <cos1+0x89>
jmp    1436 <cos1+0x316>
movsd  -0x18(%rbp),%xmm0
movsd  0xde2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12dc <cos1+0x1bc>
movsd  0xdd8(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     12dc <cos1+0x1bc>
movsd  0xdc5(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
cmpl   $0xc,-0x1c(%rbp)
jge    12d7 <cos1+0x1b7>
mov    -0x20(%rbp),%edi
movsd  0xdaf(%rip),%xmm0
call   1040 <exponential@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1040 <exponential@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <factorial@plt>
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1264 <cos1+0x144>
jmp    1431 <cos1+0x311>
movsd  -0x18(%rbp),%xmm0
movsd  0xd2f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    139b <cos1+0x27b>
movsd  0xd25(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     139b <cos1+0x27b>
movsd  -0x18(%rbp),%xmm0
movsd  0xd05(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
cmpl   $0xc,-0x1c(%rbp)
jge    1396 <cos1+0x276>
mov    -0x20(%rbp),%edi
movsd  0xcf0(%rip),%xmm0
call   1040 <exponential@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1040 <exponential@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <factorial@plt>
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1323 <cos1+0x203>
jmp    142c <cos1+0x30c>
movsd  0xc65(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
cmpl   $0xc,-0x1c(%rbp)
jge    1427 <cos1+0x307>
mov    -0x20(%rbp),%edi
movsd  0xc5f(%rip),%xmm0
call   1040 <exponential@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1040 <exponential@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <factorial@plt>
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    13b4 <cos1+0x294>
jmp    142c <cos1+0x30c>
jmp    1431 <cos1+0x311>
jmp    1436 <cos1+0x316>
movsd  -0x10(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cos1>:
sub    $0x28,%rsp
movsd  %xmm0,0x18(%rsp)
movsd  0xece(%rip),%xmm0
mov    $0x3,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1030 <factorial@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  0xe8e(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xe78(%rip),%xmm0
mov    $0x4,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
mov    $0x4,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x4,%edi
call   1030 <factorial@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xe24(%rip),%xmm0
mov    $0x5,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
mov    $0x6,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x6,%edi
call   1030 <factorial@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xdd0(%rip),%xmm0
mov    $0x6,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
mov    $0x8,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x8,%edi
call   1030 <factorial@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xd7c(%rip),%xmm0
mov    $0x7,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mov    $0xa,%edi
call   1040 <exponential@plt>
movsd  %xmm0,0x18(%rsp)
mov    $0xa,%edi
call   1030 <factorial@plt>
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @cos1(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store double %0, double* %2
store double 1.000000e+00, double* %3
%7 = load double, double* %2
store double %7, double* %4
store i32 3, i32* %6
br label %8
8: ; preds = %11, %1
%9 = load double, double* %4
%10 = fcmp ogt double %9, 0x401921FB54442D11
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load double, double* %4
%13 = fsub double %12, 0x401921FB54442D11
store double %13, double* %4
br label %8
14: ; preds = %8
%15 = load double, double* %4
%16 = fcmp oge double %15, 0.000000e+00
br i1 %16, label %17, label %41
17: ; preds = %14
%18 = load double, double* %4
%19 = fcmp ole double %18, 0x3FF921FB54442D11
br i1 %19, label %20, label %41
20: ; preds = %17
store i32 2, i32* %5
br label %21
21: ; preds = %35, %20
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 12
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = load i32, i32* %6
%26 = call double @exponential(double -1.000000e+00, i32 %25)
%27 = load double, double* %2
%28 = load i32, i32* %5
%29 = call double @exponential(double %27, i32 %28)
%30 = load i32, i32* %5
%31 = call double @factorial(i32 %30)
%32 = fdiv double %29, %31
%33 = load double, double* %3
%34 = call double @llvm.fmuladd.f64(double %26, double %32, double %33)
store double %34, double* %3
br label %35
35: ; preds = %24
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 2
store i32 %37, i32* %5
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %21
40: ; preds = %21
br label %124
41: ; preds = %17, %14
%42 = load double, double* %4
%43 = fcmp ogt double %42, 0x3FF921FB54442D11
br i1 %43, label %44, label %70
44: ; preds = %41
%45 = load double, double* %4
%46 = fcmp ole double %45, 0x400921FB54442D11
br i1 %46, label %47, label %70
47: ; preds = %44
%48 = load double, double* %4
%49 = fsub double 0x400921FB54442D11, %48
store double %49, double* %4
store i32 2, i32* %5
br label %50
50: ; preds = %64, %47
%51 = load i32, i32* %5
%52 = icmp slt i32 %51, 12
br i1 %52, label %53, label %69
53: ; preds = %50
%54 = load i32, i32* %6
%55 = call double @exponential(double -1.000000e+00, i32 %54)
%56 = load double, double* %2
%57 = load i32, i32* %5
%58 = call double @exponential(double %56, i32 %57)
%59 = load i32, i32* %5
%60 = call double @factorial(i32 %59)
%61 = fdiv double %58, %60
%62 = load double, double* %3
%63 = call double @llvm.fmuladd.f64(double %55, double %61, double %62)
store double %63, double* %3
br label %64
64: ; preds = %53
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 2
store i32 %66, i32* %5
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %50
69: ; preds = %50
br label %123
70: ; preds = %44, %41
%71 = load double, double* %4
%72 = fcmp ogt double %71, 0x400921FB54442D11
br i1 %72, label %73, label %99
73: ; preds = %70
%74 = load double, double* %4
%75 = fcmp ole double %74, 0x4012D97C7F3321CD
br i1 %75, label %76, label %99
76: ; preds = %73
%77 = load double, double* %4
%78 = fsub double %77, 0x400921FB54442D11
store double %78, double* %4
store i32 2, i32* %5
br label %79
79: ; preds = %93, %76
%80 = load i32, i32* %5
%81 = icmp slt i32 %80, 12
br i1 %81, label %82, label %98
82: ; preds = %79
%83 = load i32, i32* %6
%84 = call double @exponential(double -1.000000e+00, i32 %83)
%85 = load double, double* %2
%86 = load i32, i32* %5
%87 = call double @exponential(double %85, i32 %86)
%88 = load i32, i32* %5
%89 = call double @factorial(i32 %88)
%90 = fdiv double %87, %89
%91 = load double, double* %3
%92 = call double @llvm.fmuladd.f64(double %84, double %90, double %91)
store double %92, double* %3
br label %93
93: ; preds = %82
%94 = load i32, i32* %5
%95 = add nsw i32 %94, 2
store i32 %95, i32* %5
%96 = load i32, i32* %6
%97 = add nsw i32 %96, 1
store i32 %97, i32* %6
br label %79
98: ; preds = %79
br label %122
99: ; preds = %73, %70
%100 = load double, double* %4
%101 = fsub double 0x401921FB54442D11, %100
store double %101, double* %4
store i32 2, i32* %5
br label %102
102: ; preds = %116, %99
%103 = load i32, i32* %5
%104 = icmp slt i32 %103, 12
br i1 %104, label %105, label %121
105: ; preds = %102
%106 = load i32, i32* %6
%107 = call double @exponential(double -1.000000e+00, i32 %106)
%108 = load double, double* %2
%109 = load i32, i32* %5
%110 = call double @exponential(double %108, i32 %109)
%111 = load i32, i32* %5
%112 = call double @factorial(i32 %111)
%113 = fdiv double %110, %112
%114 = load double, double* %3
%115 = call double @llvm.fmuladd.f64(double %107, double %113, double %114)
store double %115, double* %3
br label %116
116: ; preds = %105
%117 = load i32, i32* %5
%118 = add nsw i32 %117, 2
store i32 %118, i32* %5
%119 = load i32, i32* %6
%120 = add nsw i32 %119, 1
store i32 %120, i32* %6
br label %102
121: ; preds = %102
br label %122
122: ; preds = %121, %98
br label %123
123: ; preds = %122, %69
br label %124
124: ; preds = %123, %40
%125 = load double, double* %3
ret double %125
}

LLVM IR (-O2):
define double @cos1(double %0) {
%2 = tail call double @exponential(double -1.000000e+00, i32 3)
%3 = tail call double @exponential(double %0, i32 2)
%4 = tail call double @factorial(i32 2)
%5 = fdiv double %3, %4
%6 = tail call double @llvm.fmuladd.f64(double %2, double %5, double 1.000000e+00)
%7 = tail call double @exponential(double -1.000000e+00, i32 4)
%8 = tail call double @exponential(double %0, i32 4)
%9 = tail call double @factorial(i32 4)
%10 = fdiv double %8, %9
%11 = tail call double @llvm.fmuladd.f64(double %7, double %10, double %6)
%12 = tail call double @exponential(double -1.000000e+00, i32 5)
%13 = tail call double @exponential(double %0, i32 6)
%14 = tail call double @factorial(i32 6)
%15 = fdiv double %13, %14
%16 = tail call double @llvm.fmuladd.f64(double %12, double %15, double %11)
%17 = tail call double @exponential(double -1.000000e+00, i32 6)
%18 = tail call double @exponential(double %0, i32 8)
%19 = tail call double @factorial(i32 8)
%20 = fdiv double %18, %19
%21 = tail call double @llvm.fmuladd.f64(double %17, double %20, double %16)
%22 = tail call double @exponential(double -1.000000e+00, i32 7)
%23 = tail call double @exponential(double %0, i32 10)
%24 = tail call double @factorial(i32 10)
%25 = fdiv double %23, %24
%26 = tail call double @llvm.fmuladd.f64(double %22, double %25, double %21)
ret double %26
}