#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 set_coor(double lat, double lon, double dep, int *Ngrid, double **coords) {
  if (!find_coor(coords, *Ngrid, lat, lon, dep)) {
    coords[*Ngrid][0] = lat;
    coords[*Ngrid][1] = lon;
    coords[*Ngrid][2] = dep;
    (*Ngrid)++;
  }
}


x86 assembly (clang, -O0):
<set_coor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <find_coor@plt>
cmp    $0x0,%eax
jne    11ab <set_coor+0x9b>
movsd  -0x8(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_coor>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%esi
mov    %r14,%rdi
movsd  %xmm0,(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm2,0x10(%rsp)
call   1030 <find_coor@plt>
test   %eax,%eax
jne    1167 <set_coor+0x57>
movslq (%rbx),%rax
mov    (%r14,%rax,8),%rcx
movsd  (%rsp),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rcx)
add    $0x1,%eax
mov    %eax,(%rbx)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @set_coor(double %0, double %1, double %2, i32* nocapture %3, double** %4) {
%6 = load i32, i32* %3
%7 = tail call i32 @find_coor(double** %4, i32 %6, double %0, double %1, double %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double*, double** %4, i64 %11
%13 = load double*, double** %12
store double %0, double* %13
%14 = getelementptr inbounds double, double* %13, i64 1
store double %1, double* %14
%15 = getelementptr inbounds double, double* %13, i64 2
store double %2, double* %15
%16 = add nsw i32 %10, 1
store i32 %16, i32* %3
br label %17
17: ; preds = %9, %5
ret void
}