#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double, ...);
double minimaxsin(double);
int main() {
  double input;
  double sin, cos;
  char line[15];
  FILE *ifp = fopen("trig.in", "r");
  FILE *ofp = fopen("trig.out", "w");
  while (fgets(line, 15, ifp)) {
    input = atof(line);
    sin = minimaxsin(input *
                     0.017453292519943295769236907684886127134428718885417);
    cos = minimaxsin(1.570796326794896619231321691639751442098584699687552 -
                     input *
                         0.017453292519943295769236907684886127134428718885417);
    if (cos < 0.000000001 && cos > -0.000000001) {
      fprintf(ofp, "%.7f %.7f n\n", sin, cos);
    } else {
      fprintf(ofp, "%.7f %.7f %.7f\n", sin, cos, (sin / cos));
    }
  }
  fclose(ifp);
  fclose(ofp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
lea    0xe9d(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x40(%rbp)
lea    -0x2f(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0xf,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1292 <main+0x132>
lea    -0x2f(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xe39(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1060 <minimaxsin@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe06(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe02(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <minimaxsin@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xddc(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1267 <main+0x107>
movsd  -0x20(%rbp),%xmm0
movsd  0xddc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1267 <main+0x107>
mov    -0x40(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xdda(%rip),%rsi
mov    $0x2,%al
call   1070 <fprintf@plt>
jmp    128d <main+0x12d>
mov    -0x40(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
divsd  -0x20(%rbp),%xmm2
lea    0xdbc(%rip),%rsi
mov    $0x3,%al
call   1070 <fprintf@plt>
jmp    119d <main+0x3d>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xeac(%rip),%rdi
lea    0xead(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0xea0(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0x11(%rsp),%rdi
mov    $0xf,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1262 <main+0x102>
lea    0x11(%rsp),%rbx
lea    0xe75(%rip),%r12
lea    0xe7b(%rip),%r13
jmp    11ff <main+0x9f>
nopl   0x0(%rax)
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x3,%al
call   1070 <fprintf@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1262 <main+0x102>
mov    %rbx,%rdi
call   1030 <atof@plt>
mulsd  0xdf1(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1060 <minimaxsin@plt>
movsd  %xmm0,(%rsp)
movsd  0xde1(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
call   1060 <minimaxsin@plt>
movapd %xmm0,%xmm1
movsd  0xdd2(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d0 <main+0x70>
ucomisd 0xdcc(%rip),%xmm1
jbe    11d0 <main+0x70>
mov    %r14,%rdi
mov    %r12,%rsi
movsd  (%rsp),%xmm0
mov    $0x2,%al
call   1070 <fprintf@plt>
jmp    11ea <main+0x8a>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"trig.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"trig.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [13 x i8] c"%.7f %.7f n\0A\00"
@.str.5 = [16 x i8] c"%.7f %.7f %.7f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca [15 x i8]
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %6
%9 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %9, i32** %7
br label %10
10: ; preds = %43, %0
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%12 = load i32*, i32** %6
%13 = call i64 @fgets(i8* %11, i32 15, i32* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %44
15: ; preds = %10
%16 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%17 = call double @atof(i8* %16)
store double %17, double* %2
%18 = load double, double* %2
%19 = fmul double %18, 0x3F91DF46A2529D39
%20 = call double @minimaxsin(double %19)
store double %20, double* %3
%21 = load double, double* %2
%22 = fneg double %21
%23 = call double @llvm.fmuladd.f64(double %22, double 0x3F91DF46A2529D39, double 0x3FF921FB54442D18)
%24 = call double @minimaxsin(double %23)
store double %24, double* %4
%25 = load double, double* %4
%26 = fcmp olt double %25, 1.000000e-09
br i1 %26, label %27, label %35
27: ; preds = %15
%28 = load double, double* %4
%29 = fcmp ogt double %28, -1.000000e-09
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32*, i32** %7
%32 = load double, double* %3
%33 = load double, double* %4
%34 = call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), double %32, double %33)
br label %43
35: ; preds = %27, %15
%36 = load i32*, i32** %7
%37 = load double, double* %3
%38 = load double, double* %4
%39 = load double, double* %3
%40 = load double, double* %4
%41 = fdiv double %39, %40
%42 = call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %37, double %38, double %41)
br label %43
43: ; preds = %35, %30
br label %10
44: ; preds = %10
%45 = load i32*, i32** %6
%46 = call i32 @fclose(i32* %45)
%47 = load i32*, i32** %7
%48 = call i32 @fclose(i32* %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"trig.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"trig.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [13 x i8] c"%.7f %.7f n\0A\00"
@.str.5 = [16 x i8] c"%.7f %.7f %.7f\0A\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = call i64 @fgets(i8* %2, i32 15, i32* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %0, %22
%8 = call double @atof(i8* %2)
%9 = fmul double %8, 0x3F91DF46A2529D39
%10 = call double @minimaxsin(double %9)
%11 = fneg double %8
%12 = call double @llvm.fmuladd.f64(double %11, double 0x3F91DF46A2529D39, double 0x3FF921FB54442D18)
%13 = call double @minimaxsin(double %12)
%14 = fcmp olt double %13, 1.000000e-09
%15 = fcmp ogt double %13, -1.000000e-09
%16 = and i1 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %7
%18 = call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), double %10, double %13)
br label %22
19: ; preds = %7
%20 = fdiv double %10, %13
%21 = call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %10, double %13, double %20)
br label %22
22: ; preds = %19, %17
%23 = call i64 @fgets(i8* %2, i32 15, i32* %3)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %7
25: ; preds = %22, %0
%26 = call i32 @fclose(i32* %3)
%27 = call i32 @fclose(i32* %4)
ret i32 0
}