#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 */
struct probans {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ar_test(struct probans *, unsigned int, int, long double,
                           long double *, long double *);
long double ar_auc(struct probans *ans, unsigned int num_probs, int tclass) {
  long double auc = 0;
  long double t;
  long double fpr_last = 0;
  for (t = 1.01; t >= -0.01; t -= 0.001) {
    long double tpr, fpr;
    ar_test(ans, num_probs, tclass, t, &tpr, &fpr);
    long double auc_column =
        ((fpr_last - fpr) < 0 ? ((fpr_last - fpr) * -1) : (fpr_last - fpr)) *
        tpr;
    auc += auc_column;
    fpr_last = fpr;
  }
  return auc;
}


x86 assembly (clang, -O0):
<ar_auc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
fldz
fld    %st(0)
fstpt  -0x20(%rbp)
fstpt  -0x40(%rbp)
fldl   0xecb(%rip)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldl   0xec7(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     11d6 <ar_auc+0xc6>
jmp    1152 <ar_auc+0x42>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    -0x50(%rbp),%rcx
lea    -0x60(%rbp),%r8
call   1030 <ar_test@plt>
fldt   -0x40(%rbp)
fldt   -0x60(%rbp)
fsubrp %st,%st(1)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    119c <ar_auc+0x8c>
jmp    118a <ar_auc+0x7a>
fldt   -0x40(%rbp)
fldt   -0x60(%rbp)
fsubrp %st,%st(1)
fchs
fstpt  -0x7c(%rbp)
jmp    11a7 <ar_auc+0x97>
fldt   -0x40(%rbp)
fldt   -0x60(%rbp)
fsubrp %st,%st(1)
fstpt  -0x7c(%rbp)
fldt   -0x7c(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
fstpt  -0x70(%rbp)
fldt   -0x70(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x60(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x30(%rbp)
fldl   0xe44(%rip)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
jmp    1138 <ar_auc+0x28>
fldt   -0x20(%rbp)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ar_auc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
fldl   0xed6(%rip)
fldz
lea    0x60(%rsp),%r15
lea    0x50(%rsp),%r12
fldl   0xed4(%rip)
fstpt  0x14(%rsp)
fld    %st(0)
fld    %st(1)
fstpt  0x20(%rsp)
nopl   0x0(%rax,%rax,1)
fxch   %st(1)
fstpt  0x2c(%rsp)
fstpt  0x38(%rsp)
fld    %st(0)
fstpt  0x44(%rsp)
fstpt  (%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15,%rcx
mov    %r12,%r8
call   1030 <ar_test@plt>
fldt   0x50(%rsp)
fldt   0x2c(%rsp)
fsub   %st(1),%st
fldt   0x20(%rsp)
fucomip %st(1),%st
fld    %st(0)
fchs
fxch   %st(1)
fcmovnbe %st(1),%st
fstp   %st(1)
fldt   0x60(%rsp)
fmulp  %st,%st(1)
fldt   0x38(%rsp)
faddp  %st,%st(1)
fldt   0x44(%rsp)
faddl  0xe62(%rip)
fldt   0x14(%rsp)
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
fxch   %st(2)
fxch   %st(1)
jae    1150 <ar_auc+0x40>
fstp   %st(1)
fstp   %st(1)
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.probans = type { i32 }
define x86_fp80 @ar_auc(%struct.probans* %0, i32 %1, i32 %2) {
%4 = alloca %struct.probans*
%5 = alloca i32
%6 = alloca i32
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%9 = alloca x86_fp80
%10 = alloca x86_fp80
%11 = alloca x86_fp80
%12 = alloca x86_fp80
store %struct.probans* %0, %struct.probans** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store x86_fp80 0xK00000000000000000000, x86_fp80* %7
store x86_fp80 0xK00000000000000000000, x86_fp80* %9
store x86_fp80 0xK3FFF8147AE147AE14800, x86_fp80* %8
br label %13
13: ; preds = %43, %3
%14 = load x86_fp80, x86_fp80* %8
%15 = fcmp oge x86_fp80 %14, 0xKBFF8A3D70A3D70A3D800
br i1 %15, label %16, label %46
16: ; preds = %13
%17 = load %struct.probans*, %struct.probans** %4
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = load x86_fp80, x86_fp80* %8
%21 = call i32 @ar_test(%struct.probans* %17, i32 %18, i32 %19, x86_fp80 %20, x86_fp80* %10, x86_fp80* %11)
%22 = load x86_fp80, x86_fp80* %9
%23 = load x86_fp80, x86_fp80* %11
%24 = fsub x86_fp80 %22, %23
%25 = fcmp olt x86_fp80 %24, 0xK00000000000000000000
br i1 %25, label %26, label %31
26: ; preds = %16
%27 = load x86_fp80, x86_fp80* %9
%28 = load x86_fp80, x86_fp80* %11
%29 = fsub x86_fp80 %27, %28
%30 = fmul x86_fp80 %29, 0xKBFFF8000000000000000
br label %35
31: ; preds = %16
%32 = load x86_fp80, x86_fp80* %9
%33 = load x86_fp80, x86_fp80* %11
%34 = fsub x86_fp80 %32, %33
br label %35
35: ; preds = %31, %26
%36 = phi x86_fp80 [ %30, %26 ], [ %34, %31 ]
%37 = load x86_fp80, x86_fp80* %10
%38 = fmul x86_fp80 %36, %37
store x86_fp80 %38, x86_fp80* %12
%39 = load x86_fp80, x86_fp80* %12
%40 = load x86_fp80, x86_fp80* %7
%41 = fadd x86_fp80 %40, %39
store x86_fp80 %41, x86_fp80* %7
%42 = load x86_fp80, x86_fp80* %11
store x86_fp80 %42, x86_fp80* %9
br label %43
43: ; preds = %35
%44 = load x86_fp80, x86_fp80* %8
%45 = fsub x86_fp80 %44, 0xK3FF583126E978D4FE000
store x86_fp80 %45, x86_fp80* %8
br label %13
46: ; preds = %13
%47 = load x86_fp80, x86_fp80* %7
ret x86_fp80 %47
}

LLVM IR (-O2):
%struct.probans = type { i32 }
define x86_fp80 @ar_auc(%struct.probans* %0, i32 %1, i32 %2) {
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = bitcast x86_fp80* %4 to i8*
%7 = bitcast x86_fp80* %5 to i8*
br label %8
8: ; preds = %3, %8
%9 = phi x86_fp80 [ 0xK00000000000000000000, %3 ], [ %20, %8 ]
%10 = phi x86_fp80 [ 0xK3FFF8147AE147AE14800, %3 ], [ %21, %8 ]
%11 = phi x86_fp80 [ 0xK00000000000000000000, %3 ], [ %13, %8 ]
%12 = call i32 @ar_test(%struct.probans* %0, i32 %1, i32 %2, x86_fp80 %10, x86_fp80* %4, x86_fp80* %5)
%13 = load x86_fp80, x86_fp80* %5
%14 = fsub x86_fp80 %11, %13
%15 = fcmp olt x86_fp80 %14, 0xK00000000000000000000
%16 = fneg x86_fp80 %14
%17 = select i1 %15, x86_fp80 %16, x86_fp80 %14
%18 = load x86_fp80, x86_fp80* %4
%19 = fmul x86_fp80 %18, %17
%20 = fadd x86_fp80 %9, %19
%21 = fadd x86_fp80 %10, 0xKBFF583126E978D4FE000
%22 = fcmp ult x86_fp80 %21, 0xKBFF8A3D70A3D70A3D800
br i1 %22, label %23, label %8
23: ; preds = %8
ret x86_fp80 %20
}