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


x86 assembly (clang, -O0):
<dir_gradient_circ>:
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_circ+0x35>
lea    0xea8(%rip),%rdi
call   1050 <error@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x8(%rax),%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x4(%rbp),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
cvttsd2si %xmm0,%esi
call   1030 <atan2@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <angle_diff@plt>
movaps %xmm0,%xmm1
movsd  0xe54(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bd <dir_gradient_circ+0x8d>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [34 x i8] c"dir_gradient_circ: invalid param.\00"
define i32 @dir_gradient_circ(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 ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
%16 = load i32, i32* %6
%17 = sitofp i32 %16 to double
%18 = load double*, double** %8
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fsub double %17, %20
%22 = fptosi double %21 to i32
%23 = load i32, i32* %5
%24 = sitofp i32 %23 to double
%25 = load double*, double** %8
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
%28 = fsub double %24, %27
%29 = fptosi double %28 to i32
%30 = call double @atan2(i32 %22, i32 %29)
store double %30, double* %9
%31 = load double, double* %9
%32 = load double, double* %7
%33 = call double @angle_diff(double %31, double %32)
%34 = fcmp olt double %33, 0x3FF921FB5443D6F4
br i1 %34, label %35, label %36
35: ; preds = %15
store i32 1, i32* %10
br label %36
36: ; preds = %35, %15
%37 = load i32, i32* %10
ret i32 %37
}

LLVM IR (-O2):
@.str = [34 x i8] c"dir_gradient_circ: invalid param.\00"
define i32 @dir_gradient_circ(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 ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = sitofp i32 %1 to double
%10 = getelementptr inbounds double, double* %3, i64 1
%11 = load double, double* %10
%12 = fsub double %9, %11
%13 = fptosi double %12 to i32
%14 = sitofp i32 %0 to double
%15 = load double, double* %3
%16 = fsub double %14, %15
%17 = fptosi double %16 to i32
%18 = tail call double @atan2(i32 %13, i32 %17)
%19 = tail call double @angle_diff(double %18, double %2)
%20 = fcmp olt double %19, 0x3FF921FB5443D6F4
%21 = zext i1 %20 to i32
ret i32 %21
}