#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*/ cosine(double);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int scanf(char *, double *);
int /*<<< orphan*/ sine(double);
int main() {
  double x;
  double s, c;
  if (scanf("%lf", &x) == 1) {
    while (x >= 2 * 3.14159265358979323846)
      x -= 2 * 3.14159265358979323846;
    while (x < 0)
      x += 2 * 3.14159265358979323846;
    if (0 <= x && x < 1.57079632679489661923)
      s = x, c = x;
    else if (1.57079632679489661923 <= x && x < 3.14159265358979323846)
      s = 3.14159265358979323846 - x, c = x;
    else if (3.14159265358979323846 <= x &&
             x < 3.14159265358979323846 + 1.57079632679489661923)
      s = 3.14159265358979323846 - x, c = 2 * 3.14159265358979323846 - x;
    else if (3.14159265358979323846 <=
                 3.14159265358979323846 + 1.57079632679489661923 &&
             x < 2 * 3.14159265358979323846)
      s = x - 2 * 3.14159265358979323846, c = 2 * 3.14159265358979323846 - x;
    printf("sin = %.6lf\n", sine(s));
    printf("cos = %.6lf\n", cosine(c));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    131f <main+0x1df>
jmp    116d <main+0x2d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe86(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     119f <main+0x5f>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    116d <main+0x2d>
jmp    11a4 <main+0x64>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11c9 <main+0x89>
movsd  0xe46(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11a4 <main+0x64>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1207 <main+0xc7>
movsd  0xe25(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1207 <main+0xc7>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12ef <main+0x1af>
movsd  -0x10(%rbp),%xmm0
movsd  0xdf4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1252 <main+0x112>
movsd  0xdea(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1252 <main+0x112>
movsd  0xdd7(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12ea <main+0x1aa>
movsd  -0x10(%rbp),%xmm0
movsd  0xdb1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12a5 <main+0x165>
movsd  0xda7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12a5 <main+0x165>
movsd  0xd8c(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd6a(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12e5 <main+0x1a5>
movsd  0xd53(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12e0 <main+0x1a0>
movsd  -0x10(%rbp),%xmm0
movsd  0xd3b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd2a(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12e5 <main+0x1a5>
jmp    12ea <main+0x1aa>
jmp    12ef <main+0x1af>
movsd  -0x18(%rbp),%xmm0
call   1050 <sine@plt>
mov    %eax,%esi
lea    0xd22(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
call   1030 <cosine@plt>
mov    %eax,%esi
lea    0xd17(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xedd(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1274 <main+0x134>
movsd  0x10(%rsp),%xmm2
ucomisd 0xe94(%rip),%xmm2
jb     1190 <main+0x50>
movsd  0xe92(%rip),%xmm0
movsd  0xe82(%rip),%xmm1
xchg   %ax,%ax
addsd  %xmm0,%xmm2
ucomisd %xmm1,%xmm2
jae    1180 <main+0x40>
movsd  %xmm2,0x10(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jbe    11c0 <main+0x80>
movsd  0xe5e(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addsd  %xmm1,%xmm2
ucomisd %xmm2,%xmm0
ja     11b0 <main+0x70>
movsd  %xmm2,0x10(%rsp)
ucomisd %xmm0,%xmm2
jb     11e0 <main+0xa0>
movsd  0xe42(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    11e0 <main+0xa0>
movapd %xmm2,%xmm0
movsd  %xmm2,0x8(%rsp)
jmp    1248 <main+0x108>
ucomisd 0xe28(%rip),%xmm2
jb     1204 <main+0xc4>
movsd  0xe26(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    1204 <main+0xc4>
subsd  %xmm2,%xmm0
movsd  %xmm2,0x8(%rsp)
jmp    1248 <main+0x108>
ucomisd 0xe0c(%rip),%xmm2
jb     122a <main+0xea>
movsd  0xe0a(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    122a <main+0xea>
movsd  0xdf4(%rip),%xmm0
subsd  %xmm2,%xmm0
jmp    1236 <main+0xf6>
movsd  0xdd6(%rip),%xmm0
addsd  %xmm2,%xmm0
movsd  0xdc2(%rip),%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1050 <sine@plt>
lea    0xdd8(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
call   1030 <cosine@plt>
lea    0xdcc(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [13 x i8] c"sin = %.6lf\0A\00"
@.str.2 = [13 x i8] c"cos = %.6lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %69
7: ; preds = %0
br label %8
8: ; preds = %11, %7
%9 = load double, double* %2
%10 = fcmp oge double %9, 0x401921FB54442D18
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load double, double* %2
%13 = fsub double %12, 0x401921FB54442D18
store double %13, double* %2
br label %8
14: ; preds = %8
br label %15
15: ; preds = %18, %14
%16 = load double, double* %2
%17 = fcmp olt double %16, 0.000000e+00
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load double, double* %2
%20 = fadd double %19, 0x401921FB54442D18
store double %20, double* %2
br label %15
21: ; preds = %15
%22 = load double, double* %2
%23 = fcmp ole double 0.000000e+00, %22
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load double, double* %2
%26 = fcmp olt double %25, 0x3FF921FB54442D18
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load double, double* %2
store double %28, double* %3
%29 = load double, double* %2
store double %29, double* %4
br label %62
30: ; preds = %24, %21
%31 = load double, double* %2
%32 = fcmp ole double 0x3FF921FB54442D18, %31
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load double, double* %2
%35 = fcmp olt double %34, 0x400921FB54442D18
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load double, double* %2
%38 = fsub double 0x400921FB54442D18, %37
store double %38, double* %3
%39 = load double, double* %2
store double %39, double* %4
br label %61
40: ; preds = %33, %30
%41 = load double, double* %2
%42 = fcmp ole double 0x400921FB54442D18, %41
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = load double, double* %2
%45 = fcmp olt double %44, 0x4012D97C7F3321D2
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load double, double* %2
%48 = fsub double 0x400921FB54442D18, %47
store double %48, double* %3
%49 = load double, double* %2
%50 = fsub double 0x401921FB54442D18, %49
store double %50, double* %4
br label %60
51: ; preds = %43, %40
%52 = load double, double* %2
%53 = fcmp olt double %52, 0x401921FB54442D18
br i1 %53, label %54, label %59
54: ; preds = %51
%55 = load double, double* %2
%56 = fsub double %55, 0x401921FB54442D18
store double %56, double* %3
%57 = load double, double* %2
%58 = fsub double 0x401921FB54442D18, %57
store double %58, double* %4
br label %59
59: ; preds = %54, %51
br label %60
60: ; preds = %59, %46
br label %61
61: ; preds = %60, %36
br label %62
62: ; preds = %61, %27
%63 = load double, double* %3
%64 = call i32 @sine(double %63)
%65 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %64)
%66 = load double, double* %4
%67 = call i32 @cosine(double %66)
%68 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %62, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [13 x i8] c"sin = %.6lf\0A\00"
@.str.2 = [13 x i8] c"cos = %.6lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %50
5: ; preds = %0
%6 = load double, double* %1
%7 = fcmp ult double %6, 0x401921FB54442D18
br i1 %7, label %13, label %8
8: ; preds = %5, %8
%9 = phi double [ %10, %8 ], [ %6, %5 ]
%10 = fadd double %9, 0xC01921FB54442D18
%11 = fcmp ult double %10, 0x401921FB54442D18
br i1 %11, label %12, label %8
12: ; preds = %8
store double %10, double* %1
br label %13
13: ; preds = %12, %5
%14 = phi double [ %10, %12 ], [ %6, %5 ]
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %13, %16
%17 = phi double [ %18, %16 ], [ %14, %13 ]
%18 = fadd double %17, 0x401921FB54442D18
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %16, label %20
20: ; preds = %16
store double %18, double* %1
br label %21
21: ; preds = %20, %13
%22 = phi double [ %18, %20 ], [ %14, %13 ]
%23 = fcmp oge double %22, 0.000000e+00
%24 = fcmp olt double %22, 0x3FF921FB54442D18
%25 = and i1 %23, %24
br i1 %25, label %43, label %26
26: ; preds = %21
%27 = fcmp oge double %22, 0x3FF921FB54442D18
%28 = fcmp olt double %22, 0x400921FB54442D18
%29 = and i1 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = fsub double 0x400921FB54442D18, %22
br label %43
32: ; preds = %26
%33 = fcmp oge double %22, 0x400921FB54442D18
%34 = fcmp olt double %22, 0x4012D97C7F3321D2
%35 = and i1 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = fsub double 0x400921FB54442D18, %22
%38 = fsub double 0x401921FB54442D18, %22
br label %43
39: ; preds = %32
%40 = fcmp olt double %22, 0x401921FB54442D18
%41 = fadd double %22, 0xC01921FB54442D18
%42 = fsub double 0x401921FB54442D18, %22
br label %43
43: ; preds = %21, %30, %39, %36
%44 = phi double [ %31, %30 ], [ %37, %36 ], [ %41, %39 ], [ %22, %21 ]
%45 = phi double [ %22, %30 ], [ %38, %36 ], [ %42, %39 ], [ %22, %21 ]
%46 = call i32 @sine(double %44)
%47 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = call i32 @cosine(double %45)
%49 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %43, %0
ret i32 0
}