#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*/ cos(double);
double mycos(double);
int /*<<< orphan*/ printf(char *, ...);
void taylor_cos() {
  double x, rd = 3.14159 / 180;
  printf("    x      mycos(x)        cos(x)\n");
  for (x = 0; x <= 180; x = x + 10) {
    printf("%5.1f%14.6g%14.6g\n", x, mycos(x * rd), cos(x * rd));
  }
}


x86 assembly (clang, -O0):
<taylor_cos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  0xec0(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xea5(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     11cc <taylor_cos+0x9c>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <mycos@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    %eax,%esi
lea    0xe8d(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xe53(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    115b <taylor_cos+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<taylor_cos>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
xorpd  %xmm0,%xmm0
mov    $0xfffffff6,%ebp
lea    0xeae(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
mulsd  0xe83(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <mycos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
addsd  0xe4b(%rip),%xmm0
add    $0xa,%ebp
cmp    $0xab,%ebp
jb     1170 <taylor_cos+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c" x mycos(x) cos(x)\0A\00"
@.str.1 = [19 x i8] c"%5.1f%14.6g%14.6g\0A\00"
define void @taylor_cos() {
%1 = alloca double
%2 = alloca double
store double 0x3F91DF45A50DE270, double* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %1
br label %4
4: ; preds = %18, %0
%5 = load double, double* %1
%6 = fcmp ole double %5, 1.800000e+02
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = load double, double* %1
%9 = load double, double* %1
%10 = load double, double* %2
%11 = fmul double %9, %10
%12 = call double @mycos(double %11)
%13 = load double, double* %1
%14 = load double, double* %2
%15 = fmul double %13, %14
%16 = call i32 @cos(double %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %8, double %12, i32 %16)
br label %18
18: ; preds = %7
%19 = load double, double* %1
%20 = fadd double %19, 1.000000e+01
store double %20, double* %1
br label %4
21: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"%5.1f%14.6g%14.6g\0A\00"
@str = [34 x i8] c" x mycos(x) cos(x)\00"
define void @taylor_cos() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %9, %2 ]
%4 = sitofp i32 %3 to double
%5 = fmul double %4, 0x3F91DF45A50DE270
%6 = tail call double @mycos(double %5)
%7 = tail call i32 @cos(double %5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %4, double %6, i32 %7)
%9 = add nuw nsw i32 %3, 10
%10 = icmp ugt i32 %3, 170
br i1 %10, label %11, label %2
11: ; preds = %2
ret void
}