#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 */
scalar_t__ cos(double);
scalar_t__ cosf(float);
scalar_t__ sin(double);
scalar_t__ sinf(float);
int /*<<< orphan*/ stress_long_double_put(long double);
void __attribute__((hot)) stress_cpu_trig(const char *name) {
  int i;
  long double d_sum = 0.0L;
  (void)name;
  for (i = 0; i < 1500; i++) {
    long double theta =
        (2.0L * (3.14159265358979323846264338327950288419716939937511L) *
         (long double)i) /
        1500.0L;
    {
      double thetad = (double)theta;
      float thetaf = (float)theta;
      d_sum += (((long double)cos((double)(theta))) *
                ((long double)sin((double)(theta))));
      d_sum += ((long double)cos(thetad) * (long double)sin(thetad));
      d_sum += ((long double)cosf(thetaf) * (long double)sinf(thetaf));
    }
    {
      long double thetal = theta * 2.0L;
      double thetad = (double)thetal;
      float thetaf = (float)thetal;
      d_sum += ((long double)cos((double)(thetal)));
      d_sum += (long double)cos(thetad);
      d_sum += (long double)cosf(thetaf);
    }
    {
      long double thetal = theta * 3.0L;
      double thetad = (double)thetal;
      float thetaf = (float)thetal;
      d_sum += ((long double)sin((double)(thetal)));
      d_sum += (long double)sin(thetad);
      d_sum += (long double)sinf(thetaf);
    }
  }
  stress_long_double_put(d_sum);
}


