#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 exp(double);
double expm1(double);
double fabs(double);
double cosh(double x) {
  double t, w;
  int ix;
  unsigned lx;
  ix = *(1 + (const int *)&x);
  ix &= 0x7fffffff;
  if (ix >= 0x7ff00000) {
    return x * x;
  }
  if (ix < 0x3fd62e43) {
    t = expm1(fabs(x));
    w = 1.0 + t;
    if (ix < 0x3c800000) {
      return w;
    }
    return 1.0 + (t * t) / (w + w);
  }
  if (ix < 0x40360000) {
    t = exp(fabs(x));
    return 0.5 * t + 0.5 / t;
  }
  if (ix < 0x40862E42) {
    return 0.5 * exp(fabs(x));
  }
  lx = ((1 >> 29) + (unsigned int)x);
  if ((ix < 0x408633CE) ||
      ((ix == 0x408633ce) && (lx <= (unsigned)0x8fb9f87d))) {
    w = exp(0.5 * fabs(x));
    t = 0.5 * w;
    return t * w;
  }
  return 1.0e300 * 1.0e300;
}


x86 assembly (clang, -O0):
<cosh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
and    $0x7fffffff,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x7ff00000,-0x24(%rbp)
jl     115f <cosh+0x3f>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fc <cosh+0x1dc>
cmpl   $0x3fd62e43,-0x24(%rbp)
jge    11e2 <cosh+0xc2>
movsd  -0x10(%rbp),%xmm0
movaps 0xea8(%rip),%xmm1
pand   %xmm1,%xmm0
call   1040 <expm1@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe82(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x3c800000,-0x24(%rbp)
jge    11b4 <cosh+0x94>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fc <cosh+0x1dc>
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe3c(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fc <cosh+0x1dc>
cmpl   $0x40360000,-0x24(%rbp)
jge    1235 <cosh+0x115>
movsd  -0x10(%rbp),%xmm0
movaps 0xe25(%rip),%xmm1
pand   %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdf2(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xde5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fc <cosh+0x1dc>
cmpl   $0x40862e42,-0x24(%rbp)
jge    1270 <cosh+0x150>
movsd  -0x10(%rbp),%xmm0
movaps 0xdd2(%rip),%xmm1
pand   %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xda6(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fc <cosh+0x1dc>
cvttsd2si -0x10(%rbp),%rax
add    $0x0,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x408633ce,-0x24(%rbp)
jl     12a3 <cosh+0x183>
cmpl   $0x408633ce,-0x24(%rbp)
jne    12ef <cosh+0x1cf>
cmpl   $0x8fb9f87d,-0x28(%rbp)
ja     12ef <cosh+0x1cf>
movsd  -0x10(%rbp),%xmm1
movaps 0xd71(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd4d(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xd37(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fc <cosh+0x1dc>
movsd  0xd09(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cosh>:
push   %rbx
movq   %xmm0,%rbx
shr    $0x20,%rbx
and    $0x7fffffff,%ebx
cmp    $0x7ff00000,%ebx
jb     1146 <cosh+0x26>
mulsd  %xmm0,%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rbx
ret
cmp    $0x3fd62e42,%ebx
ja     1185 <cosh+0x65>
andpd  0xeca(%rip),%xmm0
call   1040 <expm1@plt>
movsd  0xead(%rip),%xmm1
addsd  %xmm0,%xmm1
cmp    $0x3c800000,%ebx
jb     1140 <cosh+0x20>
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
addsd  0xe8d(%rip),%xmm0
jmp    113c <cosh+0x1c>
cmp    $0x4035ffff,%ebx
ja     11b4 <cosh+0x94>
andpd  0xe8b(%rip),%xmm0
call   1030 <exp@plt>
movsd  0xe66(%rip),%xmm1
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
pop    %rbx
ret
cmp    $0x40862e41,%ebx
ja     11da <cosh+0xba>
andpd  0xe5c(%rip),%xmm0
call   1030 <exp@plt>
movapd %xmm0,%xmm1
mulsd  0xe33(%rip),%xmm1
jmp    1140 <cosh+0x20>
cmp    $0x408633ce,%ebx
jb     1200 <cosh+0xe0>
movsd  0xe16(%rip),%xmm1
jne    1140 <cosh+0x20>
cvttsd2si %xmm0,%rax
cmp    $0x8fb9f87d,%eax
ja     1140 <cosh+0x20>
andpd  0xe18(%rip),%xmm0
mulsd  0xdf8(%rip),%xmm0
call   1030 <exp@plt>
movsd  0xdeb(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
jmp    1140 <cosh+0x20>

LLVM IR (-O0):
define double @cosh(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
store double %0, double* %3
%8 = bitcast double* %3 to i32*
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %9
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = and i32 %11, 2147483647
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp sge i32 %13, 2146435072
br i1 %14, label %15, label %19
15: ; preds = %1
%16 = load double, double* %3
%17 = load double, double* %3
%18 = fmul double %16, %17
store double %18, double* %2
br label %83
19: ; preds = %1
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 1071001155
br i1 %21, label %22, label %41
22: ; preds = %19
%23 = load double, double* %3
%24 = call double @llvm.fabs.f64(double %23)
%25 = call double @expm1(double %24)
store double %25, double* %4
%26 = load double, double* %4
%27 = fadd double 1.000000e+00, %26
store double %27, double* %5
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 1015021568
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = load double, double* %5
store double %31, double* %2
br label %83
32: ; preds = %22
%33 = load double, double* %4
%34 = load double, double* %4
%35 = fmul double %33, %34
%36 = load double, double* %5
%37 = load double, double* %5
%38 = fadd double %36, %37
%39 = fdiv double %35, %38
%40 = fadd double 1.000000e+00, %39
store double %40, double* %2
br label %83
41: ; preds = %19
%42 = load i32, i32* %6
%43 = icmp slt i32 %42, 1077280768
br i1 %43, label %44, label %52
44: ; preds = %41
%45 = load double, double* %3
%46 = call double @llvm.fabs.f64(double %45)
%47 = call double @exp(double %46)
store double %47, double* %4
%48 = load double, double* %4
%49 = load double, double* %4
%50 = fdiv double 5.000000e-01, %49
%51 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %48, double %50)
store double %51, double* %2
br label %83
52: ; preds = %41
%53 = load i32, i32* %6
%54 = icmp slt i32 %53, 1082535490
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = load double, double* %3
%57 = call double @llvm.fabs.f64(double %56)
%58 = call double @exp(double %57)
%59 = fmul double 5.000000e-01, %58
store double %59, double* %2
br label %83
60: ; preds = %52
%61 = load double, double* %3
%62 = fptoui double %61 to i32
%63 = add i32 0, %62
store i32 %63, i32* %7
%64 = load i32, i32* %6
%65 = icmp slt i32 %64, 1082536910
br i1 %65, label %72, label %66
66: ; preds = %60
%67 = load i32, i32* %6
%68 = icmp eq i32 %67, 1082536910
br i1 %68, label %69, label %82
69: ; preds = %66
%70 = load i32, i32* %7
%71 = icmp ule i32 %70, -1883637635
br i1 %71, label %72, label %82
72: ; preds = %69, %60
%73 = load double, double* %3
%74 = call double @llvm.fabs.f64(double %73)
%75 = fmul double 5.000000e-01, %74
%76 = call double @exp(double %75)
store double %76, double* %5
%77 = load double, double* %5
%78 = fmul double 5.000000e-01, %77
store double %78, double* %4
%79 = load double, double* %4
%80 = load double, double* %5
%81 = fmul double %79, %80
store double %81, double* %2
br label %83
82: ; preds = %69, %66
store double 0x7FF0000000000000, double* %2
br label %83
83: ; preds = %82, %72, %55, %44, %32, %30, %15
%84 = load double, double* %2
ret double %84
}

LLVM IR (-O2):
define double @cosh(double %0) {
%2 = bitcast double %0 to i64
%3 = lshr i64 %2, 32
%4 = trunc i64 %3 to i32
%5 = and i32 %4, 2147483647
%6 = icmp ugt i32 %5, 2146435071
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = fmul double %0, %0
br label %47
9: ; preds = %1
%10 = icmp ult i32 %5, 1071001155
br i1 %10, label %11, label %21
11: ; preds = %9
%12 = tail call double @llvm.fabs.f64(double %0)
%13 = tail call double @expm1(double %12)
%14 = fadd double %13, 1.000000e+00
%15 = icmp ult i32 %5, 1015021568
br i1 %15, label %47, label %16
16: ; preds = %11
%17 = fmul double %13, %13
%18 = fadd double %14, %14
%19 = fdiv double %17, %18
%20 = fadd double %19, 1.000000e+00
br label %47
21: ; preds = %9
%22 = icmp ult i32 %5, 1077280768
br i1 %22, label %23, label %28
23: ; preds = %21
%24 = tail call double @llvm.fabs.f64(double %0)
%25 = tail call double @exp(double %24)
%26 = fdiv double 5.000000e-01, %25
%27 = tail call double @llvm.fmuladd.f64(double %25, double 5.000000e-01, double %26)
br label %47
28: ; preds = %21
%29 = icmp ult i32 %5, 1082535490
br i1 %29, label %30, label %34
30: ; preds = %28
%31 = tail call double @llvm.fabs.f64(double %0)
%32 = tail call double @exp(double %31)
%33 = fmul double %32, 5.000000e-01
br label %47
34: ; preds = %28
%35 = icmp ult i32 %5, 1082536910
br i1 %35, label %41, label %36
36: ; preds = %34
%37 = fptoui double %0 to i32
%38 = icmp eq i32 %5, 1082536910
%39 = icmp ult i32 %37, -1883637634
%40 = select i1 %38, i1 %39, i1 false
br i1 %40, label %41, label %47
41: ; preds = %36, %34
%42 = tail call double @llvm.fabs.f64(double %0)
%43 = fmul double %42, 5.000000e-01
%44 = tail call double @exp(double %43)
%45 = fmul double %44, 5.000000e-01
%46 = fmul double %44, %45
br label %47
47: ; preds = %36, %11, %41, %30, %23, %16, %7
%48 = phi double [ %8, %7 ], [ %20, %16 ], [ %27, %23 ], [ %33, %30 ], [ %46, %41 ], [ %14, %11 ], [ 0x7FF0000000000000, %36 ]
ret double %48
}