#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 fabsd(double);
double sind(double rad) {
  double app;
  double diff;
  int inc = 1;
  while (rad > 2 * 3.14159265358979323846)
    rad -= 2 * 3.14159265358979323846;
  while (rad < -2 * 3.14159265358979323846)
    rad += 2 * 3.14159265358979323846;
  app = diff = rad;
  diff = (diff * (-(rad * rad))) / ((2.0 * inc) * (2.0 * inc + 1.0));
  app = app + diff;
  inc++;
  while (fabsd(diff) >= 0.00001) {
    diff = (diff * (-(rad * rad))) / ((2.0 * inc) * (2.0 * inc + 1.0));
    app = app + diff;
    inc++;
  }
  return app;
}


x86 assembly (clang, -O0):
<sind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movl   $0x1,-0x1c(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xecf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1156 <sind+0x46>
movsd  -0x8(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1124 <sind+0x14>
jmp    115b <sind+0x4b>
movsd  0xea5(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1185 <sind+0x75>
movsd  0xe8a(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    115b <sind+0x4b>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
movsd  0xe4d(%rip),%xmm1
mulsd  %xmm2,%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm2
addsd  %xmm2,%xmm2
movsd  0xe30(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabsd@plt>
movsd  0xe05(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     129f <sind+0x18f>
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
movsd  0xdbc(%rip),%xmm1
mulsd  %xmm2,%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm2
addsd  %xmm2,%xmm2
movsd  0xd9f(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1209 <sind+0xf9>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sind>:
push   %rbx
sub    $0x30,%rsp
ucomisd 0xee3(%rip),%xmm0
jbe    113a <sind+0x2a>
movsd  0xee1(%rip),%xmm2
movsd  0xed1(%rip),%xmm1
nop
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
ja     1130 <sind+0x20>
movsd  0xec6(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    115a <sind+0x4a>
movsd  0xeb0(%rip),%xmm1
addsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
ja     1150 <sind+0x40>
movapd 0xece(%rip),%xmm1
xorpd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
movapd %xmm1,0x20(%rsp)
mulsd  %xmm1,%xmm2
divsd  0xe90(%rip),%xmm2
addsd  %xmm2,%xmm0
movapd %xmm0,(%rsp)
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
call   1030 <fabsd@plt>
ucomisd 0xe78(%rip),%xmm0
jae    11a9 <sind+0x99>
movapd (%rsp),%xmm2
jmp    1215 <sind+0x105>
mov    $0x2,%ebx
movapd (%rsp),%xmm2
movapd 0x10(%rsp),%xmm3
nopl   0x0(%rax)
mulsd  0x20(%rsp),%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  %xmm0,%xmm0
movapd %xmm0,%xmm1
addsd  0xe43(%rip),%xmm1
mulsd  %xmm0,%xmm1
divsd  %xmm1,%xmm3
movapd %xmm3,0x10(%rsp)
addsd  %xmm3,%xmm2
movapd %xmm2,(%rsp)
add    $0x1,%ebx
movapd %xmm3,%xmm0
call   1030 <fabsd@plt>
movapd 0x10(%rsp),%xmm3
movapd (%rsp),%xmm2
ucomisd 0xe05(%rip),%xmm0
jae    11c0 <sind+0xb0>
movapd %xmm2,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @sind(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double %0, double* %2
store i32 1, i32* %5
br label %6
6: ; preds = %9, %1
%7 = load double, double* %2
%8 = fcmp ogt double %7, 0x401921FB54442D18
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load double, double* %2
%11 = fsub double %10, 0x401921FB54442D18
store double %11, double* %2
br label %6
12: ; preds = %6
br label %13
13: ; preds = %16, %12
%14 = load double, double* %2
%15 = fcmp olt double %14, 0xC01921FB54442D18
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load double, double* %2
%18 = fadd double %17, 0x401921FB54442D18
store double %18, double* %2
br label %13
19: ; preds = %13
%20 = load double, double* %2
store double %20, double* %4
store double %20, double* %3
%21 = load double, double* %4
%22 = load double, double* %2
%23 = load double, double* %2
%24 = fmul double %22, %23
%25 = fneg double %24
%26 = fmul double %21, %25
%27 = load i32, i32* %5
%28 = sitofp i32 %27 to double
%29 = fmul double 2.000000e+00, %28
%30 = load i32, i32* %5
%31 = sitofp i32 %30 to double
%32 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %31, double 1.000000e+00)
%33 = fmul double %29, %32
%34 = fdiv double %26, %33
store double %34, double* %4
%35 = load double, double* %3
%36 = load double, double* %4
%37 = fadd double %35, %36
store double %37, double* %3
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %40
40: ; preds = %44, %19
%41 = load double, double* %4
%42 = call double @fabsd(double %41)
%43 = fcmp oge double %42, 1.000000e-05
br i1 %43, label %44, label %64
44: ; preds = %40
%45 = load double, double* %4
%46 = load double, double* %2
%47 = load double, double* %2
%48 = fmul double %46, %47
%49 = fneg double %48
%50 = fmul double %45, %49
%51 = load i32, i32* %5
%52 = sitofp i32 %51 to double
%53 = fmul double 2.000000e+00, %52
%54 = load i32, i32* %5
%55 = sitofp i32 %54 to double
%56 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %55, double 1.000000e+00)
%57 = fmul double %53, %56
%58 = fdiv double %50, %57
store double %58, double* %4
%59 = load double, double* %3
%60 = load double, double* %4
%61 = fadd double %59, %60
store double %61, double* %3
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %40
64: ; preds = %40
%65 = load double, double* %3
ret double %65
}

LLVM IR (-O2):
define double @sind(double %0) {
%2 = fcmp ogt double %0, 0x401921FB54442D18
br i1 %2, label %6, label %3
3: ; preds = %6, %1
%4 = phi double [ %0, %1 ], [ %8, %6 ]
%5 = fcmp olt double %4, 0xC01921FB54442D18
br i1 %5, label %10, label %14
6: ; preds = %1, %6
%7 = phi double [ %8, %6 ], [ %0, %1 ]
%8 = fadd double %7, 0xC01921FB54442D18
%9 = fcmp ogt double %8, 0x401921FB54442D18
br i1 %9, label %6, label %3
10: ; preds = %3, %10
%11 = phi double [ %12, %10 ], [ %4, %3 ]
%12 = fadd double %11, 0x401921FB54442D18
%13 = fcmp olt double %12, 0xC01921FB54442D18
br i1 %13, label %10, label %14
14: ; preds = %10, %3
%15 = phi double [ %4, %3 ], [ %12, %10 ]
%16 = fneg double %15
%17 = fmul double %15, %16
%18 = fmul double %15, %17
%19 = fdiv double %18, 6.000000e+00
%20 = fadd double %15, %19
%21 = tail call double @fabsd(double %19)
%22 = fcmp ult double %21, 1.000000e-05
br i1 %22, label %37, label %23
23: ; preds = %14, %23
%24 = phi i32 [ %34, %23 ], [ 2, %14 ]
%25 = phi double [ %32, %23 ], [ %19, %14 ]
%26 = phi double [ %33, %23 ], [ %20, %14 ]
%27 = fmul double %17, %25
%28 = sitofp i32 %24 to double
%29 = fmul double %28, 2.000000e+00
%30 = tail call double @llvm.fmuladd.f64(double %28, double 2.000000e+00, double 1.000000e+00)
%31 = fmul double %29, %30
%32 = fdiv double %27, %31
%33 = fadd double %26, %32
%34 = add nuw nsw i32 %24, 1
%35 = tail call double @fabsd(double %32)
%36 = fcmp ult double %35, 1.000000e-05
br i1 %36, label %37, label %23
37: ; preds = %23, %14
%38 = phi double [ %20, %14 ], [ %33, %23 ]
ret double %38
}