#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 /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int loop, n;
  float value, sum = 0, term;
  printf("The Cosine series will be :\n");
  for (loop = 0; loop <= 360; loop = loop + 30) {
    value = loop * 3.1415 / 180;
    term = 1;
    sum = 1;
    n = 1;
    while ((term > 0.000001) || (term < -0.000001)) {
      term = (-1) * value * value * term / ((2 * n) * (2 * n - 1));
      n++;
      sum += term;
    }
    printf("\t\tCos(%d)=%f", loop, sum);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x168,-0x8(%rbp)
jg     1264 <main+0x154>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xeba(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea6(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe89(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe7c(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
movsd  0xe75(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x19(%rbp)
ja     11cb <main+0xbb>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe5f(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11db <main+0xcb>
jmp    122e <main+0x11e>
movss  0xe21(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1190 <main+0x80>
mov    -0x8(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1e,%eax
mov    %eax,-0x8(%rbp)
jmp    113c <main+0x2c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xf16(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
movsd  0xec2(%rip),%xmm4
movsd  0xec2(%rip),%xmm5
lea    0xee7(%rip),%r14
nopl   (%rax)
movsd  %xmm0,(%rsp)
mulsd  0xe93(%rip),%xmm0
divsd  0xe93(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
movaps %xmm1,%xmm0
xorps  0xeaa(%rip),%xmm0
mulss  %xmm1,%xmm0
mov    $0x1,%eax
movss  0xea9(%rip),%xmm1
movaps %xmm1,%xmm2
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%ecx
imul   %eax,%ecx
xorps  %xmm3,%xmm3
cvtsi2ss %ecx,%xmm3
mulss  %xmm0,%xmm2
divss  %xmm3,%xmm2
addss  %xmm2,%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm2,%xmm3
add    $0x2,%eax
ucomisd %xmm4,%xmm3
ja     11a0 <main+0x70>
ucomisd %xmm3,%xmm5
ja     11a0 <main+0x70>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  0xe24(%rip),%xmm5
movsd  0xe14(%rip),%xmm4
movsd  (%rsp),%xmm0
addsd  0xe17(%rip),%xmm0
lea    0x1e(%rbx),%eax
cmp    $0x14b,%ebx
mov    %eax,%ebx
jb     1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"The Cosine series will be :\0A\00"
@.str.1 = [13 x i8] c"\09\09Cos(%d)=%f\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %8
8: ; preds = %53, %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 360
br i1 %10, label %11, label %56
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 3.141500e+00
%15 = fdiv double %14, 1.800000e+02
%16 = fptrunc double %15 to float
store float %16, float* %4
store float 1.000000e+00, float* %6
store float 1.000000e+00, float* %5
store i32 1, i32* %3
br label %17
17: ; preds = %27, %11
%18 = load float, float* %6
%19 = fpext float %18 to double
%20 = fcmp ogt double %19, 0x3EB0C6F7A0B5ED8D
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load float, float* %6
%23 = fpext float %22 to double
%24 = fcmp olt double %23, 0xBEB0C6F7A0B5ED8D
br label %25
25: ; preds = %21, %17
%26 = phi i1 [ true, %17 ], [ %24, %21 ]
br i1 %26, label %27, label %47
27: ; preds = %25
%28 = load float, float* %4
%29 = fmul float -1.000000e+00, %28
%30 = load float, float* %4
%31 = fmul float %29, %30
%32 = load float, float* %6
%33 = fmul float %31, %32
%34 = load i32, i32* %3
%35 = mul nsw i32 2, %34
%36 = load i32, i32* %3
%37 = mul nsw i32 2, %36
%38 = sub nsw i32 %37, 1
%39 = mul nsw i32 %35, %38
%40 = sitofp i32 %39 to float
%41 = fdiv float %33, %40
store float %41, float* %6
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
%44 = load float, float* %6
%45 = load float, float* %5
%46 = fadd float %45, %44
store float %46, float* %5
br label %17
47: ; preds = %25
%48 = load i32, i32* %2
%49 = load float, float* %5
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %48, double %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %47
%54 = load i32, i32* %2
%55 = add nsw i32 %54, 30
store i32 %55, i32* %2
br label %8
56: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"\09\09Cos(%d)=%f\00"
@str = [28 x i8] c"The Cosine series will be :\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %26
%3 = phi i32 [ 0, %0 ], [ %30, %26 ]
%4 = sitofp i32 %3 to double
%5 = fmul double %4, 3.141500e+00
%6 = fdiv double %5, 1.800000e+02
%7 = fptrunc double %6 to float
%8 = fneg float %7
%9 = fmul float %8, %7
br label %10
10: ; preds = %2, %10
%11 = phi float [ 1.000000e+00, %2 ], [ %19, %10 ]
%12 = phi float [ 1.000000e+00, %2 ], [ %21, %10 ]
%13 = phi i32 [ 1, %2 ], [ %20, %10 ]
%14 = fmul float %9, %11
%15 = shl nuw nsw i32 %13, 1
%16 = add nsw i32 %15, -1
%17 = mul nsw i32 %16, %15
%18 = sitofp i32 %17 to float
%19 = fdiv float %14, %18
%20 = add nuw nsw i32 %13, 1
%21 = fadd float %12, %19
%22 = fpext float %19 to double
%23 = fcmp ogt double %22, 0x3EB0C6F7A0B5ED8D
%24 = fcmp olt double %22, 0xBEB0C6F7A0B5ED8D
%25 = or i1 %23, %24
br i1 %25, label %10, label %26
26: ; preds = %10
%27 = fpext float %21 to double
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %3, double %27)
%29 = tail call i32 @putchar(i32 10)
%30 = add nuw nsw i32 %3, 30
%31 = icmp ult i32 %3, 331
br i1 %31, label %2, label %32
32: ; preds = %26
ret i32 0
}