#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 fmax(double const, double const);
double fmin(double const, double const);
int /*<<< orphan*/ pvrs(double const *, double const *, double *, double *);
int /*<<< orphan*/ trrs(double const *, double const *, double *, double *);
int /*<<< orphan*/ tsrs(double const *, double const *, double *, double *);
void anrs(const double *WL, const double *WR, double *ps, double *us) {
  double pmax = fmax(WL[2], WR[2]);
  double pmin = fmin(WL[2], WR[2]);
  double Q = pmax / pmin;
  double pstar, ustar;
  pvrs(WL, WR, &pstar, &ustar);
  if ((Q < 2.0) && (pstar < pmax) && (pstar > pmin)) {
    *ps = pstar;
    *us = ustar;
  } else {
    if (pstar < pmin) {
      trrs(WL, WR, ps, us);
    } else {
      tsrs(WL, WR, &pstar, us);
      *ps = pstar;
    }
  }
  return;
}


x86 assembly (clang, -O0):
<anrs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordsd %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
maxsd  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordsd %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
minsd  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1050 <pvrs@plt>
movsd  0xe22(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    122c <anrs+0xfc>
movsd  -0x40(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122c <anrs+0xfc>
movsd  -0x40(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    122c <anrs+0xfc>
movsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1281 <anrs+0x151>
movsd  -0x40(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    125a <anrs+0x12a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <trrs@plt>
jmp    127c <anrs+0x14c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rcx
lea    -0x40(%rbp),%rdx
call   1030 <tsrs@plt>
movsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1281 <anrs+0x151>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<anrs>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movsd  0x10(%rdi),%xmm0
movsd  0x10(%rsi),%xmm3
movapd %xmm0,%xmm4
cmpunordsd %xmm0,%xmm4
movapd %xmm4,%xmm1
andpd  %xmm3,%xmm1
movapd %xmm3,%xmm2
maxsd  %xmm0,%xmm2
andnpd %xmm2,%xmm4
orpd   %xmm1,%xmm4
ucomisd %xmm0,%xmm0
jp     117c <anrs+0x4c>
minsd  %xmm0,%xmm3
movapd %xmm3,0x30(%rsp)
movapd %xmm4,%xmm0
divsd  %xmm3,%xmm0
movapd %xmm0,0x20(%rsp)
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r12,%rsi
movapd %xmm4,0x10(%rsp)
call   1050 <pvrs@plt>
movapd 0x30(%rsp),%xmm1
movsd  0xe49(%rip),%xmm0
ucomisd 0x20(%rsp),%xmm0
movsd  (%rsp),%xmm0
jbe    11e8 <anrs+0xb8>
movapd 0x10(%rsp),%xmm2
ucomisd %xmm0,%xmm2
jbe    11e8 <anrs+0xb8>
ucomisd %xmm1,%xmm0
jbe    11e8 <anrs+0xb8>
movsd  %xmm0,(%r15)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
jmp    121c <anrs+0xec>
ucomisd %xmm0,%xmm1
jbe    1201 <anrs+0xd1>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <trrs@plt>
jmp    121c <anrs+0xec>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rcx
call   1030 <tsrs@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r15)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @anrs(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 2
%16 = load double, double* %15
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
%20 = call double @llvm.maxnum.f64(double %16, double %19)
store double %20, double* %9
%21 = load double*, double** %5
%22 = getelementptr inbounds double, double* %21, i64 2
%23 = load double, double* %22
%24 = load double*, double** %6
%25 = getelementptr inbounds double, double* %24, i64 2
%26 = load double, double* %25
%27 = call double @llvm.minnum.f64(double %23, double %26)
store double %27, double* %10
%28 = load double, double* %9
%29 = load double, double* %10
%30 = fdiv double %28, %29
store double %30, double* %11
%31 = load double*, double** %5
%32 = load double*, double** %6
%33 = call i32 @pvrs(double* %31, double* %32, double* %12, double* %13)
%34 = load double, double* %11
%35 = fcmp olt double %34, 2.000000e+00
br i1 %35, label %36, label %49
36: ; preds = %4
%37 = load double, double* %12
%38 = load double, double* %9
%39 = fcmp olt double %37, %38
br i1 %39, label %40, label %49
40: ; preds = %36
%41 = load double, double* %12
%42 = load double, double* %10
%43 = fcmp ogt double %41, %42
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load double, double* %12
%46 = load double*, double** %7
store double %45, double* %46
%47 = load double, double* %13
%48 = load double*, double** %8
store double %47, double* %48
br label %67
49: ; preds = %40, %36, %4
%50 = load double, double* %12
%51 = load double, double* %10
%52 = fcmp olt double %50, %51
br i1 %52, label %53, label %59
53: ; preds = %49
%54 = load double*, double** %5
%55 = load double*, double** %6
%56 = load double*, double** %7
%57 = load double*, double** %8
%58 = call i32 @trrs(double* %54, double* %55, double* %56, double* %57)
br label %66
59: ; preds = %49
%60 = load double*, double** %5
%61 = load double*, double** %6
%62 = load double*, double** %8
%63 = call i32 @tsrs(double* %60, double* %61, double* %12, double* %62)
%64 = load double, double* %12
%65 = load double*, double** %7
store double %64, double* %65
br label %66
66: ; preds = %59, %53
br label %67
67: ; preds = %66, %44
ret void
}

LLVM IR (-O2):
define void @anrs(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = getelementptr inbounds double, double* %0, i64 2
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 2
%10 = load double, double* %9
%11 = tail call double @llvm.maxnum.f64(double %8, double %10)
%12 = tail call double @llvm.minnum.f64(double %8, double %10)
%13 = fdiv double %11, %12
%14 = bitcast double* %5 to i8*
%15 = bitcast double* %6 to i8*
%16 = call i32 @pvrs(double* %0, double* %1, double* %5, double* %6)
%17 = fcmp olt double %13, 2.000000e+00
%18 = load double, double* %5
br i1 %17, label %19, label %25
19: ; preds = %4
%20 = fcmp olt double %18, %11
%21 = fcmp ogt double %18, %12
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %23, label %25
23: ; preds = %19
store double %18, double* %2
%24 = load double, double* %6
store double %24, double* %3
br label %32
25: ; preds = %4, %19
%26 = fcmp olt double %18, %12
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = call i32 @trrs(double* %0, double* %1, double* %2, double* %3)
br label %32
29: ; preds = %25
%30 = call i32 @tsrs(double* %0, double* %1, double* %5, double* %3)
%31 = load double, double* %5
store double %31, double* %2
br label %32
32: ; preds = %27, %29, %23
ret void
}