#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 log(double);
double log1p(double);
double sqrt(double);
double acosh(double x) {
  double t;
  int hx;
  hx = *(1 + (const int *)&x);
  if (hx < 0x3ff00000) {
    return (0.0 / 0.0);
  } else if (hx >= 0x41b00000) {
    if (hx >= 0x7ff00000) {
      return x + x;
    } else {
      return log(x) + 6.93147180559945286227e-01;
    }
  } else if (((hx - 0x3ff00000) | *(const int *)&x) == 0) {
    return 0.0;
  } else if (hx > 0x40000000) {
    t = x * x;
    return log(2.0 * x - 1.0 / (x + sqrt(t - 1.0)));
  } else {
    t = x - 1.0;
    return log1p(t + sqrt(2.0 * t + t * t));
  }
}


x86 assembly (clang, -O0):
<acosh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3ff00000,-0x1c(%rbp)
jge    1162 <acosh+0x32>
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b4 <acosh+0x184>
cmpl   $0x41b00000,-0x1c(%rbp)
jl     11b0 <acosh+0x80>
cmpl   $0x7ff00000,-0x1c(%rbp)
jl     1190 <acosh+0x60>
movsd  -0x10(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b4 <acosh+0x184>
movsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movsd  0xe66(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b4 <acosh+0x184>
mov    -0x1c(%rbp),%eax
sub    $0x3ff00000,%eax
or     -0x10(%rbp),%eax
cmp    $0x0,%eax
jne    11d1 <acosh+0xa1>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b4 <acosh+0x184>
cmpl   $0x40000000,-0x1c(%rbp)
jle    1262 <acosh+0x132>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdf2(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm2
movsd  0xdd0(%rip),%xmm1
divsd  %xmm2,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12b4 <acosh+0x184>
movsd  -0x10(%rbp),%xmm0
movsd  0xd91(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1050 <log1p@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acosh>:
push   %rax
movq   %xmm0,%rcx
mov    %rcx,%rax
shr    $0x20,%rax
cmp    $0x3ff00000,%eax
jge    1152 <acosh+0x22>
movsd  0xeb4(%rip),%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret
movdqa %xmm0,%xmm2
cmp    $0x41b00000,%eax
jb     116a <acosh+0x3a>
cmp    $0x7ff00000,%eax
jb     119b <acosh+0x6b>
addsd  %xmm2,%xmm2
jmp    114c <acosh+0x1c>
lea    -0x3ff00000(%rax),%edx
or     %edx,%ecx
je     11b2 <acosh+0x82>
cmp    $0x40000001,%eax
jb     11b8 <acosh+0x88>
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe7d(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e4 <acosh+0xb4>
sqrtsd %xmm0,%xmm0
jmp    11f3 <acosh+0xc3>
movapd %xmm2,%xmm0
call   1030 <log@plt>
movapd %xmm0,%xmm2
addsd  0xe60(%rip),%xmm2
jmp    114c <acosh+0x1c>
xorpd  %xmm2,%xmm2
jmp    114c <acosh+0x1c>
addsd  0xe48(%rip),%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1215 <acosh+0xe5>
sqrtsd %xmm0,%xmm0
jmp    1224 <acosh+0xf4>
movsd  %xmm2,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm2
addsd  %xmm2,%xmm0
movsd  0xe09(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
pop    %rax
jmp    1030 <log@plt>
movsd  %xmm2,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm2
addsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
pop    %rax
jmp    1050 <log1p@plt>

LLVM IR (-O0):
define double @acosh(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double %0, double* %3
%6 = bitcast double* %3 to i32*
%7 = getelementptr inbounds i32, i32* %6, i64 1
%8 = load i32, i32* %7
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 1072693248
br i1 %10, label %11, label %12
11: ; preds = %1
store double 0x7FF8000000000000, double* %2
br label %63
12: ; preds = %1
%13 = load i32, i32* %5
%14 = icmp sge i32 %13, 1102053376
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load i32, i32* %5
%17 = icmp sge i32 %16, 2146435072
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load double, double* %3
%20 = load double, double* %3
%21 = fadd double %19, %20
store double %21, double* %2
br label %63
22: ; preds = %15
%23 = load double, double* %3
%24 = call double @log(double %23)
%25 = fadd double %24, 0x3FE62E42FEFA39EF
store double %25, double* %2
br label %63
26: ; preds = %12
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 1072693248
%29 = bitcast double* %3 to i32*
%30 = load i32, i32* %29
%31 = or i32 %28, %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %26
store double 0.000000e+00, double* %2
br label %63
34: ; preds = %26
%35 = load i32, i32* %5
%36 = icmp sgt i32 %35, 1073741824
br i1 %36, label %37, label %51
37: ; preds = %34
%38 = load double, double* %3
%39 = load double, double* %3
%40 = fmul double %38, %39
store double %40, double* %4
%41 = load double, double* %3
%42 = load double, double* %3
%43 = load double, double* %4
%44 = fsub double %43, 1.000000e+00
%45 = call double @sqrt(double %44)
%46 = fadd double %42, %45
%47 = fdiv double 1.000000e+00, %46
%48 = fneg double %47
%49 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %41, double %48)
%50 = call double @log(double %49)
store double %50, double* %2
br label %63
51: ; preds = %34
%52 = load double, double* %3
%53 = fsub double %52, 1.000000e+00
store double %53, double* %4
%54 = load double, double* %4
%55 = load double, double* %4
%56 = load double, double* %4
%57 = load double, double* %4
%58 = fmul double %56, %57
%59 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %55, double %58)
%60 = call double @sqrt(double %59)
%61 = fadd double %54, %60
%62 = call double @log1p(double %61)
store double %62, double* %2
br label %63
63: ; preds = %51, %37, %33, %22, %18, %11
%64 = load double, double* %2
ret double %64
}

LLVM IR (-O2):
define double @acosh(double %0) {
%2 = bitcast double %0 to i64
%3 = lshr i64 %2, 32
%4 = trunc i64 %3 to i32
%5 = icmp slt i32 %4, 1072693248
br i1 %5, label %37, label %6
6: ; preds = %1
%7 = icmp ugt i32 %4, 1102053375
br i1 %7, label %8, label %15
8: ; preds = %6
%9 = icmp ugt i32 %4, 2146435071
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = fadd double %0, %0
br label %37
12: ; preds = %8
%13 = tail call double @log(double %0)
%14 = fadd double %13, 0x3FE62E42FEFA39EF
br label %37
15: ; preds = %6
%16 = add nsw i32 %4, -1072693248
%17 = trunc i64 %2 to i32
%18 = or i32 %16, %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %37, label %20
20: ; preds = %15
%21 = icmp ugt i32 %4, 1073741824
br i1 %21, label %22, label %30
22: ; preds = %20
%23 = fmul double %0, %0
%24 = fadd double %23, -1.000000e+00
%25 = tail call double @sqrt(double %24)
%26 = fadd double %25, %0
%27 = fdiv double -1.000000e+00, %26
%28 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double %27)
%29 = tail call double @log(double %28)
br label %37
30: ; preds = %20
%31 = fadd double %0, -1.000000e+00
%32 = fmul double %31, %31
%33 = tail call double @llvm.fmuladd.f64(double %31, double 2.000000e+00, double %32)
%34 = tail call double @sqrt(double %33)
%35 = fadd double %31, %34
%36 = tail call double @log1p(double %35)
br label %37
37: ; preds = %15, %1, %30, %22, %12, %10
%38 = phi double [ %11, %10 ], [ %14, %12 ], [ %29, %22 ], [ %36, %30 ], [ 0x7FF8000000000000, %1 ], [ 0.000000e+00, %15 ]
ret double %38
}