#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 angle_diff(double, double);
double ellipse_normal_angle(double, double, double *);
int /*<<< orphan*/ error(char *);
int dir_gradient_ell(int px, int py, double ang, double *foci) {
  double a;
  int dir = 0;
  if (foci == NULL)
    error("dir_gradient_ell: invalid ellipse.");
  a = ellipse_normal_angle((double)px, (double)py, foci);
  if (angle_diff(a, ang) < 1.57079632679)
    dir = 1;
  return dir;
}


x86 assembly (clang, -O0):
<dir_gradient_ell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1165 <dir_gradient_ell+0x35>
lea    0xea8(%rip),%rdi
call   1050 <error@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
mov    -0x18(%rbp),%rdi
call   1030 <ellipse_normal_angle@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <angle_diff@plt>
movaps %xmm0,%xmm1
movsd  0xe69(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a8 <dir_gradient_ell+0x78>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dir_gradient_ell>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
movsd  %xmm0,0x8(%rsp)
mov    %esi,%r14d
mov    %edi,%ebp
test   %rdx,%rdx
jne    1157 <dir_gradient_ell+0x27>
lea    0xeb6(%rip),%rdi
call   1050 <error@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
cvtsi2sd %r14d,%xmm1
mov    %rbx,%rdi
call   1030 <ellipse_normal_angle@plt>
movsd  0x8(%rsp),%xmm1
call   1040 <angle_diff@plt>
movsd  0xe82(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"dir_gradient_ell: invalid ellipse.\00"
define i32 @dir_gradient_ell(i32 %0, i32 %1, double %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double*
%9 = alloca double
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
store double* %3, double** %8
store i32 0, i32* %10
%11 = load double*, double** %8
%12 = icmp eq double* %11, null
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = call i32 @error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %6
%19 = sitofp i32 %18 to double
%20 = load double*, double** %8
%21 = call double @ellipse_normal_angle(double %17, double %19, double* %20)
store double %21, double* %9
%22 = load double, double* %9
%23 = load double, double* %7
%24 = call double @angle_diff(double %22, double %23)
%25 = fcmp olt double %24, 0x3FF921FB5443D6F4
br i1 %25, label %26, label %27
26: ; preds = %15
store i32 1, i32* %10
br label %27
27: ; preds = %26, %15
%28 = load i32, i32* %10
ret i32 %28
}

LLVM IR (-O2):
@.str = [35 x i8] c"dir_gradient_ell: invalid ellipse.\00"
define i32 @dir_gradient_ell(i32 %0, i32 %1, double %2, double* %3) {
%5 = icmp eq double* %3, null
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = sitofp i32 %0 to double
%10 = sitofp i32 %1 to double
%11 = tail call double @ellipse_normal_angle(double %9, double %10, double* %3)
%12 = tail call double @angle_diff(double %11, double %2)
%13 = fcmp olt double %12, 0x3FF921FB5443D6F4
%14 = zext i1 %13 to i32
ret i32 %14
}