#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*/ find_coor(double **, int, double, double, double);
void search_emptyedges(double **coords, int Ngrid, double lat, double lon,
                       double dep, double dlat, double dlon, double **extcoords,
                       int *Next) {
  int i, N = 8;
  double lats[] = {lat + dlat, lat + dlat, lat + dlat, lat,
                   lat - dlat, lat - dlat, lat - dlat, lat};
  double lons[] = {lon - dlon, lon, lon + dlon, lon + dlon,
                   lon + dlon, lon, lon - dlon, lon - dlon};
  for (i = 0; i < N; i++) {
    if (!find_coor(coords, Ngrid, lats[i], lons[i], dep) &&
        !find_coor(extcoords, *Next, lats[i], lons[i], dep)) {
      extcoords[(*Next)][0] = lats[i];
      extcoords[(*Next)][1] = lons[i];
      extcoords[(*Next)][2] = dep;
      (*Next)++;
    }
  }
}


x86 assembly (clang, -O0):
<search_emptyedges>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
movl   $0x8,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    133a <search_emptyedges+0x22a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movslq -0x4c(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movslq -0x4c(%rbp),%rax
movsd  -0xd0(%rbp,%rax,8),%xmm1
ff ff
movsd  -0x28(%rbp),%xmm2
call   1030 <find_coor@plt>
cmp    $0x0,%eax
jne    1327 <search_emptyedges+0x217>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    (%rax),%esi
movslq -0x4c(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movslq -0x4c(%rbp),%rax
movsd  -0xd0(%rbp,%rax,8),%xmm1
ff ff
movsd  -0x28(%rbp),%xmm2
call   1030 <find_coor@plt>
cmp    $0x0,%eax
jne    1327 <search_emptyedges+0x217>
movslq -0x4c(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,(%rax)
movslq -0x4c(%rbp),%rax
movsd  -0xd0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x48(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    132c <search_emptyedges+0x21c>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    124b <search_emptyedges+0x13b>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_emptyedges>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xa0,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%r12d
mov    %rdi,%rbx
movapd %xmm0,%xmm6
addsd  %xmm3,%xmm6
movsd  %xmm6,0x60(%rsp)
movsd  %xmm6,0x68(%rsp)
movsd  %xmm6,0x70(%rsp)
movsd  %xmm0,0x78(%rsp)
movapd %xmm0,%xmm5
subsd  %xmm3,%xmm5
movsd  %xmm5,0x80(%rsp)
movsd  %xmm5,0x88(%rsp)
movsd  %xmm5,0x90(%rsp)
movsd  %xmm0,0x98(%rsp)
movapd %xmm1,%xmm3
subsd  %xmm4,%xmm3
movsd  %xmm3,0x20(%rsp)
movsd  %xmm1,0x28(%rsp)
addsd  %xmm1,%xmm4
movsd  %xmm4,0x30(%rsp)
movsd  %xmm4,0x38(%rsp)
movsd  %xmm4,0x40(%rsp)
movsd  %xmm1,0x48(%rsp)
movsd  %xmm3,0x50(%rsp)
movsd  %xmm3,0x58(%rsp)
mov    $0x1,%ebp
movsd  %xmm2,0x8(%rsp)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r12d,%esi
movsd  %xmm6,0x18(%rsp)
movapd %xmm6,%xmm0
movsd  %xmm3,0x10(%rsp)
movapd %xmm3,%xmm1
call   1030 <find_coor@plt>
test   %eax,%eax
jne    1240 <search_emptyedges+0x130>
mov    (%r15),%esi
mov    %r14,%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
call   1030 <find_coor@plt>
test   %eax,%eax
jne    1240 <search_emptyedges+0x130>
movslq (%r15),%rax
mov    (%r14,%rax,8),%rcx
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rcx)
add    $0x1,%eax
mov    %eax,(%r15)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm2
cmp    $0x8,%rbp
je     1261 <search_emptyedges+0x151>
movsd  0x60(%rsp,%rbp,8),%xmm6
movsd  0x20(%rsp,%rbp,8),%xmm3
add    $0x1,%rbp
jmp    11c0 <search_emptyedges+0xb0>
add    $0xa0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @search_emptyedges(double** %0, i32 %1, double %2, double %3, double %4, double %5, double %6, double** %7, i32* %8) {
%10 = alloca double**
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double**
%18 = alloca i32*
%19 = alloca i32
%20 = alloca i32
%21 = alloca [8 x double]
%22 = alloca [8 x double]
store double** %0, double*** %10
store i32 %1, i32* %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store double %5, double* %15
store double %6, double* %16
store double** %7, double*** %17
store i32* %8, i32** %18
store i32 8, i32* %20
%23 = getelementptr inbounds [8 x double], [8 x double]* %21, i64 0, i64 0
%24 = load double, double* %12
%25 = load double, double* %15
%26 = fadd double %24, %25
store double %26, double* %23
%27 = getelementptr inbounds double, double* %23, i64 1
%28 = load double, double* %12
%29 = load double, double* %15
%30 = fadd double %28, %29
store double %30, double* %27
%31 = getelementptr inbounds double, double* %27, i64 1
%32 = load double, double* %12
%33 = load double, double* %15
%34 = fadd double %32, %33
store double %34, double* %31
%35 = getelementptr inbounds double, double* %31, i64 1
%36 = load double, double* %12
store double %36, double* %35
%37 = getelementptr inbounds double, double* %35, i64 1
%38 = load double, double* %12
%39 = load double, double* %15
%40 = fsub double %38, %39
store double %40, double* %37
%41 = getelementptr inbounds double, double* %37, i64 1
%42 = load double, double* %12
%43 = load double, double* %15
%44 = fsub double %42, %43
store double %44, double* %41
%45 = getelementptr inbounds double, double* %41, i64 1
%46 = load double, double* %12
%47 = load double, double* %15
%48 = fsub double %46, %47
store double %48, double* %45
%49 = getelementptr inbounds double, double* %45, i64 1
%50 = load double, double* %12
store double %50, double* %49
%51 = getelementptr inbounds [8 x double], [8 x double]* %22, i64 0, i64 0
%52 = load double, double* %13
%53 = load double, double* %16
%54 = fsub double %52, %53
store double %54, double* %51
%55 = getelementptr inbounds double, double* %51, i64 1
%56 = load double, double* %13
store double %56, double* %55
%57 = getelementptr inbounds double, double* %55, i64 1
%58 = load double, double* %13
%59 = load double, double* %16
%60 = fadd double %58, %59
store double %60, double* %57
%61 = getelementptr inbounds double, double* %57, i64 1
%62 = load double, double* %13
%63 = load double, double* %16
%64 = fadd double %62, %63
store double %64, double* %61
%65 = getelementptr inbounds double, double* %61, i64 1
%66 = load double, double* %13
%67 = load double, double* %16
%68 = fadd double %66, %67
store double %68, double* %65
%69 = getelementptr inbounds double, double* %65, i64 1
%70 = load double, double* %13
store double %70, double* %69
%71 = getelementptr inbounds double, double* %69, i64 1
%72 = load double, double* %13
%73 = load double, double* %16
%74 = fsub double %72, %73
store double %74, double* %71
%75 = getelementptr inbounds double, double* %71, i64 1
%76 = load double, double* %13
%77 = load double, double* %16
%78 = fsub double %76, %77
store double %78, double* %75
store i32 0, i32* %19
br label %79
79: ; preds = %147, %9
%80 = load i32, i32* %19
%81 = load i32, i32* %20
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %150
83: ; preds = %79
%84 = load double**, double*** %10
%85 = load i32, i32* %11
%86 = load i32, i32* %19
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [8 x double], [8 x double]* %21, i64 0, i64 %87
%89 = load double, double* %88
%90 = load i32, i32* %19
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [8 x double], [8 x double]* %22, i64 0, i64 %91
%93 = load double, double* %92
%94 = load double, double* %14
%95 = call i32 @find_coor(double** %84, i32 %85, double %89, double %93, double %94)
%96 = icmp ne i32 %95, 0
br i1 %96, label %146, label %97
97: ; preds = %83
%98 = load double**, double*** %17
%99 = load i32*, i32** %18
%100 = load i32, i32* %99
%101 = load i32, i32* %19
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [8 x double], [8 x double]* %21, i64 0, i64 %102
%104 = load double, double* %103
%105 = load i32, i32* %19
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [8 x double], [8 x double]* %22, i64 0, i64 %106
%108 = load double, double* %107
%109 = load double, double* %14
%110 = call i32 @find_coor(double** %98, i32 %100, double %104, double %108, double %109)
%111 = icmp ne i32 %110, 0
br i1 %111, label %146, label %112
112: ; preds = %97
%113 = load i32, i32* %19
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [8 x double], [8 x double]* %21, i64 0, i64 %114
%116 = load double, double* %115
%117 = load double**, double*** %17
%118 = load i32*, i32** %18
%119 = load i32, i32* %118
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds double*, double** %117, i64 %120
%122 = load double*, double** %121
%123 = getelementptr inbounds double, double* %122, i64 0
store double %116, double* %123
%124 = load i32, i32* %19
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [8 x double], [8 x double]* %22, i64 0, i64 %125
%127 = load double, double* %126
%128 = load double**, double*** %17
%129 = load i32*, i32** %18
%130 = load i32, i32* %129
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds double*, double** %128, i64 %131
%133 = load double*, double** %132
%134 = getelementptr inbounds double, double* %133, i64 1
store double %127, double* %134
%135 = load double, double* %14
%136 = load double**, double*** %17
%137 = load i32*, i32** %18
%138 = load i32, i32* %137
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds double*, double** %136, i64 %139
%141 = load double*, double** %140
%142 = getelementptr inbounds double, double* %141, i64 2
store double %135, double* %142
%143 = load i32*, i32** %18
%144 = load i32, i32* %143
%145 = add nsw i32 %144, 1
store i32 %145, i32* %143
br label %146
146: ; preds = %112, %97, %83
br label %147
147: ; preds = %146
%148 = load i32, i32* %19
%149 = add nsw i32 %148, 1
store i32 %149, i32* %19
br label %79
150: ; preds = %79
ret void
}

LLVM IR (-O2):
define void @search_emptyedges(double** %0, i32 %1, double %2, double %3, double %4, double %5, double %6, double** %7, i32* nocapture %8) {
%10 = alloca [8 x double]
%11 = alloca [8 x double]
%12 = bitcast [8 x double]* %10 to i8*
%13 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 0
%14 = fadd double %2, %5
store double %14, double* %13
%15 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 1
store double %14, double* %15
%16 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 2
store double %14, double* %16
%17 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 3
store double %2, double* %17
%18 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 4
%19 = fsub double %2, %5
store double %19, double* %18
%20 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 5
store double %19, double* %20
%21 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 6
store double %19, double* %21
%22 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 7
store double %2, double* %22
%23 = bitcast [8 x double]* %11 to i8*
%24 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 0
%25 = fsub double %3, %6
store double %25, double* %24
%26 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 1
store double %3, double* %26
%27 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 2
%28 = fadd double %3, %6
store double %28, double* %27
%29 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 3
store double %28, double* %29
%30 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 4
store double %28, double* %30
%31 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 5
store double %3, double* %31
%32 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 6
store double %25, double* %32
%33 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 7
store double %25, double* %33
br label %34
34: ; preds = %55, %9
%35 = phi double [ %25, %9 ], [ %59, %55 ]
%36 = phi double [ %14, %9 ], [ %57, %55 ]
%37 = phi i64 [ 0, %9 ], [ %53, %55 ]
%38 = tail call i32 @find_coor(double** %0, i32 %1, double %36, double %35, double %4)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %52
40: ; preds = %34
%41 = load i32, i32* %8
%42 = tail call i32 @find_coor(double** %7, i32 %41, double %36, double %35, double %4)
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %52
44: ; preds = %40
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double*, double** %7, i64 %46
%48 = load double*, double** %47
store double %36, double* %48
%49 = getelementptr inbounds double, double* %48, i64 1
store double %35, double* %49
%50 = getelementptr inbounds double, double* %48, i64 2
store double %4, double* %50
%51 = add nsw i32 %45, 1
store i32 %51, i32* %8
br label %52
52: ; preds = %34, %40, %44
%53 = add nuw nsw i64 %37, 1
%54 = icmp eq i64 %53, 8
br i1 %54, label %60, label %55
55: ; preds = %52
%56 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 %53
%57 = load double, double* %56
%58 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 %53
%59 = load double, double* %58
br label %34
60: ; preds = %52
ret void
}