#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__ expm1(double);
double log1p(scalar_t__);
double logSumExp3(double a, double b, double c) {
  return (a > b)   ? (a > c)
                         ? (a + log1p(((expm1((c - a)) + expm1((b - a))) + 2)))
                         : (c + log1p(((expm1((b - c)) + expm1((a - c))) + 2)))
           : (b > c) ? (b + log1p(((expm1((c - b)) + expm1((a - b))) + 2)))
                   : (c + log1p(((expm1((b - c)) + expm1((a - c))) + 2)));
}


x86 assembly (clang, -O0):
<logSumExp3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1205 <logSumExp3+0xe5>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a9 <logSumExp3+0x89>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1030 <expm1@plt>
mov    %rax,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1030 <expm1@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1040 <log1p@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f6 <logSumExp3+0xd6>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <expm1@plt>
mov    %rax,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <expm1@plt>
mov    -0x40(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1040 <log1p@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12be <logSumExp3+0x19e>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1267 <logSumExp3+0x147>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1030 <expm1@plt>
mov    %rax,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1030 <expm1@plt>
mov    -0x60(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1040 <log1p@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12b4 <logSumExp3+0x194>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <expm1@plt>
mov    %rax,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <expm1@plt>
mov    -0x70(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1040 <log1p@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logSumExp3>:
push   %rbx
sub    $0x10,%rsp
ucomisd %xmm1,%xmm0
movsd  %xmm0,(%rsp)
jbe    1159 <logSumExp3+0x39>
ucomisd %xmm2,%xmm0
jbe    116f <logSumExp3+0x4f>
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <expm1@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
subsd  (%rsp),%xmm0
jmp    11bc <logSumExp3+0x9c>
ucomisd %xmm2,%xmm1
jbe    1192 <logSumExp3+0x72>
subsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
jmp    11a0 <logSumExp3+0x80>
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1030 <expm1@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm0
jmp    11b3 <logSumExp3+0x93>
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1030 <expm1@plt>
mov    %rax,%rbx
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <expm1@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x2,%rdi
call   1040 <log1p@plt>
addsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @logSumExp3(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%7 = load double, double* %4
%8 = load double, double* %5
%9 = fcmp ogt double %7, %8
br i1 %9, label %10, label %44
10: ; preds = %3
%11 = load double, double* %4
%12 = load double, double* %6
%13 = fcmp ogt double %11, %12
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load double, double* %4
%16 = load double, double* %6
%17 = load double, double* %4
%18 = fsub double %16, %17
%19 = call i64 @expm1(double %18)
%20 = load double, double* %5
%21 = load double, double* %4
%22 = fsub double %20, %21
%23 = call i64 @expm1(double %22)
%24 = add nsw i64 %19, %23
%25 = add nsw i64 %24, 2
%26 = call double @log1p(i64 %25)
%27 = fadd double %15, %26
br label %42
28: ; preds = %10
%29 = load double, double* %6
%30 = load double, double* %5
%31 = load double, double* %6
%32 = fsub double %30, %31
%33 = call i64 @expm1(double %32)
%34 = load double, double* %4
%35 = load double, double* %6
%36 = fsub double %34, %35
%37 = call i64 @expm1(double %36)
%38 = add nsw i64 %33, %37
%39 = add nsw i64 %38, 2
%40 = call double @log1p(i64 %39)
%41 = fadd double %29, %40
br label %42
42: ; preds = %28, %14
%43 = phi double [ %27, %14 ], [ %41, %28 ]
br label %78
44: ; preds = %3
%45 = load double, double* %5
%46 = load double, double* %6
%47 = fcmp ogt double %45, %46
br i1 %47, label %48, label %62
48: ; preds = %44
%49 = load double, double* %5
%50 = load double, double* %6
%51 = load double, double* %5
%52 = fsub double %50, %51
%53 = call i64 @expm1(double %52)
%54 = load double, double* %4
%55 = load double, double* %5
%56 = fsub double %54, %55
%57 = call i64 @expm1(double %56)
%58 = add nsw i64 %53, %57
%59 = add nsw i64 %58, 2
%60 = call double @log1p(i64 %59)
%61 = fadd double %49, %60
br label %76
62: ; preds = %44
%63 = load double, double* %6
%64 = load double, double* %5
%65 = load double, double* %6
%66 = fsub double %64, %65
%67 = call i64 @expm1(double %66)
%68 = load double, double* %4
%69 = load double, double* %6
%70 = fsub double %68, %69
%71 = call i64 @expm1(double %70)
%72 = add nsw i64 %67, %71
%73 = add nsw i64 %72, 2
%74 = call double @log1p(i64 %73)
%75 = fadd double %63, %74
br label %76
76: ; preds = %62, %48
%77 = phi double [ %61, %48 ], [ %75, %62 ]
br label %78
78: ; preds = %76, %42
%79 = phi double [ %43, %42 ], [ %77, %76 ]
ret double %79
}

LLVM IR (-O2):
define double @logSumExp3(double %0, double %1, double %2) {
%4 = fcmp ogt double %0, %1
br i1 %4, label %5, label %15
5: ; preds = %3
%6 = fcmp ogt double %0, %2
br i1 %6, label %7, label %11
7: ; preds = %5
%8 = fsub double %2, %0
%9 = tail call i64 @expm1(double %8)
%10 = fsub double %1, %0
br label %25
11: ; preds = %5
%12 = fsub double %1, %2
%13 = tail call i64 @expm1(double %12)
%14 = fsub double %0, %2
br label %25
15: ; preds = %3
%16 = fcmp ogt double %1, %2
br i1 %16, label %17, label %21
17: ; preds = %15
%18 = fsub double %2, %1
%19 = tail call i64 @expm1(double %18)
%20 = fsub double %0, %1
br label %25
21: ; preds = %15
%22 = fsub double %1, %2
%23 = tail call i64 @expm1(double %22)
%24 = fsub double %0, %2
br label %25
25: ; preds = %17, %21, %7, %11
%26 = phi double [ %20, %17 ], [ %24, %21 ], [ %10, %7 ], [ %14, %11 ]
%27 = phi i64 [ %19, %17 ], [ %23, %21 ], [ %9, %7 ], [ %13, %11 ]
%28 = phi double [ %1, %17 ], [ %2, %21 ], [ %0, %7 ], [ %2, %11 ]
%29 = tail call i64 @expm1(double %26)
%30 = add i64 %27, 2
%31 = add i64 %30, %29
%32 = tail call double @log1p(i64 %31)
%33 = fadd double %32, %28
ret double %33
}