#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 cosh(double);
double exp(double);
double fabs(double);
double sinh(double);
void cchsh(double x, double *c, double *s) {
  double e, ei;
  if (fabs(x) <= 0.5) {
    *c = cosh(x);
    *s = sinh(x);
  } else {
    e = exp(x);
    ei = 0.5 / e;
    e = 0.5 * e;
    *s = e - ei;
    *c = e + ei;
  }
}


x86 assembly (clang, -O0):
<cchsh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm1
movaps 0xebf(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xea3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1190 <cchsh+0x60>
movsd  -0x8(%rbp),%xmm0
call   1040 <cosh@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
call   1030 <sinh@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11e7 <cchsh+0xb7>
movsd  -0x8(%rbp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe59(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe47(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cchsh>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movapd 0xebb(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xebf(%rip),%xmm2
ucomisd %xmm1,%xmm2
jae    1187 <cchsh+0x57>
call   1050 <exp@plt>
movsd  0xeac(%rip),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm0
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,(%r14)
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx)
jmp    11a4 <cchsh+0x74>
movapd %xmm0,(%rsp)
call   1040 <cosh@plt>
movsd  %xmm0,(%rbx)
movapd (%rsp),%xmm0
call   1030 <sinh@plt>
movsd  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @cchsh(double %0, double* %1, double* %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double* %1, double** %5
store double* %2, double** %6
%9 = load double, double* %4
%10 = call double @llvm.fabs.f64(double %9)
%11 = fcmp ole double %10, 5.000000e-01
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load double, double* %4
%14 = call double @cosh(double %13)
%15 = load double*, double** %5
store double %14, double* %15
%16 = load double, double* %4
%17 = call double @sinh(double %16)
%18 = load double*, double** %6
store double %17, double* %18
br label %34
19: ; preds = %3
%20 = load double, double* %4
%21 = call double @exp(double %20)
store double %21, double* %7
%22 = load double, double* %7
%23 = fdiv double 5.000000e-01, %22
store double %23, double* %8
%24 = load double, double* %7
%25 = fmul double 5.000000e-01, %24
store double %25, double* %7
%26 = load double, double* %7
%27 = load double, double* %8
%28 = fsub double %26, %27
%29 = load double*, double** %6
store double %28, double* %29
%30 = load double, double* %7
%31 = load double, double* %8
%32 = fadd double %30, %31
%33 = load double*, double** %5
store double %32, double* %33
br label %34
34: ; preds = %19, %12
ret void
}

LLVM IR (-O2):
define void @cchsh(double %0, double* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = tail call double @llvm.fabs.f64(double %0)
%5 = fcmp ugt double %4, 5.000000e-01
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call double @cosh(double %0)
store double %7, double* %1
%8 = tail call double @sinh(double %0)
store double %8, double* %2
br label %15
9: ; preds = %3
%10 = tail call double @exp(double %0)
%11 = fdiv double 5.000000e-01, %10
%12 = fmul double %10, 5.000000e-01
%13 = fsub double %12, %11
store double %13, double* %2
%14 = fadd double %12, %11
store double %14, double* %1
br label %15
15: ; preds = %9, %6
ret void
}