#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*/ find_intersection(long double *, long double *,
                                     long double *, long double *,
                                     long double *);
scalar_t__ isbetween(long double *, long double *, long double *);
int segments_intersect(long double *a, long double *b, long double *c,
                       long double *d) {
  long double p[4];
  find_intersection(a, b, c, d, p);
  if (isbetween(a, b, p) && isbetween(c, d, p))
    return 1;
  else
    return 0;
  return 0;
}


x86 assembly (clang, -O0):
<segments_intersect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    -0x70(%rbp),%r8
call   1040 <find_intersection@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1030 <isbetween@plt>
cmp    $0x0,%rax
je     1193 <segments_intersect+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1030 <isbetween@plt>
cmp    $0x0,%rax
je     1193 <segments_intersect+0x73>
movl   $0x1,-0x4(%rbp)
jmp    119a <segments_intersect+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<segments_intersect>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsp,%r13
mov    %r13,%r8
call   1040 <find_intersection@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <isbetween@plt>
test   %rax,%rax
je     1172 <segments_intersect+0x52>
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <isbetween@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1174 <segments_intersect+0x54>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @segments_intersect(x86_fp80* %0, x86_fp80* %1, x86_fp80* %2, x86_fp80* %3) {
%5 = alloca i32
%6 = alloca x86_fp80*
%7 = alloca x86_fp80*
%8 = alloca x86_fp80*
%9 = alloca x86_fp80*
%10 = alloca [4 x x86_fp80]
store x86_fp80* %0, x86_fp80** %6
store x86_fp80* %1, x86_fp80** %7
store x86_fp80* %2, x86_fp80** %8
store x86_fp80* %3, x86_fp80** %9
%11 = load x86_fp80*, x86_fp80** %6
%12 = load x86_fp80*, x86_fp80** %7
%13 = load x86_fp80*, x86_fp80** %8
%14 = load x86_fp80*, x86_fp80** %9
%15 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %10, i64 0, i64 0
%16 = call i32 @find_intersection(x86_fp80* %11, x86_fp80* %12, x86_fp80* %13, x86_fp80* %14, x86_fp80* %15)
%17 = load x86_fp80*, x86_fp80** %6
%18 = load x86_fp80*, x86_fp80** %7
%19 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %10, i64 0, i64 0
%20 = call i64 @isbetween(x86_fp80* %17, x86_fp80* %18, x86_fp80* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %4
%23 = load x86_fp80*, x86_fp80** %8
%24 = load x86_fp80*, x86_fp80** %9
%25 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %10, i64 0, i64 0
%26 = call i64 @isbetween(x86_fp80* %23, x86_fp80* %24, x86_fp80* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 1, i32* %5
br label %30
29: ; preds = %22, %4
store i32 0, i32* %5
br label %30
30: ; preds = %29, %28
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
define i32 @segments_intersect(x86_fp80* %0, x86_fp80* %1, x86_fp80* %2, x86_fp80* %3) {
%5 = alloca [4 x x86_fp80]
%6 = bitcast [4 x x86_fp80]* %5 to i8*
%7 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %5, i64 0, i64 0
%8 = call i32 @find_intersection(x86_fp80* %0, x86_fp80* %1, x86_fp80* %2, x86_fp80* %3, x86_fp80* %7)
%9 = call i64 @isbetween(x86_fp80* %0, x86_fp80* %1, x86_fp80* %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = call i64 @isbetween(x86_fp80* %2, x86_fp80* %3, x86_fp80* %7)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11, %4
br label %15
15: ; preds = %11, %14
%16 = phi i32 [ 0, %14 ], [ 1, %11 ]
ret i32 %16
}