// File: FreeSlave[P]vhlt/hlbsp/surfaces.cpp
// Function: GetEdge(double const*, double const*, face_s*)
int             GetEdge(const vec3_t p1, const vec3_t p2, face_t* f)
{
    int             v1;
    int             v2;
    dedge_t*        edge;
    int             i;

    hlassert(f->contents);

    v1 = GetVertex(p1, f->planenum);
    v2 = GetVertex(p2, f->planenum);
    for (i = firstmodeledge; i < g_numedges; i++)
    {
        edge = &g_dedges[i];
        if (v1 == edge->v[1] && v2 == edge->v[0] && !edgefaces[i][1] && edgefaces[i][0]->contents == f->contents
#ifdef HLBSP_EDGESHARE_SAMESIDE
			&& edgefaces[i][0]->planenum != (f->planenum ^ 1)
			&& edgefaces[i][0]->contents == f->contents
#endif
			)
        {
            edgefaces[i][1] = f;
            return -i;
        }
    }

    // emit an edge
    hlassume(g_numedges < MAX_MAP_EDGES, assume_MAX_MAP_EDGES);
    edge = &g_dedges[g_numedges];
    g_numedges++;
    edge->v[0] = v1;
    edge->v[1] = v2;
    edgefaces[i][0] = f;

    return i;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rax
movl 0x8(%rax), %esi
callq 0x30090
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rax
movl 0x8(%rax), %esi
callq 0x30090
movl %eax, 0x10(%rsp)
movl 0x1753b(%rip), %eax     # 0x47400
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
leaq 0x1cff4f8(%rip), %rcx   # 0x1d2f3cc
cmpl (%rcx), %eax
jge 0x2ffe6
movslq 0x4(%rsp), %rcx
leaq 0x1cff4e8(%rip), %rax   # 0x1d2f3d0
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movl 0x14(%rsp), %eax
movq 0x8(%rsp), %rcx
movzwl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x2ffd4
movl 0x10(%rsp), %eax
movq 0x8(%rsp), %rcx
movzwl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x2ffd4
movslq 0x4(%rsp), %rcx
leaq 0x32bfb67(%rip), %rax   # 0x32efa90
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jne 0x2ffd4
movslq 0x4(%rsp), %rcx
leaq 0x32bfb49(%rip), %rax   # 0x32efa90
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl 0x10(%rax), %eax
movq 0x18(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x2ffd4
movslq 0x4(%rsp), %rcx
leaq 0x32bfb26(%rip), %rax   # 0x32efa90
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movq 0x18(%rsp), %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
je 0x2ffd4
movslq 0x4(%rsp), %rcx
leaq 0x32bfafe(%rip), %rax   # 0x32efa90
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl 0x10(%rax), %eax
movq 0x18(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x2ffd4
movq 0x18(%rsp), %rcx
movslq 0x4(%rsp), %rdx
leaq 0x32bfad6(%rip), %rax   # 0x32efa90
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
xorl %eax, %eax
subl 0x4(%rsp), %eax
movl %eax, 0x34(%rsp)
jmp 0x3007a
jmp 0x2ffd6
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x2fec9
leaq 0x1cff3df(%rip), %rax   # 0x1d2f3cc
cmpl $0x3e800, (%rax)        # imm = 0x3E800
setl %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x2d, %esi
callq 0xbe90
leaq 0x1cff3bf(%rip), %rax   # 0x1d2f3cc
movslq (%rax), %rcx
leaq 0x1cff3b9(%rip), %rax   # 0x1d2f3d0
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
leaq 0x1cff3a2(%rip), %rax   # 0x1d2f3cc
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x1cff396(%rip), %rax   # 0x1d2f3cc
movl %ecx, (%rax)
movl 0x14(%rsp), %eax
movw %ax, %cx
movq 0x8(%rsp), %rax
movw %cx, (%rax)
movl 0x10(%rsp), %eax
movw %ax, %cx
movq 0x8(%rsp), %rax
movw %cx, 0x2(%rax)
movq 0x18(%rsp), %rcx
movslq 0x4(%rsp), %rdx
leaq 0x32bfa28(%rip), %rax   # 0x32efa90
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movl 0x4(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)