#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 _logsumexp(double *, int, double);
int /*<<< orphan*/ _mixed_sort(double *, int /*<<< orphan*/, int);
extern double _logsumexp_sort_inplace(double *array, int size) {
  if (0 == size)
    return -(1.0 / 0.0);
  _mixed_sort(array, 0, size - 1);
  return _logsumexp(array, size, array[size - 1]);
}


x86 assembly (clang, -O0):
<_logsumexp_sort_inplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    114c <_logsumexp_sort_inplace+0x2c>
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1180 <_logsumexp_sort_inplace+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <_mixed_sort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <_logsumexp@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_logsumexp_sort_inplace>:
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     1152 <_logsumexp_sort_inplace+0x32>
mov    %esi,%ebx
mov    %rdi,%r14
lea    -0x1(%rbx),%edx
xor    %esi,%esi
call   1040 <_mixed_sort@plt>
movslq %ebx,%rax
movsd  -0x8(%r14,%rax,8),%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <_logsumexp@plt>
movsd  0xea6(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @_logsumexp_sort_inplace(double* %0, i32 %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 0, %6
br i1 %7, label %8, label %9
8: ; preds = %2
store double 0xFFF0000000000000, double* %3
br label %23
9: ; preds = %2
%10 = load double*, double** %4
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
%13 = call i32 @_mixed_sort(double* %10, i32 0, i32 %12)
%14 = load double*, double** %4
%15 = load i32, i32* %5
%16 = load double*, double** %4
%17 = load i32, i32* %5
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %16, i64 %19
%21 = load double, double* %20
%22 = call double @_logsumexp(double* %14, i32 %15, double %21)
store double %22, double* %3
br label %23
23: ; preds = %9, %8
%24 = load double, double* %3
ret double %24
}

LLVM IR (-O2):
define double @_logsumexp_sort_inplace(double* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = tail call i32 @_mixed_sort(double* %0, i32 0, i32 %5)
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds double, double* %0, i64 %7
%9 = load double, double* %8
%10 = tail call double @_logsumexp(double* %0, i32 %1, double %9)
br label %11
11: ; preds = %2, %4
%12 = phi double [ %10, %4 ], [ 0xFFF0000000000000, %2 ]
ret double %12
}