#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 = 0.0;
  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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b7 <coord_cmp+0xa7>
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    0x2e6e(%rip),%rcx
cmp    (%rcx),%rax
jl     11a4 <coord_cmp+0x94>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <coord_cmp+0xe9>
jmp    11a9 <coord_cmp+0x99>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1132 <coord_cmp+0x22>
movsd  -0x28(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2e20(%rip),%rcx
cmp    (%rcx),%rax
jge    11dd <coord_cmp+0xcd>
movl   $0x0,-0x4(%rbp)
jmp    11f9 <coord_cmp+0xe9>
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
test   %edx,%edx
jle    116e <coord_cmp+0x5e>
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,%r15d
xor    %ebx,%ebx
mov    0x2eb5(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
cmp    0x0(%r13),%rax
jge    118e <coord_cmp+0x7e>
add    $0x1,%rbx
cmp    %ebx,%r15d
movsd  0x8(%rsp),%xmm0
jne    1140 <coord_cmp+0x30>
jmp    1172 <coord_cmp+0x62>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    0x2e61(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
jl     11a6 <coord_cmp+0x96>
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 double 0.000000e+00, double* %9
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 i1 %4, label %5, label %23
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 %31
18: ; preds = %5
%19 = getelementptr inbounds double, double* %7, i64 1
%20 = getelementptr inbounds double, double* %8, i64 1
%21 = add nuw nsw i32 %6, 1
%22 = icmp eq i32 %21, %2
br i1 %22, label %23, label %5
23: ; preds = %18, %3
%24 = phi double [ 0.000000e+00, %3 ], [ %11, %18 ]
%25 = tail call i64 @fabs(double %24)
%26 = load i64, i64* @DBL_EPSILON
%27 = icmp slt i64 %25, %26
br i1 %27, label %31, label %28
28: ; preds = %23
%29 = fcmp ogt double %24, 0.000000e+00
%30 = select i1 %29, i32 1, i32 -1
br label %31
31: ; preds = %23, %28, %15
%32 = phi i32 [ %17, %15 ], [ %30, %28 ], [ 0, %23 ]
ret i32 %32
}