#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 */
scalar_t__ DBL_EPSILON;
scalar_t__ fabs(double);
int coord_cmp(double *c1, double *c2, int dim) {
  int i;
  double ret;
  for (i = 0; i < dim; i++) {
    ret = *c1++ - *c2++;
    if (fabs(ret) >= DBL_EPSILON) {
      return ret > 0 ? 1 : -1;
    }
  }
  if (fabs(ret) < DBL_EPSILON) {
    return 0;
  } else {
    return ret > 0 ? 1 : -1;
  }
}


x86 assembly (clang, -O0):
<coord_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11af <coord_cmp+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
subsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%rax
jl     119c <coord_cmp+0x8c>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11f1 <coord_cmp+0xe1>
jmp    11a1 <coord_cmp+0x91>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112a <coord_cmp+0x1a>
movsd  -0x28(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%rax
jge    11d5 <coord_cmp+0xc5>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <coord_cmp+0xe1>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coord_cmp>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
mov    %edx,%r12d
xor    %ebx,%ebx
mov    0x2eb9(%rip),%r15
nop
movsd  0x0(%r13,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
cmp    (%r15),%rax
jge    116b <coord_cmp+0x5b>
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1130 <coord_cmp+0x20>
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    (%r15),%rcx
jl     1183 <coord_cmp+0x73>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
add    %eax,%eax
add    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@DBL_EPSILON = global i64 0
define i32 @coord_cmp(double* %0, double* %1, i32 %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %10
10: ; preds = %32, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %35
14: ; preds = %10
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i32 1
store double* %16, double** %5
%17 = load double, double* %15
%18 = load double*, double** %6
%19 = getelementptr inbounds double, double* %18, i32 1
store double* %19, double** %6
%20 = load double, double* %18
%21 = fsub double %17, %20
store double %21, double* %9
%22 = load double, double* %9
%23 = call i64 @fabs(double %22)
%24 = load i64, i64* @DBL_EPSILON
%25 = icmp sge i64 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %14
%27 = load double, double* %9
%28 = fcmp ogt double %27, 0.000000e+00
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 1, i32 -1
store i32 %30, i32* %4
br label %46
31: ; preds = %14
br label %32
32: ; preds = %31
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %10
35: ; preds = %10
%36 = load double, double* %9
%37 = call i64 @fabs(double %36)
%38 = load i64, i64* @DBL_EPSILON
%39 = icmp slt i64 %37, %38
br i1 %39, label %40, label %41
40: ; preds = %35
store i32 0, i32* %4
br label %46
41: ; preds = %35
%42 = load double, double* %9
%43 = fcmp ogt double %42, 0.000000e+00
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 1, i32 -1
store i32 %45, i32* %4
br label %46
46: ; preds = %41, %40, %26
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
@DBL_EPSILON = global i64 0
define i32 @coord_cmp(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br label %5
5: ; preds = %3, %18
%6 = phi i32 [ %21, %18 ], [ 0, %3 ]
%7 = phi double* [ %19, %18 ], [ %1, %3 ]
%8 = phi double* [ %20, %18 ], [ %0, %3 ]
%9 = load double, double* %8
%10 = load double, double* %7
%11 = fsub double %9, %10
%12 = tail call i64 @fabs(double %11)
%13 = load i64, i64* @DBL_EPSILON
%14 = icmp slt i64 %12, %13
br i1 %14, label %18, label %15
15: ; preds = %5
%16 = fcmp ogt double %11, 0.000000e+00
%17 = select i1 %16, i32 1, i32 -1
br label %30
18: ; preds = %5
%19 = getelementptr inbounds double, double* %7, i64 1
%20 = getelementptr inbounds double, double* %8, i64 1
%21 = add nuw i32 %6, 1
%22 = icmp eq i32 %21, %2
br i1 %22, label %23, label %5
23: ; preds = %18
%24 = tail call i64 @fabs(double %11)
%25 = load i64, i64* @DBL_EPSILON
%26 = icmp slt i64 %24, %25
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = fcmp ogt double %11, 0.000000e+00
%29 = select i1 %28, i32 1, i32 -1
br label %30
30: ; preds = %23, %27, %15
%31 = phi i32 [ %17, %15 ], [ %29, %27 ], [ 0, %23 ]
ret i32 %31
}