#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*/ cp_3d(double *, double *);
int /*<<< orphan*/ scale_3d(double *, double *, double);
int /*<<< orphan*/ sum_3d(double *, double *, double *);
int xy_l_intersection(double *out, double *p0, double *p1) {
  if (p1[2] == 0) {
    cp_3d(out, p1);
    return 1;
  } else if (p0[2] == 0) {
    cp_3d(out, p0);
    return 1;
  } else {
    scale_3d(out, p1, -p0[2] / p1[2]);
    sum_3d(out, out, p0);
    return (p0[2] * p1[2] <= 0);
  }
}


x86 assembly (clang, -O0):
<xy_l_intersection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1179 <xy_l_intersection+0x49>
jp     1179 <xy_l_intersection+0x49>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <cp_3d@plt>
movl   $0x1,-0x4(%rbp)
jmp    1219 <xy_l_intersection+0xe9>
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ae <xy_l_intersection+0x7e>
jp     11ae <xy_l_intersection+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <cp_3d@plt>
movl   $0x1,-0x4(%rbp)
jmp    1219 <xy_l_intersection+0xe9>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x20(%rbp),%rax
divsd  0x10(%rax),%xmm0
call   1030 <scale_3d@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <sum_3d@plt>
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x20(%rbp),%rax
mulsd  0x10(%rax),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xy_l_intersection>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r15
movsd  0x10(%rdx),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    1154 <xy_l_intersection+0x24>
jp     1154 <xy_l_intersection+0x24>
mov    %r15,%rdi
mov    %rbx,%rsi
jmp    116a <xy_l_intersection+0x3a>
mov    %rsi,%r14
movsd  0x10(%rsi),%xmm0
ucomisd %xmm2,%xmm0
jne    117a <xy_l_intersection+0x4a>
jp     117a <xy_l_intersection+0x4a>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <cp_3d@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
xorpd  0xe7e(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <scale_3d@plt>
mov    %r15,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <sum_3d@plt>
movsd  0x10(%r14),%xmm0
mulsd  0x10(%rbx),%xmm0
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
jmp    1174 <xy_l_intersection+0x44>

LLVM IR (-O0):
define i32 @xy_l_intersection(double* %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
%8 = load double*, double** %7
%9 = getelementptr inbounds double, double* %8, i64 2
%10 = load double, double* %9
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load double*, double** %5
%14 = load double*, double** %7
%15 = call i32 @cp_3d(double* %13, double* %14)
store i32 1, i32* %4
br label %50
16: ; preds = %3
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
%20 = fcmp oeq double %19, 0.000000e+00
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load double*, double** %5
%23 = load double*, double** %6
%24 = call i32 @cp_3d(double* %22, double* %23)
store i32 1, i32* %4
br label %50
25: ; preds = %16
%26 = load double*, double** %5
%27 = load double*, double** %7
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 2
%30 = load double, double* %29
%31 = fneg double %30
%32 = load double*, double** %7
%33 = getelementptr inbounds double, double* %32, i64 2
%34 = load double, double* %33
%35 = fdiv double %31, %34
%36 = call i32 @scale_3d(double* %26, double* %27, double %35)
%37 = load double*, double** %5
%38 = load double*, double** %5
%39 = load double*, double** %6
%40 = call i32 @sum_3d(double* %37, double* %38, double* %39)
%41 = load double*, double** %6
%42 = getelementptr inbounds double, double* %41, i64 2
%43 = load double, double* %42
%44 = load double*, double** %7
%45 = getelementptr inbounds double, double* %44, i64 2
%46 = load double, double* %45
%47 = fmul double %43, %46
%48 = fcmp ole double %47, 0.000000e+00
%49 = zext i1 %48 to i32
store i32 %49, i32* %4
br label %50
50: ; preds = %25, %21, %12
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
define i32 @xy_l_intersection(double* %0, double* %1, double* %2) {
%4 = getelementptr inbounds double, double* %2, i64 2
%5 = load double, double* %4
%6 = fcmp oeq double %5, 0.000000e+00
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @cp_3d(double* %0, double* %2)
br label %25
9: ; preds = %3
%10 = getelementptr inbounds double, double* %1, i64 2
%11 = load double, double* %10
%12 = fcmp oeq double %11, 0.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @cp_3d(double* %0, double* %1)
br label %25
15: ; preds = %9
%16 = fneg double %11
%17 = fdiv double %16, %5
%18 = tail call i32 @scale_3d(double* %0, double* %2, double %17)
%19 = tail call i32 @sum_3d(double* %0, double* %0, double* %1)
%20 = load double, double* %10
%21 = load double, double* %4
%22 = fmul double %20, %21
%23 = fcmp ole double %22, 0.000000e+00
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %15, %13, %7
%26 = phi i32 [ 1, %7 ], [ 1, %13 ], [ %24, %15 ]
ret i32 %26
}