#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*/ error(char *);
int is_aligned(double a, double theta, double prec) {
  if (prec < 0.0)
    error("is_similar: 'prec' must be positive.");
  if (a == -1024.0)
    return 0;
  theta -= a;
  if (theta < 0.0)
    theta = -theta;
  if (theta > 4.71238898038) {
    theta -= 6.28318530718;
    if (theta < 0.0)
      theta = -theta;
  }
  return theta <= prec;
}


x86 assembly (clang, -O0):
<is_aligned>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1141 <is_aligned+0x31>
lea    0xedc(%rip),%rdi
call   1030 <error@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    116a <is_aligned+0x5a>
jp     116a <is_aligned+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    1226 <is_aligned+0x116>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11ac <is_aligned+0x9c>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe4f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    120d <is_aligned+0xfd>
movsd  -0x18(%rbp),%xmm0
movsd  0xe40(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1208 <is_aligned+0xf8>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    120d <is_aligned+0xfd>
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%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):
<is_aligned>:
sub    $0x28,%rsp
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm3
jbe    114b <is_aligned+0x3b>
lea    0xf0b(%rip),%rdi
movsd  %xmm2,0x8(%rsp)
movaps %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
call   1030 <error@plt>
movsd  (%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
xor    %eax,%eax
ucomisd 0xeab(%rip),%xmm0
jne    115e <is_aligned+0x4e>
jp     115e <is_aligned+0x4e>
add    $0x28,%rsp
ret
subsd  %xmm0,%xmm1
movapd 0xeb6(%rip),%xmm0
xorpd  %xmm1,%xmm0
xorpd  %xmm4,%xmm4
movapd %xmm1,%xmm3
cmpltsd %xmm4,%xmm3
andpd  %xmm3,%xmm0
andnpd %xmm1,%xmm3
orpd   %xmm0,%xmm3
ucomisd 0xe79(%rip),%xmm3
movapd %xmm3,%xmm0
jbe    11af <is_aligned+0x9f>
movsd  0xe73(%rip),%xmm0
addsd  %xmm3,%xmm0
ucomisd %xmm0,%xmm4
jbe    11af <is_aligned+0x9f>
xorpd  0xe71(%rip),%xmm0
xor    %eax,%eax
ucomisd %xmm0,%xmm2
setae  %al
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"is_similar: 'prec' must be positive.\00"
define i32 @is_aligned(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 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = load double, double* %5
%14 = fcmp oeq double %13, -1.024000e+03
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %4
br label %42
16: ; preds = %12
%17 = load double, double* %5
%18 = load double, double* %6
%19 = fsub double %18, %17
store double %19, double* %6
%20 = load double, double* %6
%21 = fcmp olt double %20, 0.000000e+00
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load double, double* %6
%24 = fneg double %23
store double %24, double* %6
br label %25
25: ; preds = %22, %16
%26 = load double, double* %6
%27 = fcmp ogt double %26, 0x4012D97C7F330D32
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load double, double* %6
%30 = fsub double %29, 0x401921FB54442EEA
store double %30, double* %6
%31 = load double, double* %6
%32 = fcmp olt double %31, 0.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load double, double* %6
%35 = fneg double %34
store double %35, double* %6
br label %36
36: ; preds = %33, %28
br label %37
37: ; preds = %36, %25
%38 = load double, double* %6
%39 = load double, double* %7
%40 = fcmp ole double %38, %39
%41 = zext i1 %40 to i32
store i32 %41, i32* %4
br label %42
42: ; preds = %37, %15
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
@.str = [37 x i8] c"is_similar: 'prec' must be positive.\00"
define i32 @is_aligned(double %0, double %1, double %2) {
%4 = fcmp olt double %2, 0.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = fcmp oeq double %0, -1.024000e+03
br i1 %8, label %24, label %9
9: ; preds = %7
%10 = fsub double %1, %0
%11 = fcmp olt double %10, 0.000000e+00
%12 = fneg double %10
%13 = select i1 %11, double %12, double %10
%14 = fcmp ogt double %13, 0x4012D97C7F330D32
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = fadd double %13, 0xC01921FB54442EEA
%17 = fcmp olt double %16, 0.000000e+00
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = fneg double %16
br label %20
20: ; preds = %15, %18, %9
%21 = phi double [ %19, %18 ], [ %16, %15 ], [ %13, %9 ]
%22 = fcmp ole double %21, %2
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %7, %20
%25 = phi i32 [ %23, %20 ], [ 0, %7 ]
ret i32 %25
}