#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*/ epipole(double *, double *);
double getorisig(double *, double *, double *);
int all_ori_valid(double *F, double *us, int *idx, int N) {
  double sig, sig1, ec[3], *u;
  int i;
  epipole(ec, F);
  sig1 = getorisig(F, ec, us + 6 * idx[0]);
  for (i = 1; i < N; i++) {
    u = us + 6 * idx[i];
    sig = getorisig(F, ec, u);
    if (sig1 * sig < 0)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<all_ori_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <epipole@plt>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rax
imul   $0x6,(%rax),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
call   1040 <getorisig@plt>
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11e7 <all_ori_valid+0xc7>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x5c(%rbp),%rdx
imul   $0x6,(%rcx,%rdx,4),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
call   1040 <getorisig@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11d4 <all_ori_valid+0xb4>
movl   $0x0,-0x4(%rbp)
jmp    11ee <all_ori_valid+0xce>
jmp    11d9 <all_ori_valid+0xb9>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1171 <all_ori_valid+0x51>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<all_ori_valid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <epipole@plt>
movslq (%r14),%rax
lea    (%rax,%rax,2),%rdx
shl    $0x4,%rdx
add    %r15,%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <getorisig@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%eax
cmp    $0x2,%ebp
jl     11bc <all_ori_valid+0x9c>
mov    %ebp,%ebp
mov    $0x1,%r12d
lea    0x10(%rsp),%r13
nop
movslq (%r14,%r12,4),%rax
lea    (%rax,%rax,2),%rdx
shl    $0x4,%rdx
add    %r15,%rdx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <getorisig@plt>
mulsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11ba <all_ori_valid+0x9a>
add    $0x1,%r12
cmp    %r12,%rbp
jne    1180 <all_ori_valid+0x60>
mov    $0x1,%eax
jmp    11bc <all_ori_valid+0x9c>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @all_ori_valid(double* %0, double* %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca [3 x double]
%13 = alloca double*
%14 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
%15 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%16 = load double*, double** %6
%17 = call i32 @epipole(double* %15, double* %16)
%18 = load double*, double** %6
%19 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%20 = load double*, double** %7
%21 = load i32*, i32** %8
%22 = getelementptr inbounds i32, i32* %21, i64 0
%23 = load i32, i32* %22
%24 = mul nsw i32 6, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %20, i64 %25
%27 = call double @getorisig(double* %18, double* %19, double* %26)
store double %27, double* %11
store i32 1, i32* %14
br label %28
28: ; preds = %52, %4
%29 = load i32, i32* %14
%30 = load i32, i32* %9
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %55
32: ; preds = %28
%33 = load double*, double** %7
%34 = load i32*, i32** %8
%35 = load i32, i32* %14
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = mul nsw i32 6, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %33, i64 %40
store double* %41, double** %13
%42 = load double*, double** %6
%43 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%44 = load double*, double** %13
%45 = call double @getorisig(double* %42, double* %43, double* %44)
store double %45, double* %10
%46 = load double, double* %11
%47 = load double, double* %10
%48 = fmul double %46, %47
%49 = fcmp olt double %48, 0.000000e+00
br i1 %49, label %50, label %51
50: ; preds = %32
store i32 0, i32* %5
br label %56
51: ; preds = %32
br label %52
52: ; preds = %51
%53 = load i32, i32* %14
%54 = add nsw i32 %53, 1
store i32 %54, i32* %14
br label %28
55: ; preds = %28
store i32 1, i32* %5
br label %56
56: ; preds = %55, %50
%57 = load i32, i32* %5
ret i32 %57
}

LLVM IR (-O2):
define i32 @all_ori_valid(double* %0, double* %1, i32* nocapture %2, i32 %3) {
%5 = alloca [3 x double]
%6 = bitcast [3 x double]* %5 to i8*
%7 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%8 = call i32 @epipole(double* %7, double* %0)
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %1, i64 %11
%13 = call double @getorisig(double* %0, double* %7, double* %12)
%14 = icmp sgt i32 %3, 1
br i1 %14, label %15, label %30
15: ; preds = %4
%16 = zext i32 %3 to i64
br label %19
17: ; preds = %19
%18 = icmp eq i64 %29, %16
br i1 %18, label %30, label %19
19: ; preds = %15, %17
%20 = phi i64 [ 1, %15 ], [ %29, %17 ]
%21 = getelementptr inbounds i32, i32* %2, i64 %20
%22 = load i32, i32* %21
%23 = mul nsw i32 %22, 6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %1, i64 %24
%26 = call double @getorisig(double* %0, double* %7, double* %25)
%27 = fmul double %13, %26
%28 = fcmp olt double %27, 0.000000e+00
%29 = add nuw nsw i64 %20, 1
br i1 %28, label %30, label %17
30: ; preds = %19, %17, %4
%31 = phi i32 [ 1, %4 ], [ 1, %17 ], [ 0, %19 ]
ret i32 %31
}