x86 assembly (clang, -O0):
<stress_cpu_trig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
fldz
fstpt  -0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x5dc,-0xc(%rbp)
jge    139e <stress_cpu_trig+0x24e>
mov    -0xc(%rbp),%eax
mov    %eax,-0xe4(%rbp)
fildl  -0xe4(%rbp)
fldt   0xe73(%rip)
fmulp  %st,%st(1)
flds   0xe7b(%rip)
fdivrp %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fstpl  -0x38(%rbp)
fldt   -0x30(%rbp)
fstps  -0x3c(%rbp)
fldt   -0x30(%rbp)
fstpl  -0xf0(%rbp)
movsd  -0xf0(%rbp),%xmm0
ff
call   1070 <cos@plt>
mov    %rax,-0xe0(%rbp)
fildll -0xe0(%rbp)
fstpt  -0x12c(%rbp)
fldt   -0x30(%rbp)
fstpl  -0xf8(%rbp)
movsd  -0xf8(%rbp),%xmm0
ff
call   1050 <sin@plt>
fldt   -0x12c(%rbp)
mov    %rax,-0xd8(%rbp)
fildll -0xd8(%rbp)
fldt   -0x20(%rbp)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1070 <cos@plt>
mov    %rax,-0xd0(%rbp)
fildll -0xd0(%rbp)
fstpt  -0x120(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <sin@plt>
fldt   -0x120(%rbp)
mov    %rax,-0xc8(%rbp)
fildll -0xc8(%rbp)
fldt   -0x20(%rbp)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
movss  -0x3c(%rbp),%xmm0
call   1040 <cosf@plt>
mov    %rax,-0xc0(%rbp)
fildll -0xc0(%rbp)
fstpt  -0x114(%rbp)
movss  -0x3c(%rbp),%xmm0
call   1030 <sinf@plt>
fldt   -0x114(%rbp)
mov    %rax,-0xb8(%rbp)
fildll -0xb8(%rbp)
fldt   -0x20(%rbp)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x30(%rbp)
fadd   %st,%st(0)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fstpl  -0x58(%rbp)
fldt   -0x50(%rbp)
fstps  -0x5c(%rbp)
fldt   -0x50(%rbp)
fstpl  -0x100(%rbp)
movsd  -0x100(%rbp),%xmm0
ff
call   1070 <cos@plt>
mov    %rax,-0xb0(%rbp)
fildll -0xb0(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1070 <cos@plt>
mov    %rax,-0xa8(%rbp)
fildll -0xa8(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
movss  -0x5c(%rbp),%xmm0
call   1040 <cosf@plt>
mov    %rax,-0xa0(%rbp)
fildll -0xa0(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x30(%rbp)
flds   0xcfe(%rip)
fmulp  %st,%st(1)
fstpt  -0x70(%rbp)
fldt   -0x70(%rbp)
fstpl  -0x78(%rbp)
fldt   -0x70(%rbp)
fstps  -0x7c(%rbp)
fldt   -0x70(%rbp)
fstpl  -0x108(%rbp)
movsd  -0x108(%rbp),%xmm0
ff
call   1050 <sin@plt>
mov    %rax,-0x98(%rbp)
fildll -0x98(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
movsd  -0x78(%rbp),%xmm0
call   1050 <sin@plt>
mov    %rax,-0x90(%rbp)
fildll -0x90(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
movss  -0x7c(%rbp),%xmm0
call   1030 <sinf@plt>
mov    %rax,-0x88(%rbp)
fildll -0x88(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <stress_cpu_trig+0x1b>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <stress_long_double_put@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stress_cpu_trig>:
push   %rbx
sub    $0x100,%rsp
fldz
mov    $0x5dc,%ebx
fldt   0xf5b(%rip)
fstpt  0xf4(%rsp)
fld1
fstpt  0xe8(%rsp)
fld    %st(0)
nopw   0x0(%rax,%rax,1)
fstpt  0x20(%rsp)
fstpt  0x64(%rsp)
fldt   0x64(%rsp)
fldt   0xf4(%rsp)
fmulp  %st,%st(1)
fdivs  0xf35(%rip)
fld    %st(0)
fstpt  0x40(%rsp)
fstl   0x80(%rsp)
movsd  0x80(%rsp),%xmm1
movsd  %xmm1,0x30(%rsp)
fstps  0x54(%rsp)
movss  0x54(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
movaps %xmm1,%xmm0
call   1070 <cos@plt>
mov    %rax,0x88(%rsp)
fildll 0x88(%rsp)
fstpt  0x58(%rsp)
movsd  0x30(%rsp),%xmm0
call   1050 <sin@plt>
mov    %rax,0x90(%rsp)
fildll 0x90(%rsp)
fldt   0x58(%rsp)
fmulp  %st,%st(1)
fldt   0x20(%rsp)
faddp  %st,%st(1)
fstpt  0x20(%rsp)
movsd  0x30(%rsp),%xmm0
call   1070 <cos@plt>
mov    %rax,0x98(%rsp)
fildll 0x98(%rsp)
fstpt  0x58(%rsp)
movsd  0x30(%rsp),%xmm0
call   1050 <sin@plt>
mov    %rax,0xa0(%rsp)
fildll 0xa0(%rsp)
fldt   0x58(%rsp)
fmulp  %st,%st(1)
fldt   0x20(%rsp)
faddp  %st,%st(1)
fstpt  0x30(%rsp)
movss  0x14(%rsp),%xmm0
call   1040 <cosf@plt>
mov    %rax,0xa8(%rsp)
fildll 0xa8(%rsp)
fstpt  0x20(%rsp)
movss  0x14(%rsp),%xmm0
call   1030 <sinf@plt>
mov    %rax,0xb0(%rsp)
fildll 0xb0(%rsp)
fldt   0x20(%rsp)
fmulp  %st,%st(1)
fldt   0x30(%rsp)
faddp  %st,%st(1)
fstpt  0x14(%rsp)
fldt   0x40(%rsp)
fadd   %st,%st(0)
fstl   0x78(%rsp)
movsd  0x78(%rsp),%xmm1
movsd  %xmm1,0x20(%rsp)
fstps  0x50(%rsp)
movss  0x50(%rsp),%xmm0
movss  %xmm0,0x30(%rsp)
movaps %xmm1,%xmm0
call   1070 <cos@plt>
mov    %rax,0xb8(%rsp)
fildll 0xb8(%rsp)
fldt   0x14(%rsp)
faddp  %st,%st(1)
fstpt  0x14(%rsp)
movsd  0x20(%rsp),%xmm0
call   1070 <cos@plt>
mov    %rax,0xc0(%rsp)
fildll 0xc0(%rsp)
fldt   0x14(%rsp)
faddp  %st,%st(1)
fstpt  0x14(%rsp)
movss  0x30(%rsp),%xmm0
call   1040 <cosf@plt>
mov    %rax,0xc8(%rsp)
fildll 0xc8(%rsp)
fldt   0x14(%rsp)
faddp  %st,%st(1)
fstpt  0x14(%rsp)
fldt   0x40(%rsp)
fmuls  0xd9f(%rip)
fstl   0x70(%rsp)
movsd  0x70(%rsp),%xmm1
movsd  %xmm1,0x20(%rsp)
fstps  0x4c(%rsp)
movss  0x4c(%rsp),%xmm0
movss  %xmm0,0x30(%rsp)
movaps %xmm1,%xmm0
call   1050 <sin@plt>
mov    %rax,0xd0(%rsp)
fildll 0xd0(%rsp)
fldt   0x14(%rsp)
faddp  %st,%st(1)
fstpt  0x40(%rsp)
movsd  0x20(%rsp),%xmm0
call   1050 <sin@plt>
mov    %rax,0xd8(%rsp)
fildll 0xd8(%rsp)
fldt   0x40(%rsp)
faddp  %st,%st(1)
fstpt  0x40(%rsp)
movss  0x30(%rsp),%xmm0
call   1030 <sinf@plt>
mov    %rax,0xe0(%rsp)
fildll 0xe0(%rsp)
fldt   0x40(%rsp)
faddp  %st,%st(1)
fldt   0x64(%rsp)
fldt   0xe8(%rsp)
faddp  %st,%st(1)
add    $0xffffffff,%ebx
fxch   %st(1)
jne    10c0 <stress_cpu_trig+0x30>
fstp   %st(1)
fstpt  (%rsp)
call   1060 <stress_long_double_put@plt>
add    $0x100,%rsp
pop    %rbx
ret
cs nopw 0x0(%rax,%rax,1)
nop

LLVM IR (-O0):
define void @stress_cpu_trig(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca double
%7 = alloca float
%8 = alloca x86_fp80
%9 = alloca double
%10 = alloca float
%11 = alloca x86_fp80
%12 = alloca double
%13 = alloca float
store i8* %0, i8** %2
store x86_fp80 0xK00000000000000000000, x86_fp80* %4
%14 = load i8*, i8** %2
store i32 0, i32* %3
br label %15
15: ; preds = %97, %1
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 1500
br i1 %17, label %18, label %100
18: ; preds = %15
%19 = load i32, i32* %3
%20 = sitofp i32 %19 to x86_fp80
%21 = fmul x86_fp80 0xK4001C90FDAA22168C235, %20
%22 = fdiv x86_fp80 %21, 0xK4009BB80000000000000
store x86_fp80 %22, x86_fp80* %5
%23 = load x86_fp80, x86_fp80* %5
%24 = fptrunc x86_fp80 %23 to double
store double %24, double* %6
%25 = load x86_fp80, x86_fp80* %5
%26 = fptrunc x86_fp80 %25 to float
store float %26, float* %7
%27 = load x86_fp80, x86_fp80* %5
%28 = fptrunc x86_fp80 %27 to double
%29 = call i64 @cos(double %28)
%30 = sitofp i64 %29 to x86_fp80
%31 = load x86_fp80, x86_fp80* %5
%32 = fptrunc x86_fp80 %31 to double
%33 = call i64 @sin(double %32)
%34 = sitofp i64 %33 to x86_fp80
%35 = load x86_fp80, x86_fp80* %4
%36 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %30, x86_fp80 %34, x86_fp80 %35)
store x86_fp80 %36, x86_fp80* %4
%37 = load double, double* %6
%38 = call i64 @cos(double %37)
%39 = sitofp i64 %38 to x86_fp80
%40 = load double, double* %6
%41 = call i64 @sin(double %40)
%42 = sitofp i64 %41 to x86_fp80
%43 = load x86_fp80, x86_fp80* %4
%44 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %39, x86_fp80 %42, x86_fp80 %43)
store x86_fp80 %44, x86_fp80* %4
%45 = load float, float* %7
%46 = call i64 @cosf(float %45)
%47 = sitofp i64 %46 to x86_fp80
%48 = load float, float* %7
%49 = call i64 @sinf(float %48)
%50 = sitofp i64 %49 to x86_fp80
%51 = load x86_fp80, x86_fp80* %4
%52 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %47, x86_fp80 %50, x86_fp80 %51)
store x86_fp80 %52, x86_fp80* %4
%53 = load x86_fp80, x86_fp80* %5
%54 = fmul x86_fp80 %53, 0xK40008000000000000000
store x86_fp80 %54, x86_fp80* %8
%55 = load x86_fp80, x86_fp80* %8
%56 = fptrunc x86_fp80 %55 to double
store double %56, double* %9
%57 = load x86_fp80, x86_fp80* %8
%58 = fptrunc x86_fp80 %57 to float
store float %58, float* %10
%59 = load x86_fp80, x86_fp80* %8
%60 = fptrunc x86_fp80 %59 to double
%61 = call i64 @cos(double %60)
%62 = sitofp i64 %61 to x86_fp80
%63 = load x86_fp80, x86_fp80* %4
%64 = fadd x86_fp80 %63, %62
store x86_fp80 %64, x86_fp80* %4
%65 = load double, double* %9
%66 = call i64 @cos(double %65)
%67 = sitofp i64 %66 to x86_fp80
%68 = load x86_fp80, x86_fp80* %4
%69 = fadd x86_fp80 %68, %67
store x86_fp80 %69, x86_fp80* %4
%70 = load float, float* %10
%71 = call i64 @cosf(float %70)
%72 = sitofp i64 %71 to x86_fp80
%73 = load x86_fp80, x86_fp80* %4
%74 = fadd x86_fp80 %73, %72
store x86_fp80 %74, x86_fp80* %4
%75 = load x86_fp80, x86_fp80* %5
%76 = fmul x86_fp80 %75, 0xK4000C000000000000000
store x86_fp80 %76, x86_fp80* %11
%77 = load x86_fp80, x86_fp80* %11
%78 = fptrunc x86_fp80 %77 to double
store double %78, double* %12
%79 = load x86_fp80, x86_fp80* %11
%80 = fptrunc x86_fp80 %79 to float
store float %80, float* %13
%81 = load x86_fp80, x86_fp80* %11
%82 = fptrunc x86_fp80 %81 to double
%83 = call i64 @sin(double %82)
%84 = sitofp i64 %83 to x86_fp80
%85 = load x86_fp80, x86_fp80* %4
%86 = fadd x86_fp80 %85, %84
store x86_fp80 %86, x86_fp80* %4
%87 = load double, double* %12
%88 = call i64 @sin(double %87)
%89 = sitofp i64 %88 to x86_fp80
%90 = load x86_fp80, x86_fp80* %4
%91 = fadd x86_fp80 %90, %89
store x86_fp80 %91, x86_fp80* %4
%92 = load float, float* %13
%93 = call i64 @sinf(float %92)
%94 = sitofp i64 %93 to x86_fp80
%95 = load x86_fp80, x86_fp80* %4
%96 = fadd x86_fp80 %95, %94
store x86_fp80 %96, x86_fp80* %4
br label %97
97: ; preds = %18
%98 = load i32, i32* %3
%99 = add nsw i32 %98, 1
store i32 %99, i32* %3
br label %15
100: ; preds = %15
%101 = load x86_fp80, x86_fp80* %4
%102 = call i32 @stress_long_double_put(x86_fp80 %101)
ret void
}

LLVM IR (-O2):
define void @stress_cpu_trig(i8* nocapture readnone %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %49, %2 ]
%4 = phi x86_fp80 [ 0xK00000000000000000000, %1 ], [ %48, %2 ]
%5 = sitofp i32 %3 to x86_fp80
%6 = fmul x86_fp80 %5, 0xK4001C90FDAA22168C235
%7 = fdiv x86_fp80 %6, 0xK4009BB80000000000000
%8 = fptrunc x86_fp80 %7 to double
%9 = fptrunc x86_fp80 %7 to float
%10 = tail call i64 @cos(double %8)
%11 = sitofp i64 %10 to x86_fp80
%12 = tail call i64 @sin(double %8)
%13 = sitofp i64 %12 to x86_fp80
%14 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %11, x86_fp80 %13, x86_fp80 %4)
%15 = tail call i64 @cos(double %8)
%16 = sitofp i64 %15 to x86_fp80
%17 = tail call i64 @sin(double %8)
%18 = sitofp i64 %17 to x86_fp80
%19 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %16, x86_fp80 %18, x86_fp80 %14)
%20 = tail call i64 @cosf(float %9)
%21 = sitofp i64 %20 to x86_fp80
%22 = tail call i64 @sinf(float %9)
%23 = sitofp i64 %22 to x86_fp80
%24 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %21, x86_fp80 %23, x86_fp80 %19)
%25 = fmul x86_fp80 %7, 0xK40008000000000000000
%26 = fptrunc x86_fp80 %25 to double
%27 = fptrunc x86_fp80 %25 to float
%28 = tail call i64 @cos(double %26)
%29 = sitofp i64 %28 to x86_fp80
%30 = fadd x86_fp80 %24, %29
%31 = tail call i64 @cos(double %26)
%32 = sitofp i64 %31 to x86_fp80
%33 = fadd x86_fp80 %30, %32
%34 = tail call i64 @cosf(float %27)
%35 = sitofp i64 %34 to x86_fp80
%36 = fadd x86_fp80 %33, %35
%37 = fmul x86_fp80 %7, 0xK4000C000000000000000
%38 = fptrunc x86_fp80 %37 to double
%39 = fptrunc x86_fp80 %37 to float
%40 = tail call i64 @sin(double %38)
%41 = sitofp i64 %40 to x86_fp80
%42 = fadd x86_fp80 %36, %41
%43 = tail call i64 @sin(double %38)
%44 = sitofp i64 %43 to x86_fp80
%45 = fadd x86_fp80 %42, %44
%46 = tail call i64 @sinf(float %39)
%47 = sitofp i64 %46 to x86_fp80
%48 = fadd x86_fp80 %45, %47
%49 = add nuw nsw i32 %3, 1
%50 = icmp eq i32 %49, 1500
br i1 %50, label %51, label %2
51: ; preds = %2
%52 = tail call i32 @stress_long_double_put(x86_fp80 %48)
ret void
}