#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 */
int /*<<< orphan*/ lmoutr(double *, double *, double *, double *, double *,
                          double *, double *);
double plinproj(double *, double *, double *, double *, int);
int /*<<< orphan*/ routlm(double *, double *, double *, double, double,
                          double *);
double ptriproj(double *v1, double *v2, double *v3, double *r, double *proj,
                int flag) {
  double la, mu, d;
  lmoutr(v1, v2, v3, r, &la, &mu, &d);
  if (flag) {
    if (la >= 0 && mu >= 0 && (la + mu) <= 1)
      routlm(v1, v2, v3, la, mu, proj);
    else if (la < 0)
      d = plinproj(v1, v3, r, proj, flag);
    else if (mu < 0)
      d = plinproj(v1, v2, r, proj, flag);
    else
      d = plinproj(v2, v3, r, proj, flag);
  } else {
    routlm(v1, v2, v3, la, mu, proj);
  }
  return d;
}


x86 assembly (clang, -O0):
<ptriproj>:
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    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x48(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <lmoutr@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1272 <ptriproj+0x142>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e3 <ptriproj+0xb3>
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e3 <ptriproj+0xb3>
movsd  -0x38(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xe4b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11e3 <ptriproj+0xb3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    -0x28(%rbp),%rcx
call   1030 <routlm@plt>
jmp    126d <ptriproj+0x13d>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1214 <ptriproj+0xe4>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1050 <plinproj@plt>
movsd  %xmm0,-0x48(%rbp)
jmp    1268 <ptriproj+0x138>
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1245 <ptriproj+0x115>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1050 <plinproj@plt>
movsd  %xmm0,-0x48(%rbp)
jmp    1263 <ptriproj+0x133>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1050 <plinproj@plt>
movsd  %xmm0,-0x48(%rbp)
jmp    1268 <ptriproj+0x138>
jmp    126d <ptriproj+0x13d>
jmp    1291 <ptriproj+0x161>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    -0x28(%rbp),%rcx
call   1030 <routlm@plt>
movsd  -0x48(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptriproj>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r15d
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
lea    0x20(%rsp),%r8
lea    0x18(%rsp),%r9
call   1040 <lmoutr@plt>
movsd  0x20(%rsp),%xmm0
test   %r15d,%r15d
je     11aa <ptriproj+0x7a>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
movsd  0x18(%rsp),%xmm1
jb     119f <ptriproj+0x6f>
ucomisd %xmm2,%xmm1
jb     119f <ptriproj+0x6f>
movapd %xmm0,%xmm3
addsd  %xmm1,%xmm3
movsd  0xe67(%rip),%xmm4
ucomisd %xmm3,%xmm4
jae    11b0 <ptriproj+0x80>
ucomisd %xmm0,%xmm2
jbe    11c3 <ptriproj+0x93>
mov    %rbx,%rdi
jmp    11d8 <ptriproj+0xa8>
movsd  0x18(%rsp),%xmm1
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
call   1030 <routlm@plt>
jmp    11ef <ptriproj+0xbf>
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11d5 <ptriproj+0xa5>
mov    %rbx,%rdi
mov    %rbp,%rsi
jmp    11db <ptriproj+0xab>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r15d,%r8d
call   1050 <plinproj@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @ptriproj(double* %0, double* %1, double* %2, double* %3, double* %4, i32 %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store i32 %5, i32* %12
%16 = load double*, double** %7
%17 = load double*, double** %8
%18 = load double*, double** %9
%19 = load double*, double** %10
%20 = call i32 @lmoutr(double* %16, double* %17, double* %18, double* %19, double* %13, double* %14, double* %15)
%21 = load i32, i32* %12
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %72
23: ; preds = %6
%24 = load double, double* %13
%25 = fcmp oge double %24, 0.000000e+00
br i1 %25, label %26, label %42
26: ; preds = %23
%27 = load double, double* %14
%28 = fcmp oge double %27, 0.000000e+00
br i1 %28, label %29, label %42
29: ; preds = %26
%30 = load double, double* %13
%31 = load double, double* %14
%32 = fadd double %30, %31
%33 = fcmp ole double %32, 1.000000e+00
br i1 %33, label %34, label %42
34: ; preds = %29
%35 = load double*, double** %7
%36 = load double*, double** %8
%37 = load double*, double** %9
%38 = load double, double* %13
%39 = load double, double* %14
%40 = load double*, double** %11
%41 = call i32 @routlm(double* %35, double* %36, double* %37, double %38, double %39, double* %40)
br label %71
42: ; preds = %29, %26, %23
%43 = load double, double* %13
%44 = fcmp olt double %43, 0.000000e+00
br i1 %44, label %45, label %52
45: ; preds = %42
%46 = load double*, double** %7
%47 = load double*, double** %9
%48 = load double*, double** %10
%49 = load double*, double** %11
%50 = load i32, i32* %12
%51 = call double @plinproj(double* %46, double* %47, double* %48, double* %49, i32 %50)
store double %51, double* %15
br label %70
52: ; preds = %42
%53 = load double, double* %14
%54 = fcmp olt double %53, 0.000000e+00
br i1 %54, label %55, label %62
55: ; preds = %52
%56 = load double*, double** %7
%57 = load double*, double** %8
%58 = load double*, double** %10
%59 = load double*, double** %11
%60 = load i32, i32* %12
%61 = call double @plinproj(double* %56, double* %57, double* %58, double* %59, i32 %60)
store double %61, double* %15
br label %69
62: ; preds = %52
%63 = load double*, double** %8
%64 = load double*, double** %9
%65 = load double*, double** %10
%66 = load double*, double** %11
%67 = load i32, i32* %12
%68 = call double @plinproj(double* %63, double* %64, double* %65, double* %66, i32 %67)
store double %68, double* %15
br label %69
69: ; preds = %62, %55
br label %70
70: ; preds = %69, %45
br label %71
71: ; preds = %70, %34
br label %80
72: ; preds = %6
%73 = load double*, double** %7
%74 = load double*, double** %8
%75 = load double*, double** %9
%76 = load double, double* %13
%77 = load double, double* %14
%78 = load double*, double** %11
%79 = call i32 @routlm(double* %73, double* %74, double* %75, double %76, double %77, double* %78)
br label %80
80: ; preds = %72, %71
%81 = load double, double* %15
ret double %81
}

LLVM IR (-O2):
define double @ptriproj(double* %0, double* %1, double* %2, double* %3, double* %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = bitcast double* %7 to i8*
%11 = bitcast double* %8 to i8*
%12 = bitcast double* %9 to i8*
%13 = call i32 @lmoutr(double* %0, double* %1, double* %2, double* %3, double* %7, double* %8, double* %9)
%14 = icmp eq i32 %5, 0
%15 = load double, double* %7
br i1 %14, label %36, label %16
16: ; preds = %6
%17 = fcmp ult double %15, 0.000000e+00
%18 = load double, double* %8
%19 = fcmp ult double %18, 0.000000e+00
%20 = select i1 %17, i1 true, i1 %19
%21 = fadd double %15, %18
%22 = fcmp ugt double %21, 1.000000e+00
%23 = select i1 %20, i1 true, i1 %22
br i1 %23, label %26, label %24
24: ; preds = %16
%25 = call i32 @routlm(double* %0, double* %1, double* %2, double %15, double %18, double* %4)
br label %39
26: ; preds = %16
%27 = fcmp olt double %15, 0.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call double @plinproj(double* %0, double* %2, double* %3, double* %4, i32 %5)
store double %29, double* %9
br label %39
30: ; preds = %26
%31 = fcmp olt double %18, 0.000000e+00
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = call double @plinproj(double* %0, double* %1, double* %3, double* %4, i32 %5)
store double %33, double* %9
br label %39
34: ; preds = %30
%35 = call double @plinproj(double* %1, double* %2, double* %3, double* %4, i32 %5)
store double %35, double* %9
br label %39
36: ; preds = %6
%37 = load double, double* %8
%38 = call i32 @routlm(double* %0, double* %1, double* %2, double %15, double %37, double* %4)
br label %39
39: ; preds = %24, %32, %34, %28, %36
%40 = load double, double* %9
ret double %40
}